Refactor actions to be entities with components (#19900)
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
using Content.Shared.Actions.ActionTypes;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Server.Abilities.Mime
|
||||
{
|
||||
@@ -22,18 +20,12 @@ namespace Content.Server.Abilities.Mime
|
||||
/// The wall prototype to use.
|
||||
/// </summary>
|
||||
[DataField("wallPrototype", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
|
||||
public string WallPrototype = "WallInvisible";
|
||||
public string WallPrototype = "ActionMimeInvisibleWall";
|
||||
|
||||
[DataField("invisibleWallAction")]
|
||||
public InstantAction InvisibleWallAction = new()
|
||||
{
|
||||
UseDelay = TimeSpan.FromSeconds(30),
|
||||
Icon = new SpriteSpecifier.Texture(new("Structures/Walls/solid.rsi/full.png")),
|
||||
DisplayName = "mime-invisible-wall",
|
||||
Description = "mime-invisible-wall-desc",
|
||||
Priority = -1,
|
||||
Event = new InvisibleWallActionEvent(),
|
||||
};
|
||||
[DataField("invisibleWallAction", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
|
||||
public string? InvisibleWallAction;
|
||||
|
||||
[DataField("invisibleWallActionEntity")] public EntityUid? InvisibleWallActionEntity;
|
||||
|
||||
// The vow zone lies below
|
||||
public bool VowBroken = false;
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
using Content.Server.Popups;
|
||||
using Content.Server.Speech.Muting;
|
||||
using Content.Shared.Actions;
|
||||
using Content.Shared.Actions.Events;
|
||||
using Content.Shared.Alert;
|
||||
using Content.Shared.Coordinates.Helpers;
|
||||
using Content.Shared.Physics;
|
||||
using Content.Shared.Doors.Components;
|
||||
using Content.Shared.Maps;
|
||||
using Content.Shared.Mobs.Components;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Timing;
|
||||
using Content.Server.Speech.Muting;
|
||||
using Content.Shared.Physics;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Server.Abilities.Mime
|
||||
{
|
||||
@@ -29,8 +28,10 @@ namespace Content.Server.Abilities.Mime
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<MimePowersComponent, ComponentInit>(OnComponentInit);
|
||||
SubscribeLocalEvent<MimePowersComponent, MapInitEvent>(OnComponentMapInit);
|
||||
SubscribeLocalEvent<MimePowersComponent, InvisibleWallActionEvent>(OnInvisibleWall);
|
||||
}
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
base.Update(frameTime);
|
||||
@@ -53,10 +54,14 @@ namespace Content.Server.Abilities.Mime
|
||||
private void OnComponentInit(EntityUid uid, MimePowersComponent component, ComponentInit args)
|
||||
{
|
||||
EnsureComp<MutedComponent>(uid);
|
||||
_actionsSystem.AddAction(uid, component.InvisibleWallAction, uid);
|
||||
_alertsSystem.ShowAlert(uid, AlertType.VowOfSilence);
|
||||
}
|
||||
|
||||
private void OnComponentMapInit(EntityUid uid, MimePowersComponent component, MapInitEvent args)
|
||||
{
|
||||
_actionsSystem.AddAction(uid, ref component.InvisibleWallActionEntity, component.InvisibleWallAction, uid);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an invisible wall in a free space after some checks.
|
||||
/// </summary>
|
||||
@@ -116,7 +121,7 @@ namespace Content.Server.Abilities.Mime
|
||||
RemComp<MutedComponent>(uid);
|
||||
_alertsSystem.ClearAlert(uid, AlertType.VowOfSilence);
|
||||
_alertsSystem.ShowAlert(uid, AlertType.VowBroken);
|
||||
_actionsSystem.RemoveAction(uid, mimePowers.InvisibleWallAction);
|
||||
_actionsSystem.RemoveAction(uid, mimePowers.InvisibleWallActionEntity);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -139,11 +144,7 @@ namespace Content.Server.Abilities.Mime
|
||||
AddComp<MutedComponent>(uid);
|
||||
_alertsSystem.ClearAlert(uid, AlertType.VowBroken);
|
||||
_alertsSystem.ShowAlert(uid, AlertType.VowOfSilence);
|
||||
_actionsSystem.AddAction(uid, mimePowers.InvisibleWallAction, uid);
|
||||
_actionsSystem.AddAction(uid, ref mimePowers.InvisibleWallActionEntity, mimePowers.InvisibleWallAction, uid);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed partial class InvisibleWallActionEvent : InstantActionEvent
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user