Skip to content
This repository has been archived by the owner on Mar 26, 2024. It is now read-only.

Commit

Permalink
Cleanup code
Browse files Browse the repository at this point in the history
  • Loading branch information
TrueDoctor committed Dec 31, 2020
1 parent f4201c7 commit 53dc781
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 104 deletions.
2 changes: 1 addition & 1 deletion rask-engine/src/engine/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl GameEngine for RaskEngine {
let mut tick_dispatcher = DispatcherBuilder::new()
.with_pool(pool)
.with(EventSystem, "events", &[])
.with(CheckPresentSystem, "check_present", &["events"])
.with(CheckPresentSystem, "check_present", &[]) // does not depend on anything, because resource parsing is handled asynchronously
.with(UpdateAnimationSystem, "update_anim", &["check_present"])
.with(MovementSystem, "movement", &["events"])
.with(GravitationSystem, "gravitation", &["movement"])
Expand Down
103 changes: 19 additions & 84 deletions rask-engine/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,94 +3,29 @@
use std::collections::HashMap;
use std::sync::atomic::AtomicBool;

#[rustfmt::skip]
lazy_static::lazy_static! {
/// This is an example for using doc comment attributes
static ref MAPPING: HashMap<u32, u32> = [
(977763216, 0),
(977535019, 1),
(251549619, 2),
(930625636, 3),
(4247333604, 4),
(2823983839, 5),
(2897055625, 6),
(3915039450, 7),
(12763084, 8),
(3908895692, 9),
(759638320, 10),
(2079612435, 11),
(1564800910, 12),
(83829, 13),
(80085222, 14),
(67114680, 15),
(3357475935, 16),
(2691421945, 17),
(3357357270, 18),
(79966557, 19),
(2387108321, 20),
(65290933, 21),
(1289876625, 22),
(78401116, 23),
(1149837940, 24),
(1422382255, 25),
(74348624, 26),
(67204884, 27),
(923631601, 28),
(2383081898, 29),
(1318883673, 30),
(2255103, 31),
(69819, 32),
(2195042009, 33),
(2043376075, 34),
(2046924995, 35),
(2046924996, 36),
(2046924997, 37),
(2046924998, 38),
(2046924999, 39),
(2046925000, 40),
(2046925001, 41),
(2046925002, 42),
(2046925003, 43),
(2046925004, 44),
(2335202, 45),
(2335203, 46),
(2335204, 47),
(2335205, 48),
(2335206, 49),
(2335207, 50),
(2335208, 51),
(2335209, 52),
(2335210, 53),
(2335211, 54),
(2335212, 55),
(2335213, 56),
(2335214, 57),
(2335215, 58),
(2335216, 59),
(2335217, 60),
(2335218, 61),
(2335219, 62),
(2335220, 63),
(2335221, 64),
(2335222, 65),
(2335223, 66),
(2335224, 67),
(2335225, 68),
(2335226, 69),
(2335227, 70),
(2219, 71),
(2220, 72),
(2221, 73),
(2222, 74),
(2223, 75),
(2224, 76),
(2225, 77),
(2226, 78),
(2227, 79),
(68837, 80),
(68838, 81),
(68839, 82),
].iter().copied().collect();
(977763216, 0),(977535019, 1),(251549619, 2),(930625636, 3),(4247333604, 4),
(2823983839, 5),(2897055625, 6),(3915039450, 7),(12763084, 8),(3908895692, 9),
(759638320, 10),(2079612435, 11),(1564800910, 12),(83829, 13),(80085222, 14),
(67114680, 15),(3357475935, 16),(2691421945, 17),(3357357270, 18),(79966557, 19),
(2387108321, 20),(65290933, 21),(1289876625, 22),(78401116, 23),(1149837940, 24),
(1422382255, 25),(74348624, 26),(67204884, 27),(923631601, 28),(2383081898, 29),
(1318883673, 30),(2255103, 31),(69819, 32),(2195042009, 33),(2043376075, 34),
(2046924995, 35),(2046924996, 36),(2046924997, 37),(2046924998, 38),(2046924999, 39),
(2046925000, 40),(2046925001, 41),(2046925002, 42),(2046925003, 43),(2046925004, 44),
(2335202, 45),(2335203, 46),(2335204, 47),(2335205, 48),(2335206, 49),
(2335207, 50),(2335208, 51),(2335209, 52),(2335210, 53),(2335211, 54),
(2335212, 55),(2335213, 56),(2335214, 57),(2335215, 58),(2335216, 59),
(2335217, 60),(2335218, 61),(2335219, 62),(2335220, 63),(2335221, 64),
(2335222, 65),(2335223, 66),(2335224, 67),(2335225, 68),(2335226, 69),
(2335227, 70),(2219, 71),(2220, 72),(2221, 73),(2222, 74),
(2223, 75),(2224, 76),(2225, 77),(2226, 78),(2227, 79),
(68837, 80),(68838, 81),(68839, 82)].iter().copied().collect();
}

#[derive(Debug, Clone, Copy, Eq, PartialEq)]
pub struct Key(u32);

Expand Down
41 changes: 22 additions & 19 deletions rask-engine/src/resources/character.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,26 +159,29 @@ impl Character {
fade_time: f32,
) -> Result<(), EngineError> {
self.animation.with_mut(|fields| {
*fields.animation = Some(
if let Some(anim) = &fields.animation {
anim.get_animated_skin_with_transiton(
&fields.skeleton_contents,
"default",
anim_name,
current_time,
start_offset,
fade_time,
)
} else {
fields
.skeleton_contents
.get_animated_skin("default", Some(anim_name))
let animation = if let Some(anim) = &fields.animation {
anim.get_animated_skin_with_transiton(
&fields.skeleton_contents,
"default",
anim_name,
current_time,
start_offset,
fade_time,
)
} else {
fields
.skeleton_contents
.get_animated_skin("default", Some(anim_name))
};
match animation {
Ok(animation) => {
*fields.animation = Some(animation);
*fields.animation_name = anim_name.to_owned();
Ok(())
}
.unwrap(),
);
*fields.animation_name = anim_name.to_owned();
});
Ok(())
Err(e) => Err(EngineError::Animation(format!("{}", e))),
}
})
}
pub fn interpolate(&self, time: f32) -> Result<AnimationStates, EngineError> {
if let Some(animated_skin) = self.animation.with_animation(|anim| anim) {
Expand Down

0 comments on commit 53dc781

Please sign in to comment.