From 01270a4f7616623199bf303f4497dd702d5d5d7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kat=20March=C3=A1n?= <kzm@zkat.tech> Date: Mon, 12 Apr 2021 21:57:58 -0700 Subject: [PATCH] despawn finished actions --- src/thinker.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/thinker.rs b/src/thinker.rs index 442c202..b8bcce6 100644 --- a/src/thinker.rs +++ b/src/thinker.rs @@ -232,9 +232,7 @@ fn exec_picked_action( // actual Action component (and we assume it exists). let mut curr_action_state = states.get_mut(action_ent.0).expect("Couldn't find a component corresponding to the current action. This is definitely a bug."); // If the action is executing, or was requested, we - // need to cancel it to make sure it stops. The Action - // system will take care of resetting its state as - // needed. + // need to cancel it to make sure it stops. match *curr_action_state { ActionState::Executing | ActionState::Requested => { *curr_action_state = ActionState::Cancelled; @@ -243,6 +241,8 @@ fn exec_picked_action( } ActionState::Init | ActionState::Success | ActionState::Failure => { let old_state = curr_action_state.clone(); + // Despawn the action itself. + cmd.entity(action_ent.0).despawn_recursive(); thinker.current_action = Some(( ActionEnt(picked_action.1.attach(cmd, actor)), picked_action.clone(), -- GitLab