From a5ad45ff306a4610cb1cf31945f52dd61e211511 Mon Sep 17 00:00:00 2001 From: Anuken Date: Tue, 1 Dec 2020 15:57:20 -0500 Subject: [PATCH] Fixed #3706 --- core/src/mindustry/type/UnitType.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/core/src/mindustry/type/UnitType.java b/core/src/mindustry/type/UnitType.java index 57a5aba215..fc32ec7bbc 100644 --- a/core/src/mindustry/type/UnitType.java +++ b/core/src/mindustry/type/UnitType.java @@ -109,6 +109,8 @@ public class UnitType extends UnlockableContent{ occlusionRegion, jointRegion, footRegion, legBaseRegion, baseJointRegion, outlineRegion; public TextureRegion[] wreckRegions; + protected @Nullable ItemStack[] cachedRequirements; + public UnitType(String name){ super(name); @@ -193,6 +195,10 @@ public class UnitType extends UnlockableContent{ } } } + + for(ItemStack stack : researchRequirements()){ + cons.get(stack.item); + } } @Override @@ -357,6 +363,10 @@ public class UnitType extends UnlockableContent{ @Override public ItemStack[] researchRequirements(){ + if(cachedRequirements != null){ + return cachedRequirements; + } + ItemStack[] stacks = null; //calculate costs based on reconstructors or factories found @@ -377,6 +387,8 @@ public class UnitType extends UnlockableContent{ out[i] = new ItemStack(stacks[i].item, UI.roundAmount((int)(Math.pow(stacks[i].amount, 1.1) * 50))); } + cachedRequirements = out; + return out; }