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();
}
SubscribeLocalEvent<ActionsComponent, DidUnequipEvent>(OnDidUnequip);
SubscribeLocalEvent<ActionsComponent, DidUnequipHandEvent>(OnHandUnequipped);
+ SubscribeLocalEvent<ActionsComponent, ComponentShutdown>(OnShutdown);
+
SubscribeLocalEvent<ActionsComponent, ComponentGetState>(OnActionsGetState);
SubscribeLocalEvent<InstantActionComponent, ComponentGetState>(OnInstantGetState);
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);
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;
}