Added unit build requirements to stats
This commit is contained in:
@@ -141,8 +141,7 @@ public class UnitType extends UnlockableContent{
|
|||||||
public TextureRegion[] wreckRegions;
|
public TextureRegion[] wreckRegions;
|
||||||
|
|
||||||
protected float buildTime = -1f;
|
protected float buildTime = -1f;
|
||||||
protected @Nullable ItemStack[] cachedRequirements;
|
protected @Nullable ItemStack[] totalRequirements, cachedRequirements, firstRequirements;
|
||||||
protected @Nullable ItemStack[] totalRequirements;
|
|
||||||
|
|
||||||
public UnitType(String name){
|
public UnitType(String name){
|
||||||
super(name);
|
super(name);
|
||||||
@@ -307,6 +306,12 @@ public class UnitType extends UnlockableContent{
|
|||||||
stats.add(Stat.payloadCapacity, (payloadCapacity / (tilesize * tilesize)), StatUnit.blocksSquared);
|
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()){
|
if(weapons.any()){
|
||||||
stats.add(Stat.weapons, StatValues.weapons(this, weapons));
|
stats.add(Stat.weapons, StatValues.weapons(this, weapons));
|
||||||
}
|
}
|
||||||
@@ -547,6 +552,13 @@ public class UnitType extends UnlockableContent{
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public @Nullable ItemStack[] getFirstRequirements(){
|
||||||
|
if(firstRequirements == null){
|
||||||
|
firstRequirements = getRequirements(null, null);
|
||||||
|
}
|
||||||
|
return firstRequirements;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack[] researchRequirements(){
|
public ItemStack[] researchRequirements(){
|
||||||
if(cachedRequirements != null){
|
if(cachedRequirements != null){
|
||||||
|
|||||||
Reference in New Issue
Block a user