Landmine stepoff (#22962)
* 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>
This commit is contained in:
@@ -1,43 +1,43 @@
|
||||
using Content.Server.Explosion.EntitySystems;
|
||||
using Content.Server.Explosion.EntitySystems;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.StepTrigger;
|
||||
using Content.Shared.StepTrigger.Systems;
|
||||
using Robust.Shared.Player;
|
||||
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, StepTriggeredEvent>(HandleTriggered);
|
||||
SubscribeLocalEvent<LandMineComponent, StepTriggerAttemptEvent>(HandleTriggerAttempt);
|
||||
SubscribeLocalEvent<LandMineComponent, StepTriggeredOnEvent>(HandleStepOnTriggered);
|
||||
SubscribeLocalEvent<LandMineComponent, StepTriggeredOffEvent>(HandleStepOffTriggered);
|
||||
|
||||
SubscribeLocalEvent<LandMineComponent, StepTriggerAttemptEvent>(HandleStepTriggerAttempt);
|
||||
}
|
||||
|
||||
private static void HandleTriggerAttempt(
|
||||
EntityUid uid,
|
||||
LandMineComponent component,
|
||||
ref StepTriggerAttemptEvent args)
|
||||
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;
|
||||
}
|
||||
|
||||
private void HandleTriggered(EntityUid uid, LandMineComponent component, ref StepTriggeredEvent args)
|
||||
{
|
||||
// This doesn't use TriggerOnStepTrigger since we don't want to display the popup if nothing happens
|
||||
// and I didn't feel like making an `AfterTrigger` event
|
||||
if (_trigger.Trigger(uid, args.Tripper))
|
||||
{
|
||||
_popupSystem.PopupCoordinates(
|
||||
Loc.GetString("land-mine-triggered", ("mine", uid)),
|
||||
Transform(uid).Coordinates,
|
||||
args.Tripper,
|
||||
PopupType.LargeCaution);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user