All stat stuff converted to non-enums

This commit is contained in:
Anuken
2022-04-29 12:10:49 -04:00
parent a2d4363c9f
commit db7e567832
9 changed files with 163 additions and 124 deletions

View File

@@ -4112,7 +4112,7 @@ public class Blocks{
); );
}}; }};
repairPoint = new RepairPoint("repair-point"){{ repairPoint = new RepairTurret("repair-point"){{
requirements(Category.units, with(Items.lead, 30, Items.copper, 30, Items.silicon, 20)); requirements(Category.units, with(Items.lead, 30, Items.copper, 30, Items.silicon, 20));
repairSpeed = 0.45f; repairSpeed = 0.45f;
repairRadius = 60f; repairRadius = 60f;
@@ -4121,7 +4121,7 @@ public class Blocks{
pulseRadius = 5f; pulseRadius = 5f;
}}; }};
repairTurret = new RepairPoint("repair-turret"){{ repairTurret = new RepairTurret("repair-turret"){{
requirements(Category.units, with(Items.silicon, 90, Items.thorium, 80, Items.plastanium, 60)); requirements(Category.units, with(Items.silicon, 90, Items.thorium, 80, Items.plastanium, 60));
size = 2; size = 2;
length = 6f; length = 6f;

View File

@@ -1,6 +1,7 @@
package mindustry.mod; package mindustry.mod;
import arc.struct.*; import arc.struct.*;
import mindustry.world.blocks.units.*;
import mindustry.world.draw.*; import mindustry.world.draw.*;
/** Generated class. Maps simple class names to concrete classes. For use in JSON mods. */ /** Generated class. Maps simple class names to concrete classes. For use in JSON mods. */
@@ -379,8 +380,8 @@ public class ClassMap{
classes.put("EffectDroneAI", mindustry.world.blocks.units.DroneCenter.EffectDroneAI.class); classes.put("EffectDroneAI", mindustry.world.blocks.units.DroneCenter.EffectDroneAI.class);
classes.put("Reconstructor", mindustry.world.blocks.units.Reconstructor.class); classes.put("Reconstructor", mindustry.world.blocks.units.Reconstructor.class);
classes.put("ReconstructorBuild", mindustry.world.blocks.units.Reconstructor.ReconstructorBuild.class); classes.put("ReconstructorBuild", mindustry.world.blocks.units.Reconstructor.ReconstructorBuild.class);
classes.put("RepairPoint", mindustry.world.blocks.units.RepairPoint.class); classes.put("RepairPoint", RepairTurret.class);
classes.put("RepairPointBuild", mindustry.world.blocks.units.RepairPoint.RepairPointBuild.class); classes.put("RepairPointBuild", RepairTurret.RepairPointBuild.class);
classes.put("UnitAssembler", mindustry.world.blocks.units.UnitAssembler.class); classes.put("UnitAssembler", mindustry.world.blocks.units.UnitAssembler.class);
classes.put("AssemblerUnitPlan", mindustry.world.blocks.units.UnitAssembler.AssemblerUnitPlan.class); classes.put("AssemblerUnitPlan", mindustry.world.blocks.units.UnitAssembler.AssemblerUnitPlan.class);
classes.put("UnitAssemblerBuild", mindustry.world.blocks.units.UnitAssembler.UnitAssemblerBuild.class); classes.put("UnitAssemblerBuild", mindustry.world.blocks.units.UnitAssembler.UnitAssemblerBuild.class);

View File

@@ -168,7 +168,7 @@ public class RepairBeamWeapon extends Weapon{
wy = unit.y + Angles.trnsy(weaponRotation, x, y); wy = unit.y + Angles.trnsy(weaponRotation, x, y);
float z = Draw.z(); float z = Draw.z();
RepairPoint.drawBeam(wx, wy, unit.rotation + mount.rotation, shootY, unit.id, mount.target == null || controllable ? null : (Sized)mount.target, unit.team, heal.strength, RepairTurret.drawBeam(wx, wy, unit.rotation + mount.rotation, shootY, unit.id, mount.target == null || controllable ? null : (Sized)mount.target, unit.team, heal.strength,
pulseStroke, pulseRadius, beamWidth + Mathf.absin(widthSinScl, widthSinMag), heal.lastEnd, heal.offset, laserColor, laserTopColor, pulseStroke, pulseRadius, beamWidth + Mathf.absin(widthSinScl, widthSinMag), heal.lastEnd, heal.offset, laserColor, laserTopColor,
laser, laserEnd, laserTop, laserTopEnd); laser, laserEnd, laserTop, laserTopEnd);
Draw.z(z); Draw.z(z);

View File

@@ -61,7 +61,7 @@ public class ContentInfoDialog extends BaseDialog{
if(map.size == 0) continue; if(map.size == 0) continue;
if(stats.useCategories){ if(stats.useCategories){
table.add("@category." + cat.name()).color(Pal.accent).fillX(); table.add("@category." + cat.name).color(Pal.accent).fillX();
table.row(); table.row();
} }

View File

@@ -20,7 +20,7 @@ import mindustry.world.meta.*;
import static mindustry.Vars.*; import static mindustry.Vars.*;
public class RepairPoint extends Block{ public class RepairTurret extends Block{
static final Rect rect = new Rect(); static final Rect rect = new Rect();
static final Rand rand = new Rand(); static final Rand rand = new Rand();
@@ -50,7 +50,7 @@ public class RepairPoint extends Block{
public Color laserColor = Color.valueOf("98ffa9"), laserTopColor = Color.white.cpy(); public Color laserColor = Color.valueOf("98ffa9"), laserTopColor = Color.white.cpy();
public RepairPoint(String name){ public RepairTurret(String name){
super(name); super(name);
update = true; update = true;
solid = true; solid = true;

View File

@@ -5,7 +5,7 @@ public class ConsumeCoolant extends ConsumeLiquidFilter{
public float maxTemp = 0.5f, maxFlammability = 0.1f; public float maxTemp = 0.5f, maxFlammability = 0.1f;
public ConsumeCoolant(float amount){ public ConsumeCoolant(float amount){
this.filter = liquid -> liquid.coolant && liquid.temperature <= maxTemp && liquid.flammability < maxFlammability; this.filter = liquid -> liquid.coolant && !liquid.gas && liquid.temperature <= maxTemp && liquid.flammability < maxFlammability;
this.amount = amount; this.amount = amount;
} }

View File

@@ -1,107 +1,122 @@
package mindustry.world.meta; package mindustry.world.meta;
import arc.*; import arc.*;
import arc.struct.*;
import java.util.*; import java.util.*;
/** Describes one type of stat for content. */ /** Describes one type of stat for content. */
public enum Stat{ public class Stat implements Comparable<Stat>{
health, public static final Seq<Stat> all = new Seq<>();
armor,
size,
displaySize,
buildTime,
buildCost,
memoryCapacity,
explosiveness,
flammability,
radioactivity,
charge,
heatCapacity,
viscosity,
temperature,
flying,
speed,
buildSpeed,
mineSpeed,
mineTier,
payloadCapacity,
baseDeflectChance,
lightningChance,
lightningDamage,
abilities,
canBoost,
maxUnits,
damageMultiplier, public static final Stat
healthMultiplier,
speedMultiplier,
reloadMultiplier,
buildSpeedMultiplier,
reactive,
healing,
immunities,
itemCapacity(StatCat.items), health = new Stat("health"),
itemsMoved(StatCat.items), armor = new Stat("armor"),
launchTime(StatCat.items), size = new Stat("size"),
maxConsecutive(StatCat.items), displaySize = new Stat("displaySize"),
buildTime = new Stat("buildTime"),
buildCost = new Stat("buildCost"),
memoryCapacity = new Stat("memoryCapacity"),
explosiveness = new Stat("explosiveness"),
flammability = new Stat("flammability"),
radioactivity = new Stat("radioactivity"),
charge = new Stat("charge"),
heatCapacity = new Stat("heatCapacity"),
viscosity = new Stat("viscosity"),
temperature = new Stat("temperature"),
flying = new Stat("flying"),
speed = new Stat("speed"),
buildSpeed = new Stat("buildSpeed"),
mineSpeed = new Stat("mineSpeed"),
mineTier = new Stat("mineTier"),
payloadCapacity = new Stat("payloadCapacity"),
baseDeflectChance = new Stat("baseDeflectChance"),
lightningChance = new Stat("lightningChance"),
lightningDamage = new Stat("lightningDamage"),
abilities = new Stat("abilities"),
canBoost = new Stat("canBoost"),
maxUnits = new Stat("maxUnits"),
liquidCapacity(StatCat.liquids), damageMultiplier = new Stat("damageMultiplier"),
healthMultiplier = new Stat("healthMultiplier"),
speedMultiplier = new Stat("speedMultiplier"),
reloadMultiplier = new Stat("reloadMultiplier"),
buildSpeedMultiplier = new Stat("buildSpeedMultiplier"),
reactive = new Stat("reactive"),
healing = new Stat("healing"),
immunities = new Stat("immunities"),
powerCapacity(StatCat.power), itemCapacity = new Stat("itemCapacity", StatCat.items),
powerUse(StatCat.power), itemsMoved = new Stat("itemsMoved", StatCat.items),
powerDamage(StatCat.power), launchTime = new Stat("launchTime", StatCat.items),
powerRange(StatCat.power), maxConsecutive = new Stat("maxConsecutive", StatCat.items),
powerConnections(StatCat.power),
basePowerGeneration(StatCat.power),
tiles(StatCat.crafting), liquidCapacity = new Stat("liquidCapacity", StatCat.liquids),
input(StatCat.crafting),
output(StatCat.crafting),
productionTime(StatCat.crafting),
maxEfficiency(StatCat.crafting),
drillTier(StatCat.crafting),
drillSpeed(StatCat.crafting),
linkRange(StatCat.crafting),
instructions(StatCat.crafting),
weapons(StatCat.function), powerCapacity = new Stat("powerCapacity", StatCat.power),
bullet(StatCat.function), powerUse = new Stat("powerUse", StatCat.power),
powerDamage = new Stat("powerDamage", StatCat.power),
powerRange = new Stat("powerRange", StatCat.power),
powerConnections = new Stat("powerConnections", StatCat.power),
basePowerGeneration = new Stat("basePowerGeneration", StatCat.power),
speedIncrease(StatCat.function), tiles = new Stat("tiles", StatCat.crafting),
repairTime(StatCat.function), input = new Stat("input", StatCat.crafting),
repairSpeed(StatCat.function), output = new Stat("output", StatCat.crafting),
range(StatCat.function), productionTime = new Stat("productionTime", StatCat.crafting),
shootRange(StatCat.function), maxEfficiency = new Stat("maxEfficiency", StatCat.crafting),
inaccuracy(StatCat.function), drillTier = new Stat("drillTier", StatCat.crafting),
shots(StatCat.function), drillSpeed = new Stat("drillSpeed", StatCat.crafting),
reload(StatCat.function), linkRange = new Stat("linkRange", StatCat.crafting),
powerShot(StatCat.function), instructions = new Stat("instructions", StatCat.crafting),
targetsAir(StatCat.function),
targetsGround(StatCat.function),
damage(StatCat.function),
ammo(StatCat.function),
ammoUse(StatCat.function),
shieldHealth(StatCat.function),
cooldownTime(StatCat.function),
booster(StatCat.optional), weapons = new Stat("weapons", StatCat.function),
boostEffect(StatCat.optional), bullet = new Stat("bullet", StatCat.function),
affinities(StatCat.optional),
opposites(StatCat.optional); speedIncrease = new Stat("speedIncrease", StatCat.function),
repairTime = new Stat("repairTime", StatCat.function),
repairSpeed = new Stat("repairSpeed", StatCat.function),
range = new Stat("range", StatCat.function),
shootRange = new Stat("shootRange", StatCat.function),
inaccuracy = new Stat("inaccuracy", StatCat.function),
shots = new Stat("shots", StatCat.function),
reload = new Stat("reload", StatCat.function),
powerShot = new Stat("powerShot", StatCat.function),
targetsAir = new Stat("targetsAir", StatCat.function),
targetsGround = new Stat("targetsGround", StatCat.function),
damage = new Stat("damage", StatCat.function),
ammo = new Stat("ammo", StatCat.function),
ammoUse = new Stat("ammoUse", StatCat.function),
shieldHealth = new Stat("shieldHealth", StatCat.function),
cooldownTime = new Stat("cooldownTime", StatCat.function),
booster = new Stat("booster", StatCat.optional),
boostEffect = new Stat("boostEffect", StatCat.optional),
affinities = new Stat("affinities", StatCat.optional),
opposites = new Stat("opposites", StatCat.optional);
public final StatCat category; public final StatCat category;
public final String name;
public final int id;
Stat(StatCat category){ public Stat(String name, StatCat category){
this.category = category; this.category = category;
this.name = name;
id = all.size;
all.add(this);
} }
Stat(){ public Stat(String name){
this.category = StatCat.general; this(name, StatCat.general);
} }
public String localized(){ public String localized(){
return Core.bundle.get("stat." + name().toLowerCase(Locale.ROOT)); return Core.bundle.get("stat." + name.toLowerCase(Locale.ROOT));
}
@Override
public int compareTo(Stat o){
return id - o.id;
} }
} }

View File

@@ -1,18 +1,37 @@
package mindustry.world.meta; package mindustry.world.meta;
import arc.*; import arc.*;
import arc.struct.*;
/** A specific category for a stat. */ /** A specific category for a stat. */
public enum StatCat{ public class StatCat implements Comparable<StatCat>{
general, public static final Seq<StatCat> all = new Seq<>();
power,
liquids, public static final StatCat
items,
crafting, general = new StatCat("general"),
function, power = new StatCat("power"),
optional; liquids = new StatCat("liquids"),
items = new StatCat("items"),
crafting = new StatCat("crafting"),
function = new StatCat("function"),
optional = new StatCat("optional");
public final String name;
public final int id;
public StatCat(String name){
this.name = name;
id = all.size;
all.add(this);
}
public String localized(){ public String localized(){
return Core.bundle.get("category." + name()); return Core.bundle.get("category." + name);
}
@Override
public int compareTo(StatCat o){
return id - o.id;
} }
} }

View File

@@ -7,40 +7,44 @@ import java.util.*;
/** /**
* Defines a unit of measurement for block stats. * Defines a unit of measurement for block stats.
*/ */
public enum StatUnit{ public class StatUnit{
blocks, public static final StatUnit
blocksSquared,
tilesSecond, blocks = new StatUnit("blocks"),
powerSecond, blocksSquared = new StatUnit("blocksSquared"),
liquidSecond, tilesSecond = new StatUnit("tilesSecond"),
itemsSecond, powerSecond = new StatUnit("powerSecond"),
liquidUnits, liquidSecond = new StatUnit("liquidSecond"),
powerUnits, itemsSecond = new StatUnit("itemsSecond"),
heatUnits, liquidUnits = new StatUnit("liquidUnits"),
degrees, powerUnits = new StatUnit("powerUnits"),
seconds, heatUnits = new StatUnit("heatUnits"),
minutes, degrees = new StatUnit("degrees"),
perSecond(false), seconds = new StatUnit("seconds"),
perMinute(false), minutes = new StatUnit("minutes"),
perShot(false), perSecond = new StatUnit("perSecond", false),
timesSpeed(false), perMinute = new StatUnit("perMinute", false),
percent(false), perShot = new StatUnit("perShot", false),
shieldHealth, timesSpeed = new StatUnit("timesSpeed", false),
none, percent = new StatUnit("percent", false),
items; shieldHealth = new StatUnit("shieldHealth"),
none = new StatUnit("none"),
items = new StatUnit("items");
public final boolean space; public final boolean space;
public final String name;
StatUnit(boolean space){ public StatUnit(String name, boolean space){
this.name = name;
this.space = space; this.space = space;
} }
StatUnit(){ public StatUnit(String name){
this(true); this(name, true);
} }
public String localized(){ public String localized(){
if(this == none) return ""; if(this == none) return "";
return Core.bundle.get("unit." + name().toLowerCase(Locale.ROOT)); return Core.bundle.get("unit." + name.toLowerCase(Locale.ROOT));
} }
} }