dedupe optional line for tile
This commit is contained in:
parent
5d76798ace
commit
df2d0105e6
10
src/tile.rs
10
src/tile.rs
|
@ -1,4 +1,4 @@
|
|||
use crate::{AnimationFrames, from_base36, ToBase36};
|
||||
use crate::{AnimationFrames, from_base36, ToBase36, optional_data_line};
|
||||
use crate::image::Image;
|
||||
use crate::mock;
|
||||
|
||||
|
@ -10,6 +10,12 @@ pub struct Tile {
|
|||
pub animation_frames: Vec<Image>,
|
||||
}
|
||||
|
||||
impl Tile {
|
||||
fn name_line(&self) -> String {
|
||||
optional_data_line("NAME", self.name.as_ref())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<String> for Tile {
|
||||
#[inline]
|
||||
fn from(string: String) -> Tile {
|
||||
|
@ -52,7 +58,7 @@ impl ToString for Tile {
|
|||
"TIL {}\n{}{}{}",
|
||||
self.id.to_base36(),
|
||||
self.animation_frames.to_string(),
|
||||
if self.name.as_ref().is_some() { format!("\nNAME {}", self.name.as_ref().unwrap())} else {"".to_string() },
|
||||
self.name_line(),
|
||||
if self.wall {"\nWAL true"} else {""}
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue