Skip to content

Commit

Permalink
feat: add max_event_capacity impl SpriteSheetAnimation
Browse files Browse the repository at this point in the history
  • Loading branch information
zuiyu1998 committed Jun 18, 2024
1 parent a113b63 commit dc92a18
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion fyrox-animation/src/spritesheet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ where
#[reflect(hidden)]
#[visit(skip)]
events: VecDeque<Event>,
max_event_capacity: usize,
}

impl<T: SpriteSheetTexture> PartialEq for SpriteSheetAnimation<T> {
Expand Down Expand Up @@ -204,6 +205,7 @@ where
signals: Default::default(),
texture: None,
events: Default::default(),
max_event_capacity: 32,
}
}
}
Expand Down Expand Up @@ -370,6 +372,16 @@ where
self.texture.clone()
}

/// Gets the maximum capacity of events.
pub fn get_max_event_capacity(&self) -> usize {
self.max_event_capacity
}

/// Sets the maximum capacity of events.
pub fn set_max_event_capacity(&mut self, max_event_capacity: usize) {
self.max_event_capacity = max_event_capacity;
}

/// Returns a shared reference to inner frames container.
pub fn frames(&self) -> &SpriteSheetFramesContainer<T> {
&self.frames_container
Expand Down Expand Up @@ -415,7 +427,7 @@ where
&& (self.current_frame < signal_frame && next_frame >= signal_frame)
|| self.speed < 0.0
&& (self.current_frame > signal_frame && next_frame <= signal_frame))
&& self.events.len() < 32
&& self.events.len() < self.max_event_capacity
{
self.events.push_back(Event::Signal(signal.id));
}
Expand Down

0 comments on commit dc92a18

Please sign in to comment.