Files
wwdpublic/Content.Server/LandMines/LandMineSystem.cs
SimpleStation14 2bf744ddf6 Mirror: Landmine stepoff (#358)
## Mirror of PR #22962: [Landmine
stepoff](https://github.com/space-wizards/space-station-14/pull/22962)
from <img src="https://avatars.githubusercontent.com/u/10567778?v=4"
alt="space-wizards" width="22"/>
[space-wizards](https://github.com/space-wizards)/[space-station-14](https://github.com/space-wizards/space-station-14)

###### `54dd273f660d6d8d523d0771bb8d8437373b082e`

PR opened by <img
src="https://avatars.githubusercontent.com/u/59531932?v=4"
width="16"/><a href="https://github.com/YuriyKiss"> YuriyKiss</a> at
2023-12-25 12:38:55 UTC

---

PR changed 13 files with 95 additions and 47 deletions.

The PR had the following labels:
- Status: Awaiting Changes


---

<details open="true"><summary><h1>Original Body</h1></summary>

> ## About the PR
> Landmine will explode when player steps off it. Landmine will make a
sound effect when player steps on it
> Close #21658 (Issue has some other suggestions, turn them into
separate issues if relevant)
> 
> Requires https://github.com/space-wizards/RobustToolbox/pull/4883
> 
> ## Why / Balance
> IRL some landmines will only trigger after you release the pressure
put on them.
> 
> ## Technical details
> There are two landmine modes now, one will make landmine trigger
immediately after player steps on them another one will only trigger
after player steps off the landmine (this is the default now).
> 
> ## Media
> Landmine stepoff in action:
> 
>
https://github.com/space-wizards/space-station-14/assets/59531932/6e884619-7217-4301-bd78-6e843e0d78f1
> 
> - [X] I have added screenshots/videos to this PR showcasing its
changes ingame, **or** this PR does not require an ingame showcase
> 
> ## Breaking changes
> 
> 
> **Changelog**
> - tweak: landmines will trigger after you step off them
> - add: landmine trigger sound
> 


</details>

Signed-off-by: VMSolidus <evilexecutive@gmail.com>
Co-authored-by: SimpleStation14 <Unknown>
Co-authored-by: VMSolidus <evilexecutive@gmail.com>
2024-06-17 11:12:29 +01:00

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;
}
}