Refactor actions to be entities with components (#19900)
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
using Content.Shared.Actions.ActionTypes;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
|
||||
@@ -7,11 +6,13 @@ namespace Content.Server.RatKing
|
||||
[RegisterComponent]
|
||||
public sealed partial class RatKingComponent : Component
|
||||
{
|
||||
[DataField("actionRaiseArmy", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
|
||||
public string ActionRaiseArmy = "ActionRatKingRaiseArmy";
|
||||
|
||||
/// <summary>
|
||||
/// The action for the Raise Army ability
|
||||
/// </summary>
|
||||
[DataField("actionRaiseArmy", required: true)]
|
||||
public InstantAction ActionRaiseArmy = new();
|
||||
[DataField("actionRaiseArmyEntity")] public EntityUid? ActionRaiseArmyEntity;
|
||||
|
||||
/// <summary>
|
||||
/// The amount of hunger one use of Raise Army consumes
|
||||
@@ -25,11 +26,14 @@ namespace Content.Server.RatKing
|
||||
[ViewVariables(VVAccess.ReadWrite), DataField("armyMobSpawnId", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
|
||||
public string ArmyMobSpawnId = "MobRatServant";
|
||||
|
||||
[DataField("actionDomain", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
|
||||
public string ActionDomain = "ActionRatKingDomain";
|
||||
|
||||
/// <summary>
|
||||
/// The action for the Domain ability
|
||||
/// </summary>
|
||||
[DataField("actionDomain", required: true)]
|
||||
public InstantAction ActionDomain = new();
|
||||
[DataField("actionDomainEntity")]
|
||||
public EntityUid? ActionDomainEntity;
|
||||
|
||||
/// <summary>
|
||||
/// The amount of hunger one use of Domain consumes
|
||||
@@ -43,4 +47,4 @@ namespace Content.Server.RatKing
|
||||
[DataField("molesMiasmaPerDomain")]
|
||||
public float MolesMiasmaPerDomain = 100f;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
using Content.Server.Actions;
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Server.Nutrition.Components;
|
||||
using Content.Server.Popups;
|
||||
using Content.Shared.Actions;
|
||||
using Content.Shared.Atmos;
|
||||
using Content.Shared.Nutrition.Components;
|
||||
using Content.Shared.Nutrition.EntitySystems;
|
||||
using Content.Shared.RatKing;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Player;
|
||||
|
||||
namespace Content.Server.RatKing
|
||||
{
|
||||
@@ -23,16 +21,16 @@ namespace Content.Server.RatKing
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<RatKingComponent, ComponentStartup>(OnStartup);
|
||||
SubscribeLocalEvent<RatKingComponent, MapInitEvent>(OnMapInit);
|
||||
|
||||
SubscribeLocalEvent<RatKingComponent, RatKingRaiseArmyActionEvent>(OnRaiseArmy);
|
||||
SubscribeLocalEvent<RatKingComponent, RatKingDomainActionEvent>(OnDomain);
|
||||
}
|
||||
|
||||
private void OnStartup(EntityUid uid, RatKingComponent component, ComponentStartup args)
|
||||
private void OnMapInit(EntityUid uid, RatKingComponent component, MapInitEvent args)
|
||||
{
|
||||
_action.AddAction(uid, component.ActionRaiseArmy, null);
|
||||
_action.AddAction(uid, component.ActionDomain, null);
|
||||
_action.AddAction(uid, ref component.ActionRaiseArmyEntity, component.ActionRaiseArmy);
|
||||
_action.AddAction(uid, ref component.ActionDomainEntity, component.ActionDomain);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -86,14 +84,4 @@ namespace Content.Server.RatKing
|
||||
tileMix?.AdjustMoles(Gas.Miasma, component.MolesMiasmaPerDomain);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed partial class RatKingRaiseArmyActionEvent : InstantActionEvent
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public sealed partial class RatKingDomainActionEvent : InstantActionEvent
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user