Prevent crates, pet carriers and other things from going into disposals (#35557)

* Initial commit

* Solve underlying bug, readd to disposals

* Apply suggestions from code review

---------

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
This commit is contained in:
SlamBamActionman
2025-02-27 18:43:56 +01:00
committed by GitHub
parent 19c23682b0
commit c7b9a76342
5 changed files with 39 additions and 12 deletions

View File

@@ -30,6 +30,12 @@ public sealed class ThrowInsertContainerSystem : EntitySystem
if (!_containerSystem.CanInsert(args.Thrown, container))
return;
var beforeThrowArgs = new BeforeThrowInsertEvent(args.Thrown);
RaiseLocalEvent(ent, ref beforeThrowArgs);
if (beforeThrowArgs.Cancelled)
return;
if (_random.Prob(ent.Comp.Probability))
{
_audio.PlayPvs(ent.Comp.MissSound, ent);
@@ -46,3 +52,10 @@ public sealed class ThrowInsertContainerSystem : EntitySystem
_adminLogger.Add(LogType.Landed, LogImpact.Low, $"{ToPrettyString(args.Thrown)} thrown by {ToPrettyString(args.Component.Thrower.Value):player} landed in {ToPrettyString(ent)}");
}
}
/// <summary>
/// Sent before the insertion is made.
/// Allows preventing the insertion if any system on the entity should need to.
/// </summary>
[ByRefEvent]
public record struct BeforeThrowInsertEvent(EntityUid ThrownEntity, bool Cancelled = false);