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
|
if state
|
||||||
.ecs()
|
.ecs()
|
||||||
.read_storage::<comp::Projectile>()
|
.read_storage::<comp::CharacterState>()
|
||||||
.get(entity)
|
.get(entity)
|
||||||
.is_none()
|
.is_some()
|
||||||
{
|
{
|
||||||
if let Some(pos) = state.ecs().read_storage::<Pos>().get(entity) {
|
if let Some(pos) = state.ecs().read_storage::<Pos>().get(entity) {
|
||||||
state
|
state
|
||||||
|
@ -1338,27 +1338,23 @@ impl FigureMgr {
|
|||||||
CharacterState::ComboMelee(s) => {
|
CharacterState::ComboMelee(s) => {
|
||||||
let stage_index = (s.stage - 1) as usize;
|
let stage_index = (s.stage - 1) as usize;
|
||||||
let stage_time = s.timer.as_secs_f32();
|
let stage_time = s.timer.as_secs_f32();
|
||||||
let stage_progress = match s.stage_section {
|
let stage_progress =
|
||||||
StageSection::Buildup => {
|
if let Some(stage) = s.static_data.stage_data.get(stage_index) {
|
||||||
stage_time
|
match s.stage_section {
|
||||||
/ s.static_data.stage_data[stage_index]
|
StageSection::Buildup => {
|
||||||
.base_buildup_duration
|
stage_time / stage.base_buildup_duration.as_secs_f32()
|
||||||
.as_secs_f32()
|
},
|
||||||
},
|
StageSection::Swing => {
|
||||||
StageSection::Swing => {
|
stage_time / stage.base_swing_duration.as_secs_f32()
|
||||||
stage_time
|
},
|
||||||
/ s.static_data.stage_data[stage_index]
|
StageSection::Recover => {
|
||||||
.base_swing_duration
|
stage_time / stage.base_recover_duration.as_secs_f32()
|
||||||
.as_secs_f32()
|
},
|
||||||
},
|
_ => 0.0,
|
||||||
StageSection::Recover => {
|
}
|
||||||
stage_time
|
} else {
|
||||||
/ s.static_data.stage_data[stage_index]
|
0.0
|
||||||
.base_recover_duration
|
};
|
||||||
.as_secs_f32()
|
|
||||||
},
|
|
||||||
_ => 0.0,
|
|
||||||
};
|
|
||||||
match s.stage {
|
match s.stage {
|
||||||
1 => anim::character::AlphaAnimation::update_skeleton(
|
1 => anim::character::AlphaAnimation::update_skeleton(
|
||||||
&target_base,
|
&target_base,
|
||||||
@ -1664,27 +1660,23 @@ impl FigureMgr {
|
|||||||
CharacterState::ComboMelee(s) => {
|
CharacterState::ComboMelee(s) => {
|
||||||
let stage_index = (s.stage - 1) as usize;
|
let stage_index = (s.stage - 1) as usize;
|
||||||
let stage_time = s.timer.as_secs_f32();
|
let stage_time = s.timer.as_secs_f32();
|
||||||
let stage_progress = match s.stage_section {
|
let stage_progress =
|
||||||
StageSection::Buildup => {
|
if let Some(stage) = s.static_data.stage_data.get(stage_index) {
|
||||||
stage_time
|
match s.stage_section {
|
||||||
/ s.static_data.stage_data[stage_index]
|
StageSection::Buildup => {
|
||||||
.base_buildup_duration
|
stage_time / stage.base_buildup_duration.as_secs_f32()
|
||||||
.as_secs_f32()
|
},
|
||||||
},
|
StageSection::Swing => {
|
||||||
StageSection::Swing => {
|
stage_time / stage.base_swing_duration.as_secs_f32()
|
||||||
stage_time
|
},
|
||||||
/ s.static_data.stage_data[stage_index]
|
StageSection::Recover => {
|
||||||
.base_swing_duration
|
stage_time / stage.base_recover_duration.as_secs_f32()
|
||||||
.as_secs_f32()
|
},
|
||||||
},
|
_ => 0.0,
|
||||||
StageSection::Recover => {
|
}
|
||||||
stage_time
|
} else {
|
||||||
/ s.static_data.stage_data[stage_index]
|
0.0
|
||||||
.base_recover_duration
|
};
|
||||||
.as_secs_f32()
|
|
||||||
},
|
|
||||||
_ => 0.0,
|
|
||||||
};
|
|
||||||
{
|
{
|
||||||
anim::quadruped_small::AlphaAnimation::update_skeleton(
|
anim::quadruped_small::AlphaAnimation::update_skeleton(
|
||||||
&target_base,
|
&target_base,
|
||||||
@ -1955,27 +1947,23 @@ impl FigureMgr {
|
|||||||
CharacterState::ComboMelee(s) => {
|
CharacterState::ComboMelee(s) => {
|
||||||
let stage_index = (s.stage - 1) as usize;
|
let stage_index = (s.stage - 1) as usize;
|
||||||
let stage_time = s.timer.as_secs_f32();
|
let stage_time = s.timer.as_secs_f32();
|
||||||
let stage_progress = match s.stage_section {
|
let stage_progress =
|
||||||
StageSection::Buildup => {
|
if let Some(stage) = s.static_data.stage_data.get(stage_index) {
|
||||||
stage_time
|
match s.stage_section {
|
||||||
/ s.static_data.stage_data[stage_index]
|
StageSection::Buildup => {
|
||||||
.base_buildup_duration
|
stage_time / stage.base_buildup_duration.as_secs_f32()
|
||||||
.as_secs_f32()
|
},
|
||||||
},
|
StageSection::Swing => {
|
||||||
StageSection::Swing => {
|
stage_time / stage.base_swing_duration.as_secs_f32()
|
||||||
stage_time
|
},
|
||||||
/ s.static_data.stage_data[stage_index]
|
StageSection::Recover => {
|
||||||
.base_swing_duration
|
stage_time / stage.base_recover_duration.as_secs_f32()
|
||||||
.as_secs_f32()
|
},
|
||||||
},
|
_ => 0.0,
|
||||||
StageSection::Recover => {
|
}
|
||||||
stage_time
|
} else {
|
||||||
/ s.static_data.stage_data[stage_index]
|
0.0
|
||||||
.base_recover_duration
|
};
|
||||||
.as_secs_f32()
|
|
||||||
},
|
|
||||||
_ => 0.0,
|
|
||||||
};
|
|
||||||
match s.stage {
|
match s.stage {
|
||||||
1 => anim::quadruped_medium::AlphaAnimation::update_skeleton(
|
1 => anim::quadruped_medium::AlphaAnimation::update_skeleton(
|
||||||
&target_base,
|
&target_base,
|
||||||
@ -2315,27 +2303,23 @@ impl FigureMgr {
|
|||||||
CharacterState::ComboMelee(s) => {
|
CharacterState::ComboMelee(s) => {
|
||||||
let stage_index = (s.stage - 1) as usize;
|
let stage_index = (s.stage - 1) as usize;
|
||||||
let stage_time = s.timer.as_secs_f32();
|
let stage_time = s.timer.as_secs_f32();
|
||||||
let stage_progress = match s.stage_section {
|
let stage_progress =
|
||||||
StageSection::Buildup => {
|
if let Some(stage) = s.static_data.stage_data.get(stage_index) {
|
||||||
stage_time
|
match s.stage_section {
|
||||||
/ s.static_data.stage_data[stage_index]
|
StageSection::Buildup => {
|
||||||
.base_buildup_duration
|
stage_time / stage.base_buildup_duration.as_secs_f32()
|
||||||
.as_secs_f32()
|
},
|
||||||
},
|
StageSection::Swing => {
|
||||||
StageSection::Swing => {
|
stage_time / stage.base_swing_duration.as_secs_f32()
|
||||||
stage_time
|
},
|
||||||
/ s.static_data.stage_data[stage_index]
|
StageSection::Recover => {
|
||||||
.base_swing_duration
|
stage_time / stage.base_recover_duration.as_secs_f32()
|
||||||
.as_secs_f32()
|
},
|
||||||
},
|
_ => 0.0,
|
||||||
StageSection::Recover => {
|
}
|
||||||
stage_time
|
} else {
|
||||||
/ s.static_data.stage_data[stage_index]
|
0.0
|
||||||
.base_recover_duration
|
};
|
||||||
.as_secs_f32()
|
|
||||||
},
|
|
||||||
_ => 0.0,
|
|
||||||
};
|
|
||||||
match s.stage {
|
match s.stage {
|
||||||
1 => anim::quadruped_low::AlphaAnimation::update_skeleton(
|
1 => anim::quadruped_low::AlphaAnimation::update_skeleton(
|
||||||
&target_base,
|
&target_base,
|
||||||
@ -2917,27 +2901,23 @@ impl FigureMgr {
|
|||||||
CharacterState::ComboMelee(s) => {
|
CharacterState::ComboMelee(s) => {
|
||||||
let stage_index = (s.stage - 1) as usize;
|
let stage_index = (s.stage - 1) as usize;
|
||||||
let stage_time = s.timer.as_secs_f32();
|
let stage_time = s.timer.as_secs_f32();
|
||||||
let stage_progress = match s.stage_section {
|
let stage_progress =
|
||||||
StageSection::Buildup => {
|
if let Some(stage) = s.static_data.stage_data.get(stage_index) {
|
||||||
stage_time
|
match s.stage_section {
|
||||||
/ s.static_data.stage_data[stage_index]
|
StageSection::Buildup => {
|
||||||
.base_buildup_duration
|
stage_time / stage.base_buildup_duration.as_secs_f32()
|
||||||
.as_secs_f32()
|
},
|
||||||
},
|
StageSection::Swing => {
|
||||||
StageSection::Swing => {
|
stage_time / stage.base_swing_duration.as_secs_f32()
|
||||||
stage_time
|
},
|
||||||
/ s.static_data.stage_data[stage_index]
|
StageSection::Recover => {
|
||||||
.base_swing_duration
|
stage_time / stage.base_recover_duration.as_secs_f32()
|
||||||
.as_secs_f32()
|
},
|
||||||
},
|
_ => 0.0,
|
||||||
StageSection::Recover => {
|
}
|
||||||
stage_time
|
} else {
|
||||||
/ s.static_data.stage_data[stage_index]
|
0.0
|
||||||
.base_recover_duration
|
};
|
||||||
.as_secs_f32()
|
|
||||||
},
|
|
||||||
_ => 0.0,
|
|
||||||
};
|
|
||||||
match s.stage {
|
match s.stage {
|
||||||
1 => anim::biped_small::AlphaAnimation::update_skeleton(
|
1 => anim::biped_small::AlphaAnimation::update_skeleton(
|
||||||
&target_base,
|
&target_base,
|
||||||
@ -3178,27 +3158,23 @@ impl FigureMgr {
|
|||||||
CharacterState::ComboMelee(s) => {
|
CharacterState::ComboMelee(s) => {
|
||||||
let stage_index = (s.stage - 1) as usize;
|
let stage_index = (s.stage - 1) as usize;
|
||||||
let stage_time = s.timer.as_secs_f32();
|
let stage_time = s.timer.as_secs_f32();
|
||||||
let stage_progress = match s.stage_section {
|
let stage_progress =
|
||||||
StageSection::Buildup => {
|
if let Some(stage) = s.static_data.stage_data.get(stage_index) {
|
||||||
stage_time
|
match s.stage_section {
|
||||||
/ s.static_data.stage_data[stage_index]
|
StageSection::Buildup => {
|
||||||
.base_buildup_duration
|
stage_time / stage.base_buildup_duration.as_secs_f32()
|
||||||
.as_secs_f32()
|
},
|
||||||
},
|
StageSection::Swing => {
|
||||||
StageSection::Swing => {
|
stage_time / stage.base_swing_duration.as_secs_f32()
|
||||||
stage_time
|
},
|
||||||
/ s.static_data.stage_data[stage_index]
|
StageSection::Recover => {
|
||||||
.base_swing_duration
|
stage_time / stage.base_recover_duration.as_secs_f32()
|
||||||
.as_secs_f32()
|
},
|
||||||
},
|
_ => 0.0,
|
||||||
StageSection::Recover => {
|
}
|
||||||
stage_time
|
} else {
|
||||||
/ s.static_data.stage_data[stage_index]
|
0.0
|
||||||
.base_recover_duration
|
};
|
||||||
.as_secs_f32()
|
|
||||||
},
|
|
||||||
_ => 0.0,
|
|
||||||
};
|
|
||||||
match s.stage {
|
match s.stage {
|
||||||
1 => anim::theropod::AlphaAnimation::update_skeleton(
|
1 => anim::theropod::AlphaAnimation::update_skeleton(
|
||||||
&target_base,
|
&target_base,
|
||||||
@ -3406,27 +3382,23 @@ impl FigureMgr {
|
|||||||
CharacterState::ComboMelee(s) => {
|
CharacterState::ComboMelee(s) => {
|
||||||
let stage_index = (s.stage - 1) as usize;
|
let stage_index = (s.stage - 1) as usize;
|
||||||
let stage_time = s.timer.as_secs_f32();
|
let stage_time = s.timer.as_secs_f32();
|
||||||
let stage_progress = match s.stage_section {
|
let stage_progress =
|
||||||
StageSection::Buildup => {
|
if let Some(stage) = s.static_data.stage_data.get(stage_index) {
|
||||||
stage_time
|
match s.stage_section {
|
||||||
/ s.static_data.stage_data[stage_index]
|
StageSection::Buildup => {
|
||||||
.base_buildup_duration
|
stage_time / stage.base_buildup_duration.as_secs_f32()
|
||||||
.as_secs_f32()
|
},
|
||||||
},
|
StageSection::Swing => {
|
||||||
StageSection::Swing => {
|
stage_time / stage.base_swing_duration.as_secs_f32()
|
||||||
stage_time
|
},
|
||||||
/ s.static_data.stage_data[stage_index]
|
StageSection::Recover => {
|
||||||
.base_swing_duration
|
stage_time / stage.base_recover_duration.as_secs_f32()
|
||||||
.as_secs_f32()
|
},
|
||||||
},
|
_ => 0.0,
|
||||||
StageSection::Recover => {
|
}
|
||||||
stage_time
|
} else {
|
||||||
/ s.static_data.stage_data[stage_index]
|
0.0
|
||||||
.base_recover_duration
|
};
|
||||||
.as_secs_f32()
|
|
||||||
},
|
|
||||||
_ => 0.0,
|
|
||||||
};
|
|
||||||
|
|
||||||
anim::bird_large::AlphaAnimation::update_skeleton(
|
anim::bird_large::AlphaAnimation::update_skeleton(
|
||||||
&target_base,
|
&target_base,
|
||||||
@ -4049,27 +4021,23 @@ impl FigureMgr {
|
|||||||
CharacterState::ComboMelee(s) => {
|
CharacterState::ComboMelee(s) => {
|
||||||
let stage_index = (s.stage - 1) as usize;
|
let stage_index = (s.stage - 1) as usize;
|
||||||
let stage_time = s.timer.as_secs_f32();
|
let stage_time = s.timer.as_secs_f32();
|
||||||
let stage_progress = match s.stage_section {
|
let stage_progress =
|
||||||
StageSection::Buildup => {
|
if let Some(stage) = s.static_data.stage_data.get(stage_index) {
|
||||||
stage_time
|
match s.stage_section {
|
||||||
/ s.static_data.stage_data[stage_index]
|
StageSection::Buildup => {
|
||||||
.base_buildup_duration
|
stage_time / stage.base_buildup_duration.as_secs_f32()
|
||||||
.as_secs_f32()
|
},
|
||||||
},
|
StageSection::Swing => {
|
||||||
StageSection::Swing => {
|
stage_time / stage.base_swing_duration.as_secs_f32()
|
||||||
stage_time
|
},
|
||||||
/ s.static_data.stage_data[stage_index]
|
StageSection::Recover => {
|
||||||
.base_swing_duration
|
stage_time / stage.base_recover_duration.as_secs_f32()
|
||||||
.as_secs_f32()
|
},
|
||||||
},
|
_ => 0.0,
|
||||||
StageSection::Recover => {
|
}
|
||||||
stage_time
|
} else {
|
||||||
/ s.static_data.stage_data[stage_index]
|
0.0
|
||||||
.base_recover_duration
|
};
|
||||||
.as_secs_f32()
|
|
||||||
},
|
|
||||||
_ => 0.0,
|
|
||||||
};
|
|
||||||
match s.stage {
|
match s.stage {
|
||||||
1 => anim::biped_large::AlphaAnimation::update_skeleton(
|
1 => anim::biped_large::AlphaAnimation::update_skeleton(
|
||||||
&target_base,
|
&target_base,
|
||||||
@ -4409,27 +4377,23 @@ impl FigureMgr {
|
|||||||
CharacterState::ComboMelee(s) => {
|
CharacterState::ComboMelee(s) => {
|
||||||
let stage_index = (s.stage - 1) as usize;
|
let stage_index = (s.stage - 1) as usize;
|
||||||
let stage_time = s.timer.as_secs_f32();
|
let stage_time = s.timer.as_secs_f32();
|
||||||
let stage_progress = match s.stage_section {
|
let stage_progress =
|
||||||
StageSection::Buildup => {
|
if let Some(stage) = s.static_data.stage_data.get(stage_index) {
|
||||||
stage_time
|
match s.stage_section {
|
||||||
/ s.static_data.stage_data[stage_index]
|
StageSection::Buildup => {
|
||||||
.base_buildup_duration
|
stage_time / stage.base_buildup_duration.as_secs_f32()
|
||||||
.as_secs_f32()
|
},
|
||||||
},
|
StageSection::Swing => {
|
||||||
StageSection::Swing => {
|
stage_time / stage.base_swing_duration.as_secs_f32()
|
||||||
stage_time
|
},
|
||||||
/ s.static_data.stage_data[stage_index]
|
StageSection::Recover => {
|
||||||
.base_swing_duration
|
stage_time / stage.base_recover_duration.as_secs_f32()
|
||||||
.as_secs_f32()
|
},
|
||||||
},
|
_ => 0.0,
|
||||||
StageSection::Recover => {
|
}
|
||||||
stage_time
|
} else {
|
||||||
/ s.static_data.stage_data[stage_index]
|
0.0
|
||||||
.base_recover_duration
|
};
|
||||||
.as_secs_f32()
|
|
||||||
},
|
|
||||||
_ => 0.0,
|
|
||||||
};
|
|
||||||
|
|
||||||
anim::golem::AlphaAnimation::update_skeleton(
|
anim::golem::AlphaAnimation::update_skeleton(
|
||||||
&target_base,
|
&target_base,
|
||||||
|
Loading…
Reference in New Issue
Block a user