diff --git a/Content.Server/CardboardBox/CardboardBoxSystem.cs b/Content.Server/CardboardBox/CardboardBoxSystem.cs index e7a0c8f973..c199c2473a 100644 --- a/Content.Server/CardboardBox/CardboardBoxSystem.cs +++ b/Content.Server/CardboardBox/CardboardBoxSystem.cs @@ -31,12 +31,28 @@ public sealed class CardboardBoxSystem : SharedCardboardBoxSystem SubscribeLocalEvent(AfterStorageOpen); SubscribeLocalEvent(BeforeStorageOpen); SubscribeLocalEvent(AfterStorageClosed); + SubscribeLocalEvent(OnInteracted); SubscribeLocalEvent(OnNoHandInteracted); SubscribeLocalEvent(OnEntInserted); SubscribeLocalEvent(OnEntRemoved); SubscribeLocalEvent(OnDamage); } + + private void OnInteracted(EntityUid uid, CardboardBoxComponent component, ActivateInWorldEvent args) + { + if (!TryComp(uid, out var box)) + return; + + args.Handled = true; + _storage.ToggleOpen(args.User, uid, box); + + if (box.Contents.Contains(args.User) && !box.Open) + { + _mover.SetRelay(args.User, uid); + component.Mover = args.User; + } + } private void OnNoHandInteracted(EntityUid uid, CardboardBoxComponent component, InteractedNoHandEvent args) { @@ -49,6 +65,9 @@ public sealed class CardboardBoxSystem : SharedCardboardBoxSystem private void BeforeStorageOpen(EntityUid uid, CardboardBoxComponent component, ref StorageBeforeOpenEvent args) { + if (component.Quiet) + return; + //Play effect & sound if (component.Mover != null) { @@ -91,17 +110,11 @@ public sealed class CardboardBoxSystem : SharedCardboardBoxSystem if (!TryComp(args.Entity, out MobMoverComponent? mover)) return; - if (component.Mover != null) + if (component.Mover == null) { - // player movers take priority - if (HasComp(component.Mover) || !HasComp(args.Entity)) - return; - - RemComp(component.Mover.Value); + _mover.SetRelay(args.Entity, uid); + component.Mover = args.Entity; } - - _mover.SetRelay(args.Entity, uid); - component.Mover = args.Entity; } /// diff --git a/Content.Shared/CardboardBox/Components/CardboardBoxComponent.cs b/Content.Shared/CardboardBox/Components/CardboardBoxComponent.cs index fa4bb3b639..33db21593e 100644 --- a/Content.Shared/CardboardBox/Components/CardboardBoxComponent.cs +++ b/Content.Shared/CardboardBox/Components/CardboardBoxComponent.cs @@ -30,6 +30,13 @@ public sealed class CardboardBoxComponent : Component [ViewVariables(VVAccess.ReadWrite)] [DataField("effectSound")] public SoundSpecifier? EffectSound; + + /// + /// Whether to prevent the box from making the sound and effect + /// + [ViewVariables(VVAccess.ReadWrite)] + [DataField("quiet")] + public bool Quiet = false; /// /// How far should the box opening effect go?