using Content.Shared.Actions;
using Content.Shared.Popups;
using Content.Shared.Xenoarchaeology.Artifact.Components;
using Robust.Shared.Containers;
using Robust.Shared.Network;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Timing;
namespace Content.Shared.Xenoarchaeology.Artifact;
///
/// Handles all logic for generating and facilitating interactions with XenoArtifacts
///
public abstract partial class SharedXenoArtifactSystem : EntitySystem
{
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly INetManager _net = default!;
[Dependency] protected readonly IPrototypeManager PrototypeManager = default!;
[Dependency] protected readonly IRobustRandom RobustRandom = default!;
[Dependency] private readonly SharedActionsSystem _actions = default!;
[Dependency] private readonly SharedContainerSystem _container = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;
///
public override void Initialize()
{
SubscribeLocalEvent(OnStartup);
SubscribeLocalEvent(OnSelfActivate);
InitializeNode();
InitializeUnlock();
InitializeXAT();
InitializeXAE();
}
///
public override void Update(float frameTime)
{
base.Update(frameTime);
UpdateUnlock(frameTime);
}
/// As all artifacts have to contain nodes - we ensure that they are containers.
private void OnStartup(Entity ent, ref ComponentStartup args)
{
_actions.AddAction(ent, ent.Comp.SelfActivateAction);
ent.Comp.NodeContainer = _container.EnsureContainer(ent, XenoArtifactComponent.NodeContainerId);
}
private void OnSelfActivate(Entity ent, ref ArtifactSelfActivateEvent args)
{
args.Handled = TryActivateXenoArtifact(ent, ent, null, Transform(ent).Coordinates, false);
}
public void SetSuppressed(Entity ent, bool val)
{
if (ent.Comp.Suppressed == val)
return;
ent.Comp.Suppressed = val;
Dirty(ent);
}
}