Files
crystall-punk-14/Content.Server/LandMines/LandMineSystem.cs
Pieter-Jan Briers ebfe5e888f Kick mines (real) (#8056)
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
2022-05-18 14:07:35 +10:00

41 lines
1.2 KiB
C#

using Content.Server.Explosion.EntitySystems;
using Content.Shared.Popups;
using Content.Shared.StepTrigger;
using Robust.Shared.Player;
namespace Content.Server.LandMines;
public sealed class LandMineSystem : EntitySystem
{
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
[Dependency] private readonly TriggerSystem _trigger = default!;
public override void Initialize()
{
SubscribeLocalEvent<LandMineComponent, StepTriggeredEvent>(HandleTriggered);
SubscribeLocalEvent<LandMineComponent, StepTriggerAttemptEvent>(HandleTriggerAttempt);
}
private static void HandleTriggerAttempt(
EntityUid uid,
LandMineComponent component,
ref StepTriggerAttemptEvent args)
{
args.Continue = true;
}
private void HandleTriggered(EntityUid uid, LandMineComponent component, ref StepTriggeredEvent args)
{
_popupSystem.PopupCoordinates(
Loc.GetString("land-mine-triggered", ("mine", uid)),
Transform(uid).Coordinates,
Filter.Entities(args.Tripper));
_trigger.Trigger(uid, args.Tripper);
QueueDel(uid);
}
}