Skip to content

Commit

Permalink
Also show actions data in the entity inspector
Browse files Browse the repository at this point in the history
  • Loading branch information
vE5li committed Feb 17, 2024
1 parent 7a17707 commit 33c326f
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/loaders/action/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ impl AnimationState {
pub struct Actions {
actions: Vec<Action>,
delays: Vec<f32>,
#[cfg(feature = "debug")]
actions_data: ActionsData,
}

impl Actions {
Expand Down Expand Up @@ -169,7 +171,7 @@ impl Actions {
}
}

#[derive(Debug, Named, ByteConvertable, PrototypeElement)]
#[derive(Debug, Clone, Named, ByteConvertable, PrototypeElement)]
struct SpriteClip {
pub position: Vector2<i32>,
pub sprite_number: u32,
Expand All @@ -188,14 +190,14 @@ struct SpriteClip {
pub size: Option<Vector2<u32>>,
}

#[derive(Debug, Named, ByteConvertable, PrototypeElement)]
#[derive(Debug, Clone, Named, ByteConvertable, PrototypeElement)]
struct AttachPoint {
pub ignored: u32,
pub position: Vector2<i32>,
pub attribute: u32,
}

#[derive(Debug, Named, ByteConvertable, PrototypeElement)]
#[derive(Debug, Clone, Named, ByteConvertable, PrototypeElement)]
struct Motion {
pub range1: [i32; 4], // maybe just skip this?
pub range2: [i32; 4], // maybe just skip this?
Expand All @@ -211,20 +213,20 @@ struct Motion {
pub attach_points: Vec<AttachPoint>,
}

#[derive(Debug, Named, ByteConvertable, PrototypeElement)]
#[derive(Debug, Clone, Named, ByteConvertable, PrototypeElement)]
struct Action {
pub motion_count: u32,
#[repeating(self.motion_count)]
pub motions: Vec<Motion>,
}

#[derive(Debug, Named, FromBytes, PrototypeElement)]
#[derive(Debug, Clone, Named, FromBytes, PrototypeElement)]
struct Event {
#[length_hint(40)]
pub name: String,
}

#[derive(Debug, Named, FromBytes, PrototypeElement)]
#[derive(Debug, Clone, Named, FromBytes, PrototypeElement)]
struct ActionsData {
#[version]
pub version: Version<MinorFirst>,
Expand Down Expand Up @@ -260,13 +262,18 @@ impl ActionLoader {

let actions_data = ActionsData::from_bytes(&mut byte_stream, None).unwrap();

#[cfg(feature = "debug")]
let saved_actions_data = actions_data.clone();

let delays = actions_data
.delays
.unwrap_or_else(|| actions_data.actions.iter().map(|_| 0.0).collect());

let sprite = Arc::new(Actions {
actions: actions_data.actions,
delays,
#[cfg(feature = "debug")]
actions_data: saved_actions_data,
});

self.cache.insert(path.to_string(), sprite.clone());
Expand Down

0 comments on commit 33c326f

Please sign in to comment.