Action bugfixes (#21321)

This commit is contained in:
Leon Friedrich 2023-10-29 19:10:30 +11:00 committed by Debug
parent f5538e9aec
commit 6745b65ef0
2 changed files with 17 additions and 1 deletions

View File

@ -213,6 +213,9 @@ public sealed class ActionContainerSystem : EntitySystem
private void OnShutdown(EntityUid uid, ActionsContainerComponent component, ComponentShutdown args)
{
if (_timing.ApplyingState && component.NetSyncEnabled)
return; // The game state should handle the container removal & action deletion.
component.Container.Shutdown();
}

View File

@ -36,6 +36,8 @@ public abstract class SharedActionsSystem : EntitySystem
SubscribeLocalEvent<ActionsComponent, DidUnequipEvent>(OnDidUnequip);
SubscribeLocalEvent<ActionsComponent, DidUnequipHandEvent>(OnHandUnequipped);
SubscribeLocalEvent<ActionsComponent, ComponentShutdown>(OnShutdown);
SubscribeLocalEvent<ActionsComponent, ComponentGetState>(OnActionsGetState);
SubscribeLocalEvent<InstantActionComponent, ComponentGetState>(OnInstantGetState);
@ -49,6 +51,14 @@ public abstract class SharedActionsSystem : EntitySystem
SubscribeAllEvent<RequestPerformActionEvent>(OnActionRequest);
}
private void OnShutdown(EntityUid uid, ActionsComponent component, ComponentShutdown args)
{
foreach (var act in component.Actions)
{
RemoveAction(uid, act, component);
}
}
private void OnInstantGetState(EntityUid uid, InstantActionComponent component, ref ComponentGetState args)
{
args.State = new InstantActionComponentState(component, EntityManager);
@ -611,7 +621,10 @@ public abstract class SharedActionsSystem : EntitySystem
if (action.AttachedEntity != performer)
{
Log.Error($"Attempted to remove an action {ToPrettyString(actionId)} from an entity that it was never attached to: {ToPrettyString(performer)}");
DebugTools.Assert(!Resolve(performer, ref comp, false) || !comp.Actions.Contains(actionId.Value));
if (!GameTiming.ApplyingState)
Log.Error($"Attempted to remove an action {ToPrettyString(actionId)} from an entity that it was never attached to: {ToPrettyString(performer)}");
return;
}