Thrown soap/banana/(etc?) will fail to slip until it lands (#24494)
* throw miss * event * whoops Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> * fix popup duplication * Separate cancellable event * no popup, no problem * remove leftover stuff --------- Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
@@ -1,9 +1,12 @@
|
|||||||
using Content.Shared.Administration.Logs;
|
using Content.Shared.Administration.Logs;
|
||||||
using Content.Shared.Database;
|
using Content.Shared.Database;
|
||||||
using Content.Shared.Inventory;
|
using Content.Shared.Inventory;
|
||||||
|
using Robust.Shared.Network;
|
||||||
|
using Content.Shared.Popups;
|
||||||
using Content.Shared.StatusEffect;
|
using Content.Shared.StatusEffect;
|
||||||
using Content.Shared.StepTrigger.Systems;
|
using Content.Shared.StepTrigger.Systems;
|
||||||
using Content.Shared.Stunnable;
|
using Content.Shared.Stunnable;
|
||||||
|
using Content.Shared.Throwing;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Shared.Audio.Systems;
|
using Robust.Shared.Audio.Systems;
|
||||||
using Robust.Shared.Containers;
|
using Robust.Shared.Containers;
|
||||||
@@ -30,6 +33,7 @@ public sealed class SlipperySystem : EntitySystem
|
|||||||
SubscribeLocalEvent<SlipperyComponent, StepTriggerAttemptEvent>(HandleAttemptCollide);
|
SubscribeLocalEvent<SlipperyComponent, StepTriggerAttemptEvent>(HandleAttemptCollide);
|
||||||
SubscribeLocalEvent<SlipperyComponent, StepTriggeredEvent>(HandleStepTrigger);
|
SubscribeLocalEvent<SlipperyComponent, StepTriggeredEvent>(HandleStepTrigger);
|
||||||
SubscribeLocalEvent<NoSlipComponent, SlipAttemptEvent>(OnNoSlipAttempt);
|
SubscribeLocalEvent<NoSlipComponent, SlipAttemptEvent>(OnNoSlipAttempt);
|
||||||
|
SubscribeLocalEvent<ThrownItemComponent, SlipCausingAttemptEvent>(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).
|
// 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<NoSlipComponent, InventoryRelayedEvent<SlipAttemptEvent>>((e, c, ev) => OnNoSlipAttempt(e, c, ev.Args));
|
SubscribeLocalEvent<NoSlipComponent, InventoryRelayedEvent<SlipAttemptEvent>>((e, c, ev) => OnNoSlipAttempt(e, c, ev.Args));
|
||||||
}
|
}
|
||||||
@@ -52,6 +56,11 @@ public sealed class SlipperySystem : EntitySystem
|
|||||||
args.Cancel();
|
args.Cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnThrownSlipAttempt(EntityUid uid, ThrownItemComponent comp, ref SlipCausingAttemptEvent args)
|
||||||
|
{
|
||||||
|
args.Cancelled = true;
|
||||||
|
}
|
||||||
|
|
||||||
private bool CanSlip(EntityUid uid, EntityUid toSlip)
|
private bool CanSlip(EntityUid uid, EntityUid toSlip)
|
||||||
{
|
{
|
||||||
return !_container.IsEntityInContainer(uid)
|
return !_container.IsEntityInContainer(uid)
|
||||||
@@ -68,6 +77,11 @@ public sealed class SlipperySystem : EntitySystem
|
|||||||
if (attemptEv.Cancelled)
|
if (attemptEv.Cancelled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
var attemptCausingEv = new SlipCausingAttemptEvent();
|
||||||
|
RaiseLocalEvent(uid, ref attemptCausingEv);
|
||||||
|
if (attemptCausingEv.Cancelled)
|
||||||
|
return;
|
||||||
|
|
||||||
var ev = new SlipEvent(other);
|
var ev = new SlipEvent(other);
|
||||||
RaiseLocalEvent(uid, ref ev);
|
RaiseLocalEvent(uid, ref ev);
|
||||||
|
|
||||||
@@ -107,7 +121,13 @@ public sealed class SlipAttemptEvent : CancellableEntityEventArgs, IInventoryRel
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 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.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="Cancelled">If the slip should be cancelled</param>
|
||||||
|
[ByRefEvent]
|
||||||
|
public record struct SlipCausingAttemptEvent (bool Cancelled);
|
||||||
|
|
||||||
|
/// Raised on an entity that CAUSED some other entity to slip (e.g., the banana peel).
|
||||||
|
/// <param name="Slipped">The entity being slipped</param>
|
||||||
[ByRefEvent]
|
[ByRefEvent]
|
||||||
public readonly record struct SlipEvent(EntityUid Slipped);
|
public readonly record struct SlipEvent(EntityUid Slipped);
|
||||||
|
|||||||
Reference in New Issue
Block a user