minor rename
parent
56160a8abe
commit
cb65b67530
|
@ -1,4 +1,4 @@
|
|||
use crate::{AnimSectionHandle, Content, SectionEdge, SpriteHandle, SpriteStart};
|
||||
use crate::{AnimSectionHandle, Content, SectionEdge, SpriteHandle, StartEdge};
|
||||
|
||||
/// A single frame's state
|
||||
#[derive(Debug, Clone)]
|
||||
|
@ -74,12 +74,12 @@ impl AnimAutomaton {
|
|||
let sprite = ct.get_sprite(sprite_handle);
|
||||
|
||||
let (current_section, texture, current_direction) = match sprite.start_at {
|
||||
SpriteStart::Top { section } => (
|
||||
StartEdge::Top { section } => (
|
||||
section,
|
||||
*sprite.get_section(section).frames.first().unwrap(),
|
||||
AnimDirection::Down,
|
||||
),
|
||||
SpriteStart::Bot { section } => (
|
||||
StartEdge::Bot { section } => (
|
||||
section,
|
||||
*sprite.get_section(section).frames.last().unwrap(),
|
||||
AnimDirection::Up,
|
||||
|
|
|
@ -8,7 +8,7 @@ pub(crate) mod syntax {
|
|||
use galactica_util::to_radians;
|
||||
use serde::Deserialize;
|
||||
|
||||
use crate::{Content, ContentBuildContext, EffectHandle, SpriteStart};
|
||||
use crate::{Content, ContentBuildContext, EffectHandle, StartEdge};
|
||||
// Raw serde syntax structs.
|
||||
// These are never seen by code outside this crate.
|
||||
|
||||
|
@ -59,8 +59,8 @@ pub(crate) mod syntax {
|
|||
// Match lifetime of first section of sprite
|
||||
let sprite = content.get_sprite(sprite);
|
||||
let sec = match sprite.start_at {
|
||||
SpriteStart::Top { section } => sprite.get_section(section),
|
||||
SpriteStart::Bot { section } => sprite.get_section(section),
|
||||
StartEdge::Top { section } => sprite.get_section(section),
|
||||
StartEdge::Bot { section } => sprite.get_section(section),
|
||||
};
|
||||
sec.frame_duration * sec.frames.len() as f32
|
||||
} else {
|
||||
|
|
|
@ -141,13 +141,13 @@ pub(crate) mod syntax {
|
|||
pub fn resolve_as_start(
|
||||
&self,
|
||||
all_sections: &HashMap<String, AnimSectionHandle>,
|
||||
) -> Result<super::SpriteStart> {
|
||||
) -> Result<super::StartEdge> {
|
||||
let e = self
|
||||
.resolve_as_edge(all_sections)
|
||||
.with_context(|| format!("while resolving start edge"))?;
|
||||
match e {
|
||||
super::SectionEdge::Bot { section } => Ok(super::SpriteStart::Bot { section }),
|
||||
super::SectionEdge::Top { section } => Ok(super::SpriteStart::Top { section }),
|
||||
super::SectionEdge::Bot { section } => Ok(super::StartEdge::Bot { section }),
|
||||
super::SectionEdge::Top { section } => Ok(super::StartEdge::Top { section }),
|
||||
_ => {
|
||||
bail!("bad section start specification `{}`", self.val);
|
||||
}
|
||||
|
@ -229,7 +229,7 @@ pub enum SectionEdge {
|
|||
|
||||
/// Where to start an animation
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum SpriteStart {
|
||||
pub enum StartEdge {
|
||||
/// Play the given section from the bottm
|
||||
Bot {
|
||||
/// The section to play
|
||||
|
@ -253,7 +253,7 @@ pub struct Sprite {
|
|||
pub handle: SpriteHandle,
|
||||
|
||||
/// Where this sprite starts playing
|
||||
pub start_at: SpriteStart,
|
||||
pub start_at: StartEdge,
|
||||
|
||||
/// This sprite's animation sections
|
||||
sections: Vec<SpriteSection>,
|
||||
|
@ -271,8 +271,8 @@ impl Sprite {
|
|||
/// Get this sprite's first frame
|
||||
pub fn get_first_frame(&self) -> u32 {
|
||||
match self.start_at {
|
||||
SpriteStart::Bot { section } => *self.get_section(section).frames.last().unwrap(),
|
||||
SpriteStart::Top { section } => *self.get_section(section).frames.first().unwrap(),
|
||||
StartEdge::Bot { section } => *self.get_section(section).frames.last().unwrap(),
|
||||
StartEdge::Top { section } => *self.get_section(section).frames.first().unwrap(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -337,7 +337,7 @@ impl crate::Build for Sprite {
|
|||
|
||||
content.sprites.push(Self {
|
||||
name: sprite_name,
|
||||
start_at: SpriteStart::Top {
|
||||
start_at: StartEdge::Top {
|
||||
section: AnimSectionHandle(0),
|
||||
},
|
||||
sections: vec![SpriteSection {
|
||||
|
@ -373,7 +373,7 @@ impl crate::Build for Sprite {
|
|||
content.sprites.push(Self {
|
||||
name: sprite_name,
|
||||
sections,
|
||||
start_at: SpriteStart::Bot {
|
||||
start_at: StartEdge::Bot {
|
||||
section: AnimSectionHandle(0),
|
||||
},
|
||||
handle: h,
|
||||
|
|
Loading…
Reference in New Issue