Refactor actions to be entities with components (#19900)
This commit is contained in:
@@ -1,21 +1,22 @@
|
||||
using Content.Shared.Actions;
|
||||
using Content.Shared.Actions.ActionTypes;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Content.Shared.Devour;
|
||||
using Content.Shared.Whitelist;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
|
||||
namespace Content.Server.Devour.Components;
|
||||
namespace Content.Shared.Devour.Components;
|
||||
|
||||
[RegisterComponent, NetworkedComponent]
|
||||
[Access(typeof(SharedDevourSystem))]
|
||||
public sealed partial class DevourerComponent : Component
|
||||
{
|
||||
[DataField("devourAction")]
|
||||
public EntityTargetAction? DevourAction;
|
||||
[DataField("devourAction", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
|
||||
public string? DevourAction = "ActionDevour";
|
||||
|
||||
[DataField("devourActionEntity")]
|
||||
public EntityUid? DevourActionEntity;
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite), DataField("soundDevour")]
|
||||
public SoundSpecifier? SoundDevour = new SoundPathSpecifier("/Audio/Effects/demon_consume.ogg")
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using Content.Server.Devour.Components;
|
||||
using Content.Shared.Actions;
|
||||
using Content.Shared.Devour.Components;
|
||||
using Content.Shared.DoAfter;
|
||||
using Content.Shared.Mobs;
|
||||
using Content.Shared.Mobs.Components;
|
||||
@@ -21,18 +21,17 @@ public abstract class SharedDevourSystem : EntitySystem
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<DevourerComponent, ComponentStartup>(OnStartup);
|
||||
SubscribeLocalEvent<DevourerComponent, MapInitEvent>(OnMapInit);
|
||||
SubscribeLocalEvent<DevourerComponent, DevourActionEvent>(OnDevourAction);
|
||||
}
|
||||
|
||||
protected void OnStartup(EntityUid uid, DevourerComponent component, ComponentStartup args)
|
||||
protected void OnMapInit(EntityUid uid, DevourerComponent component, MapInitEvent args)
|
||||
{
|
||||
//Devourer doesn't actually chew, since he sends targets right into his stomach.
|
||||
//I did it mom, I added ERP content into upstream. Legally!
|
||||
component.Stomach = _containerSystem.EnsureContainer<Container>(uid, "stomach");
|
||||
|
||||
if (component.DevourAction != null)
|
||||
_actionsSystem.AddAction(uid, component.DevourAction, null);
|
||||
_actionsSystem.AddAction(uid, ref component.DevourActionEntity, component.DevourAction);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user