mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fix issue where controller events aren't processed while mounted. Fix non humanoids being able to climb and glide.
This commit is contained in:
parent
c9caf14877
commit
1acf08390a
@ -48,6 +48,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Fixed the bow fire rate
|
||||
- Healthbars now flash on critical health
|
||||
- Fixed ghosts when going back to character screen
|
||||
- Fixed not being able to unmount
|
||||
- Fixed non-humanoids being able to climb and glide
|
||||
|
||||
### Removed
|
||||
|
||||
|
@ -44,7 +44,7 @@ opt-level = 2
|
||||
inherits= 'dev'
|
||||
debug = true
|
||||
|
||||
# this profil is used for veloren releases, compile time doesn't matter
|
||||
# this profile is used for veloren releases, compile time doesn't matter
|
||||
# we need stacktraces, light debug information, as much checks as possible
|
||||
# I would like to put it in a seperate `official_release` target, but that doesnt share caches with `cargo test` and `cargo bench`
|
||||
[profile.release]
|
||||
|
@ -327,6 +327,24 @@ impl<'a> System<'a> for Sys {
|
||||
// Or do nothing
|
||||
continue;
|
||||
}
|
||||
|
||||
// Process controller events
|
||||
for event in controller.events.drain(..) {
|
||||
match event {
|
||||
ControlEvent::Mount(mountee_uid) => {
|
||||
if let Some(mountee_entity) =
|
||||
uid_allocator.retrieve_entity_internal(mountee_uid.id())
|
||||
{
|
||||
server_emitter.emit(ServerEvent::Mount(entity, mountee_entity));
|
||||
}
|
||||
}
|
||||
ControlEvent::Unmount => server_emitter.emit(ServerEvent::Unmount(entity)),
|
||||
ControlEvent::InventoryManip(manip) => {
|
||||
server_emitter.emit(ServerEvent::InventoryManip(entity, manip))
|
||||
} //ControlEvent::Respawn => server_emitter.emit(ServerEvent::Unmount(entity)),
|
||||
}
|
||||
}
|
||||
|
||||
// If mounted, character state is controlled by mount
|
||||
if mount.is_some() {
|
||||
character.movement = Sit;
|
||||
@ -394,16 +412,17 @@ impl<'a> System<'a> for Sys {
|
||||
// Any Action + Falling
|
||||
(action_state, Fall) => {
|
||||
character.movement = get_state_from_move_dir(&inputs.move_dir);
|
||||
if inputs.glide.is_pressed() {
|
||||
if inputs.glide.is_pressed() && can_glide(body) {
|
||||
character.movement = Glide;
|
||||
continue;
|
||||
}
|
||||
// Try to climb
|
||||
if let (true, Some(_wall_dir)) = (
|
||||
inputs.climb.is_pressed() | inputs.climb_down.is_pressed()
|
||||
&& body.is_humanoid(),
|
||||
(inputs.climb.is_pressed() | inputs.climb_down.is_pressed())
|
||||
&& can_climb(body),
|
||||
physics.on_wall,
|
||||
) {
|
||||
println!("here 1");
|
||||
character.movement = Climb;
|
||||
continue;
|
||||
}
|
||||
@ -530,10 +549,11 @@ impl<'a> System<'a> for Sys {
|
||||
|
||||
// Try to climb
|
||||
if let (true, Some(_wall_dir)) = (
|
||||
inputs.climb.is_pressed() | inputs.climb_down.is_pressed()
|
||||
&& body.is_humanoid(),
|
||||
(inputs.climb.is_pressed() | inputs.climb_down.is_pressed())
|
||||
&& can_climb(body),
|
||||
physics.on_wall,
|
||||
) {
|
||||
println!("here 2");
|
||||
character.movement = Climb;
|
||||
continue;
|
||||
}
|
||||
@ -578,9 +598,7 @@ impl<'a> System<'a> for Sys {
|
||||
// While not on ground ...
|
||||
else {
|
||||
// Try to glide
|
||||
if physics.on_wall == None
|
||||
&& inputs.glide.is_pressed()
|
||||
&& body.is_humanoid()
|
||||
if physics.on_wall == None && inputs.glide.is_pressed() && can_glide(&body)
|
||||
{
|
||||
character.movement = Glide;
|
||||
continue;
|
||||
@ -652,7 +670,8 @@ impl<'a> System<'a> for Sys {
|
||||
|
||||
if !inputs.glide.is_pressed() {
|
||||
character.movement = Fall;
|
||||
} else if let Some(_wall_dir) = physics.on_wall {
|
||||
} else if let (Some(_wall_dir), true) = (physics.on_wall, can_climb(body)) {
|
||||
println!("here 3");
|
||||
character.movement = Climb;
|
||||
}
|
||||
|
||||
@ -681,23 +700,14 @@ impl<'a> System<'a> for Sys {
|
||||
// character.movement = Fall;
|
||||
// }
|
||||
};
|
||||
|
||||
// Process other controller events
|
||||
for event in controller.events.drain(..) {
|
||||
match event {
|
||||
ControlEvent::Mount(mountee_uid) => {
|
||||
if let Some(mountee_entity) =
|
||||
uid_allocator.retrieve_entity_internal(mountee_uid.id())
|
||||
{
|
||||
server_emitter.emit(ServerEvent::Mount(entity, mountee_entity));
|
||||
}
|
||||
}
|
||||
ControlEvent::Unmount => server_emitter.emit(ServerEvent::Unmount(entity)),
|
||||
ControlEvent::InventoryManip(manip) => {
|
||||
server_emitter.emit(ServerEvent::InventoryManip(entity, manip))
|
||||
} //ControlEvent::Respawn => server_emitter.emit(ServerEvent::Unmount(entity)),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn can_glide(body: &Body) -> bool {
|
||||
body.is_humanoid()
|
||||
}
|
||||
|
||||
fn can_climb(body: &Body) -> bool {
|
||||
body.is_humanoid()
|
||||
}
|
||||
|
@ -24,8 +24,8 @@ const CLEANUP_SYS: &str = "cleanup_sys";
|
||||
|
||||
pub fn add_local_systems(dispatch_builder: &mut DispatcherBuilder) {
|
||||
dispatch_builder.add(agent::Sys, AGENT_SYS, &[]);
|
||||
dispatch_builder.add(controller::Sys, CONTROLLER_SYS, &[AGENT_SYS]);
|
||||
dispatch_builder.add(mount::Sys, MOUNT_SYS, &[CONTROLLER_SYS]);
|
||||
dispatch_builder.add(mount::Sys, MOUNT_SYS, &[AGENT_SYS]);
|
||||
dispatch_builder.add(controller::Sys, CONTROLLER_SYS, &[AGENT_SYS, MOUNT_SYS]);
|
||||
dispatch_builder.add(movement::Sys, MOVEMENT_SYS, &[]);
|
||||
dispatch_builder.add(combat::Sys, COMBAT_SYS, &[CONTROLLER_SYS]);
|
||||
dispatch_builder.add(stats::Sys, STATS_SYS, &[COMBAT_SYS]);
|
||||
|
@ -40,9 +40,15 @@ impl<'a> System<'a> for Sys {
|
||||
match mount_states.get_unchecked() {
|
||||
MountState::Unmounted => {}
|
||||
MountState::MountedBy(mounter_uid) => {
|
||||
if let Some((controller, mounter)) = uid_allocator
|
||||
// Note: currently controller events are not passed through since none of them
|
||||
// are currently relevant to controlling the mounted entity
|
||||
if let Some((inputs, mounter)) = uid_allocator
|
||||
.retrieve_entity_internal(mounter_uid.id())
|
||||
.and_then(|mounter| controllers.get(mounter).cloned().map(|x| (x, mounter)))
|
||||
.and_then(|mounter| {
|
||||
controllers
|
||||
.get(mounter)
|
||||
.map(|c| (c.inputs.clone(), mounter))
|
||||
})
|
||||
{
|
||||
// TODO: consider joining on these? (remember we can use .maybe())
|
||||
let pos = positions.get(entity).copied();
|
||||
@ -53,7 +59,13 @@ impl<'a> System<'a> for Sys {
|
||||
let _ = orientations.insert(mounter, ori);
|
||||
let _ = velocities.insert(mounter, vel);
|
||||
}
|
||||
let _ = controllers.insert(entity, controller);
|
||||
let _ = controllers.insert(
|
||||
entity,
|
||||
Controller {
|
||||
inputs,
|
||||
..Default::default()
|
||||
},
|
||||
);
|
||||
} else {
|
||||
*(mount_states.get_mut_unchecked()) = MountState::Unmounted;
|
||||
}
|
||||
|
@ -209,8 +209,7 @@ impl<'a> System<'a> for Sys {
|
||||
|
||||
// Climb
|
||||
if let (true, Some(_wall_dir)) = (
|
||||
(inputs.climb.is_pressed() | inputs.climb_down.is_pressed())
|
||||
&& vel.0.z <= CLIMB_SPEED,
|
||||
character.movement == Climb && vel.0.z <= CLIMB_SPEED,
|
||||
physics.on_wall,
|
||||
) {
|
||||
if inputs.climb_down.is_pressed() && !inputs.climb.is_pressed() {
|
||||
|
Loading…
Reference in New Issue
Block a user