From: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com> Date: Sun, 29 Oct 2023 08:10:30 +0000 (+1100) Subject: Action bugfixes (#21321) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=6e49331e4dfc010e564f5442a126a6f1703cdd94;p=space-station-14.git Action bugfixes (#21321) --- diff --git a/Content.Shared/Actions/ActionContainerSystem.cs b/Content.Shared/Actions/ActionContainerSystem.cs index 86d50e3989..d7c02ffd63 100644 --- a/Content.Shared/Actions/ActionContainerSystem.cs +++ b/Content.Shared/Actions/ActionContainerSystem.cs @@ -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(); } diff --git a/Content.Shared/Actions/SharedActionsSystem.cs b/Content.Shared/Actions/SharedActionsSystem.cs index 00a17ace25..7384ab30b1 100644 --- a/Content.Shared/Actions/SharedActionsSystem.cs +++ b/Content.Shared/Actions/SharedActionsSystem.cs @@ -36,6 +36,8 @@ public abstract class SharedActionsSystem : EntitySystem SubscribeLocalEvent(OnDidUnequip); SubscribeLocalEvent(OnHandUnequipped); + SubscribeLocalEvent(OnShutdown); + SubscribeLocalEvent(OnActionsGetState); SubscribeLocalEvent(OnInstantGetState); @@ -49,6 +51,14 @@ public abstract class SharedActionsSystem : EntitySystem SubscribeAllEvent(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; }