bugs attack

This commit is contained in:
artem 2024-02-25 12:35:10 +03:00
parent 062daf6743
commit 1f03c20237
3 changed files with 5 additions and 4 deletions

View File

@ -187,10 +187,10 @@ impl Enemy {
if !self.fight { if !self.fight {
return; return;
} }
let index = ctx.scene.graph.try_get_script_index_of::<Player>(self.player_handle).unwrap();
match ctx match ctx
.scene .scene
.graph .graph.try_get_mut(self.player_handle).and_then(|node| node.try_get_script_mut::<Player>(index))
.try_get_script_of_mut::<Player>(self.player_handle)
{ {
Some(script) => { Some(script) => {
if script.get_health() <= 0.0 { if script.get_health() <= 0.0 {

View File

@ -358,10 +358,11 @@ impl Player {
parent = Some(d.parent()); parent = Some(d.parent());
} }
if let Some(d) = parent { if let Some(d) = parent {
let index = context.scene.graph.try_get_script_index_of::<Enemy>(d).unwrap();
match context match context
.scene .scene
.graph .graph
.try_get_script_of_mut::<Enemy>(d) .try_get_mut(d).and_then(|node| node.try_get_script_mut::<Enemy>(index))
{ {
Some(script) => { Some(script) => {
script.take_damage(&self.damage); script.take_damage(&self.damage);