Fixing updates
This commit is contained in:
parent
0a8ea8972a
commit
10f6103016
2 changed files with 24 additions and 28 deletions
|
@ -142,22 +142,23 @@ impl Scene {
|
||||||
world.add_update(
|
world.add_update(
|
||||||
"animate",
|
"animate",
|
||||||
5_500_000,
|
5_500_000,
|
||||||
|commands: &mut Commands, _entity, draw: &mut Draw, animation: &mut Animation| {
|
|commands: &mut Commands, mut query: Query<(&mut Draw, &mut Animation)>| {
|
||||||
|
let (draw, animation) = &mut *query;
|
||||||
|
|
||||||
animation.animate(commands.now(), draw)?;
|
animation.animate(commands.now(), draw)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
},
|
},
|
||||||
EmptyFilter,
|
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
world.add_update(
|
world.add_update(
|
||||||
"particle_system",
|
"particle_system",
|
||||||
5_000_000,
|
5_000_000,
|
||||||
|commands: &mut Commands,
|
|commands: &mut Commands, mut query: Query<&mut ParticleSystem>, scene: &mut Scene| {
|
||||||
entity,
|
|
||||||
particle_system: &mut ParticleSystem,
|
|
||||||
scene: &mut Scene| {
|
|
||||||
let now = commands.now();
|
let now = commands.now();
|
||||||
|
let entity = query.entity();
|
||||||
|
|
||||||
|
let particle_system = &mut *query;
|
||||||
|
|
||||||
if !particle_system.update(now) {
|
if !particle_system.update(now) {
|
||||||
commands.remove_entity(entity);
|
commands.remove_entity(entity);
|
||||||
|
@ -179,7 +180,6 @@ impl Scene {
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
},
|
},
|
||||||
EmptyFilter,
|
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -251,29 +251,22 @@ impl Game {
|
||||||
|
|
||||||
impl Game {
|
impl Game {
|
||||||
pub fn setup_updates(world_builder: &mut WorldBuilder) -> Result<()> {
|
pub fn setup_updates(world_builder: &mut WorldBuilder) -> Result<()> {
|
||||||
world_builder.add_update(
|
world_builder.add_update("player_rotation", 200, Self::player_orientation)?;
|
||||||
"player_rotation",
|
|
||||||
200,
|
|
||||||
Self::player_orientation,
|
|
||||||
EmptyFilter,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
if !FREE_CAMERA_CONTROL {
|
if !FREE_CAMERA_CONTROL {
|
||||||
world_builder.add_update("camera_position", 1_000, Self::camera_update, EmptyFilter)?;
|
world_builder.add_update("camera_position", 1_000, Self::camera_update)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
world_builder.add_update(
|
world_builder.add_update(
|
||||||
"celestial velocity update",
|
"celestial velocity update",
|
||||||
100,
|
100,
|
||||||
Self::celestial_velocity_update,
|
Self::celestial_velocity_update,
|
||||||
(EmptyFilter, EmptyFilter),
|
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
world_builder.add_update(
|
world_builder.add_update(
|
||||||
"celestial buffer update",
|
"celestial buffer update",
|
||||||
110,
|
110,
|
||||||
Self::celestial_buffer_update,
|
Self::celestial_buffer_update,
|
||||||
EmptyFilter,
|
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -322,21 +315,21 @@ impl Game {
|
||||||
impl Game {
|
impl Game {
|
||||||
fn player_orientation(
|
fn player_orientation(
|
||||||
commands: &mut Commands,
|
commands: &mut Commands,
|
||||||
_entity: Entity,
|
mut query: Query<(&mut Draw, &mut FreeSpaceControl)>,
|
||||||
draw: &mut Draw,
|
|
||||||
control: &mut FreeSpaceControl,
|
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
|
let (draw, control) = &mut *query;
|
||||||
|
|
||||||
control.update(commands.now());
|
control.update(commands.now());
|
||||||
draw.set_transform(control.transform())
|
draw.set_transform(control.transform())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn camera_update(
|
fn camera_update(
|
||||||
_commands: &mut Commands,
|
_commands: &mut Commands,
|
||||||
_entity: Entity,
|
query: Query<&mut FreeSpaceControl>,
|
||||||
control: &mut FreeSpaceControl,
|
|
||||||
scene: &mut Scene,
|
scene: &mut Scene,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let view = scene.view_mut();
|
let view = scene.view_mut();
|
||||||
|
let control = &*query;
|
||||||
|
|
||||||
view.camera_mut()
|
view.camera_mut()
|
||||||
.set_center((control.translation() * Vector4::unit_w()).truncate());
|
.set_center((control.translation() * Vector4::unit_w()).truncate());
|
||||||
|
@ -350,10 +343,10 @@ impl Game {
|
||||||
|
|
||||||
fn celestial_buffer_update(
|
fn celestial_buffer_update(
|
||||||
_commands: &mut Commands,
|
_commands: &mut Commands,
|
||||||
_: Entity,
|
mut query: Query<(&mut Draw, &mut CelestialObjectSettings)>,
|
||||||
draw: &mut Draw,
|
|
||||||
control: &mut CelestialObjectSettings,
|
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
|
let (draw, control) = &mut *query;
|
||||||
|
|
||||||
draw.set_transform(control.model_matrix())?;
|
draw.set_transform(control.model_matrix())?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -361,14 +354,17 @@ impl Game {
|
||||||
|
|
||||||
fn celestial_velocity_update(
|
fn celestial_velocity_update(
|
||||||
commands: &mut Commands,
|
commands: &mut Commands,
|
||||||
(_, draw, lhs_control, reference): (
|
mut lhs: Query<(
|
||||||
Entity,
|
|
||||||
&mut Draw,
|
&mut Draw,
|
||||||
&mut CelestialObjectSettings,
|
&mut CelestialObjectSettings,
|
||||||
&mut CelestialReference,
|
&mut CelestialReference,
|
||||||
),
|
)>,
|
||||||
(rhs_entity, rhs_control): (Entity, &mut CelestialObjectSettings),
|
rhs: Query<&mut CelestialObjectSettings>,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
|
let (draw, lhs_control, reference) = &mut *lhs;
|
||||||
|
let rhs_entity = rhs.entity();
|
||||||
|
let rhs_control = &*rhs;
|
||||||
|
|
||||||
if reference.entity == rhs_entity {
|
if reference.entity == rhs_entity {
|
||||||
lhs_control.update(commands.now(), draw, rhs_control)?;
|
lhs_control.update(commands.now(), draw, rhs_control)?;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue