pub struct Level {
pub id: Uuid,
pub name: String,
pub width: u32,
pub height: u32,
pub layers: Vec<Layer>,
pub entities: Vec<EntityInstance>,
pub world_x: i32,
pub world_y: i32,
pub bg_color: Option<String>,
}Expand description
A level/map containing tiles and entities
Fields§
§id: Uuid§name: String§width: u32§height: u32§layers: Vec<Layer>§entities: Vec<EntityInstance>§world_x: i32World X position in pixels (for world view)
world_y: i32World Y position in pixels (for world view)
bg_color: Option<String>Background color for world view (hex format, e.g., “#3C3C50”)
Implementations§
Source§impl Level
impl Level
Sourcepub fn new_at(
name: String,
width: u32,
height: u32,
world_x: i32,
world_y: i32,
) -> Self
pub fn new_at( name: String, width: u32, height: u32, world_x: i32, world_y: i32, ) -> Self
Create a new level at a specific world position
Sourcepub fn set_world_position(&mut self, x: i32, y: i32)
pub fn set_world_position(&mut self, x: i32, y: i32)
Set the world position
Sourcepub fn world_position(&self) -> (i32, i32)
pub fn world_position(&self) -> (i32, i32)
Get the world position as a tuple
Sourcepub fn add_entity(&mut self, entity: EntityInstance)
pub fn add_entity(&mut self, entity: EntityInstance)
Add an entity to the level
Sourcepub fn remove_entity(&mut self, id: Uuid) -> Option<EntityInstance>
pub fn remove_entity(&mut self, id: Uuid) -> Option<EntityInstance>
Remove an entity by ID
Sourcepub fn get_entity(&self, id: Uuid) -> Option<&EntityInstance>
pub fn get_entity(&self, id: Uuid) -> Option<&EntityInstance>
Get entity by ID
Sourcepub fn get_entity_mut(&mut self, id: Uuid) -> Option<&mut EntityInstance>
pub fn get_entity_mut(&mut self, id: Uuid) -> Option<&mut EntityInstance>
Get mutable entity by ID
Sourcepub fn get_tile(&self, layer_index: usize, x: u32, y: u32) -> Option<u32>
pub fn get_tile(&self, layer_index: usize, x: u32, y: u32) -> Option<u32>
Get tile at position for a specific layer
Sourcepub fn set_tile(
&mut self,
layer_index: usize,
x: u32,
y: u32,
tile: Option<u32>,
)
pub fn set_tile( &mut self, layer_index: usize, x: u32, y: u32, tile: Option<u32>, )
Set tile at position for a specific layer
Sourcepub fn remove_layer(&mut self, index: usize) -> Option<Layer>
pub fn remove_layer(&mut self, index: usize) -> Option<Layer>
Remove a layer by index
Sourcepub fn move_layer_up(&mut self, index: usize) -> bool
pub fn move_layer_up(&mut self, index: usize) -> bool
Move a layer up (toward index 0)
Sourcepub fn move_layer_down(&mut self, index: usize) -> bool
pub fn move_layer_down(&mut self, index: usize) -> bool
Move a layer down (toward higher index)
Sourcepub fn toggle_layer_visibility(&mut self, index: usize) -> bool
pub fn toggle_layer_visibility(&mut self, index: usize) -> bool
Toggle layer visibility
Sourcepub fn get_layer_mut(&mut self, index: usize) -> Option<&mut Layer>
pub fn get_layer_mut(&mut self, index: usize) -> Option<&mut Layer>
Get mutable layer by index
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Level
impl<'de> Deserialize<'de> for Level
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Level
impl RefUnwindSafe for Level
impl Send for Level
impl Sync for Level
impl Unpin for Level
impl UnsafeUnpin for Level
impl UnwindSafe for Level
Blanket Implementations§
Source§impl<T, U> AsBindGroupShaderType<U> for T
impl<T, U> AsBindGroupShaderType<U> for T
Source§fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
Return the
T ShaderType for self. When used in AsBindGroup
derives, it is safe to assume that all images in self exist.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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Converts
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Converts
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Converts
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Converts
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
Converts
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>
Converts
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 moreSource§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
Source§fn into_result(self) -> Result<T, RunSystemError>
fn into_result(self) -> Result<T, RunSystemError>
Converts this type into the system output type.
Source§impl<T> Serialize for T
impl<T> Serialize for T
fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>
fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>
Source§impl<T, U> ToSample<U> for Twhere
U: FromSample<T>,
impl<T, U> ToSample<U> for Twhere
U: FromSample<T>,
fn to_sample_(self) -> U
Source§impl<T> TypeData for T
impl<T> TypeData for T
Source§fn clone_type_data(&self) -> Box<dyn TypeData>
fn clone_type_data(&self) -> Box<dyn TypeData>
Creates a type-erased clone of this value.