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