// SPDX-FileCopyrightText: 2025 GoobBot // SPDX-FileCopyrightText: 2025 deltanedas <@deltanedas:kde.org> // // SPDX-License-Identifier: AGPL-3.0-or-later using Content.Shared.Materials; using Content.Shared.Power.EntitySystems; namespace Content.Shared._Goobstation.Factory.Slots; /// /// Abstraction over inserting /// Removing items is not supported. /// public sealed partial class AutomatedMaterialStorage : AutomationSlot { private SharedMaterialStorageSystem _material; private SharedPowerReceiverSystem _power; private EntityQuery _materialQuery; private EntityQuery _storageQuery; private EntityQuery _compositionQuery; public override void Initialize() { base.Initialize(); _material = EntMan.System(); _power = EntMan.System(); _materialQuery = EntMan.GetEntityQuery(); _storageQuery = EntMan.GetEntityQuery(); _compositionQuery = EntMan.GetEntityQuery(); } public override bool Insert(EntityUid item) { return base.Insert(item) && _material.TryInsertMaterialEntity(user: Owner, item, Owner); } public override bool CanInsert(EntityUid item) { if (!base.CanInsert(item) || !_storageQuery.TryComp(Owner, out var storage)) return false; // don't bypass power check for lathes and stuff if (!_power.IsPowered(Owner)) return false; // this has to be essentially copypasted because goidacode doesnt have a CanInsertMaterial method if (!_materialQuery.HasComp(item) || !_compositionQuery.HasComp(item)) return false; // not checking volume etc since all lathes currently have unlimited capacity return _whitelist.IsWhitelistPassOrNull(storage.Whitelist, item); } }