From dc92a18e0148ebf796a30cb8db9f2b5692c156d8 Mon Sep 17 00:00:00 2001 From: zuiyu1998 <1542844298@qq.com> Date: Tue, 18 Jun 2024 11:32:14 +0800 Subject: [PATCH] feat: add max_event_capacity impl SpriteSheetAnimation --- fyrox-animation/src/spritesheet/mod.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/fyrox-animation/src/spritesheet/mod.rs b/fyrox-animation/src/spritesheet/mod.rs index 88d048f33..7c7412b57 100644 --- a/fyrox-animation/src/spritesheet/mod.rs +++ b/fyrox-animation/src/spritesheet/mod.rs @@ -168,6 +168,7 @@ where #[reflect(hidden)] #[visit(skip)] events: VecDeque, + max_event_capacity: usize, } impl PartialEq for SpriteSheetAnimation { @@ -204,6 +205,7 @@ where signals: Default::default(), texture: None, events: Default::default(), + max_event_capacity: 32, } } } @@ -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 { &self.frames_container @@ -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)); }