Mounting fix

This commit is contained in:
Sam 2021-03-15 00:26:19 -04:00
parent 41342deab6
commit 0c7ea992c2
2 changed files with 14 additions and 11 deletions

View File

@ -153,15 +153,6 @@ impl<'a> System<'a> for Sys {
// Do nothing
continue;
}
// If mounted, character state is controlled by mount
// TODO: Make mounting a state
if let Some(Mounting(_)) = read_data.mountings.get(entity) {
let sit_state = CharacterState::Sit {};
if char_state.get_unchecked() != &sit_state {
*char_state.get_mut_unchecked() = sit_state;
}
continue;
}
// Enter stunned state if poise damage is enough
if let Some(mut poise) = poises.get_mut(entity) {
@ -317,6 +308,17 @@ impl<'a> System<'a> for Sys {
incorporate_update(&mut join_struct, state_update);
}
// Mounted occurs after control actions have been handled
// If mounted, character state is controlled by mount
// TODO: Make mounting a state
if let Some(Mounting(_)) = read_data.mountings.get(entity) {
let sit_state = CharacterState::Sit {};
if join_struct.char_state.get_unchecked() != &sit_state {
*join_struct.char_state.get_mut_unchecked() = sit_state;
}
continue;
}
let j = JoinData::new(
&join_struct,
&read_data.lazy_update,

View File

@ -53,12 +53,12 @@ impl<'a> System<'a> for Sys {
MountState::MountedBy(mounter_uid) => {
// 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
if let Some((inputs, queued_inputs, mounter)) = uid_allocator
.retrieve_entity_internal(mounter_uid.id())
.and_then(|mounter| {
controllers
.get(mounter)
.map(|c| (c.inputs.clone(), mounter))
.map(|c| (c.inputs.clone(), c.queued_inputs.clone(), mounter))
})
{
// TODO: consider joining on these? (remember we can use .maybe())
@ -75,6 +75,7 @@ impl<'a> System<'a> for Sys {
if let Some(controller) = controllers.get_mut(entity) {
*controller = Controller {
inputs,
queued_inputs,
..Default::default()
}
}