mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-22 20:48:33 +07:00
Added unit build requirements to stats
This commit is contained in:
parent
4a94d9f2b3
commit
1a0bcfc745
@ -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){
|
||||
|
Loading…
Reference in New Issue
Block a user