Removed potential for accessing OOB index and panicking in animations for combo melee.

Made only entities with a character state component emit a death outcome on death.
This commit is contained in:
Sam 2021-06-29 06:20:26 -05:00
parent aaf5f89076
commit 4cdf081a40
2 changed files with 157 additions and 192 deletions

View File

@ -138,12 +138,13 @@ pub fn handle_destroy(server: &mut Server, entity: EcsEntity, cause: HealthSourc
}
};
// Push an outcome
// Push an outcome if entity is has a character state (entities that don't have
// one, we probably don't care about emitting death outcome)
if state
.ecs()
.read_storage::<comp::Projectile>()
.read_storage::<comp::CharacterState>()
.get(entity)
.is_none()
.is_some()
{
if let Some(pos) = state.ecs().read_storage::<Pos>().get(entity) {
state

View File

@ -1338,27 +1338,23 @@ impl FigureMgr {
CharacterState::ComboMelee(s) => {
let stage_index = (s.stage - 1) as usize;
let stage_time = s.timer.as_secs_f32();
let stage_progress = match s.stage_section {
StageSection::Buildup => {
stage_time
/ s.static_data.stage_data[stage_index]
.base_buildup_duration
.as_secs_f32()
},
StageSection::Swing => {
stage_time
/ s.static_data.stage_data[stage_index]
.base_swing_duration
.as_secs_f32()
},
StageSection::Recover => {
stage_time
/ s.static_data.stage_data[stage_index]
.base_recover_duration
.as_secs_f32()
},
_ => 0.0,
};
let stage_progress =
if let Some(stage) = s.static_data.stage_data.get(stage_index) {
match s.stage_section {
StageSection::Buildup => {
stage_time / stage.base_buildup_duration.as_secs_f32()
},
StageSection::Swing => {
stage_time / stage.base_swing_duration.as_secs_f32()
},
StageSection::Recover => {
stage_time / stage.base_recover_duration.as_secs_f32()
},
_ => 0.0,
}
} else {
0.0
};
match s.stage {
1 => anim::character::AlphaAnimation::update_skeleton(
&target_base,
@ -1664,27 +1660,23 @@ impl FigureMgr {
CharacterState::ComboMelee(s) => {
let stage_index = (s.stage - 1) as usize;
let stage_time = s.timer.as_secs_f32();
let stage_progress = match s.stage_section {
StageSection::Buildup => {
stage_time
/ s.static_data.stage_data[stage_index]
.base_buildup_duration
.as_secs_f32()
},
StageSection::Swing => {
stage_time
/ s.static_data.stage_data[stage_index]
.base_swing_duration
.as_secs_f32()
},
StageSection::Recover => {
stage_time
/ s.static_data.stage_data[stage_index]
.base_recover_duration
.as_secs_f32()
},
_ => 0.0,
};
let stage_progress =
if let Some(stage) = s.static_data.stage_data.get(stage_index) {
match s.stage_section {
StageSection::Buildup => {
stage_time / stage.base_buildup_duration.as_secs_f32()
},
StageSection::Swing => {
stage_time / stage.base_swing_duration.as_secs_f32()
},
StageSection::Recover => {
stage_time / stage.base_recover_duration.as_secs_f32()
},
_ => 0.0,
}
} else {
0.0
};
{
anim::quadruped_small::AlphaAnimation::update_skeleton(
&target_base,
@ -1955,27 +1947,23 @@ impl FigureMgr {
CharacterState::ComboMelee(s) => {
let stage_index = (s.stage - 1) as usize;
let stage_time = s.timer.as_secs_f32();
let stage_progress = match s.stage_section {
StageSection::Buildup => {
stage_time
/ s.static_data.stage_data[stage_index]
.base_buildup_duration
.as_secs_f32()
},
StageSection::Swing => {
stage_time
/ s.static_data.stage_data[stage_index]
.base_swing_duration
.as_secs_f32()
},
StageSection::Recover => {
stage_time
/ s.static_data.stage_data[stage_index]
.base_recover_duration
.as_secs_f32()
},
_ => 0.0,
};
let stage_progress =
if let Some(stage) = s.static_data.stage_data.get(stage_index) {
match s.stage_section {
StageSection::Buildup => {
stage_time / stage.base_buildup_duration.as_secs_f32()
},
StageSection::Swing => {
stage_time / stage.base_swing_duration.as_secs_f32()
},
StageSection::Recover => {
stage_time / stage.base_recover_duration.as_secs_f32()
},
_ => 0.0,
}
} else {
0.0
};
match s.stage {
1 => anim::quadruped_medium::AlphaAnimation::update_skeleton(
&target_base,
@ -2315,27 +2303,23 @@ impl FigureMgr {
CharacterState::ComboMelee(s) => {
let stage_index = (s.stage - 1) as usize;
let stage_time = s.timer.as_secs_f32();
let stage_progress = match s.stage_section {
StageSection::Buildup => {
stage_time
/ s.static_data.stage_data[stage_index]
.base_buildup_duration
.as_secs_f32()
},
StageSection::Swing => {
stage_time
/ s.static_data.stage_data[stage_index]
.base_swing_duration
.as_secs_f32()
},
StageSection::Recover => {
stage_time
/ s.static_data.stage_data[stage_index]
.base_recover_duration
.as_secs_f32()
},
_ => 0.0,
};
let stage_progress =
if let Some(stage) = s.static_data.stage_data.get(stage_index) {
match s.stage_section {
StageSection::Buildup => {
stage_time / stage.base_buildup_duration.as_secs_f32()
},
StageSection::Swing => {
stage_time / stage.base_swing_duration.as_secs_f32()
},
StageSection::Recover => {
stage_time / stage.base_recover_duration.as_secs_f32()
},
_ => 0.0,
}
} else {
0.0
};
match s.stage {
1 => anim::quadruped_low::AlphaAnimation::update_skeleton(
&target_base,
@ -2917,27 +2901,23 @@ impl FigureMgr {
CharacterState::ComboMelee(s) => {
let stage_index = (s.stage - 1) as usize;
let stage_time = s.timer.as_secs_f32();
let stage_progress = match s.stage_section {
StageSection::Buildup => {
stage_time
/ s.static_data.stage_data[stage_index]
.base_buildup_duration
.as_secs_f32()
},
StageSection::Swing => {
stage_time
/ s.static_data.stage_data[stage_index]
.base_swing_duration
.as_secs_f32()
},
StageSection::Recover => {
stage_time
/ s.static_data.stage_data[stage_index]
.base_recover_duration
.as_secs_f32()
},
_ => 0.0,
};
let stage_progress =
if let Some(stage) = s.static_data.stage_data.get(stage_index) {
match s.stage_section {
StageSection::Buildup => {
stage_time / stage.base_buildup_duration.as_secs_f32()
},
StageSection::Swing => {
stage_time / stage.base_swing_duration.as_secs_f32()
},
StageSection::Recover => {
stage_time / stage.base_recover_duration.as_secs_f32()
},
_ => 0.0,
}
} else {
0.0
};
match s.stage {
1 => anim::biped_small::AlphaAnimation::update_skeleton(
&target_base,
@ -3178,27 +3158,23 @@ impl FigureMgr {
CharacterState::ComboMelee(s) => {
let stage_index = (s.stage - 1) as usize;
let stage_time = s.timer.as_secs_f32();
let stage_progress = match s.stage_section {
StageSection::Buildup => {
stage_time
/ s.static_data.stage_data[stage_index]
.base_buildup_duration
.as_secs_f32()
},
StageSection::Swing => {
stage_time
/ s.static_data.stage_data[stage_index]
.base_swing_duration
.as_secs_f32()
},
StageSection::Recover => {
stage_time
/ s.static_data.stage_data[stage_index]
.base_recover_duration
.as_secs_f32()
},
_ => 0.0,
};
let stage_progress =
if let Some(stage) = s.static_data.stage_data.get(stage_index) {
match s.stage_section {
StageSection::Buildup => {
stage_time / stage.base_buildup_duration.as_secs_f32()
},
StageSection::Swing => {
stage_time / stage.base_swing_duration.as_secs_f32()
},
StageSection::Recover => {
stage_time / stage.base_recover_duration.as_secs_f32()
},
_ => 0.0,
}
} else {
0.0
};
match s.stage {
1 => anim::theropod::AlphaAnimation::update_skeleton(
&target_base,
@ -3406,27 +3382,23 @@ impl FigureMgr {
CharacterState::ComboMelee(s) => {
let stage_index = (s.stage - 1) as usize;
let stage_time = s.timer.as_secs_f32();
let stage_progress = match s.stage_section {
StageSection::Buildup => {
stage_time
/ s.static_data.stage_data[stage_index]
.base_buildup_duration
.as_secs_f32()
},
StageSection::Swing => {
stage_time
/ s.static_data.stage_data[stage_index]
.base_swing_duration
.as_secs_f32()
},
StageSection::Recover => {
stage_time
/ s.static_data.stage_data[stage_index]
.base_recover_duration
.as_secs_f32()
},
_ => 0.0,
};
let stage_progress =
if let Some(stage) = s.static_data.stage_data.get(stage_index) {
match s.stage_section {
StageSection::Buildup => {
stage_time / stage.base_buildup_duration.as_secs_f32()
},
StageSection::Swing => {
stage_time / stage.base_swing_duration.as_secs_f32()
},
StageSection::Recover => {
stage_time / stage.base_recover_duration.as_secs_f32()
},
_ => 0.0,
}
} else {
0.0
};
anim::bird_large::AlphaAnimation::update_skeleton(
&target_base,
@ -4049,27 +4021,23 @@ impl FigureMgr {
CharacterState::ComboMelee(s) => {
let stage_index = (s.stage - 1) as usize;
let stage_time = s.timer.as_secs_f32();
let stage_progress = match s.stage_section {
StageSection::Buildup => {
stage_time
/ s.static_data.stage_data[stage_index]
.base_buildup_duration
.as_secs_f32()
},
StageSection::Swing => {
stage_time
/ s.static_data.stage_data[stage_index]
.base_swing_duration
.as_secs_f32()
},
StageSection::Recover => {
stage_time
/ s.static_data.stage_data[stage_index]
.base_recover_duration
.as_secs_f32()
},
_ => 0.0,
};
let stage_progress =
if let Some(stage) = s.static_data.stage_data.get(stage_index) {
match s.stage_section {
StageSection::Buildup => {
stage_time / stage.base_buildup_duration.as_secs_f32()
},
StageSection::Swing => {
stage_time / stage.base_swing_duration.as_secs_f32()
},
StageSection::Recover => {
stage_time / stage.base_recover_duration.as_secs_f32()
},
_ => 0.0,
}
} else {
0.0
};
match s.stage {
1 => anim::biped_large::AlphaAnimation::update_skeleton(
&target_base,
@ -4409,27 +4377,23 @@ impl FigureMgr {
CharacterState::ComboMelee(s) => {
let stage_index = (s.stage - 1) as usize;
let stage_time = s.timer.as_secs_f32();
let stage_progress = match s.stage_section {
StageSection::Buildup => {
stage_time
/ s.static_data.stage_data[stage_index]
.base_buildup_duration
.as_secs_f32()
},
StageSection::Swing => {
stage_time
/ s.static_data.stage_data[stage_index]
.base_swing_duration
.as_secs_f32()
},
StageSection::Recover => {
stage_time
/ s.static_data.stage_data[stage_index]
.base_recover_duration
.as_secs_f32()
},
_ => 0.0,
};
let stage_progress =
if let Some(stage) = s.static_data.stage_data.get(stage_index) {
match s.stage_section {
StageSection::Buildup => {
stage_time / stage.base_buildup_duration.as_secs_f32()
},
StageSection::Swing => {
stage_time / stage.base_swing_duration.as_secs_f32()
},
StageSection::Recover => {
stage_time / stage.base_recover_duration.as_secs_f32()
},
_ => 0.0,
}
} else {
0.0
};
anim::golem::AlphaAnimation::update_skeleton(
&target_base,