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