From 76c9bde45fdf54a8dbeaf7d0ebd1d4025e481f28 Mon Sep 17 00:00:00 2001 From: SimpleStation14 Date: Mon, 22 Apr 2024 05:46:24 -0400 Subject: [PATCH] Cherry-picked commit e061cb3f8c9dc8ddc26624ead2086dfb41465aae from space-wizards/space-station-14/master --- Content.Shared/Slippery/SlipperySystem.cs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/Content.Shared/Slippery/SlipperySystem.cs b/Content.Shared/Slippery/SlipperySystem.cs index 1f602b9b52b..d20495cfa6c 100644 --- a/Content.Shared/Slippery/SlipperySystem.cs +++ b/Content.Shared/Slippery/SlipperySystem.cs @@ -1,9 +1,12 @@ using Content.Shared.Administration.Logs; using Content.Shared.Database; using Content.Shared.Inventory; +using Robust.Shared.Network; +using Content.Shared.Popups; using Content.Shared.StatusEffect; using Content.Shared.StepTrigger.Systems; using Content.Shared.Stunnable; +using Content.Shared.Throwing; using JetBrains.Annotations; using Robust.Shared.Audio.Systems; using Robust.Shared.Containers; @@ -30,6 +33,7 @@ public override void Initialize() SubscribeLocalEvent(HandleAttemptCollide); SubscribeLocalEvent(HandleStepTrigger); SubscribeLocalEvent(OnNoSlipAttempt); + SubscribeLocalEvent(OnThrownSlipAttempt); // as long as slip-resistant mice are never added, this should be fine (otherwise a mouse-hat will transfer it's power to the wearer). SubscribeLocalEvent>((e, c, ev) => OnNoSlipAttempt(e, c, ev.Args)); } @@ -52,6 +56,11 @@ private static void OnNoSlipAttempt(EntityUid uid, NoSlipComponent component, Sl args.Cancel(); } + private void OnThrownSlipAttempt(EntityUid uid, ThrownItemComponent comp, ref SlipCausingAttemptEvent args) + { + args.Cancelled = true; + } + private bool CanSlip(EntityUid uid, EntityUid toSlip) { return !_container.IsEntityInContainer(uid) @@ -68,6 +77,11 @@ private void TrySlip(EntityUid uid, SlipperyComponent component, EntityUid other if (attemptEv.Cancelled) return; + var attemptCausingEv = new SlipCausingAttemptEvent(); + RaiseLocalEvent(uid, ref attemptCausingEv); + if (attemptCausingEv.Cancelled) + return; + var ev = new SlipEvent(other); RaiseLocalEvent(uid, ref ev); @@ -107,7 +121,13 @@ public sealed class SlipAttemptEvent : CancellableEntityEventArgs, IInventoryRel } /// -/// This event is raised directed at an entity that CAUSED some other entity to slip (e.g., the banana peel). +/// Raised on an entity that is causing the slip event (e.g, the banana peel), to determine if the slip attempt should be cancelled. /// +/// If the slip should be cancelled +[ByRefEvent] +public record struct SlipCausingAttemptEvent (bool Cancelled); + +/// Raised on an entity that CAUSED some other entity to slip (e.g., the banana peel). +/// The entity being slipped [ByRefEvent] public readonly record struct SlipEvent(EntityUid Slipped);