Files

50 lines
1.8 KiB
C#
Raw Permalink Normal View History

2023-01-03 17:13:10 -06:00
using Content.Server.Actions;
using Content.Server.Popups;
using Content.Shared.Xenoarchaeology.XenoArtifacts;
using Robust.Shared.Prototypes;
namespace Content.Server.Xenoarchaeology.XenoArtifacts;
public partial class ArtifactSystem
{
[Dependency] private readonly ActionsSystem _actions = default!;
[Dependency] private readonly PopupSystem _popup = default!;
[ValidatePrototypeId<EntityPrototype>] private const string ArtifactActivateActionId = "ActionArtifactActivate";
2023-01-03 17:13:10 -06:00
/// <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, MapInitEvent>(OnMapInit);
2023-01-03 17:13:10 -06:00
SubscribeLocalEvent<ArtifactComponent, ComponentRemove>(OnRemove);
SubscribeLocalEvent<ArtifactComponent, ArtifactSelfActivateEvent>(OnSelfActivate);
}
private void OnMapInit(EntityUid uid, ArtifactComponent component, MapInitEvent args)
2023-01-03 17:13:10 -06:00
{
RandomizeArtifact(uid, component);
_actions.AddAction(uid, ref component.ActivateActionEntity, ArtifactActivateActionId);
2023-01-03 17:13:10 -06:00
}
private void OnRemove(EntityUid uid, ArtifactComponent component, ComponentRemove args)
{
_actions.RemoveAction(uid, component.ActivateActionEntity);
2023-01-03 17:13:10 -06:00
}
private void OnSelfActivate(EntityUid uid, ArtifactComponent component, ArtifactSelfActivateEvent args)
{
2023-03-23 22:50:24 -04:00
if (component.CurrentNodeId == null)
2023-01-03 17:13:10 -06:00
return;
2023-03-23 22:50:24 -04:00
var curNode = GetNodeFromId(component.CurrentNodeId.Value, component).Id;
2023-01-03 17:13:10 -06:00
_popup.PopupEntity(Loc.GetString("activate-artifact-popup-self", ("node", curNode)), uid, uid);
TryActivateArtifact(uid, uid, component);
args.Handled = true;
}
}