Make results of wind simulation push the player

This commit is contained in:
Oresavna 2021-05-12 12:10:56 +02:00 committed by Ludvig Böklin
parent 63f2105c84
commit 766897ce65
2 changed files with 19 additions and 4 deletions

View File

@ -27,8 +27,9 @@ use common::{
invite::{InviteKind, InviteResponse},
skills::Skill,
slot::Slot,
ChatMode, ControlAction, ControlEvent, Controller, ControllerInputs, GroupManip, InputKind,
InventoryAction, InventoryEvent, InventoryUpdateEvent, UtteranceKind,
ChatMode, ControlAction, ControlEvent, Controller, ControllerInputs, Fluid, GroupManip,
InputKind, InventoryAction, InventoryEvent, InventoryUpdateEvent, PhysicsState,
UtteranceKind, Vel,
},
event::{EventBus, LocalEvent},
grid::Grid,
@ -1985,6 +1986,20 @@ impl Client {
},
ServerGeneral::WindUpdate(vel) => {
println!("Windupdate {}", vel);
let player_entity = self.entity();
self.state
.ecs_mut()
.write_storage::<PhysicsState>()
.get_mut(player_entity)
.map(|physics_state| {
physics_state.in_fluid = physics_state
.in_fluid
.filter(|fluid| matches!(fluid, Fluid::Water { .. }))
.or(Some(Fluid::Air {
elevation: 0.0,
vel: Vel(vel),
}));
});
},
_ => unreachable!("Not a in_game message"),
}

View File

@ -23,13 +23,13 @@ impl<'a> System<'a> for Sys {
let wind_sources: Vec<(Pos, Vel)> = vec![(
Pos(Vec3 {
x: 9999.0,
y: 9999.0,
y: 9599.0,
z: 200.0,
}),
Vel(Vec3 {
x: 100.0,
y: 100.0,
z: 100.0,
z: 500.0,
}),
)];
windsim.tick(wind_sources, &dt);