1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
use { constants::Color, objects::{Flag, HasPosition}, }; simple_accessors! { Flag; (color -> color -> Color), (name -> name -> String), (secondary_color -> secondaryColor -> Color), } impl Flag { pub fn remove(&self) { js! {@{self.as_ref()}.remove();}; } pub fn set_color(&self, color: Color, secondary_color: Option<Color>) { match secondary_color { None => js! {@{self.as_ref()}.setColor(@{u32::from(color)});}, Some(sec_color) => js! { @{self.as_ref()}.setColor( @{u32::from(color)}, @{u32::from(sec_color)}, ); }, }; } pub fn set_position<T: HasPosition>(&self, pos: T) { let room_pos = pos.pos(); js! {@{self.as_ref()}.setPosition(@{room_pos.as_ref()});}; } pub fn set_position_xy(&self, x: u32, y: u32) { js! {@{self.as_ref()}.setPosition(@{x}, @{y});}; } }