diff --git a/Content.Server/Storage/Components/ArtifactStorageComponent.cs b/Content.Server/Storage/Components/ArtifactStorageComponent.cs deleted file mode 100644 index 4d1153cf90..0000000000 --- a/Content.Server/Storage/Components/ArtifactStorageComponent.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Content.Server.Storage.Components; - -[RegisterComponent] -public sealed class ArtifactStorageComponent : Component -{ - -} diff --git a/Content.Server/Storage/Components/EntityStorageComponent.cs b/Content.Server/Storage/Components/EntityStorageComponent.cs index 93e4bd02fc..8fa27d2efb 100644 --- a/Content.Server/Storage/Components/EntityStorageComponent.cs +++ b/Content.Server/Storage/Components/EntityStorageComponent.cs @@ -1,5 +1,6 @@ using Content.Shared.Physics; using Content.Shared.Sound; +using Content.Shared.Whitelist; using Robust.Shared.Containers; namespace Content.Server.Storage.Components; @@ -64,6 +65,13 @@ public sealed class EntityStorageComponent : Component [DataField("openSound")] public SoundSpecifier OpenSound = new SoundPathSpecifier("/Audio/Effects/closetopen.ogg"); + /// + /// Whitelist for what entities are allowed to be inserted into this container. If this is not null, the + /// standard requirement that the entity must be an item or mob is waived. + /// + [DataField("whitelist")] + public EntityWhitelist? Whitelist; + [ViewVariables] public Container Contents = default!; @@ -93,7 +101,10 @@ public sealed class StorageBeforeCloseEvent : EventArgs public HashSet Contents; - public HashSet ContentsWhitelist = new(); + /// + /// Entities that will get inserted, regardless of any insertion or whitelist checks. + /// + public HashSet BypassChecks = new(); public StorageBeforeCloseEvent(EntityUid container, HashSet contents) { diff --git a/Content.Server/Storage/EntitySystems/ArtifactStorageSystem.cs b/Content.Server/Storage/EntitySystems/ArtifactStorageSystem.cs deleted file mode 100644 index 972a296177..0000000000 --- a/Content.Server/Storage/EntitySystems/ArtifactStorageSystem.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Content.Server.Storage.Components; -using Content.Server.Xenoarchaeology.XenoArtifacts; - -namespace Content.Server.Storage.EntitySystems; - -public sealed class ArtifactStorageSystem : EntitySystem -{ - public override void Initialize() - { - base.Initialize(); - - SubscribeLocalEvent(OnBeforeClose); - } - - private void OnBeforeClose(EntityUid uid, ArtifactStorageComponent component, StorageBeforeCloseEvent args) - { - foreach (var ent in args.Contents) - { - if (HasComp(ent)) - args.ContentsWhitelist.Add(ent); - } - } -} diff --git a/Content.Server/Storage/EntitySystems/EntityStorageSystem.cs b/Content.Server/Storage/EntitySystems/EntityStorageSystem.cs index d2ff9daa6c..b57f5f43d9 100644 --- a/Content.Server/Storage/EntitySystems/EntityStorageSystem.cs +++ b/Content.Server/Storage/EntitySystems/EntityStorageSystem.cs @@ -10,6 +10,7 @@ using Content.Shared.Interaction; using Content.Shared.Item; using Content.Shared.Placeable; using Content.Shared.Storage; +using Content.Shared.Whitelist; using Robust.Server.Containers; using Robust.Shared.Audio; using Robust.Shared.Containers; @@ -143,16 +144,20 @@ public sealed class EntityStorageSystem : EntitySystem var targetCoordinates = new EntityCoordinates(uid, component.EnteringOffset); - var ev = new StorageBeforeCloseEvent(uid, _lookup.GetEntitiesInRange(targetCoordinates, component.EnteringRange, LookupFlags.Approximate)); + var entities = _lookup.GetEntitiesInRange(targetCoordinates, component.EnteringRange, LookupFlags.Approximate); + + var ev = new StorageBeforeCloseEvent(uid, entities); RaiseLocalEvent(uid, ev, true); var count = 0; foreach (var entity in ev.Contents) { - if (!ev.ContentsWhitelist.Contains(entity)) - if (!CanFit(entity, uid)) + if (!ev.BypassChecks.Contains(entity)) + { + if (!CanFit(entity, uid, component.Whitelist)) continue; - + } + if (!AddToContents(entity, uid, component)) continue; @@ -279,7 +284,7 @@ public sealed class EntityStorageSystem : EntitySystem return Insert(toAdd, container, component); } - public bool CanFit(EntityUid toInsert, EntityUid container) + public bool CanFit(EntityUid toInsert, EntityUid container, EntityWhitelist? whitelist) { // conditions are complicated because of pizzabox-related issues, so follow this guide // 0. Accomplish your goals at all costs. @@ -296,13 +301,12 @@ public sealed class EntityStorageSystem : EntitySystem if (attemptEvent.Cancelled) return false; - // checks - // TODO: Make the others sub to it. - var targetIsItem = HasComp(toInsert); var targetIsMob = HasComp(toInsert); var storageIsItem = HasComp(container); - var allowedToEat = targetIsItem; + var allowedToEat = whitelist == null + ? HasComp(toInsert) + : whitelist.IsValid(toInsert); // BEFORE REPLACING THIS WITH, I.E. A PROPERTY: // Make absolutely 100% sure you have worked out how to stop people ending up in backpacks. diff --git a/Resources/Prototypes/Entities/Objects/Specific/Xenoarchaeology/artifact_equipment.yml b/Resources/Prototypes/Entities/Objects/Specific/Xenoarchaeology/artifact_equipment.yml index ea3abe5c31..298cc462b9 100644 --- a/Resources/Prototypes/Entities/Objects/Specific/Xenoarchaeology/artifact_equipment.yml +++ b/Resources/Prototypes/Entities/Objects/Specific/Xenoarchaeology/artifact_equipment.yml @@ -40,7 +40,9 @@ state: artifact_container_icon - type: EntityStorage Capacity: 1 - - type: ArtifactStorage + whitelist: + components: + - Artifact - type: Weldable - type: SuppressArtifactContainer - type: PlaceableSurface