Add methods to transfer actions between containers (#20901)

This commit is contained in:
Leon Friedrich
2023-10-12 04:50:10 +11:00
committed by GitHub
parent 8177c406f6
commit fcd0d9ef0f
3 changed files with 98 additions and 17 deletions

View File

@@ -586,9 +586,16 @@ public abstract class SharedActionsSystem : EntitySystem
if (!ResolveActionData(actionId, ref action))
return;
if (action.AttachedEntity != performer)
{
Log.Error($"Attempted to remove an action {ToPrettyString(actionId)} from an entity that it was never attached to: {ToPrettyString(performer)}");
return;
}
if (!Resolve(performer, ref comp, false))
{
DebugTools.AssertNull(action.AttachedEntity);
DebugTools.Assert(action.AttachedEntity == null || TerminatingOrDeleted(action.AttachedEntity.Value));
action.AttachedEntity = null;
return;
}
@@ -599,7 +606,6 @@ public abstract class SharedActionsSystem : EntitySystem
return;
}
DebugTools.Assert(action.AttachedEntity == performer);
comp.Actions.Remove(actionId.Value);
action.AttachedEntity = null;
Dirty(actionId.Value, action);