rendering, physics, player and camera WIP
This commit is contained in:
38
src/systems/state_machine.rs
Normal file
38
src/systems/state_machine.rs
Normal file
@@ -0,0 +1,38 @@
|
||||
use crate::world::World;
|
||||
|
||||
pub fn state_machine_system(world: &mut World, delta: f32)
|
||||
{
|
||||
let entities: Vec<_> = world.state_machines.all();
|
||||
|
||||
for entity in entities
|
||||
{
|
||||
if let Some(mut state_machine) = world.state_machines.components.remove(&entity)
|
||||
{
|
||||
state_machine.update(world, delta);
|
||||
world
|
||||
.state_machines
|
||||
.components
|
||||
.insert(entity, state_machine);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn state_machine_physics_system(world: &mut World, delta: f32)
|
||||
{
|
||||
let entities: Vec<_> = world.state_machines.all();
|
||||
|
||||
for entity in entities
|
||||
{
|
||||
if let Some(mut state_machine) = world.state_machines.components.remove(&entity)
|
||||
{
|
||||
if let Some(current_state) = state_machine.get_current_state_mut()
|
||||
{
|
||||
current_state.on_state_physics_update(world, delta);
|
||||
}
|
||||
world
|
||||
.state_machines
|
||||
.components
|
||||
.insert(entity, state_machine);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user