Move vending restocks to EntityTableContainerFills (#41442)

* Move vending restocks to EntityTableContainerFills

* Glad I can actually see that fail now

* I could of just gone back to checking all the containers but nooo had to be stubborn

* Apply changes from code review
This commit is contained in:
SnappingOpossum
2025-11-22 07:51:32 +11:00
committed by GitHub
parent 9f94f94cb6
commit eb95f4b214
2 changed files with 120 additions and 85 deletions

View File

@@ -3,11 +3,13 @@ using System.Collections.Generic;
using Content.Server.VendingMachines; using Content.Server.VendingMachines;
using Content.Server.Wires; using Content.Server.Wires;
using Content.Shared.Cargo.Prototypes; using Content.Shared.Cargo.Prototypes;
using Content.Shared.Containers;
using Content.Shared.Damage; using Content.Shared.Damage;
using Content.Shared.Damage.Prototypes; using Content.Shared.Damage.Prototypes;
using Content.Shared.Damage.Systems; using Content.Shared.Damage.Systems;
using Content.Shared.EntityTable;
using Content.Shared.Prototypes; using Content.Shared.Prototypes;
using Content.Shared.Storage.Components; using Content.Shared.Storage.EntitySystems;
using Content.Shared.VendingMachines; using Content.Shared.VendingMachines;
using Content.Shared.Wires; using Content.Shared.Wires;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
@@ -115,6 +117,7 @@ namespace Content.IntegrationTests.Tests
var prototypeManager = server.ResolveDependency<IPrototypeManager>(); var prototypeManager = server.ResolveDependency<IPrototypeManager>();
var compFact = server.ResolveDependency<IComponentFactory>(); var compFact = server.ResolveDependency<IComponentFactory>();
var entityTable = server.EntMan.System<EntityTableSystem>();
await server.WaitAssertion(() => await server.WaitAssertion(() =>
{ {
@@ -134,17 +137,23 @@ namespace Content.IntegrationTests.Tests
restocks.Add(proto.ID); restocks.Add(proto.ID);
} }
// Collect all the prototypes with StorageFills referencing those entities. // Collect all the prototypes with EntityTableContainerFills referencing those entities.
foreach (var proto in prototypeManager.EnumeratePrototypes<EntityPrototype>()) foreach (var proto in prototypeManager.EnumeratePrototypes<EntityPrototype>())
{ {
if (!proto.TryGetComponent<StorageFillComponent>(out var storage, compFact)) if (!proto.TryGetComponent<EntityTableContainerFillComponent>(out var storage, compFact))
continue;
var containers = storage.Containers;
if (!containers.TryGetValue(SharedEntityStorageSystem.ContainerName, out var container)) // We only care about this container type.
continue; continue;
List<string> restockStore = new(); List<string> restockStore = new();
foreach (var spawnEntry in storage.Contents)
foreach (var spawnEntry in entityTable.GetSpawns(container))
{ {
if (spawnEntry.PrototypeId != null && restocks.Contains(spawnEntry.PrototypeId)) if (restocks.Contains(spawnEntry))
restockStore.Add(spawnEntry.PrototypeId); restockStore.Add(spawnEntry);
} }
if (restockStore.Count > 0) if (restockStore.Count > 0)
@@ -153,7 +162,7 @@ namespace Content.IntegrationTests.Tests
// Iterate through every CargoProduct and make sure each // Iterate through every CargoProduct and make sure each
// prototype with a restock component is referenced in a // prototype with a restock component is referenced in a
// purchaseable entity with a StorageFill. // purchaseable entity with an EntityTableContianerFill.
foreach (var proto in prototypeManager.EnumeratePrototypes<CargoProductPrototype>()) foreach (var proto in prototypeManager.EnumeratePrototypes<CargoProductPrototype>())
{ {
if (restockStores.ContainsKey(proto.Product)) if (restockStores.ContainsKey(proto.Product))

View File

@@ -4,9 +4,10 @@
name: Booze-O-Mat restock crate name: Booze-O-Mat restock crate
description: Contains a restock box for the Booze-O-Mat. description: Contains a restock box for the Booze-O-Mat.
components: components:
- type: StorageFill - type: EntityTableContainerFill
contents: containers:
- id: VendingMachineRestockBooze entity_storage:
id: VendingMachineRestockBooze
- type: entity - type: entity
id: CrateVendingMachineRestockChefvendFilled id: CrateVendingMachineRestockChefvendFilled
@@ -14,9 +15,10 @@
name: ChefVend restock crate name: ChefVend restock crate
description: Contains a restock box for the ChefVend. description: Contains a restock box for the ChefVend.
components: components:
- type: StorageFill - type: EntityTableContainerFill
contents: containers:
- id: VendingMachineRestockChefvend entity_storage:
id: VendingMachineRestockChefvend
- type: entity - type: entity
id: CrateVendingMachineRestockClothesFilled id: CrateVendingMachineRestockClothesFilled
@@ -24,9 +26,10 @@
name: clothing restock crate name: clothing restock crate
description: Contains a restock box for the clothes vending machines. description: Contains a restock box for the clothes vending machines.
components: components:
- type: StorageFill - type: EntityTableContainerFill
contents: containers:
- id: VendingMachineRestockClothes entity_storage:
id: VendingMachineRestockClothes
- type: entity - type: entity
id: CrateVendingMachineRestockAutoDrobeFilled id: CrateVendingMachineRestockAutoDrobeFilled
@@ -34,9 +37,10 @@
name: AutoDrobe restock crate name: AutoDrobe restock crate
description: Contains a restock box for the AutoDrobe. description: Contains a restock box for the AutoDrobe.
components: components:
- type: StorageFill - type: EntityTableContainerFill
contents: containers:
- id: VendingMachineRestockCostumes entity_storage:
id: VendingMachineRestockCostumes
- type: entity - type: entity
id: CrateVendingMachineRestockCondimentStationFilled id: CrateVendingMachineRestockCondimentStationFilled
@@ -44,9 +48,10 @@
name: condiment station restock crate name: condiment station restock crate
description: Contains a restock box for the condiment station. description: Contains a restock box for the condiment station.
components: components:
- type: StorageFill - type: EntityTableContainerFill
contents: containers:
- id: VendingMachineRestockCondimentStation entity_storage:
id: VendingMachineRestockCondimentStation
- type: entity - type: entity
id: CrateVendingMachineRestockDinnerwareFilled id: CrateVendingMachineRestockDinnerwareFilled
@@ -54,9 +59,10 @@
name: Plasteel Chef restock crate name: Plasteel Chef restock crate
description: Contains a restock box for the Plasteel Chef vending machine. description: Contains a restock box for the Plasteel Chef vending machine.
components: components:
- type: StorageFill - type: EntityTableContainerFill
contents: containers:
- id: VendingMachineRestockDinnerware entity_storage:
id: VendingMachineRestockDinnerware
- type: entity - type: entity
id: CrateVendingMachineRestockEngineeringFilled id: CrateVendingMachineRestockEngineeringFilled
@@ -64,9 +70,10 @@
name: EngiVend restock crate name: EngiVend restock crate
description: Contains a restock box for the EngiVend. Also supports the YouTool. description: Contains a restock box for the EngiVend. Also supports the YouTool.
components: components:
- type: StorageFill - type: EntityTableContainerFill
contents: containers:
- id: VendingMachineRestockEngineering entity_storage:
id: VendingMachineRestockEngineering
- type: entity - type: entity
id: CrateVendingMachineRestockGamesFilled id: CrateVendingMachineRestockGamesFilled
@@ -74,9 +81,10 @@
name: Good Clean Fun restock crate name: Good Clean Fun restock crate
description: Contains a restock box for the Good Clean Fun vending machine. description: Contains a restock box for the Good Clean Fun vending machine.
components: components:
- type: StorageFill - type: EntityTableContainerFill
contents: containers:
- id: VendingMachineRestockGames entity_storage:
id: VendingMachineRestockGames
- type: entity - type: entity
id: CrateVendingMachineRestockHotDrinksFilled id: CrateVendingMachineRestockHotDrinksFilled
@@ -84,9 +92,10 @@
name: Solar's Best restock crate name: Solar's Best restock crate
description: Contains two restock boxes for Solar's Best Hot Drinks vending machine. description: Contains two restock boxes for Solar's Best Hot Drinks vending machine.
components: components:
- type: StorageFill - type: EntityTableContainerFill
contents: containers:
- id: VendingMachineRestockHotDrinks entity_storage:
id: VendingMachineRestockHotDrinks
amount: 2 amount: 2
- type: entity - type: entity
@@ -95,9 +104,10 @@
name: NanoMed restock crate name: NanoMed restock crate
description: Contains a restock box, compatible with the NanoMed and NanoMedPlus. description: Contains a restock box, compatible with the NanoMed and NanoMedPlus.
components: components:
- type: StorageFill - type: EntityTableContainerFill
contents: containers:
- id: VendingMachineRestockMedical entity_storage:
id: VendingMachineRestockMedical
- type: entity - type: entity
id: CrateVendingMachineRestockChemVendFilled id: CrateVendingMachineRestockChemVendFilled
@@ -105,9 +115,10 @@
name: ChemVend restock crate name: ChemVend restock crate
description: Contains a restock box for the ChemVend. description: Contains a restock box for the ChemVend.
components: components:
- type: StorageFill - type: EntityTableContainerFill
contents: containers:
- id: VendingMachineRestockChemVend entity_storage:
id: VendingMachineRestockChemVend
- type: entity - type: entity
id: CrateVendingMachineRestockNutriMaxFilled id: CrateVendingMachineRestockNutriMaxFilled
@@ -115,9 +126,10 @@
name: NutriMax restock crate name: NutriMax restock crate
description: Contains a restock box for the NutriMax vending machine. description: Contains a restock box for the NutriMax vending machine.
components: components:
- type: StorageFill - type: EntityTableContainerFill
contents: containers:
- id: VendingMachineRestockNutriMax entity_storage:
id: VendingMachineRestockNutriMax
- type: entity - type: entity
id: CrateVendingMachineRestockPTechFilled id: CrateVendingMachineRestockPTechFilled
@@ -125,9 +137,10 @@
name: PTech restock crate name: PTech restock crate
description: Contains a restock box for the PTech bureaucracy dispenser. description: Contains a restock box for the PTech bureaucracy dispenser.
components: components:
- type: StorageFill - type: EntityTableContainerFill
contents: containers:
- id: VendingMachineRestockPTech entity_storage:
id: VendingMachineRestockPTech
- type: entity - type: entity
id: CrateVendingMachineRestockRobustSoftdrinksFilled id: CrateVendingMachineRestockRobustSoftdrinksFilled
@@ -135,9 +148,10 @@
name: beverage vendor restock crate name: beverage vendor restock crate
description: Contains restock boxes for beverage vending machines. description: Contains restock boxes for beverage vending machines.
components: components:
- type: StorageFill - type: EntityTableContainerFill
contents: containers:
- id: VendingMachineRestockRobustSoftdrinks entity_storage:
id: VendingMachineRestockRobustSoftdrinks
amount: 2 amount: 2
- type: entity - type: entity
@@ -146,9 +160,10 @@
name: Salvage restock crate name: Salvage restock crate
description: Contains a restock box for the salvage vendor. description: Contains a restock box for the salvage vendor.
components: components:
- type: StorageFill - type: EntityTableContainerFill
contents: containers:
- id: VendingMachineRestockSalvageEquipment entity_storage:
id: VendingMachineRestockSalvageEquipment
- type: entity - type: entity
id: CrateVendingMachineRestockSecTechFilled id: CrateVendingMachineRestockSecTechFilled
@@ -156,9 +171,10 @@
name: SecTech restock crate name: SecTech restock crate
description: Contains a restock box for the SecTech vending machine. description: Contains a restock box for the SecTech vending machine.
components: components:
- type: StorageFill - type: EntityTableContainerFill
contents: containers:
- id: VendingMachineRestockSecTech entity_storage:
id: VendingMachineRestockSecTech
- type: entity - type: entity
id: CrateVendingMachineRestockSeedsFilled id: CrateVendingMachineRestockSeedsFilled
@@ -166,9 +182,10 @@
name: MegaSeed restock crate name: MegaSeed restock crate
description: Contains a restock box for the MegaSeed vending machine. description: Contains a restock box for the MegaSeed vending machine.
components: components:
- type: StorageFill - type: EntityTableContainerFill
contents: containers:
- id: VendingMachineRestockSeeds entity_storage:
id: VendingMachineRestockSeeds
- type: entity - type: entity
id: CrateVendingMachineRestockSmokesFilled id: CrateVendingMachineRestockSmokesFilled
@@ -176,9 +193,10 @@
name: ShadyCigs restock crate name: ShadyCigs restock crate
description: Contains two restock boxes for the ShadyCigs vending machine. description: Contains two restock boxes for the ShadyCigs vending machine.
components: components:
- type: StorageFill - type: EntityTableContainerFill
contents: containers:
- id: VendingMachineRestockSmokes entity_storage:
id: VendingMachineRestockSmokes
amount: 2 amount: 2
- type: entity - type: entity
@@ -187,9 +205,10 @@
name: Vendomat restock crate name: Vendomat restock crate
description: Contains a restock box for a Vendomat vending machine. description: Contains a restock box for a Vendomat vending machine.
components: components:
- type: StorageFill - type: EntityTableContainerFill
contents: containers:
- id: VendingMachineRestockVendomat entity_storage:
id: VendingMachineRestockVendomat
- type: entity - type: entity
id: CrateVendingMachineRestockRoboticsFilled id: CrateVendingMachineRestockRoboticsFilled
@@ -197,9 +216,10 @@
name: Robotech Deluxe restock crate name: Robotech Deluxe restock crate
description: Contains a restock box for a Robotech Deluxe vending machine. description: Contains a restock box for a Robotech Deluxe vending machine.
components: components:
- type: StorageFill - type: EntityTableContainerFill
contents: containers:
- id: VendingMachineRestockRobotics entity_storage:
id: VendingMachineRestockRobotics
- type: entity - type: entity
id: CrateVendingMachineRestockTankDispenserFilled id: CrateVendingMachineRestockTankDispenserFilled
@@ -207,9 +227,10 @@
name: tank dispenser restock crate name: tank dispenser restock crate
description: Contains a restock box for an Engineering or Atmospherics tank dispenser. description: Contains a restock box for an Engineering or Atmospherics tank dispenser.
components: components:
- type: StorageFill - type: EntityTableContainerFill
contents: containers:
- id: VendingMachineRestockTankDispenser entity_storage:
id: VendingMachineRestockTankDispenser
- type: entity - type: entity
id: CrateVendingMachineRestockHappyHonkFilled id: CrateVendingMachineRestockHappyHonkFilled
@@ -217,9 +238,10 @@
name: Happy Honk restock crate name: Happy Honk restock crate
description: Contains a restock box for a happy honk dispenser. description: Contains a restock box for a happy honk dispenser.
components: components:
- type: StorageFill - type: EntityTableContainerFill
contents: containers:
- id: VendingMachineRestockHappyHonk entity_storage:
id: VendingMachineRestockHappyHonk
amount: 2 amount: 2
- type: entity - type: entity
@@ -228,9 +250,10 @@
name: Getmore Chocolate Corp restock crate name: Getmore Chocolate Corp restock crate
description: Contains a restock box for a Getmore Chocolate Corp dispenser. description: Contains a restock box for a Getmore Chocolate Corp dispenser.
components: components:
- type: StorageFill - type: EntityTableContainerFill
contents: containers:
- id: VendingMachineRestockGetmoreChocolateCorp entity_storage:
id: VendingMachineRestockGetmoreChocolateCorp
amount: 2 amount: 2
- type: entity - type: entity
@@ -239,9 +262,10 @@
name: Chang restock crate name: Chang restock crate
description: Contains a restock box for a Mr. Chang dispenser. description: Contains a restock box for a Mr. Chang dispenser.
components: components:
- type: StorageFill - type: EntityTableContainerFill
contents: containers:
- id: VendingMachineRestockChang entity_storage:
id: VendingMachineRestockChang
amount: 2 amount: 2
- type: entity - type: entity
@@ -250,9 +274,10 @@
name: Discount Dans restock crate name: Discount Dans restock crate
description: Contains a restock box for a Discount Dan's dispenser. description: Contains a restock box for a Discount Dan's dispenser.
components: components:
- type: StorageFill - type: EntityTableContainerFill
contents: containers:
- id: VendingMachineRestockDiscountDans entity_storage:
id: VendingMachineRestockDiscountDans
amount: 2 amount: 2
- type: entity - type: entity
@@ -261,7 +286,8 @@
name: Donut restock crate name: Donut restock crate
description: Contains a restock box for a Monkin' Donuts dispenser. description: Contains a restock box for a Monkin' Donuts dispenser.
components: components:
- type: StorageFill - type: EntityTableContainerFill
contents: containers:
- id: VendingMachineRestockDonut entity_storage:
id: VendingMachineRestockDonut
amount: 2 amount: 2