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);
_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);
using System.Linq;
using Content.Server.Administration.Logs;
using Content.Server.Atmos.EntitySystems;
+using Content.Server.Containers;
using Content.Server.Disposal.Tube;
using Content.Server.Disposal.Tube.Components;
using Content.Server.Disposal.Unit.Components;
SubscribeLocalEvent<DisposalUnitComponent, DisposalDoAfterEvent>(OnDoAfter);
+ SubscribeLocalEvent<DisposalUnitComponent, BeforeThrowInsertEvent>(OnThrowInsert);
+
SubscribeLocalEvent<DisposalUnitComponent, SharedDisposalUnitComponent.UiButtonPressedMessage>(OnUiButtonPressed);
}
args.Handled = true;
}
+ private void OnThrowInsert(Entity<DisposalUnitComponent> ent, ref BeforeThrowInsertEvent args)
+ {
+ if (!CanInsert(ent, ent, args.ThrownEntity))
+ args.Cancelled = true;
+ }
+
public override void DoInsertDisposalUnit(EntityUid uid, EntityUid toInsert, EntityUid user, SharedDisposalUnitComponent? disposal = null)
{
if (!ResolveDisposals(uid, ref disposal))
if (!ResolveStorage(container, ref component))
return false;
- RemComp<InsideEntityStorageComponent>(toRemove);
_container.Remove(toRemove, component.Contents);
+
+ if (_container.IsEntityInContainer(container))
+ {
+ if (_container.TryGetOuterContainer(container, Transform(container), out var outerContainer) &&
+ !HasComp<HandsComponent>(outerContainer.Owner))
+ {
+ _container.Insert(toRemove, outerContainer);
+ return true;
+ }
+ }
+
+ RemComp<InsideEntityStorageComponent>(toRemove);
+
var pos = TransformSystem.GetWorldPosition(xform) + TransformSystem.GetWorldRotation(xform).RotateVec(component.EnteringOffset);
TransformSystem.SetWorldPosition(toRemove, pos);
return true;
return false;
}
- if (_container.IsEntityInContainer(target))
- {
- if (_container.TryGetOuterContainer(target,Transform(target) ,out var container) &&
- !HasComp<HandsComponent>(container.Owner))
- {
- Popup.PopupClient(Loc.GetString("entity-storage-component-already-contains-user-message"), user, user);
-
- return false;
- }
- }
-
//Checks to see if the opening position, if offset, is inside of a wall.
if (component.EnteringOffset != new Vector2(0, 0) && !HasComp<WallMountComponent>(target)) //if the entering position is offset
{
- HumanoidAppearance
- Plunger
- SolutionTransfer
+ - EntityStorage
whitelist:
components:
- Item
whitelist:
components:
- Item
+ blacklist:
+ components:
+ - EntityStorage
- type: MailingUnit
- type: DeviceNetwork
deviceNetId: Wired