pub struct SpriteManager {
defs: Vec<SpriteDef>,
slot_to_index: HashMap<u32, usize>,
active: Vec<ActiveSprite>,
cycle_cursor: usize,
}Expand description
Sprite system: definitions + active instances.
Fields§
§defs: Vec<SpriteDef>Parsed MILK_IMG.INI entries indexed by load order. The
public API targets entries by slot (1-based, matching the
section headers); [slot_to_index] converts.
slot_to_index: HashMap<u32, usize>Slot → defs-vector position map. Sparse, since users can
author [img01] then jump to [img50].
active: Vec<ActiveSprite>Active sprites — drawn in spawn order so later spawns paint over earlier ones.
cycle_cursor: usizeCursor for “cycle to next” (the K keybind). Walks the
slot list mod defs.len().
Implementations§
Source§impl SpriteManager
impl SpriteManager
pub fn new() -> Self
Sourcepub fn load_defs(&mut self, defs: Vec<SpriteDef>)
pub fn load_defs(&mut self, defs: Vec<SpriteDef>)
Load a freshly-parsed set of sprite definitions, replacing
any previous load. Doesn’t touch the active list — running
sprites keep their def_index-back-reference until they
finish naturally, even though the def is gone (we re-resolve
the texture each frame in case the renderer reloaded).
Sourcepub fn active_count(&self) -> usize
pub fn active_count(&self) -> usize
Number of sprites currently being drawn each frame.
Sourcepub fn spawn_slot(&mut self, slot: u32) -> bool
pub fn spawn_slot(&mut self, slot: u32) -> bool
Spawn a sprite by INI slot. Returns false if the slot
isn’t loaded. Multiple spawns of the same slot stack — that
matches MD2 behaviour and lets users build up effects by
hammering the key.
fn spawn_index(&mut self, idx: usize)
Sourcepub fn cycle_next(&mut self) -> Option<u32>
pub fn cycle_next(&mut self) -> Option<u32>
K keybind: load the next sprite slot in cyclic order.
Sourcepub fn spawn_random(&mut self, seed: u64) -> Option<u32>
pub fn spawn_random(&mut self, seed: u64) -> Option<u32>
Shift+K: pick a slot at random. The caller passes the RNG
seed so we stay deterministic in tests.
Sourcepub fn pop_most_recent(&mut self) -> bool
pub fn pop_most_recent(&mut self) -> bool
Delete variant that only removes the most recent sprite
(last-in-first-out). Returns true when something was
removed so the GUI can suppress redundant Delete events on
an already-empty list.
Sourcepub fn tick(
&mut self,
time: f32,
q_snapshot: &[f32; 32],
) -> Vec<SpriteRenderInstance>
pub fn tick( &mut self, time: f32, q_snapshot: &[f32; 32], ) -> Vec<SpriteRenderInstance>
Advance every active sprite by one frame. Returns the list
of SpriteRenderInstances for the renderer.
time is the engine’s global clock (seconds, monotonic).
q_snapshot is the preset’s q1..q32 after the preset’s
per_frame block runs, exposed so sprite equations can
piggyback on the preset’s audio-reactive computations.
Sourcepub fn defs(&self) -> &[SpriteDef]
pub fn defs(&self) -> &[SpriteDef]
Borrow the parsed defs — useful for the renderer’s texture
loader (resolve img= strings against an XDG sprite dir).
Sourcepub fn resolve_img_path(root: &Path, def: &SpriteDef) -> PathBuf
pub fn resolve_img_path(root: &Path, def: &SpriteDef) -> PathBuf
Path the engine expects sprite assets to live under, relative to a sprite-bank root. Pure helper, no I/O.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SpriteManager
impl !RefUnwindSafe for SpriteManager
impl Send for SpriteManager
impl Sync for SpriteManager
impl Unpin for SpriteManager
impl !UnwindSafe for SpriteManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().