Refactor actions to be entities with components (#19900)
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
using System.Linq;
|
||||
using Content.Shared.Actions;
|
||||
using Content.Shared.Actions.ActionTypes;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Damage.Prototypes;
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.Hands;
|
||||
using Content.Shared.Hands.Components;
|
||||
@@ -80,11 +78,7 @@ public sealed partial class BlockingSystem : EntitySystem
|
||||
|
||||
private void OnGetActions(EntityUid uid, BlockingComponent component, GetItemActionsEvent args)
|
||||
{
|
||||
if (component.BlockingToggleAction == null && _proto.TryIndex(component.BlockingToggleActionId, out InstantActionPrototype? act))
|
||||
component.BlockingToggleAction = new(act);
|
||||
|
||||
if (component.BlockingToggleAction != null)
|
||||
args.Actions.Add(component.BlockingToggleAction);
|
||||
args.AddAction(ref component.BlockingToggleActionEntity, component.BlockingToggleAction);
|
||||
}
|
||||
|
||||
private void OnToggleAction(EntityUid uid, BlockingComponent component, ToggleActionEvent args)
|
||||
@@ -191,7 +185,7 @@ public sealed partial class BlockingSystem : EntitySystem
|
||||
CantBlockError(user);
|
||||
return false;
|
||||
}
|
||||
_actionsSystem.SetToggled(component.BlockingToggleAction, true);
|
||||
_actionsSystem.SetToggled(component.BlockingToggleActionEntity, true);
|
||||
_popupSystem.PopupEntity(msgUser, user, user);
|
||||
_popupSystem.PopupEntity(msgOther, user, Filter.PvsExcept(user), true);
|
||||
}
|
||||
@@ -252,7 +246,7 @@ public sealed partial class BlockingSystem : EntitySystem
|
||||
if (xform.Anchored)
|
||||
_transformSystem.Unanchor(user, xform);
|
||||
|
||||
_actionsSystem.SetToggled(component.BlockingToggleAction, false);
|
||||
_actionsSystem.SetToggled(component.BlockingToggleActionEntity, false);
|
||||
_fixtureSystem.DestroyFixture(user, BlockingComponent.BlockFixtureID, body: physicsComponent);
|
||||
_physics.SetBodyType(user, blockingUserComponent.OriginalBodyType, body: physicsComponent);
|
||||
_popupSystem.PopupEntity(msgUser, user, user);
|
||||
|
||||
Reference in New Issue
Block a user