Move more into SceneEntities

This commit is contained in:
hodasemi 2024-08-28 16:14:07 +02:00
parent fab7f14298
commit fade27c74f
2 changed files with 16 additions and 10 deletions

View file

@ -228,16 +228,6 @@ impl Scene {
Ok(()) Ok(())
} }
pub fn entity_resource(
&mut self,
entity: Entity,
) -> Result<(&mut Resources, &mut EntityObject)> {
Ok((
unsafe { remove_life_time_mut(&mut self.resources) },
self.entity_mut(entity)?,
))
}
pub fn view_resource(&mut self) -> (&mut View, &mut Resources) { pub fn view_resource(&mut self) -> (&mut View, &mut Resources) {
(self.renderer.view_mut(), &mut self.resources) (self.renderer.view_mut(), &mut self.resources)
} }
@ -703,6 +693,13 @@ impl SceneEntities for Scene {
Ok(e) Ok(e)
} }
fn entity_resource(&mut self, entity: Entity) -> Result<(&mut Resources, &mut EntityObject)> {
Ok((
unsafe { remove_life_time_mut(&mut self.resources) },
self.entity_mut(entity)?,
))
}
fn archetype_info(&self, name: impl ToString) -> Result<ArchetypeInfo> { fn archetype_info(&self, name: impl ToString) -> Result<ArchetypeInfo> {
let name = name.to_string(); let name = name.to_string();
let archetype = self let archetype = self

View file

@ -45,6 +45,8 @@ pub trait SceneEntities {
fn add_entity(&mut self, entity_object: EntityObject) -> Result<Entity>; fn add_entity(&mut self, entity_object: EntityObject) -> Result<Entity>;
fn archetype_info(&self, name: impl ToString) -> Result<ArchetypeInfo>; fn archetype_info(&self, name: impl ToString) -> Result<ArchetypeInfo>;
fn entity_resource(&mut self, entity: Entity) -> Result<(&mut Resources, &mut EntityObject)>;
fn insert_component<T: EntityComponent + ComponentDebug>( fn insert_component<T: EntityComponent + ComponentDebug>(
&mut self, &mut self,
entity: Entity, entity: Entity,
@ -358,6 +360,13 @@ impl<'a> SceneEntities for SceneContents<'a> {
self.entities.add_entity(entity_object) self.entities.add_entity(entity_object)
} }
fn entity_resource(&mut self, entity: Entity) -> Result<(&mut Resources, &mut EntityObject)> {
Ok((
unsafe { remove_life_time_mut(&mut self.resources) },
self.entity_mut(entity)?,
))
}
fn archetype_info(&self, name: impl ToString) -> Result<ArchetypeInfo> { fn archetype_info(&self, name: impl ToString) -> Result<ArchetypeInfo> {
let name = name.to_string(); let name = name.to_string();
let archetype = self let archetype = self