Refactor actions to be entities with components (#19900)
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
using Content.Server.Actions;
|
||||
using Content.Server.Popups;
|
||||
using Content.Shared.Actions;
|
||||
using Content.Shared.Actions.ActionTypes;
|
||||
using Content.Shared.Xenoarchaeology.XenoArtifacts;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
@@ -12,32 +10,29 @@ public partial class ArtifactSystem
|
||||
[Dependency] private readonly ActionsSystem _actions = default!;
|
||||
[Dependency] private readonly PopupSystem _popup = default!;
|
||||
|
||||
[ValidatePrototypeId<EntityPrototype>] private const string ArtifactActivateActionId = "ActionArtifactActivate";
|
||||
|
||||
/// <summary>
|
||||
/// Used to add the artifact activation action (hehe), which lets sentient artifacts activate themselves,
|
||||
/// either through admemery or the sentience effect.
|
||||
/// </summary>
|
||||
public void InitializeActions()
|
||||
{
|
||||
SubscribeLocalEvent<ArtifactComponent, ComponentStartup>(OnStartup);
|
||||
SubscribeLocalEvent<ArtifactComponent, MapInitEvent>(OnStartup);
|
||||
SubscribeLocalEvent<ArtifactComponent, ComponentRemove>(OnRemove);
|
||||
|
||||
SubscribeLocalEvent<ArtifactComponent, ArtifactSelfActivateEvent>(OnSelfActivate);
|
||||
}
|
||||
|
||||
private void OnStartup(EntityUid uid, ArtifactComponent component, ComponentStartup args)
|
||||
private void OnStartup(EntityUid uid, ArtifactComponent component, MapInitEvent args)
|
||||
{
|
||||
if (_prototype.TryIndex<InstantActionPrototype>("ArtifactActivate", out var proto))
|
||||
{
|
||||
_actions.AddAction(uid, new InstantAction(proto), null);
|
||||
}
|
||||
RandomizeArtifact(uid, component);
|
||||
_actions.AddAction(uid, Spawn(ArtifactActivateActionId), null);
|
||||
}
|
||||
|
||||
private void OnRemove(EntityUid uid, ArtifactComponent component, ComponentRemove args)
|
||||
{
|
||||
if (_prototype.TryIndex<InstantActionPrototype>("ArtifactActivate", out var proto))
|
||||
{
|
||||
_actions.RemoveAction(uid, new InstantAction(proto));
|
||||
}
|
||||
_actions.RemoveAction(uid, ArtifactActivateActionId);
|
||||
}
|
||||
|
||||
private void OnSelfActivate(EntityUid uid, ArtifactComponent component, ArtifactSelfActivateEvent args)
|
||||
@@ -52,4 +47,3 @@ public partial class ArtifactSystem
|
||||
args.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,12 +6,12 @@ using Content.Server.Power.EntitySystems;
|
||||
using Content.Server.Xenoarchaeology.Equipment.Components;
|
||||
using Content.Server.Xenoarchaeology.XenoArtifacts.Events;
|
||||
using Content.Server.Xenoarchaeology.XenoArtifacts.Triggers.Components;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.Xenoarchaeology.XenoArtifacts;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Random;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Configuration;
|
||||
using Content.Shared.CCVar;
|
||||
|
||||
namespace Content.Server.Xenoarchaeology.XenoArtifacts;
|
||||
|
||||
@@ -30,7 +30,6 @@ public sealed partial class ArtifactSystem : EntitySystem
|
||||
|
||||
_sawmill = Logger.GetSawmill("artifact");
|
||||
|
||||
SubscribeLocalEvent<ArtifactComponent, MapInitEvent>(OnInit);
|
||||
SubscribeLocalEvent<ArtifactComponent, PriceCalculationEvent>(GetPrice);
|
||||
SubscribeLocalEvent<RoundEndTextAppendEvent>(OnRoundEnd);
|
||||
|
||||
@@ -38,11 +37,6 @@ public sealed partial class ArtifactSystem : EntitySystem
|
||||
InitializeActions();
|
||||
}
|
||||
|
||||
private void OnInit(EntityUid uid, ArtifactComponent component, MapInitEvent args)
|
||||
{
|
||||
RandomizeArtifact(uid, component);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the price of an artifact based on
|
||||
/// how many nodes have been unlocked/triggered
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Content.Server.Magic.Events;
|
||||
using Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Components;
|
||||
using Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Components;
|
||||
using Content.Server.Xenoarchaeology.XenoArtifacts.Events;
|
||||
using Content.Shared.Magic.Events;
|
||||
|
||||
namespace Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Systems;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user