Refactor actions to be entities with components (#19900)
This commit is contained in:
@@ -1,9 +1,6 @@
|
||||
using Content.Server.Actions;
|
||||
using Content.Shared.Actions.ActionTypes;
|
||||
using Content.Shared.Inventory;
|
||||
using Content.Shared.Inventory.Events;
|
||||
using Content.Shared.Speech;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Server.VoiceMask;
|
||||
|
||||
@@ -12,7 +9,6 @@ public sealed partial class VoiceMaskSystem
|
||||
{
|
||||
[Dependency] private readonly InventorySystem _inventory = default!;
|
||||
[Dependency] private readonly ActionsSystem _actions = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
|
||||
private const string MaskSlot = "mask";
|
||||
|
||||
@@ -26,12 +22,7 @@ public sealed partial class VoiceMaskSystem
|
||||
var comp = EnsureComp<VoiceMaskComponent>(user);
|
||||
comp.VoiceName = component.LastSetName;
|
||||
|
||||
if (!_prototypeManager.TryIndex<InstantActionPrototype>(component.Action, out var action))
|
||||
{
|
||||
throw new ArgumentException("Could not get voice masking prototype.");
|
||||
}
|
||||
|
||||
_actions.AddAction(user, (InstantAction) action.Clone(), uid);
|
||||
_actions.AddAction(user, ref component.ActionEntity, component.Action, uid);
|
||||
}
|
||||
|
||||
private void OnUnequip(EntityUid uid, VoiceMaskerComponent compnent, GotUnequippedEvent args)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using Content.Server.Administration.Logs;
|
||||
using Content.Server.Chat.Systems;
|
||||
using Content.Server.Popups;
|
||||
using Content.Shared.Actions;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.Inventory.Events;
|
||||
using Content.Shared.Preferences;
|
||||
@@ -88,7 +87,3 @@ public sealed partial class VoiceMaskSystem : EntitySystem
|
||||
UserInterfaceSystem.SetUiState(bui, new VoiceMaskBuiState(component.VoiceName));
|
||||
}
|
||||
}
|
||||
|
||||
public sealed partial class VoiceMaskSetNameEvent : InstantActionEvent
|
||||
{
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Content.Shared.Actions.ActionTypes;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
|
||||
namespace Content.Server.VoiceMask;
|
||||
@@ -8,6 +8,8 @@ public sealed partial class VoiceMaskerComponent : Component
|
||||
{
|
||||
[ViewVariables(VVAccess.ReadWrite)] public string LastSetName = "Unknown";
|
||||
|
||||
[DataField("action", customTypeSerializer: typeof(PrototypeIdSerializer<InstantActionPrototype>))]
|
||||
public string Action = "ChangeVoiceMask";
|
||||
[DataField("action", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
|
||||
public string Action = "ActionChangeVoiceMask";
|
||||
|
||||
[DataField("actionEntity")] public EntityUid? ActionEntity;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user