2022-01-22 15:55:11 +03:00
|
|
|
using Content.Server.Xenoarchaeology.XenoArtifacts.Triggers.Components;
|
|
|
|
|
using Content.Shared.Interaction;
|
2024-03-19 14:30:56 +11:00
|
|
|
using Content.Shared.Movement.Pulling.Events;
|
2022-09-29 15:51:59 +10:00
|
|
|
using Content.Shared.Weapons.Melee.Events;
|
2022-01-22 15:55:11 +03:00
|
|
|
|
|
|
|
|
namespace Content.Server.Xenoarchaeology.XenoArtifacts.Triggers.Systems;
|
|
|
|
|
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class ArtifactInteractionTriggerSystem : EntitySystem
|
2022-01-22 15:55:11 +03:00
|
|
|
{
|
|
|
|
|
[Dependency] private readonly ArtifactSystem _artifactSystem = default!;
|
|
|
|
|
|
|
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
2022-02-19 22:16:49 +03:00
|
|
|
SubscribeLocalEvent<ArtifactInteractionTriggerComponent, PullStartedMessage>(OnPull);
|
|
|
|
|
SubscribeLocalEvent<ArtifactInteractionTriggerComponent, AttackedEvent>(OnAttack);
|
2022-01-22 15:55:11 +03:00
|
|
|
SubscribeLocalEvent<ArtifactInteractionTriggerComponent, InteractHandEvent>(OnInteract);
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-19 22:16:49 +03:00
|
|
|
private void OnPull(EntityUid uid, ArtifactInteractionTriggerComponent component, PullStartedMessage args)
|
|
|
|
|
{
|
|
|
|
|
if (!component.PullActivation)
|
|
|
|
|
return;
|
|
|
|
|
|
2024-03-19 14:30:56 +11:00
|
|
|
_artifactSystem.TryActivateArtifact(uid, args.PullerUid);
|
2022-02-19 22:16:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnAttack(EntityUid uid, ArtifactInteractionTriggerComponent component, AttackedEvent args)
|
|
|
|
|
{
|
|
|
|
|
if (!component.AttackActivation)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
_artifactSystem.TryActivateArtifact(uid, args.User);
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-22 15:55:11 +03:00
|
|
|
private void OnInteract(EntityUid uid, ArtifactInteractionTriggerComponent component, InteractHandEvent args)
|
|
|
|
|
{
|
|
|
|
|
if (args.Handled)
|
|
|
|
|
return;
|
|
|
|
|
|
2022-02-19 22:16:49 +03:00
|
|
|
if (!component.EmptyHandActivation)
|
|
|
|
|
return;
|
|
|
|
|
|
2022-01-22 15:55:11 +03:00
|
|
|
args.Handled = _artifactSystem.TryActivateArtifact(uid, args.User);
|
|
|
|
|
}
|
|
|
|
|
}
|