* make landmine work on stepping off * update methods naming * made both step modes possible * updated stepoff event raise to not interfere with game physics internals * added comments * figuring out how audiosystem works * added beep sound effect, updated how stepoff trigger works to make it more consistent * updated source in attributions.yml * made stepoff working every time * introduced suggested changes * updated janitor's WetSignMine to have audio * made cleaner events and bashing my head at OnEndCollide event raise * inverted conditional where applicable * review --------- Co-authored-by: Yurii Kis <yurii.kis@smartteksas.com> Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
44 lines
1.5 KiB
C#
44 lines
1.5 KiB
C#
using Content.Server.Explosion.EntitySystems;
|
|
using Content.Shared.Popups;
|
|
using Content.Shared.StepTrigger.Systems;
|
|
using Robust.Shared.Audio;
|
|
using Robust.Shared.Audio.Systems;
|
|
|
|
namespace Content.Server.LandMines;
|
|
|
|
public sealed class LandMineSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly SharedAudioSystem _audioSystem = default!;
|
|
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
|
|
[Dependency] private readonly TriggerSystem _trigger = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
SubscribeLocalEvent<LandMineComponent, StepTriggeredOnEvent>(HandleStepOnTriggered);
|
|
SubscribeLocalEvent<LandMineComponent, StepTriggeredOffEvent>(HandleStepOffTriggered);
|
|
|
|
SubscribeLocalEvent<LandMineComponent, StepTriggerAttemptEvent>(HandleStepTriggerAttempt);
|
|
}
|
|
|
|
private void HandleStepOnTriggered(EntityUid uid, LandMineComponent component, ref StepTriggeredOnEvent args)
|
|
{
|
|
_popupSystem.PopupCoordinates(
|
|
Loc.GetString("land-mine-triggered", ("mine", uid)),
|
|
Transform(uid).Coordinates,
|
|
args.Tripper,
|
|
PopupType.LargeCaution);
|
|
|
|
_audioSystem.PlayPvs(component.Sound, uid);
|
|
}
|
|
|
|
private void HandleStepOffTriggered(EntityUid uid, LandMineComponent component, ref StepTriggeredOffEvent args)
|
|
{
|
|
_trigger.Trigger(uid, args.Tripper);
|
|
}
|
|
|
|
private static void HandleStepTriggerAttempt(EntityUid uid, LandMineComponent component, ref StepTriggerAttemptEvent args)
|
|
{
|
|
args.Continue = true;
|
|
}
|
|
}
|