diff --git a/Content.Server/Buckle/Systems/BuckleSystem.cs b/Content.Server/Buckle/Systems/BuckleSystem.cs index 442bb9e7d6..685c293557 100644 --- a/Content.Server/Buckle/Systems/BuckleSystem.cs +++ b/Content.Server/Buckle/Systems/BuckleSystem.cs @@ -1,5 +1,6 @@ using Content.Server.Buckle.Components; using Content.Server.Interaction; +using Content.Server.Storage.Components; using Content.Shared.Buckle; using Content.Shared.Interaction; using Content.Shared.Verbs; @@ -32,6 +33,7 @@ namespace Content.Server.Buckle.Systems SubscribeLocalEvent(HandleInteractHand); SubscribeLocalEvent>(AddUnbuckleVerb); + SubscribeLocalEvent(OnEntityStorageInsertAttempt); } private void AddUnbuckleVerb(EntityUid uid, BuckleComponent component, GetVerbsEvent args) @@ -133,5 +135,11 @@ namespace Content.Server.Buckle.Systems buckle.ReAttach(strap); } } + + public void OnEntityStorageInsertAttempt(EntityUid uid, BuckleComponent comp, InsertIntoEntityStorageAttemptEvent args) + { + if (comp.Buckled) + args.Cancel(); + } } } diff --git a/Content.Server/Foldable/FoldableSystem.cs b/Content.Server/Foldable/FoldableSystem.cs index 9fb98aeeea..85e245161a 100644 --- a/Content.Server/Foldable/FoldableSystem.cs +++ b/Content.Server/Foldable/FoldableSystem.cs @@ -19,6 +19,7 @@ namespace Content.Server.Foldable SubscribeLocalEvent(OnFoldableOpenAttempt); SubscribeLocalEvent>(AddFoldVerb); + SubscribeLocalEvent(OnEntityStorageInsertAttempt); } private void OnFoldableOpenAttempt(EntityUid uid, FoldableComponent component, StorageOpenAttemptEvent args) @@ -86,6 +87,12 @@ namespace Content.Server.Foldable strap.Enabled = !component.IsFolded; } + public void OnEntityStorageInsertAttempt(EntityUid uid, FoldableComponent comp, InsertIntoEntityStorageAttemptEvent args) + { + if (!comp.IsFolded) + args.Cancel(); + } + #region Verb private void AddFoldVerb(EntityUid uid, FoldableComponent component, GetVerbsEvent args) diff --git a/Content.Server/Ghost/GhostSystem.cs b/Content.Server/Ghost/GhostSystem.cs index 37773a02c0..a58ebdf7e3 100644 --- a/Content.Server/Ghost/GhostSystem.cs +++ b/Content.Server/Ghost/GhostSystem.cs @@ -4,6 +4,7 @@ using Content.Server.Ghost.Components; using Content.Server.Mind; using Content.Server.Mind.Components; using Content.Server.Players; +using Content.Server.Storage.Components; using Content.Server.Visible; using Content.Server.Warps; using Content.Shared.Actions; @@ -51,6 +52,7 @@ namespace Content.Server.Ghost SubscribeNetworkEvent(OnGhostWarpToTargetRequest); SubscribeLocalEvent(OnActionPerform); + SubscribeLocalEvent(OnEntityStorageInsertAttempt); } private void OnActionPerform(EntityUid uid, GhostComponent component, BooActionEvent args) { @@ -265,5 +267,10 @@ namespace Content.Server.Ghost return players; } + + public void OnEntityStorageInsertAttempt(EntityUid uid, GhostComponent comp, InsertIntoEntityStorageAttemptEvent args) + { + args.Cancel(); + } } } diff --git a/Content.Server/Storage/Components/EntityStorageComponent.cs b/Content.Server/Storage/Components/EntityStorageComponent.cs index 175bc7f4e2..45719a0634 100644 --- a/Content.Server/Storage/Components/EntityStorageComponent.cs +++ b/Content.Server/Storage/Components/EntityStorageComponent.cs @@ -1,5 +1,7 @@ using System.Linq; +using Content.Server.Buckle.Components; using Content.Server.Construction; +using Content.Server.Construction.Completions; using Content.Server.Construction.Components; using Content.Server.Ghost.Components; using Content.Server.Storage.EntitySystems; @@ -215,8 +217,9 @@ namespace Content.Server.Storage.Components // 5. if this is NOT AN ITEM, then mobs can always be eaten unless unless a previous law prevents it // 6. if this is an item, then mobs must only be eaten if some other component prevents pick-up interactions while a mob is inside (e.g. foldable) - // Let's not insert admin ghosts, yeah? This is really a a hack and should be replaced by attempt events - if (_entMan.HasComponent(entity)) + var attemptEvent = new InsertIntoEntityStorageAttemptEvent(); + _entMan.EventBus.RaiseLocalEvent(entity, attemptEvent); + if (attemptEvent.Cancelled) return false; // checks @@ -236,13 +239,9 @@ namespace Content.Server.Storage.Components { if (!storageIsItem) allowedToEat = true; - else - { - // make an exception if this is a foldable-item that is currently un-folded (e.g., body bags). - allowedToEat = _entMan.TryGetComponent(Owner, out FoldableComponent? foldable) && !foldable.IsFolded; - } } + _entMan.EventBus.RaiseLocalEvent(entity, allowedToEat); return allowedToEat; } @@ -365,6 +364,10 @@ namespace Content.Server.Storage.Components } } + public sealed class InsertIntoEntityStorageAttemptEvent : CancellableEntityEventArgs + { + + } public sealed class StorageOpenAttemptEvent : CancellableEntityEventArgs {