Skip to content
Snippets Groups Projects
Unverified Commit 01270a4f authored by Kat Marchán's avatar Kat Marchán
Browse files

despawn finished actions

parent 27335f0f
No related branches found
No related tags found
No related merge requests found
...@@ -232,9 +232,7 @@ fn exec_picked_action( ...@@ -232,9 +232,7 @@ fn exec_picked_action(
// actual Action component (and we assume it exists). // 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."); 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 // If the action is executing, or was requested, we
// need to cancel it to make sure it stops. The Action // need to cancel it to make sure it stops.
// system will take care of resetting its state as
// needed.
match *curr_action_state { match *curr_action_state {
ActionState::Executing | ActionState::Requested => { ActionState::Executing | ActionState::Requested => {
*curr_action_state = ActionState::Cancelled; *curr_action_state = ActionState::Cancelled;
...@@ -243,6 +241,8 @@ fn exec_picked_action( ...@@ -243,6 +241,8 @@ fn exec_picked_action(
} }
ActionState::Init | ActionState::Success | ActionState::Failure => { ActionState::Init | ActionState::Success | ActionState::Failure => {
let old_state = curr_action_state.clone(); let old_state = curr_action_state.clone();
// Despawn the action itself.
cmd.entity(action_ent.0).despawn_recursive();
thinker.current_action = Some(( thinker.current_action = Some((
ActionEnt(picked_action.1.attach(cmd, actor)), ActionEnt(picked_action.1.attach(cmd, actor)),
picked_action.clone(), picked_action.clone(),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment