diff --git a/core/src/mindustry/type/UnitType.java b/core/src/mindustry/type/UnitType.java index d934824d3b..fcff622497 100644 --- a/core/src/mindustry/type/UnitType.java +++ b/core/src/mindustry/type/UnitType.java @@ -141,8 +141,7 @@ public class UnitType extends UnlockableContent{ public TextureRegion[] wreckRegions; protected float buildTime = -1f; - protected @Nullable ItemStack[] cachedRequirements; - protected @Nullable ItemStack[] totalRequirements; + protected @Nullable ItemStack[] totalRequirements, cachedRequirements, firstRequirements; public UnitType(String name){ super(name); @@ -307,6 +306,12 @@ public class UnitType extends UnlockableContent{ stats.add(Stat.payloadCapacity, (payloadCapacity / (tilesize * tilesize)), StatUnit.blocksSquared); } + var reqs = getFirstRequirements(); + + if(reqs != null){ + stats.add(Stat.buildCost, StatValues.items(reqs)); + } + if(weapons.any()){ stats.add(Stat.weapons, StatValues.weapons(this, weapons)); } @@ -547,6 +552,13 @@ public class UnitType extends UnlockableContent{ return null; } + public @Nullable ItemStack[] getFirstRequirements(){ + if(firstRequirements == null){ + firstRequirements = getRequirements(null, null); + } + return firstRequirements; + } + @Override public ItemStack[] researchRequirements(){ if(cachedRequirements != null){