Fix action state handling bug (#25395)
* Rejig action state handling * Fix entity arg * Fix deserialization
This commit is contained in:
@@ -8,7 +8,6 @@ using Content.Shared.Hands;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Inventory.Events;
|
||||
using Content.Shared.Mind;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Audio.Systems;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameStates;
|
||||
@@ -35,9 +34,13 @@ public abstract class SharedActionsSystem : EntitySystem
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<InstantActionComponent, MapInitEvent>(OnInit);
|
||||
SubscribeLocalEvent<EntityTargetActionComponent, MapInitEvent>(OnInit);
|
||||
SubscribeLocalEvent<WorldTargetActionComponent, MapInitEvent>(OnInit);
|
||||
SubscribeLocalEvent<InstantActionComponent, MapInitEvent>(OnActionMapInit);
|
||||
SubscribeLocalEvent<EntityTargetActionComponent, MapInitEvent>(OnActionMapInit);
|
||||
SubscribeLocalEvent<WorldTargetActionComponent, MapInitEvent>(OnActionMapInit);
|
||||
|
||||
SubscribeLocalEvent<InstantActionComponent, ComponentShutdown>(OnActionShutdown);
|
||||
SubscribeLocalEvent<EntityTargetActionComponent, ComponentShutdown>(OnActionShutdown);
|
||||
SubscribeLocalEvent<WorldTargetActionComponent, ComponentShutdown>(OnActionShutdown);
|
||||
|
||||
SubscribeLocalEvent<ActionsComponent, DidEquipEvent>(OnDidEquip);
|
||||
SubscribeLocalEvent<ActionsComponent, DidEquipHandEvent>(OnHandEquipped);
|
||||
@@ -60,10 +63,19 @@ public abstract class SharedActionsSystem : EntitySystem
|
||||
SubscribeAllEvent<RequestPerformActionEvent>(OnActionRequest);
|
||||
}
|
||||
|
||||
private void OnInit(EntityUid uid, BaseActionComponent component, MapInitEvent args)
|
||||
private void OnActionMapInit(EntityUid uid, BaseActionComponent component, MapInitEvent args)
|
||||
{
|
||||
if (component.Charges != null)
|
||||
component.MaxCharges = component.Charges.Value;
|
||||
if (component.Charges == null)
|
||||
return;
|
||||
|
||||
component.MaxCharges ??= component.Charges.Value;
|
||||
Dirty(uid, component);
|
||||
}
|
||||
|
||||
private void OnActionShutdown(EntityUid uid, BaseActionComponent component, ComponentShutdown args)
|
||||
{
|
||||
if (component.AttachedEntity != null && !TerminatingOrDeleted(component.AttachedEntity.Value))
|
||||
RemoveAction(component.AttachedEntity.Value, uid, action: component);
|
||||
}
|
||||
|
||||
private void OnShutdown(EntityUid uid, ActionsComponent component, ComponentShutdown args)
|
||||
|
||||
Reference in New Issue
Block a user