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));
repairSpeed = 0.45f;
repairRadius = 60f;
@@ -4121,7 +4121,7 @@ public class Blocks{
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));
size = 2;
length = 6f;

View File

@@ -1,6 +1,7 @@
package mindustry.mod;
import arc.struct.*;
import mindustry.world.blocks.units.*;
import mindustry.world.draw.*;
/** 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("Reconstructor", mindustry.world.blocks.units.Reconstructor.class);
classes.put("ReconstructorBuild", mindustry.world.blocks.units.Reconstructor.ReconstructorBuild.class);
classes.put("RepairPoint", mindustry.world.blocks.units.RepairPoint.class);
classes.put("RepairPointBuild", mindustry.world.blocks.units.RepairPoint.RepairPointBuild.class);
classes.put("RepairPoint", RepairTurret.class);
classes.put("RepairPointBuild", RepairTurret.RepairPointBuild.class);
classes.put("UnitAssembler", mindustry.world.blocks.units.UnitAssembler.class);
classes.put("AssemblerUnitPlan", mindustry.world.blocks.units.UnitAssembler.AssemblerUnitPlan.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);
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,
laser, laserEnd, laserTop, laserTopEnd);
Draw.z(z);

View File

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

View File

@@ -20,7 +20,7 @@ import mindustry.world.meta.*;
import static mindustry.Vars.*;
public class RepairPoint extends Block{
public class RepairTurret extends Block{
static final Rect rect = new Rect();
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 RepairPoint(String name){
public RepairTurret(String name){
super(name);
update = true;
solid = true;

View File

@@ -5,7 +5,7 @@ public class ConsumeCoolant extends ConsumeLiquidFilter{
public float maxTemp = 0.5f, maxFlammability = 0.1f;
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;
}

View File

@@ -1,107 +1,122 @@
package mindustry.world.meta;
import arc.*;
import arc.struct.*;
import java.util.*;
/** Describes one type of stat for content. */
public enum Stat{
health,
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,
public class Stat implements Comparable<Stat>{
public static final Seq<Stat> all = new Seq<>();
damageMultiplier,
healthMultiplier,
speedMultiplier,
reloadMultiplier,
buildSpeedMultiplier,
reactive,
healing,
immunities,
public static final Stat
itemCapacity(StatCat.items),
itemsMoved(StatCat.items),
launchTime(StatCat.items),
maxConsecutive(StatCat.items),
health = new Stat("health"),
armor = new Stat("armor"),
size = new Stat("size"),
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),
powerUse(StatCat.power),
powerDamage(StatCat.power),
powerRange(StatCat.power),
powerConnections(StatCat.power),
basePowerGeneration(StatCat.power),
itemCapacity = new Stat("itemCapacity", StatCat.items),
itemsMoved = new Stat("itemsMoved", StatCat.items),
launchTime = new Stat("launchTime", StatCat.items),
maxConsecutive = new Stat("maxConsecutive", StatCat.items),
tiles(StatCat.crafting),
input(StatCat.crafting),
output(StatCat.crafting),
productionTime(StatCat.crafting),
maxEfficiency(StatCat.crafting),
drillTier(StatCat.crafting),
drillSpeed(StatCat.crafting),
linkRange(StatCat.crafting),
instructions(StatCat.crafting),
liquidCapacity = new Stat("liquidCapacity", StatCat.liquids),
weapons(StatCat.function),
bullet(StatCat.function),
powerCapacity = new Stat("powerCapacity", StatCat.power),
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),
repairTime(StatCat.function),
repairSpeed(StatCat.function),
range(StatCat.function),
shootRange(StatCat.function),
inaccuracy(StatCat.function),
shots(StatCat.function),
reload(StatCat.function),
powerShot(StatCat.function),
targetsAir(StatCat.function),
targetsGround(StatCat.function),
damage(StatCat.function),
ammo(StatCat.function),
ammoUse(StatCat.function),
shieldHealth(StatCat.function),
cooldownTime(StatCat.function),
tiles = new Stat("tiles", StatCat.crafting),
input = new Stat("input", StatCat.crafting),
output = new Stat("output", StatCat.crafting),
productionTime = new Stat("productionTime", StatCat.crafting),
maxEfficiency = new Stat("maxEfficiency", StatCat.crafting),
drillTier = new Stat("drillTier", StatCat.crafting),
drillSpeed = new Stat("drillSpeed", StatCat.crafting),
linkRange = new Stat("linkRange", StatCat.crafting),
instructions = new Stat("instructions", StatCat.crafting),
booster(StatCat.optional),
boostEffect(StatCat.optional),
affinities(StatCat.optional),
opposites(StatCat.optional);
weapons = new Stat("weapons", StatCat.function),
bullet = new Stat("bullet", StatCat.function),
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 String name;
public final int id;
Stat(StatCat category){
public Stat(String name, StatCat category){
this.category = category;
this.name = name;
id = all.size;
all.add(this);
}
Stat(){
this.category = StatCat.general;
public Stat(String name){
this(name, StatCat.general);
}
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;
import arc.*;
import arc.struct.*;
/** A specific category for a stat. */
public enum StatCat{
general,
power,
liquids,
items,
crafting,
function,
optional;
public class StatCat implements Comparable<StatCat>{
public static final Seq<StatCat> all = new Seq<>();
public static final StatCat
general = new StatCat("general"),
power = new StatCat("power"),
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(){
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.
*/
public enum StatUnit{
blocks,
blocksSquared,
tilesSecond,
powerSecond,
liquidSecond,
itemsSecond,
liquidUnits,
powerUnits,
heatUnits,
degrees,
seconds,
minutes,
perSecond(false),
perMinute(false),
perShot(false),
timesSpeed(false),
percent(false),
shieldHealth,
none,
items;
public class StatUnit{
public static final StatUnit
blocks = new StatUnit("blocks"),
blocksSquared = new StatUnit("blocksSquared"),
tilesSecond = new StatUnit("tilesSecond"),
powerSecond = new StatUnit("powerSecond"),
liquidSecond = new StatUnit("liquidSecond"),
itemsSecond = new StatUnit("itemsSecond"),
liquidUnits = new StatUnit("liquidUnits"),
powerUnits = new StatUnit("powerUnits"),
heatUnits = new StatUnit("heatUnits"),
degrees = new StatUnit("degrees"),
seconds = new StatUnit("seconds"),
minutes = new StatUnit("minutes"),
perSecond = new StatUnit("perSecond", false),
perMinute = new StatUnit("perMinute", false),
perShot = new StatUnit("perShot", false),
timesSpeed = new StatUnit("timesSpeed", false),
percent = new StatUnit("percent", false),
shieldHealth = new StatUnit("shieldHealth"),
none = new StatUnit("none"),
items = new StatUnit("items");
public final boolean space;
public final String name;
StatUnit(boolean space){
public StatUnit(String name, boolean space){
this.name = name;
this.space = space;
}
StatUnit(){
this(true);
public StatUnit(String name){
this(name, true);
}
public String localized(){
if(this == none) return "";
return Core.bundle.get("unit." + name().toLowerCase(Locale.ROOT));
return Core.bundle.get("unit." + name.toLowerCase(Locale.ROOT));
}
}