From 1a0bcfc745b515c3dad43644f5b3b13d756740d5 Mon Sep 17 00:00:00 2001 From: Anuken Date: Sat, 30 Oct 2021 22:49:53 -0400 Subject: [PATCH] Added unit build requirements to stats --- core/src/mindustry/type/UnitType.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) 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){