2024-03-24 07:33:45 +02:00
|
|
|
using Content.Server.Explosion.EntitySystems;
|
2022-05-18 06:07:35 +02:00
|
|
|
using Content.Shared.Popups;
|
2022-07-10 02:28:37 -07:00
|
|
|
using Content.Shared.StepTrigger.Systems;
|
2024-03-24 07:33:45 +02:00
|
|
|
using Robust.Shared.Audio;
|
|
|
|
|
using Robust.Shared.Audio.Systems;
|
2022-05-18 06:07:35 +02:00
|
|
|
|
|
|
|
|
namespace Content.Server.LandMines;
|
|
|
|
|
|
|
|
|
|
public sealed class LandMineSystem : EntitySystem
|
|
|
|
|
{
|
2024-03-24 07:33:45 +02:00
|
|
|
[Dependency] private readonly SharedAudioSystem _audioSystem = default!;
|
2022-05-18 06:07:35 +02:00
|
|
|
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
|
|
|
|
|
[Dependency] private readonly TriggerSystem _trigger = default!;
|
|
|
|
|
|
|
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
2024-03-24 07:33:45 +02:00
|
|
|
SubscribeLocalEvent<LandMineComponent, StepTriggeredOnEvent>(HandleStepOnTriggered);
|
|
|
|
|
SubscribeLocalEvent<LandMineComponent, StepTriggeredOffEvent>(HandleStepOffTriggered);
|
|
|
|
|
|
|
|
|
|
SubscribeLocalEvent<LandMineComponent, StepTriggerAttemptEvent>(HandleStepTriggerAttempt);
|
2022-05-18 06:07:35 +02:00
|
|
|
}
|
|
|
|
|
|
2024-03-24 07:33:45 +02:00
|
|
|
private void HandleStepOnTriggered(EntityUid uid, LandMineComponent component, ref StepTriggeredOnEvent args)
|
2022-05-18 06:07:35 +02:00
|
|
|
{
|
2024-03-24 07:33:45 +02:00
|
|
|
_popupSystem.PopupCoordinates(
|
|
|
|
|
Loc.GetString("land-mine-triggered", ("mine", uid)),
|
|
|
|
|
Transform(uid).Coordinates,
|
|
|
|
|
args.Tripper,
|
|
|
|
|
PopupType.LargeCaution);
|
|
|
|
|
|
|
|
|
|
_audioSystem.PlayPvs(component.Sound, uid);
|
2022-05-18 06:07:35 +02:00
|
|
|
}
|
|
|
|
|
|
2024-03-24 07:33:45 +02:00
|
|
|
private void HandleStepOffTriggered(EntityUid uid, LandMineComponent component, ref StepTriggeredOffEvent args)
|
2022-05-18 06:07:35 +02:00
|
|
|
{
|
2024-03-24 07:33:45 +02:00
|
|
|
_trigger.Trigger(uid, args.Tripper);
|
2022-05-18 06:07:35 +02:00
|
|
|
}
|
|
|
|
|
|
2024-03-24 07:33:45 +02:00
|
|
|
private static void HandleStepTriggerAttempt(EntityUid uid, LandMineComponent component, ref StepTriggerAttemptEvent args)
|
|
|
|
|
{
|
|
|
|
|
args.Continue = true;
|
|
|
|
|
}
|
|
|
|
|
}
|