mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
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:
parent
aaf5f89076
commit
4cdf081a40
@ -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
|
||||
|
@ -1338,26 +1338,22 @@ 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 {
|
||||
let stage_progress =
|
||||
if let Some(stage) = s.static_data.stage_data.get(stage_index) {
|
||||
match s.stage_section {
|
||||
StageSection::Buildup => {
|
||||
stage_time
|
||||
/ s.static_data.stage_data[stage_index]
|
||||
.base_buildup_duration
|
||||
.as_secs_f32()
|
||||
stage_time / stage.base_buildup_duration.as_secs_f32()
|
||||
},
|
||||
StageSection::Swing => {
|
||||
stage_time
|
||||
/ s.static_data.stage_data[stage_index]
|
||||
.base_swing_duration
|
||||
.as_secs_f32()
|
||||
stage_time / stage.base_swing_duration.as_secs_f32()
|
||||
},
|
||||
StageSection::Recover => {
|
||||
stage_time
|
||||
/ s.static_data.stage_data[stage_index]
|
||||
.base_recover_duration
|
||||
.as_secs_f32()
|
||||
stage_time / stage.base_recover_duration.as_secs_f32()
|
||||
},
|
||||
_ => 0.0,
|
||||
}
|
||||
} else {
|
||||
0.0
|
||||
};
|
||||
match s.stage {
|
||||
1 => anim::character::AlphaAnimation::update_skeleton(
|
||||
@ -1664,26 +1660,22 @@ 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 {
|
||||
let stage_progress =
|
||||
if let Some(stage) = s.static_data.stage_data.get(stage_index) {
|
||||
match s.stage_section {
|
||||
StageSection::Buildup => {
|
||||
stage_time
|
||||
/ s.static_data.stage_data[stage_index]
|
||||
.base_buildup_duration
|
||||
.as_secs_f32()
|
||||
stage_time / stage.base_buildup_duration.as_secs_f32()
|
||||
},
|
||||
StageSection::Swing => {
|
||||
stage_time
|
||||
/ s.static_data.stage_data[stage_index]
|
||||
.base_swing_duration
|
||||
.as_secs_f32()
|
||||
stage_time / stage.base_swing_duration.as_secs_f32()
|
||||
},
|
||||
StageSection::Recover => {
|
||||
stage_time
|
||||
/ s.static_data.stage_data[stage_index]
|
||||
.base_recover_duration
|
||||
.as_secs_f32()
|
||||
stage_time / stage.base_recover_duration.as_secs_f32()
|
||||
},
|
||||
_ => 0.0,
|
||||
}
|
||||
} else {
|
||||
0.0
|
||||
};
|
||||
{
|
||||
anim::quadruped_small::AlphaAnimation::update_skeleton(
|
||||
@ -1955,26 +1947,22 @@ 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 {
|
||||
let stage_progress =
|
||||
if let Some(stage) = s.static_data.stage_data.get(stage_index) {
|
||||
match s.stage_section {
|
||||
StageSection::Buildup => {
|
||||
stage_time
|
||||
/ s.static_data.stage_data[stage_index]
|
||||
.base_buildup_duration
|
||||
.as_secs_f32()
|
||||
stage_time / stage.base_buildup_duration.as_secs_f32()
|
||||
},
|
||||
StageSection::Swing => {
|
||||
stage_time
|
||||
/ s.static_data.stage_data[stage_index]
|
||||
.base_swing_duration
|
||||
.as_secs_f32()
|
||||
stage_time / stage.base_swing_duration.as_secs_f32()
|
||||
},
|
||||
StageSection::Recover => {
|
||||
stage_time
|
||||
/ s.static_data.stage_data[stage_index]
|
||||
.base_recover_duration
|
||||
.as_secs_f32()
|
||||
stage_time / stage.base_recover_duration.as_secs_f32()
|
||||
},
|
||||
_ => 0.0,
|
||||
}
|
||||
} else {
|
||||
0.0
|
||||
};
|
||||
match s.stage {
|
||||
1 => anim::quadruped_medium::AlphaAnimation::update_skeleton(
|
||||
@ -2315,26 +2303,22 @@ 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 {
|
||||
let stage_progress =
|
||||
if let Some(stage) = s.static_data.stage_data.get(stage_index) {
|
||||
match s.stage_section {
|
||||
StageSection::Buildup => {
|
||||
stage_time
|
||||
/ s.static_data.stage_data[stage_index]
|
||||
.base_buildup_duration
|
||||
.as_secs_f32()
|
||||
stage_time / stage.base_buildup_duration.as_secs_f32()
|
||||
},
|
||||
StageSection::Swing => {
|
||||
stage_time
|
||||
/ s.static_data.stage_data[stage_index]
|
||||
.base_swing_duration
|
||||
.as_secs_f32()
|
||||
stage_time / stage.base_swing_duration.as_secs_f32()
|
||||
},
|
||||
StageSection::Recover => {
|
||||
stage_time
|
||||
/ s.static_data.stage_data[stage_index]
|
||||
.base_recover_duration
|
||||
.as_secs_f32()
|
||||
stage_time / stage.base_recover_duration.as_secs_f32()
|
||||
},
|
||||
_ => 0.0,
|
||||
}
|
||||
} else {
|
||||
0.0
|
||||
};
|
||||
match s.stage {
|
||||
1 => anim::quadruped_low::AlphaAnimation::update_skeleton(
|
||||
@ -2917,26 +2901,22 @@ 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 {
|
||||
let stage_progress =
|
||||
if let Some(stage) = s.static_data.stage_data.get(stage_index) {
|
||||
match s.stage_section {
|
||||
StageSection::Buildup => {
|
||||
stage_time
|
||||
/ s.static_data.stage_data[stage_index]
|
||||
.base_buildup_duration
|
||||
.as_secs_f32()
|
||||
stage_time / stage.base_buildup_duration.as_secs_f32()
|
||||
},
|
||||
StageSection::Swing => {
|
||||
stage_time
|
||||
/ s.static_data.stage_data[stage_index]
|
||||
.base_swing_duration
|
||||
.as_secs_f32()
|
||||
stage_time / stage.base_swing_duration.as_secs_f32()
|
||||
},
|
||||
StageSection::Recover => {
|
||||
stage_time
|
||||
/ s.static_data.stage_data[stage_index]
|
||||
.base_recover_duration
|
||||
.as_secs_f32()
|
||||
stage_time / stage.base_recover_duration.as_secs_f32()
|
||||
},
|
||||
_ => 0.0,
|
||||
}
|
||||
} else {
|
||||
0.0
|
||||
};
|
||||
match s.stage {
|
||||
1 => anim::biped_small::AlphaAnimation::update_skeleton(
|
||||
@ -3178,26 +3158,22 @@ 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 {
|
||||
let stage_progress =
|
||||
if let Some(stage) = s.static_data.stage_data.get(stage_index) {
|
||||
match s.stage_section {
|
||||
StageSection::Buildup => {
|
||||
stage_time
|
||||
/ s.static_data.stage_data[stage_index]
|
||||
.base_buildup_duration
|
||||
.as_secs_f32()
|
||||
stage_time / stage.base_buildup_duration.as_secs_f32()
|
||||
},
|
||||
StageSection::Swing => {
|
||||
stage_time
|
||||
/ s.static_data.stage_data[stage_index]
|
||||
.base_swing_duration
|
||||
.as_secs_f32()
|
||||
stage_time / stage.base_swing_duration.as_secs_f32()
|
||||
},
|
||||
StageSection::Recover => {
|
||||
stage_time
|
||||
/ s.static_data.stage_data[stage_index]
|
||||
.base_recover_duration
|
||||
.as_secs_f32()
|
||||
stage_time / stage.base_recover_duration.as_secs_f32()
|
||||
},
|
||||
_ => 0.0,
|
||||
}
|
||||
} else {
|
||||
0.0
|
||||
};
|
||||
match s.stage {
|
||||
1 => anim::theropod::AlphaAnimation::update_skeleton(
|
||||
@ -3406,26 +3382,22 @@ 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 {
|
||||
let stage_progress =
|
||||
if let Some(stage) = s.static_data.stage_data.get(stage_index) {
|
||||
match s.stage_section {
|
||||
StageSection::Buildup => {
|
||||
stage_time
|
||||
/ s.static_data.stage_data[stage_index]
|
||||
.base_buildup_duration
|
||||
.as_secs_f32()
|
||||
stage_time / stage.base_buildup_duration.as_secs_f32()
|
||||
},
|
||||
StageSection::Swing => {
|
||||
stage_time
|
||||
/ s.static_data.stage_data[stage_index]
|
||||
.base_swing_duration
|
||||
.as_secs_f32()
|
||||
stage_time / stage.base_swing_duration.as_secs_f32()
|
||||
},
|
||||
StageSection::Recover => {
|
||||
stage_time
|
||||
/ s.static_data.stage_data[stage_index]
|
||||
.base_recover_duration
|
||||
.as_secs_f32()
|
||||
stage_time / stage.base_recover_duration.as_secs_f32()
|
||||
},
|
||||
_ => 0.0,
|
||||
}
|
||||
} else {
|
||||
0.0
|
||||
};
|
||||
|
||||
anim::bird_large::AlphaAnimation::update_skeleton(
|
||||
@ -4049,26 +4021,22 @@ 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 {
|
||||
let stage_progress =
|
||||
if let Some(stage) = s.static_data.stage_data.get(stage_index) {
|
||||
match s.stage_section {
|
||||
StageSection::Buildup => {
|
||||
stage_time
|
||||
/ s.static_data.stage_data[stage_index]
|
||||
.base_buildup_duration
|
||||
.as_secs_f32()
|
||||
stage_time / stage.base_buildup_duration.as_secs_f32()
|
||||
},
|
||||
StageSection::Swing => {
|
||||
stage_time
|
||||
/ s.static_data.stage_data[stage_index]
|
||||
.base_swing_duration
|
||||
.as_secs_f32()
|
||||
stage_time / stage.base_swing_duration.as_secs_f32()
|
||||
},
|
||||
StageSection::Recover => {
|
||||
stage_time
|
||||
/ s.static_data.stage_data[stage_index]
|
||||
.base_recover_duration
|
||||
.as_secs_f32()
|
||||
stage_time / stage.base_recover_duration.as_secs_f32()
|
||||
},
|
||||
_ => 0.0,
|
||||
}
|
||||
} else {
|
||||
0.0
|
||||
};
|
||||
match s.stage {
|
||||
1 => anim::biped_large::AlphaAnimation::update_skeleton(
|
||||
@ -4409,26 +4377,22 @@ 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 {
|
||||
let stage_progress =
|
||||
if let Some(stage) = s.static_data.stage_data.get(stage_index) {
|
||||
match s.stage_section {
|
||||
StageSection::Buildup => {
|
||||
stage_time
|
||||
/ s.static_data.stage_data[stage_index]
|
||||
.base_buildup_duration
|
||||
.as_secs_f32()
|
||||
stage_time / stage.base_buildup_duration.as_secs_f32()
|
||||
},
|
||||
StageSection::Swing => {
|
||||
stage_time
|
||||
/ s.static_data.stage_data[stage_index]
|
||||
.base_swing_duration
|
||||
.as_secs_f32()
|
||||
stage_time / stage.base_swing_duration.as_secs_f32()
|
||||
},
|
||||
StageSection::Recover => {
|
||||
stage_time
|
||||
/ s.static_data.stage_data[stage_index]
|
||||
.base_recover_duration
|
||||
.as_secs_f32()
|
||||
stage_time / stage.base_recover_duration.as_secs_f32()
|
||||
},
|
||||
_ => 0.0,
|
||||
}
|
||||
} else {
|
||||
0.0
|
||||
};
|
||||
|
||||
anim::golem::AlphaAnimation::update_skeleton(
|
||||
|
Loading…
Reference in New Issue
Block a user