Merge remote-tracking branch 'upstream/master' into wall-stats
This commit is contained in:
@@ -14,6 +14,7 @@ import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import arc.util.pooling.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.core.*;
|
||||
import mindustry.ctype.*;
|
||||
import mindustry.entities.*;
|
||||
@@ -50,7 +51,6 @@ public class Block extends UnlockableContent{
|
||||
public float liquidCapacity = 10f;
|
||||
public float liquidPressure = 1f;
|
||||
|
||||
public final BlockStats stats = new BlockStats();
|
||||
public final BlockBars bars = new BlockBars();
|
||||
public final Consumers consumes = new Consumers();
|
||||
|
||||
@@ -320,27 +320,30 @@ public class Block extends UnlockableContent{
|
||||
return update || destructible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStats(){
|
||||
stats.add(BlockStat.size, "@x@", size, size);
|
||||
stats.add(BlockStat.health, health, StatUnit.none);
|
||||
super.setStats();
|
||||
|
||||
stats.add(Stat.size, "@x@", size, size);
|
||||
stats.add(Stat.health, health, StatUnit.none);
|
||||
if(canBeBuilt()){
|
||||
stats.add(BlockStat.buildTime, buildCost / 60, StatUnit.seconds);
|
||||
stats.add(BlockStat.buildCost, new ItemListValue(false, requirements));
|
||||
stats.add(Stat.buildTime, buildCost / 60, StatUnit.seconds);
|
||||
stats.add(Stat.buildCost, new ItemListValue(false, requirements));
|
||||
}
|
||||
|
||||
if(instantTransfer){
|
||||
stats.add(BlockStat.maxConsecutive, 2, StatUnit.none);
|
||||
stats.add(Stat.maxConsecutive, 2, StatUnit.none);
|
||||
}
|
||||
|
||||
consumes.display(stats);
|
||||
|
||||
// Note: Power stats are added by the consumers.
|
||||
if(hasLiquids) stats.add(BlockStat.liquidCapacity, liquidCapacity, StatUnit.liquidUnits);
|
||||
if(hasItems && itemCapacity > 0) stats.add(BlockStat.itemCapacity, itemCapacity, StatUnit.items);
|
||||
//Note: Power stats are added by the consumers.
|
||||
if(hasLiquids) stats.add(Stat.liquidCapacity, liquidCapacity, StatUnit.liquidUnits);
|
||||
if(hasItems && itemCapacity > 0) stats.add(Stat.itemCapacity, itemCapacity, StatUnit.items);
|
||||
}
|
||||
|
||||
public void setBars(){
|
||||
bars.add("health", entity -> new Bar("blocks.health", Pal.health, entity::healthf).blink(Color.white));
|
||||
bars.add("health", entity -> new Bar("stat.health", Pal.health, entity::healthf).blink(Color.white));
|
||||
|
||||
if(hasLiquids){
|
||||
Func<Building, Liquid> current;
|
||||
@@ -348,7 +351,7 @@ public class Block extends UnlockableContent{
|
||||
Liquid liquid = consumes.<ConsumeLiquid>get(ConsumeType.liquid).liquid;
|
||||
current = entity -> liquid;
|
||||
}else{
|
||||
current = entity -> entity.liquids.current();
|
||||
current = entity -> entity.liquids == null ? Liquids.water : entity.liquids.current();
|
||||
}
|
||||
bars.add("liquid", entity -> new Bar(() -> entity.liquids.get(current.get(entity)) <= 0.001f ? Core.bundle.get("bar.liquid") : current.get(entity).localizedName,
|
||||
() -> current.get(entity).barColor(), () -> entity.liquids.get(current.get(entity)) / liquidCapacity));
|
||||
@@ -617,7 +620,7 @@ public class Block extends UnlockableContent{
|
||||
public ItemStack[] researchRequirements(){
|
||||
ItemStack[] out = new ItemStack[requirements.length];
|
||||
for(int i = 0; i < out.length; i++){
|
||||
int quantity = 40 + Mathf.round(Mathf.pow(requirements[i].amount, 1.25f) * 20 * researchCostMultiplier, 10);
|
||||
int quantity = 40 + Mathf.round(Mathf.pow(requirements[i].amount, 1.15f) * 20 * researchCostMultiplier, 10);
|
||||
|
||||
out[i] = new ItemStack(requirements[i].item, UI.roundAmount(quantity));
|
||||
}
|
||||
@@ -633,11 +636,6 @@ public class Block extends UnlockableContent{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayInfo(Table table){
|
||||
ContentDisplay.displayBlock(table, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContentType getContentType(){
|
||||
return ContentType.block;
|
||||
@@ -668,9 +666,10 @@ public class Block extends UnlockableContent{
|
||||
if(consumes.has(ConsumeType.item)) hasItems = true;
|
||||
if(consumes.has(ConsumeType.liquid)) hasLiquids = true;
|
||||
|
||||
setStats();
|
||||
setBars();
|
||||
|
||||
stats.useCategories = true;
|
||||
|
||||
consumes.init();
|
||||
|
||||
if(!outputsPower && consumes.hasPower() && consumes.getPower().buffered){
|
||||
|
||||
@@ -45,7 +45,7 @@ public class Build{
|
||||
Core.app.post(() -> Events.fire(new BlockBuildBeginEvent(tile, team, true)));
|
||||
}
|
||||
|
||||
/** Places a BuildBlock at this location. */
|
||||
/** Places a ConstructBlock at this location. */
|
||||
@Remote(called = Loc.server)
|
||||
public static void beginPlace(Block result, Team team, int x, int y, int rotation){
|
||||
if(!validPlace(result, team, x, y, rotation)){
|
||||
|
||||
@@ -21,7 +21,7 @@ public class CachedTile extends Tile{
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void changeEntity(Team team, Prov<Building> entityprov, int rotation){
|
||||
protected void changeBuild(Team team, Prov<Building> entityprov, int rotation){
|
||||
build = null;
|
||||
|
||||
Block block = block();
|
||||
|
||||
@@ -45,7 +45,7 @@ public class Tile implements Position, QuadTreeObject, Displayable{
|
||||
this.block = wall;
|
||||
|
||||
//update entity and create it if needed
|
||||
changeEntity(Team.derelict, wall::newBuilding, 0);
|
||||
changeBuild(Team.derelict, wall::newBuilding, 0);
|
||||
changed();
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ public class Tile implements Position, QuadTreeObject, Displayable{
|
||||
|
||||
this.block = type;
|
||||
preChanged();
|
||||
changeEntity(team, entityprov, (byte)Mathf.mod(rotation, 4));
|
||||
changeBuild(team, entityprov, (byte)Mathf.mod(rotation, 4));
|
||||
|
||||
if(build != null){
|
||||
build.team(team);
|
||||
@@ -430,15 +430,15 @@ public class Tile implements Position, QuadTreeObject, Displayable{
|
||||
getHitbox(rect);
|
||||
}
|
||||
|
||||
public Tile getNearby(Point2 relative){
|
||||
public Tile nearby(Point2 relative){
|
||||
return world.tile(x + relative.x, y + relative.y);
|
||||
}
|
||||
|
||||
public Tile getNearby(int dx, int dy){
|
||||
public Tile nearby(int dx, int dy){
|
||||
return world.tile(x + dx, y + dy);
|
||||
}
|
||||
|
||||
public Tile getNearby(int rotation){
|
||||
public Tile nearby(int rotation){
|
||||
if(rotation == 0) return world.tile(x + 1, y);
|
||||
if(rotation == 1) return world.tile(x, y + 1);
|
||||
if(rotation == 2) return world.tile(x - 1, y);
|
||||
@@ -446,7 +446,7 @@ public class Tile implements Position, QuadTreeObject, Displayable{
|
||||
return null;
|
||||
}
|
||||
|
||||
public Building getNearbyEntity(int rotation){
|
||||
public Building nearbyBuild(int rotation){
|
||||
if(rotation == 0) return world.build(x + 1, y);
|
||||
if(rotation == 1) return world.build(x, y + 1);
|
||||
if(rotation == 2) return world.build(x - 1, y);
|
||||
@@ -503,7 +503,7 @@ public class Tile implements Position, QuadTreeObject, Displayable{
|
||||
}
|
||||
}
|
||||
|
||||
protected void changeEntity(Team team, Prov<Building> entityprov, int rotation){
|
||||
protected void changeBuild(Team team, Prov<Building> entityprov, int rotation){
|
||||
if(build != null){
|
||||
int size = build.block.size;
|
||||
build.remove();
|
||||
|
||||
@@ -133,7 +133,7 @@ public interface Autotiler{
|
||||
|
||||
for(int i = 0; i < 4; i++){
|
||||
int realDir = Mathf.mod(rotation - i, 4);
|
||||
if(blends(tile, rotation, directional, i, world) && (tile != null && tile.getNearbyEntity(realDir) != null && !tile.getNearbyEntity(realDir).block.squareSprite)){
|
||||
if(blends(tile, rotation, directional, i, world) && (tile != null && tile.nearbyBuild(realDir) != null && !tile.nearbyBuild(realDir).block.squareSprite)){
|
||||
blendresult[4] |= (1 << i);
|
||||
}
|
||||
}
|
||||
@@ -194,7 +194,7 @@ public interface Autotiler{
|
||||
|
||||
// TODO docs -- use for direction?
|
||||
default boolean blends(Tile tile, int rotation, int direction){
|
||||
Building other = tile.getNearbyEntity(Mathf.mod(rotation - direction, 4));
|
||||
Building other = tile.nearbyBuild(Mathf.mod(rotation - direction, 4));
|
||||
return other != null && other.team == tile.team() && blends(tile, rotation, other.tileX(), other.tileY(), other.rotation, other.block);
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ public class ConstructBlock extends Block{
|
||||
consBlocks[size - 1] = this;
|
||||
}
|
||||
|
||||
/** Returns a BuildBlock by size. */
|
||||
/** Returns a ConstructBlock by size. */
|
||||
public static ConstructBlock get(int size){
|
||||
if(size > maxSize) throw new IllegalArgumentException("No. Don't place ConstructBlock of size greater than " + maxSize);
|
||||
return consBlocks[size - 1];
|
||||
|
||||
@@ -10,4 +10,14 @@ public interface ControlBlock{
|
||||
default boolean isControlled(){
|
||||
return unit().isPlayer();
|
||||
}
|
||||
|
||||
/** @return whether this block can be controlled at all. */
|
||||
default boolean canControl(){
|
||||
return true;
|
||||
}
|
||||
|
||||
/** @return whether targets should automatically be selected (on mobile) */
|
||||
default boolean shouldAutoTarget(){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public class LaunchPad extends Block{
|
||||
public void setStats(){
|
||||
super.setStats();
|
||||
|
||||
stats.add(BlockStat.launchTime, launchTime / 60f, StatUnit.seconds);
|
||||
stats.add(Stat.launchTime, launchTime / 60f, StatUnit.seconds);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -61,11 +61,11 @@ public class ForceProjector extends Block{
|
||||
@Override
|
||||
public void setStats(){
|
||||
super.setStats();
|
||||
stats.add(BlockStat.shieldHealth, breakage, StatUnit.none);
|
||||
stats.add(BlockStat.cooldownTime, (int) (breakage / cooldownBrokenBase / 60f), StatUnit.seconds);
|
||||
stats.add(BlockStat.powerUse, basePowerDraw * 60f, StatUnit.powerSecond);
|
||||
stats.add(BlockStat.boostEffect, phaseRadiusBoost / tilesize, StatUnit.blocks);
|
||||
stats.add(BlockStat.boostEffect, phaseShieldBoost, StatUnit.shieldHealth);
|
||||
stats.add(Stat.shieldHealth, breakage, StatUnit.none);
|
||||
stats.add(Stat.cooldownTime, (int) (breakage / cooldownBrokenBase / 60f), StatUnit.seconds);
|
||||
stats.add(Stat.powerUse, basePowerDraw * 60f, StatUnit.powerSecond);
|
||||
stats.add(Stat.boostEffect, phaseRadiusBoost / tilesize, StatUnit.blocks);
|
||||
stats.add(Stat.boostEffect, phaseShieldBoost, StatUnit.shieldHealth);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -44,11 +44,11 @@ public class MendProjector extends Block{
|
||||
public void setStats(){
|
||||
super.setStats();
|
||||
|
||||
stats.add(BlockStat.repairTime, (int)(100f / healPercent * reload / 60f), StatUnit.seconds);
|
||||
stats.add(BlockStat.range, range / tilesize, StatUnit.blocks);
|
||||
stats.add(Stat.repairTime, (int)(100f / healPercent * reload / 60f), StatUnit.seconds);
|
||||
stats.add(Stat.range, range / tilesize, StatUnit.blocks);
|
||||
|
||||
stats.add(BlockStat.boostEffect, phaseRangeBoost / tilesize, StatUnit.blocks);
|
||||
stats.add(BlockStat.boostEffect, (phaseBoost + healPercent) / healPercent, StatUnit.timesSpeed);
|
||||
stats.add(Stat.boostEffect, phaseRangeBoost / tilesize, StatUnit.blocks);
|
||||
stats.add(Stat.boostEffect, (phaseBoost + healPercent) / healPercent, StatUnit.timesSpeed);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -51,13 +51,13 @@ public class OverdriveProjector extends Block{
|
||||
public void setStats(){
|
||||
super.setStats();
|
||||
|
||||
stats.add(BlockStat.speedIncrease, (int)(100f * speedBoost), StatUnit.percent);
|
||||
stats.add(BlockStat.range, range / tilesize, StatUnit.blocks);
|
||||
stats.add(BlockStat.productionTime, useTime / 60f, StatUnit.seconds);
|
||||
stats.add(Stat.speedIncrease, (int)(100f * speedBoost), StatUnit.percent);
|
||||
stats.add(Stat.range, range / tilesize, StatUnit.blocks);
|
||||
stats.add(Stat.productionTime, useTime / 60f, StatUnit.seconds);
|
||||
|
||||
if(hasBoost){
|
||||
stats.add(BlockStat.boostEffect, phaseRangeBoost / tilesize, StatUnit.blocks);
|
||||
stats.add(BlockStat.boostEffect, (int)((speedBoost + speedBoostPhase) * 100f), StatUnit.percent);
|
||||
stats.add(Stat.boostEffect, phaseRangeBoost / tilesize, StatUnit.blocks);
|
||||
stats.add(Stat.boostEffect, (int)((speedBoost + speedBoostPhase) * 100f), StatUnit.percent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
package mindustry.world.blocks.defense.turrets;
|
||||
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.logic.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.consumers.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public abstract class BaseTurret extends Block{
|
||||
public float range = 80f;
|
||||
public float rotateSpeed = 5;
|
||||
|
||||
public boolean acceptCoolant = true;
|
||||
/** Effect displayed when coolant is used. */
|
||||
public Effect coolEffect = Fx.fuelburn;
|
||||
/** How much reload is lowered by for each unit of liquid of heat capacity. */
|
||||
public float coolantMultiplier = 5f;
|
||||
|
||||
public BaseTurret(String name){
|
||||
super(name);
|
||||
|
||||
update = true;
|
||||
solid = true;
|
||||
outlineIcon = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(){
|
||||
if(acceptCoolant && !consumes.has(ConsumeType.liquid)){
|
||||
hasLiquids = true;
|
||||
consumes.add(new ConsumeLiquidFilter(liquid -> liquid.temperature <= 0.5f && liquid.flammability < 0.1f, 0.2f)).update(false).boost();
|
||||
}
|
||||
|
||||
super.init();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPlace(int x, int y, int rotation, boolean valid){
|
||||
Drawf.dashCircle(x * tilesize + offset, y * tilesize + offset, range, Pal.placing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStats(){
|
||||
super.setStats();
|
||||
|
||||
stats.add(Stat.shootRange, range / tilesize, StatUnit.blocks);
|
||||
}
|
||||
|
||||
public class BaseTurretBuild extends Building implements Ranged{
|
||||
public float rotation = 90;
|
||||
|
||||
@Override
|
||||
public float range(){
|
||||
return range;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawSelect(){
|
||||
Drawf.dashCircle(x, y, range, team.color);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,8 +35,8 @@ public class ItemTurret extends Turret{
|
||||
public void setStats(){
|
||||
super.setStats();
|
||||
|
||||
stats.remove(BlockStat.itemCapacity);
|
||||
stats.add(BlockStat.ammo, new AmmoListValue<>(ammoTypes));
|
||||
stats.remove(Stat.itemCapacity);
|
||||
stats.add(Stat.ammo, new AmmoListValue<>(ammoTypes));
|
||||
consumes.add(new ConsumeItemFilter(i -> ammoTypes.containsKey(i)){
|
||||
@Override
|
||||
public void build(Building tile, Table table){
|
||||
@@ -54,7 +54,7 @@ public class ItemTurret extends Turret{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void display(BlockStats stats){
|
||||
public void display(Stats stats){
|
||||
//don't display
|
||||
}
|
||||
});
|
||||
@@ -83,7 +83,7 @@ public class ItemTurret extends Turret{
|
||||
public void displayBars(Table bars){
|
||||
super.displayBars(bars);
|
||||
|
||||
bars.add(new Bar("blocks.ammo", Pal.ammo, () -> (float)totalAmmo / maxAmmo)).growX();
|
||||
bars.add(new Bar("stat.ammo", Pal.ammo, () -> (float)totalAmmo / maxAmmo)).growX();
|
||||
bars.row();
|
||||
}
|
||||
|
||||
|
||||
@@ -33,11 +33,11 @@ public class LaserTurret extends PowerTurret{
|
||||
public void setStats(){
|
||||
super.setStats();
|
||||
|
||||
stats.remove(BlockStat.booster);
|
||||
stats.add(BlockStat.input, new BoosterListValue(reloadTime, consumes.<ConsumeLiquidBase>get(ConsumeType.liquid).amount, coolantMultiplier, false, l -> consumes.liquidfilters.get(l.id)));
|
||||
stats.remove(BlockStat.damage);
|
||||
stats.remove(Stat.booster);
|
||||
stats.add(Stat.input, new BoosterListValue(reloadTime, consumes.<ConsumeLiquidBase>get(ConsumeType.liquid).amount, coolantMultiplier, false, l -> consumes.liquidfilters.get(l.id)));
|
||||
stats.remove(Stat.damage);
|
||||
//damages every 5 ticks, at least in meltdown's case
|
||||
stats.add(BlockStat.damage, shootType.damage * 60f / 5f, StatUnit.perSecond);
|
||||
stats.add(Stat.damage, shootType.damage * 60f / 5f, StatUnit.perSecond);
|
||||
}
|
||||
|
||||
public class LaserTurretBuild extends PowerTurretBuild{
|
||||
|
||||
@@ -36,7 +36,11 @@ public class LiquidTurret extends Turret{
|
||||
public void setStats(){
|
||||
super.setStats();
|
||||
|
||||
stats.add(BlockStat.ammo, new AmmoListValue<>(ammoTypes));
|
||||
stats.add(Stat.ammo, new AmmoListValue<>(ammoTypes));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(){
|
||||
consumes.add(new ConsumeLiquidFilter(i -> ammoTypes.containsKey(i), 1f){
|
||||
@Override
|
||||
public boolean valid(Building entity){
|
||||
@@ -49,10 +53,12 @@ public class LiquidTurret extends Turret{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void display(BlockStats stats){
|
||||
public void display(Stats stats){
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
super.init();
|
||||
}
|
||||
|
||||
public class LiquidTurretBuild extends TurretBuild{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package mindustry.world.blocks.defense;
|
||||
package mindustry.world.blocks.defense.turrets;
|
||||
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
@@ -11,12 +11,9 @@ import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class PointDefenseTurret extends Block{
|
||||
public class PointDefenseTurret extends ReloadTurret{
|
||||
public final int timerTarget = timers++;
|
||||
public float retargetTime = 5f;
|
||||
|
||||
@@ -27,9 +24,6 @@ public class PointDefenseTurret extends Block{
|
||||
public Effect hitEffect = Fx.pointHit;
|
||||
public Effect shootEffect = Fx.sparkShoot;
|
||||
|
||||
public float range = 80f;
|
||||
public float reloadTime = 30f;
|
||||
public float rotateSpeed = 20;
|
||||
public float shootCone = 5f;
|
||||
public float bulletDamage = 10f;
|
||||
public float shootLength = 3f;
|
||||
@@ -37,13 +31,12 @@ public class PointDefenseTurret extends Block{
|
||||
public PointDefenseTurret(String name){
|
||||
super(name);
|
||||
|
||||
outlineIcon = true;
|
||||
update = true;
|
||||
}
|
||||
rotateSpeed = 20f;
|
||||
reloadTime = 30f;
|
||||
|
||||
@Override
|
||||
public void drawPlace(int x, int y, int rotation, boolean valid){
|
||||
Drawf.dashCircle(x * tilesize + offset, y * tilesize + offset, range, Pal.accent);
|
||||
coolantMultiplier = 2f;
|
||||
//disabled due to version mismatch problems
|
||||
acceptCoolant = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -55,12 +48,10 @@ public class PointDefenseTurret extends Block{
|
||||
public void setStats(){
|
||||
super.setStats();
|
||||
|
||||
stats.add(BlockStat.shootRange, range / tilesize, StatUnit.blocks);
|
||||
stats.add(BlockStat.reload, 60f / reloadTime, StatUnit.none);
|
||||
stats.add(Stat.reload, 60f / reloadTime, StatUnit.none);
|
||||
}
|
||||
|
||||
public class PointDefenseBuild extends Building{
|
||||
public float rotation = 90, reload;
|
||||
public class PointDefenseBuild extends ReloadTurretBuild{
|
||||
public @Nullable Bullet target;
|
||||
|
||||
@Override
|
||||
@@ -76,14 +67,18 @@ public class PointDefenseTurret extends Block{
|
||||
target = null;
|
||||
}
|
||||
|
||||
if(acceptCoolant){
|
||||
updateCooling();
|
||||
}
|
||||
|
||||
//look at target
|
||||
if(target != null && target.within(this, range) && target.team != team && target.type() != null && target.type().hittable){
|
||||
float dest = angleTo(target);
|
||||
rotation = Angles.moveToward(rotation, dest, rotateSpeed * edelta());
|
||||
reload -= edelta();
|
||||
reload += edelta();
|
||||
|
||||
//shoot when possible
|
||||
if(Angles.within(rotation, dest, shootCone) && reload <= 0f){
|
||||
if(Angles.within(rotation, dest, shootCone) && reload >= reloadTime){
|
||||
if(target.damage() > bulletDamage){
|
||||
target.damage(target.damage() - bulletDamage);
|
||||
}else{
|
||||
@@ -95,18 +90,13 @@ public class PointDefenseTurret extends Block{
|
||||
beamEffect.at(x + Tmp.v1.x, y + Tmp.v1.y, rotation, color, new Vec2().set(target));
|
||||
shootEffect.at(x + Tmp.v1.x, y + Tmp.v1.y, rotation, color);
|
||||
hitEffect.at(target.x, target.y, color);
|
||||
reload = reloadTime;
|
||||
reload = 0;
|
||||
}
|
||||
}else{
|
||||
target = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawSelect(){
|
||||
Drawf.dashCircle(x, y, range, Pal.accent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
Draw.rect(baseRegion, x, y);
|
||||
@@ -16,7 +16,7 @@ public class PowerTurret extends Turret{
|
||||
@Override
|
||||
public void setStats(){
|
||||
super.setStats();
|
||||
stats.add(BlockStat.damage, shootType.damage, StatUnit.none);
|
||||
stats.add(Stat.damage, shootType.damage, StatUnit.none);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package mindustry.world.blocks.defense.turrets;
|
||||
|
||||
import arc.math.*;
|
||||
import arc.util.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.consumers.*;
|
||||
import mindustry.world.meta.*;
|
||||
import mindustry.world.meta.values.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public abstract class ReloadTurret extends BaseTurret{
|
||||
public float reloadTime = 10f;
|
||||
|
||||
public ReloadTurret(String name){
|
||||
super(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStats(){
|
||||
super.setStats();
|
||||
|
||||
if(acceptCoolant){
|
||||
stats.add(Stat.booster, new BoosterListValue(reloadTime, consumes.<ConsumeLiquidBase>get(ConsumeType.liquid).amount, coolantMultiplier, true, l -> consumes.liquidfilters.get(l.id)));
|
||||
}
|
||||
}
|
||||
|
||||
public class ReloadTurretBuild extends BaseTurretBuild{
|
||||
public float reload;
|
||||
|
||||
protected void updateCooling(){
|
||||
float maxUsed = consumes.<ConsumeLiquidBase>get(ConsumeType.liquid).amount;
|
||||
|
||||
Liquid liquid = liquids.current();
|
||||
|
||||
float used = Math.min(Math.min(liquids.get(liquid), maxUsed * Time.delta), Math.max(0, ((reloadTime - reload) / coolantMultiplier) / liquid.heatCapacity)) * baseReloadSpeed();
|
||||
reload += used * liquid.heatCapacity * coolantMultiplier;
|
||||
liquids.remove(liquid, used);
|
||||
|
||||
if(Mathf.chance(0.06 * used)){
|
||||
coolEffect.at(x + Mathf.range(size * tilesize / 2f), y + Mathf.range(size * tilesize / 2f));
|
||||
}
|
||||
}
|
||||
|
||||
protected float baseReloadSpeed(){
|
||||
return efficiency();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package mindustry.world.blocks.defense;
|
||||
package mindustry.world.blocks.defense.turrets;
|
||||
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
@@ -9,12 +9,13 @@ import mindustry.annotations.Annotations.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.consumers.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class TractorBeamTurret extends Block{
|
||||
public class TractorBeamTurret extends BaseTurret{
|
||||
public final int timerTarget = timers++;
|
||||
public float retargetTime = 5f;
|
||||
|
||||
@@ -22,8 +23,6 @@ public class TractorBeamTurret extends Block{
|
||||
public @Load("@-laser") TextureRegion laser;
|
||||
public @Load("@-laser-end") TextureRegion laserEnd;
|
||||
|
||||
public float range = 80f;
|
||||
public float rotateSpeed = 10;
|
||||
public float shootCone = 6f;
|
||||
public float laserWidth = 0.6f;
|
||||
public float force = 0.3f;
|
||||
@@ -35,14 +34,11 @@ public class TractorBeamTurret extends Block{
|
||||
public TractorBeamTurret(String name){
|
||||
super(name);
|
||||
|
||||
update = true;
|
||||
solid = true;
|
||||
outlineIcon = true;
|
||||
}
|
||||
rotateSpeed = 10f;
|
||||
coolantMultiplier = 1f;
|
||||
|
||||
@Override
|
||||
public void drawPlace(int x, int y, int rotation, boolean valid){
|
||||
Drawf.dashCircle(x * tilesize + offset, y * tilesize + offset, range, Pal.accent);
|
||||
//disabled due to version mismatch problems
|
||||
acceptCoolant = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -54,17 +50,16 @@ public class TractorBeamTurret extends Block{
|
||||
public void setStats(){
|
||||
super.setStats();
|
||||
|
||||
stats.add(BlockStat.shootRange, range / tilesize, StatUnit.blocks);
|
||||
stats.add(BlockStat.targetsAir, targetAir);
|
||||
stats.add(BlockStat.targetsGround, targetGround);
|
||||
stats.add(BlockStat.damage, damage * 60f, StatUnit.perSecond);
|
||||
stats.add(Stat.targetsAir, targetAir);
|
||||
stats.add(Stat.targetsGround, targetGround);
|
||||
stats.add(Stat.damage, damage * 60f, StatUnit.perSecond);
|
||||
}
|
||||
|
||||
public class TractorBeamBuild extends Building{
|
||||
public float rotation = 90;
|
||||
public class TractorBeamBuild extends BaseTurretBuild{
|
||||
public @Nullable Unit target;
|
||||
public float lastX, lastY, strength;
|
||||
public boolean any;
|
||||
public float coolant = 1f;
|
||||
|
||||
@Override
|
||||
public void updateTile(){
|
||||
@@ -74,6 +69,23 @@ public class TractorBeamTurret extends Block{
|
||||
target = Units.closestEnemy(team, x, y, range, u -> u.checkTarget(targetAir, targetGround));
|
||||
}
|
||||
|
||||
//consume coolant
|
||||
if(target != null && acceptCoolant){
|
||||
float maxUsed = consumes.<ConsumeLiquidBase>get(ConsumeType.liquid).amount;
|
||||
|
||||
Liquid liquid = liquids.current();
|
||||
|
||||
float used = Math.min(Math.min(liquids.get(liquid), maxUsed * Time.delta), Math.max(0, (1f / coolantMultiplier) / liquid.heatCapacity));
|
||||
|
||||
liquids.remove(liquid, used);
|
||||
|
||||
if(Mathf.chance(0.06 * used)){
|
||||
coolEffect.at(x + Mathf.range(size * tilesize / 2f), y + Mathf.range(size * tilesize / 2f));
|
||||
}
|
||||
|
||||
coolant = 1f + (used * liquid.heatCapacity * coolantMultiplier);
|
||||
}
|
||||
|
||||
//look at target
|
||||
if(target != null && target.within(this, range) && target.team() != team && target.type.flying && efficiency() > 0.01f){
|
||||
any = true;
|
||||
@@ -98,8 +110,8 @@ public class TractorBeamTurret extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawSelect(){
|
||||
Drawf.dashCircle(x, y, range, Pal.accent);
|
||||
public float efficiency() {
|
||||
return super.efficiency() * coolant;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -21,15 +21,13 @@ import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.logic.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.*;
|
||||
import mindustry.world.consumers.*;
|
||||
import mindustry.world.meta.*;
|
||||
import mindustry.world.meta.values.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public abstract class Turret extends Block{
|
||||
public abstract class Turret extends ReloadTurret{
|
||||
//after being logic-controlled and this amount of time passes, the turret will resume normal AI
|
||||
public final static float logicControlCooldown = 60 * 2;
|
||||
|
||||
@@ -45,8 +43,6 @@ public abstract class Turret extends Block{
|
||||
public int maxAmmo = 30;
|
||||
public int ammoPerShot = 1;
|
||||
public float ammoEjectBack = 1f;
|
||||
public float range = 50f;
|
||||
public float reloadTime = 10f;
|
||||
public float inaccuracy = 0f;
|
||||
public float velocityInaccuracy = 0f;
|
||||
public int shots = 1;
|
||||
@@ -54,7 +50,6 @@ public abstract class Turret extends Block{
|
||||
public float recoilAmount = 1f;
|
||||
public float restitution = 0.02f;
|
||||
public float cooldown = 0.02f;
|
||||
public float rotateSpeed = 5f; //in degrees per tick
|
||||
public float shootCone = 8f;
|
||||
public float shootShake = 0f;
|
||||
public float xRand = 0f;
|
||||
@@ -64,11 +59,7 @@ public abstract class Turret extends Block{
|
||||
public boolean alternate = false;
|
||||
public boolean targetAir = true;
|
||||
public boolean targetGround = true;
|
||||
public boolean acceptCoolant = true;
|
||||
/** How much reload is lowered by for each unit of liquid of heat capacity. */
|
||||
public float coolantMultiplier = 5f;
|
||||
/** Effect displayed when coolant is used. */
|
||||
public Effect coolEffect = Fx.fuelburn;
|
||||
|
||||
public Sortf unitSort = Unit::dst2;
|
||||
|
||||
protected Vec2 tr = new Vec2();
|
||||
@@ -108,15 +99,10 @@ public abstract class Turret extends Block{
|
||||
public void setStats(){
|
||||
super.setStats();
|
||||
|
||||
stats.add(BlockStat.shootRange, range / tilesize, StatUnit.blocks);
|
||||
stats.add(BlockStat.inaccuracy, (int)inaccuracy, StatUnit.degrees);
|
||||
stats.add(BlockStat.reload, 60f / reloadTime * shots, StatUnit.none);
|
||||
stats.add(BlockStat.targetsAir, targetAir);
|
||||
stats.add(BlockStat.targetsGround, targetGround);
|
||||
|
||||
if(acceptCoolant){
|
||||
stats.add(BlockStat.booster, new BoosterListValue(reloadTime, consumes.<ConsumeLiquidBase>get(ConsumeType.liquid).amount, coolantMultiplier, true, l -> consumes.liquidfilters.get(l.id)));
|
||||
}
|
||||
stats.add(Stat.inaccuracy, (int)inaccuracy, StatUnit.degrees);
|
||||
stats.add(Stat.reload, 60f / reloadTime * shots, StatUnit.none);
|
||||
stats.add(Stat.targetsAir, targetAir);
|
||||
stats.add(Stat.targetsGround, targetGround);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -134,32 +120,22 @@ public abstract class Turret extends Block{
|
||||
return new TextureRegion[]{baseRegion, region};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPlace(int x, int y, int rotation, boolean valid){
|
||||
Drawf.dashCircle(x * tilesize + offset, y * tilesize + offset, range, Pal.placing);
|
||||
}
|
||||
|
||||
public static abstract class AmmoEntry{
|
||||
public int amount;
|
||||
|
||||
public abstract BulletType type();
|
||||
}
|
||||
|
||||
public class TurretBuild extends Building implements ControlBlock, Ranged{
|
||||
public class TurretBuild extends ReloadTurretBuild implements ControlBlock{
|
||||
public Seq<AmmoEntry> ammo = new Seq<>();
|
||||
public int totalAmmo;
|
||||
public float reload, rotation = 90, recoil, heat, logicControlTime = -1;
|
||||
public float recoil, heat, logicControlTime = -1;
|
||||
public int shotCounter;
|
||||
public boolean logicShooting = false;
|
||||
public @Nullable Posc target;
|
||||
public Vec2 targetPos = new Vec2();
|
||||
public BlockUnitc unit = Nulls.blockUnit;
|
||||
|
||||
@Override
|
||||
public float range(){
|
||||
return range;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void created(){
|
||||
unit = (BlockUnitc)UnitTypes.block.create(team);
|
||||
@@ -197,8 +173,8 @@ public abstract class Turret extends Block{
|
||||
case ammo -> totalAmmo;
|
||||
case ammoCapacity -> maxAmmo;
|
||||
case rotation -> rotation;
|
||||
case shootX -> targetPos.x;
|
||||
case shootY -> targetPos.y;
|
||||
case shootX -> World.conv(targetPos.x);
|
||||
case shootY -> World.conv(targetPos.y);
|
||||
case shooting -> (isControlled() ? unit.isShooting() : logicControlled() ? logicShooting : validateTarget()) ? 1 : 0;
|
||||
default -> super.sense(sensor);
|
||||
};
|
||||
@@ -301,11 +277,6 @@ public abstract class Turret extends Block{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawSelect(){
|
||||
Drawf.dashCircle(x, y, range, team.color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleLiquid(Building source, Liquid liquid, float amount){
|
||||
if(acceptCoolant && liquids.currentAmount() <= 0.001f){
|
||||
@@ -315,20 +286,6 @@ public abstract class Turret extends Block{
|
||||
super.handleLiquid(source, liquid, amount);
|
||||
}
|
||||
|
||||
protected void updateCooling(){
|
||||
float maxUsed = consumes.<ConsumeLiquidBase>get(ConsumeType.liquid).amount;
|
||||
|
||||
Liquid liquid = liquids.current();
|
||||
|
||||
float used = Math.min(Math.min(liquids.get(liquid), maxUsed * Time.delta), Math.max(0, ((reloadTime - reload) / coolantMultiplier) / liquid.heatCapacity)) * baseReloadSpeed();
|
||||
reload += used * liquid.heatCapacity * coolantMultiplier;
|
||||
liquids.remove(liquid, used);
|
||||
|
||||
if(Mathf.chance(0.06 * used)){
|
||||
coolEffect.at(x + Mathf.range(size * tilesize / 2f), y + Mathf.range(size * tilesize / 2f));
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean validateTarget(){
|
||||
return !Units.invalidateTarget(target, team, x, y) || isControlled() || logicControlled();
|
||||
}
|
||||
@@ -453,10 +410,6 @@ public abstract class Turret extends Block{
|
||||
ammoUseEffect.at(x - Angles.trnsx(rotation, ammoEjectBack), y - Angles.trnsy(rotation, ammoEjectBack), rotation);
|
||||
}
|
||||
|
||||
protected float baseReloadSpeed(){
|
||||
return efficiency();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(Writes write){
|
||||
super.write(write);
|
||||
|
||||
@@ -52,7 +52,7 @@ public class Conveyor extends Block implements Autotiler{
|
||||
super.setStats();
|
||||
|
||||
//have to add a custom calculated speed, since the actual movement speed is apparently not linear
|
||||
stats.add(BlockStat.itemsMoved, displayedSpeed, StatUnit.itemsSecond);
|
||||
stats.add(Stat.itemsMoved, displayedSpeed, StatUnit.itemsSecond);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -202,7 +202,7 @@ public class ItemBridge extends Block{
|
||||
|
||||
for(int i = 1; i <= range; i++){
|
||||
for(int j = 0; j < 4; j++){
|
||||
Tile other = tile.getNearby(Geometry.d4[j].x * i, Geometry.d4[j].y * i);
|
||||
Tile other = tile.nearby(Geometry.d4[j].x * i, Geometry.d4[j].y * i);
|
||||
if(linkValid(tile, other)){
|
||||
boolean linked = other.pos() == link;
|
||||
|
||||
@@ -336,16 +336,18 @@ public class ItemBridge extends Block{
|
||||
|
||||
Tile other = world.tile(link);
|
||||
|
||||
if(items.total() >= itemCapacity) return false;
|
||||
|
||||
if(linked(source)) return true;
|
||||
|
||||
if(linkValid(tile, other)){
|
||||
int rel = relativeTo(other);
|
||||
int rel2 = relativeTo(Edges.getFacingEdge(source, this));
|
||||
|
||||
if(rel == rel2) return false;
|
||||
}else{
|
||||
return linked(source) && items.total() < itemCapacity;
|
||||
return rel != rel2;
|
||||
}
|
||||
|
||||
return items.total() < itemCapacity;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -359,16 +361,18 @@ public class ItemBridge extends Block{
|
||||
|
||||
Tile other = world.tile(link);
|
||||
|
||||
if(!(liquids.current() == liquid || liquids.get(liquids.current()) < 0.2f)) return false;
|
||||
|
||||
if(linked(source)) return true;
|
||||
|
||||
if(linkValid(tile, other)){
|
||||
int rel = relativeTo(other.x, other.y);
|
||||
int rel2 = relativeTo(Edges.getFacingEdge(source, this));
|
||||
|
||||
if(rel == rel2) return false;
|
||||
}else if(!(linked(source))){
|
||||
return false;
|
||||
return rel != rel2;
|
||||
}
|
||||
|
||||
return (liquids.current() == liquid || liquids.get(liquids.current()) < 0.2f);
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean linked(Building source){
|
||||
|
||||
@@ -87,7 +87,7 @@ public class PayloadConveyor extends Block{
|
||||
}
|
||||
|
||||
int ntrns = 1 + size/2;
|
||||
Tile next = tile.getNearby(Geometry.d4(rotation).x * ntrns, Geometry.d4(rotation).y * ntrns);
|
||||
Tile next = tile.nearby(Geometry.d4(rotation).x * ntrns, Geometry.d4(rotation).y * ntrns);
|
||||
blocked = (next != null && next.solid() && !next.block().outputsPayload) || (this.next != null && (this.next.rotation + 2)%4 == rotation);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
package mindustry.world.blocks.distribution;
|
||||
|
||||
import arc.math.*;
|
||||
import arc.util.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
public class Router extends Block{
|
||||
@@ -20,10 +23,30 @@ public class Router extends Block{
|
||||
noUpdateDisabled = true;
|
||||
}
|
||||
|
||||
public class RouterBuild extends Building{
|
||||
public class RouterBuild extends Building implements ControlBlock{
|
||||
public Item lastItem;
|
||||
public Tile lastInput;
|
||||
public float time;
|
||||
public @Nullable BlockUnitc unit;
|
||||
|
||||
@Override
|
||||
public Unit unit(){
|
||||
if(unit == null){
|
||||
unit = (BlockUnitc)UnitTypes.block.create(team);
|
||||
unit.tile(this);
|
||||
}
|
||||
return (Unit)unit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canControl(){
|
||||
return size == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldAutoTarget(){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTile(){
|
||||
@@ -72,6 +95,23 @@ public class Router extends Block{
|
||||
}
|
||||
|
||||
public Building getTileTarget(Item item, Tile from, boolean set){
|
||||
if(unit != null && isControlled()){
|
||||
unit.health(health);
|
||||
unit.ammo(unit.type().ammoCapacity * (items.total() > 0 ? 1f : 0f));
|
||||
unit.team(team);
|
||||
|
||||
int angle = Mathf.mod((int)((angleTo(unit.aimX(), unit.aimY()) + 45) / 90), 4);
|
||||
|
||||
if(unit.isShooting()){
|
||||
Building other = nearby(angle);
|
||||
if(other != null && other.acceptItem(this, item)){
|
||||
return other;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
int counter = rotation;
|
||||
for(int i = 0; i < proximity.size; i++){
|
||||
Building other = proximity.get((i + counter) % proximity.size);
|
||||
|
||||
@@ -53,7 +53,7 @@ public class StackConveyor extends Block implements Autotiler{
|
||||
public void setStats(){
|
||||
super.setStats();
|
||||
|
||||
stats.add(BlockStat.itemsMoved, Mathf.round(itemCapacity * speed * 60), StatUnit.itemsSecond);
|
||||
stats.add(Stat.itemsMoved, Mathf.round(itemCapacity * speed * 60), StatUnit.itemsSecond);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -183,7 +183,7 @@ public class Floor extends Block{
|
||||
|
||||
for(int i = 0; i < 8; i++){
|
||||
Point2 point = Geometry.d8[i];
|
||||
Tile other = tile.getNearby(point);
|
||||
Tile other = tile.nearby(point);
|
||||
if(other != null && other.floor().cacheLayer == layer && other.floor().edges() != null){
|
||||
if(!blended.getAndSet(other.floor().id)){
|
||||
blenders.add(other.floor());
|
||||
@@ -200,7 +200,7 @@ public class Floor extends Block{
|
||||
|
||||
for(int i = 0; i < 8; i++){
|
||||
Point2 point = Geometry.d8[i];
|
||||
Tile other = tile.getNearby(point);
|
||||
Tile other = tile.nearby(point);
|
||||
if(other != null && doEdge(other.floor()) && other.floor().cacheLayer == cacheLayer && other.floor().edges() != null){
|
||||
if(!blended.getAndSet(other.floor().id)){
|
||||
blenders.add(other.floor());
|
||||
@@ -217,7 +217,7 @@ public class Floor extends Block{
|
||||
for(Block block : blenders){
|
||||
for(int i = 0; i < 8; i++){
|
||||
Point2 point = Geometry.d8[i];
|
||||
Tile other = tile.getNearby(point);
|
||||
Tile other = tile.nearby(point);
|
||||
if(other != null && other.floor() == block){
|
||||
TextureRegion region = edge((Floor)block, 1 - point.x, 1 - point.y);
|
||||
Draw.rect(region, tile.worldx(), tile.worldy());
|
||||
@@ -229,7 +229,7 @@ public class Floor extends Block{
|
||||
//'new' style of edges with shadows instead of colors, not used currently
|
||||
protected void drawEdgesFlat(Tile tile, boolean sameLayer){
|
||||
for(int i = 0; i < 4; i++){
|
||||
Tile other = tile.getNearby(i);
|
||||
Tile other = tile.nearby(i);
|
||||
if(other != null && doEdge(other.floor())){
|
||||
Color color = other.floor().mapColor;
|
||||
Draw.color(color.r, color.g, color.b, 1f);
|
||||
|
||||
@@ -21,7 +21,7 @@ public class StaticTree extends StaticWall{
|
||||
float oy = 0;
|
||||
|
||||
for(int i = 0; i < 4; i++){
|
||||
if(tile.getNearby(i) != null && tile.getNearby(i).block() instanceof StaticWall){
|
||||
if(tile.nearby(i) != null && tile.nearby(i).block() instanceof StaticWall){
|
||||
|
||||
if(i == 0){
|
||||
r.setWidth(r.width - crop);
|
||||
|
||||
@@ -99,7 +99,7 @@ public class BlockForge extends PayloadAcceptor{
|
||||
public void buildConfiguration(Table table){
|
||||
Seq<Block> blocks = Vars.content.blocks().select(b -> b.isVisible() && b.size <= 2);
|
||||
|
||||
ItemSelection.buildTable(table, blocks, () -> recipe, block -> recipe = block);
|
||||
ItemSelection.buildTable(table, blocks, () -> recipe, this::configure);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -14,7 +14,7 @@ public class LiquidJunction extends LiquidBlock{
|
||||
@Override
|
||||
public void setStats(){
|
||||
super.setStats();
|
||||
stats.remove(BlockStat.liquidCapacity);
|
||||
stats.remove(Stat.liquidCapacity);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -117,8 +117,8 @@ public class LogicBlock extends Block{
|
||||
public void setStats(){
|
||||
super.setStats();
|
||||
|
||||
stats.add(BlockStat.linkRange, range / 8, StatUnit.blocks);
|
||||
stats.add(BlockStat.instructions, instructionsPerTick * 60, StatUnit.perSecond);
|
||||
stats.add(Stat.linkRange, range / 8, StatUnit.blocks);
|
||||
stats.add(Stat.instructions, instructionsPerTick * 60, StatUnit.perSecond);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -279,10 +279,13 @@ public class LogicBlock extends Block{
|
||||
|
||||
//store link objects
|
||||
executor.links = new Building[links.count(l -> l.valid && l.active)];
|
||||
executor.linkIds.clear();
|
||||
int index = 0;
|
||||
for(LogicLink link : links){
|
||||
if(link.active && link.valid){
|
||||
executor.links[index ++] = world.build(link.x, link.y);
|
||||
Building build = world.build(link.x, link.y);
|
||||
executor.links[index ++] = build;
|
||||
if(build != null) executor.linkIds.add(build.id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ public class LogicDisplay extends Block{
|
||||
public void setStats(){
|
||||
super.setStats();
|
||||
|
||||
stats.add(BlockStat.displaySize, "@x@", displaySize, displaySize);
|
||||
stats.add(Stat.displaySize, "@x@", displaySize, displaySize);
|
||||
}
|
||||
|
||||
public class LogicDisplayBuild extends Building{
|
||||
|
||||
@@ -18,7 +18,7 @@ public class MemoryBlock extends Block{
|
||||
public void setStats(){
|
||||
super.setStats();
|
||||
|
||||
stats.add(BlockStat.memoryCapacity, memoryCapacity, StatUnit.none);
|
||||
stats.add(Stat.memoryCapacity, memoryCapacity, StatUnit.none);
|
||||
}
|
||||
|
||||
public class MemoryBuild extends Building{
|
||||
|
||||
@@ -20,7 +20,7 @@ public class Battery extends PowerDistributor{
|
||||
super(name);
|
||||
outputsPower = true;
|
||||
consumesPower = true;
|
||||
flags = EnumSet.of(BlockFlag.powerRes);
|
||||
flags = EnumSet.of(BlockFlag.battery);
|
||||
}
|
||||
|
||||
public class BatteryBuild extends Building{
|
||||
|
||||
@@ -55,7 +55,7 @@ public class ImpactReactor extends PowerGenerator{
|
||||
super.setStats();
|
||||
|
||||
if(hasItems){
|
||||
stats.add(BlockStat.productionTime, itemDuration / 60f, StatUnit.seconds);
|
||||
stats.add(Stat.productionTime, itemDuration / 60f, StatUnit.seconds);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ public class ItemLiquidGenerator extends PowerGenerator{
|
||||
super.setStats();
|
||||
|
||||
if(hasItems){
|
||||
stats.add(BlockStat.productionTime, itemDuration / 60f, StatUnit.seconds);
|
||||
stats.add(Stat.productionTime, itemDuration / 60f, StatUnit.seconds);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import arc.util.io.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
@@ -47,6 +48,7 @@ public class NuclearReactor extends PowerGenerator{
|
||||
hasItems = true;
|
||||
hasLiquids = true;
|
||||
rebuildable = false;
|
||||
flags = EnumSet.of(BlockFlag.reactor);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -54,7 +56,7 @@ public class NuclearReactor extends PowerGenerator{
|
||||
super.setStats();
|
||||
|
||||
if(hasItems){
|
||||
stats.add(BlockStat.productionTime, itemDuration / 60f, StatUnit.seconds);
|
||||
stats.add(Stat.productionTime, itemDuration / 60f, StatUnit.seconds);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,13 +12,13 @@ import mindustry.world.meta.*;
|
||||
public class PowerGenerator extends PowerDistributor{
|
||||
/** The amount of power produced per tick in case of an efficiency of 1.0, which represents 100%. */
|
||||
public float powerProduction;
|
||||
public BlockStat generationType = BlockStat.basePowerGeneration;
|
||||
public Stat generationType = Stat.basePowerGeneration;
|
||||
|
||||
public PowerGenerator(String name){
|
||||
super(name);
|
||||
sync = true;
|
||||
baseExplosiveness = 5f;
|
||||
flags = EnumSet.of(BlockFlag.producer);
|
||||
flags = EnumSet.of(BlockFlag.generator);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -124,8 +124,8 @@ public class PowerNode extends PowerBlock{
|
||||
public void setStats(){
|
||||
super.setStats();
|
||||
|
||||
stats.add(BlockStat.powerRange, laserRange, StatUnit.blocks);
|
||||
stats.add(BlockStat.powerConnections, maxNodes, StatUnit.none);
|
||||
stats.add(Stat.powerRange, laserRange, StatUnit.blocks);
|
||||
stats.add(Stat.powerConnections, maxNodes, StatUnit.none);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -22,7 +22,7 @@ public class ThermalGenerator extends PowerGenerator{
|
||||
public void setStats(){
|
||||
super.setStats();
|
||||
|
||||
stats.add(BlockStat.tiles, attribute, floating);
|
||||
stats.add(Stat.tiles, attribute, floating);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -37,7 +37,7 @@ public class AttributeSmelter extends GenericSmelter{
|
||||
public void setStats(){
|
||||
super.setStats();
|
||||
|
||||
stats.add(BlockStat.affinities, attribute, boostScale);
|
||||
stats.add(Stat.affinities, attribute, boostScale);
|
||||
}
|
||||
|
||||
public class AttributeSmelterBuild extends SmelterBuild{
|
||||
|
||||
@@ -42,7 +42,7 @@ public class Cultivator extends GenericCrafter{
|
||||
public void setStats(){
|
||||
super.setStats();
|
||||
|
||||
stats.add(BlockStat.affinities, attribute);
|
||||
stats.add(Stat.affinities, attribute);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,7 +16,9 @@ import mindustry.graphics.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.environment.*;
|
||||
import mindustry.world.meta.*;
|
||||
import mindustry.world.meta.values.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
@@ -135,29 +137,11 @@ public class Drill extends Block{
|
||||
public void setStats(){
|
||||
super.setStats();
|
||||
|
||||
stats.add(BlockStat.drillTier, table -> {
|
||||
Seq<Block> list = content.blocks().select(b -> b.isFloor() && b.asFloor().itemDrop != null && b.asFloor().itemDrop.hardness <= tier);
|
||||
stats.add(Stat.drillTier, new BlockFilterValue(b -> b instanceof Floor f && f.itemDrop != null && f.itemDrop.hardness <= tier));
|
||||
|
||||
table.table(l -> {
|
||||
l.left();
|
||||
|
||||
for(int i = 0; i < list.size; i++){
|
||||
Block item = list.get(i);
|
||||
|
||||
l.image(item.icon(Cicon.small)).size(8 * 3).padRight(2).padLeft(2).padTop(3).padBottom(3);
|
||||
l.add(item.localizedName).left().padLeft(1).padRight(4);
|
||||
if(i % 5 == 4){
|
||||
l.row();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
stats.add(BlockStat.drillSpeed, 60f / drillTime * size * size, StatUnit.itemsSecond);
|
||||
stats.add(Stat.drillSpeed, 60f / drillTime * size * size, StatUnit.itemsSecond);
|
||||
if(liquidBoostIntensity != 1){
|
||||
stats.add(BlockStat.boostEffect, liquidBoostIntensity * liquidBoostIntensity, StatUnit.timesSpeed);
|
||||
stats.add(Stat.boostEffect, liquidBoostIntensity * liquidBoostIntensity, StatUnit.timesSpeed);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ public class Fracker extends SolidPump{
|
||||
public void setStats(){
|
||||
super.setStats();
|
||||
|
||||
stats.add(BlockStat.productionTime, itemUseTime / 60f, StatUnit.seconds);
|
||||
stats.add(Stat.productionTime, itemUseTime / 60f, StatUnit.seconds);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -45,7 +45,7 @@ public class Fracker extends SolidPump{
|
||||
Draw.rect(region, x, y);
|
||||
super.drawCracks();
|
||||
|
||||
Drawf.liquid(liquidRegion, x, y, liquids.total() / liquidCapacity, result.color);
|
||||
Drawf.liquid(liquidRegion, x, y, liquids.get(result) / liquidCapacity, result.color);
|
||||
|
||||
Draw.rect(rotatorRegion, x, y, pumpTime);
|
||||
Draw.rect(topRegion, x, y);
|
||||
|
||||
@@ -2,6 +2,7 @@ package mindustry.world.blocks.production;
|
||||
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.io.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
@@ -23,9 +24,6 @@ public class GenericCrafter extends Block{
|
||||
|
||||
public DrawBlock drawer = new DrawBlock();
|
||||
|
||||
//public Cons<GenericCrafterEntity> drawer = null;
|
||||
//public Prov<TextureRegion[]> drawIcons = null;
|
||||
|
||||
public GenericCrafter(String name){
|
||||
super(name);
|
||||
update = true;
|
||||
@@ -34,6 +32,7 @@ public class GenericCrafter extends Block{
|
||||
idleSound = Sounds.machine;
|
||||
sync = true;
|
||||
idleSoundVolume = 0.03f;
|
||||
flags = EnumSet.of(BlockFlag.factory);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -44,14 +43,14 @@ public class GenericCrafter extends Block{
|
||||
}
|
||||
|
||||
super.setStats();
|
||||
stats.add(BlockStat.productionTime, craftTime / 60f, StatUnit.seconds);
|
||||
stats.add(Stat.productionTime, craftTime / 60f, StatUnit.seconds);
|
||||
|
||||
if(outputItem != null){
|
||||
stats.add(BlockStat.output, outputItem);
|
||||
stats.add(Stat.output, outputItem);
|
||||
}
|
||||
|
||||
if(outputLiquid != null){
|
||||
stats.add(BlockStat.output, outputLiquid.liquid, outputLiquid.amount, false);
|
||||
stats.add(Stat.output, outputLiquid.liquid, outputLiquid.amount, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,8 +26,8 @@ public class LiquidConverter extends GenericCrafter{
|
||||
@Override
|
||||
public void setStats(){
|
||||
super.setStats();
|
||||
stats.remove(BlockStat.output);
|
||||
stats.add(BlockStat.output, outputLiquid.liquid, outputLiquid.amount * craftTime, false);
|
||||
stats.remove(Stat.output);
|
||||
stats.add(Stat.output, outputLiquid.liquid, outputLiquid.amount * craftTime, false);
|
||||
}
|
||||
|
||||
public class LiquidConverterBuild extends GenericCrafterBuild{
|
||||
|
||||
@@ -26,7 +26,7 @@ public class Pump extends LiquidBlock{
|
||||
@Override
|
||||
public void setStats(){
|
||||
super.setStats();
|
||||
stats.add(BlockStat.output, 60f * pumpAmount * size * size, StatUnit.liquidSecond);
|
||||
stats.add(Stat.output, 60f * pumpAmount * size * size, StatUnit.liquidSecond);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -41,14 +41,14 @@ public class Separator extends Block{
|
||||
|
||||
super.setStats();
|
||||
|
||||
stats.add(BlockStat.output, new ItemFilterValue(item -> {
|
||||
stats.add(Stat.output, new ItemFilterValue(item -> {
|
||||
for(ItemStack i : results){
|
||||
if(item == i.item) return true;
|
||||
}
|
||||
return false;
|
||||
}));
|
||||
|
||||
stats.add(BlockStat.productionTime, craftTime / 60f, StatUnit.seconds);
|
||||
stats.add(Stat.productionTime, craftTime / 60f, StatUnit.seconds);
|
||||
}
|
||||
|
||||
public class SeparatorBuild extends Building{
|
||||
|
||||
@@ -53,10 +53,10 @@ public class SolidPump extends Pump{
|
||||
public void setStats(){
|
||||
super.setStats();
|
||||
|
||||
stats.remove(BlockStat.output);
|
||||
stats.add(BlockStat.output, result, 60f * pumpAmount, true);
|
||||
stats.remove(Stat.output);
|
||||
stats.add(Stat.output, result, 60f * pumpAmount, true);
|
||||
if(attribute != null){
|
||||
stats.add(baseEfficiency > 0.0001f ? BlockStat.affinities : BlockStat.tiles, attribute);
|
||||
stats.add(baseEfficiency > 0.0001f ? Stat.affinities : Stat.tiles, attribute);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,8 +11,8 @@ public class PowerVoid extends PowerBlock{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(){
|
||||
super.init();
|
||||
stats.remove(BlockStat.powerUse);
|
||||
public void setStats(){
|
||||
super.setStats();
|
||||
stats.remove(Stat.powerUse);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ public class CoreBlock extends StorageBlock{
|
||||
update = true;
|
||||
hasItems = true;
|
||||
priority = TargetPriority.core;
|
||||
flags = EnumSet.of(BlockFlag.core, BlockFlag.producer, BlockFlag.unitModifier);
|
||||
flags = EnumSet.of(BlockFlag.core, BlockFlag.unitModifier);
|
||||
unitCapModifier = 10;
|
||||
activeSound = Sounds.respawning;
|
||||
activeSoundVolume = 1f;
|
||||
@@ -77,12 +77,16 @@ public class CoreBlock extends StorageBlock{
|
||||
public void setStats(){
|
||||
super.setStats();
|
||||
|
||||
stats.add(BlockStat.buildTime, 0, StatUnit.seconds);
|
||||
stats.add(Stat.buildTime, 0, StatUnit.seconds);
|
||||
}
|
||||
|
||||
bars.add("capacity", (CoreBuild e) ->
|
||||
new Bar(
|
||||
() -> Core.bundle.format("bar.capacity", UI.formatAmount(e.storageCapacity)),
|
||||
() -> Pal.items,
|
||||
@Override
|
||||
public void setBars(){
|
||||
super.setBars();
|
||||
|
||||
bars.add("capacity", (CoreBuild e) -> new Bar(
|
||||
() -> Core.bundle.format("bar.capacity", UI.formatAmount(e.storageCapacity)),
|
||||
() -> Pal.items,
|
||||
() -> e.items.total() / ((float)e.storageCapacity * content.items().count(i -> i.unlockedNow()))
|
||||
));
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public class StorageBlock extends Block{
|
||||
Tile edge = Edges.getFacingEdge(source, self);
|
||||
Tile edge2 = Edges.getFacingEdge(self, source);
|
||||
if(edge != null && edge2 != null){
|
||||
Fx.fuelburn.at((edge.worldx() + edge2.worldx())/2f, (edge.worldy() + edge2.worldy())/2f);
|
||||
Fx.coreBurn.at((edge.worldx() + edge2.worldx())/2f, (edge.worldy() + edge2.worldy())/2f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +63,23 @@ public class Reconstructor extends UnitBlock{
|
||||
public void setStats(){
|
||||
super.setStats();
|
||||
|
||||
stats.add(BlockStat.productionTime, constructTime / 60f, StatUnit.seconds);
|
||||
stats.add(Stat.productionTime, constructTime / 60f, StatUnit.seconds);
|
||||
stats.add(Stat.output, table -> {
|
||||
table.row();
|
||||
for(var upgrade : upgrades){
|
||||
float size = 8*3;
|
||||
if(upgrade[0].unlockedNow() && upgrade[1].unlockedNow()){
|
||||
table.image(upgrade[0].icon(Cicon.small)).size(size).padRight(4).padLeft(10).scaling(Scaling.fit).right();
|
||||
table.add(upgrade[0].localizedName).left();
|
||||
|
||||
table.add("[lightgray] -> ");
|
||||
|
||||
table.image(upgrade[1].icon(Cicon.small)).size(size).padRight(4).scaling(Scaling.fit);
|
||||
table.add(upgrade[1].localizedName).left();
|
||||
table.row();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -42,7 +42,7 @@ public class RepairPoint extends Block{
|
||||
@Override
|
||||
public void setStats(){
|
||||
super.setStats();
|
||||
stats.add(BlockStat.range, repairRadius / tilesize, StatUnit.blocks);
|
||||
stats.add(Stat.range, repairRadius / tilesize, StatUnit.blocks);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -87,7 +87,7 @@ public class UnitFactory extends UnitBlock{
|
||||
public void setStats(){
|
||||
super.setStats();
|
||||
|
||||
stats.remove(BlockStat.itemCapacity);
|
||||
stats.remove(Stat.itemCapacity);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -69,5 +69,5 @@ public abstract class Consume{
|
||||
|
||||
public abstract boolean valid(Building entity);
|
||||
|
||||
public abstract void display(BlockStats stats);
|
||||
public abstract void display(Stats stats);
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ public class ConsumeItemDynamic extends Consume{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void display(BlockStats stats){
|
||||
public void display(Stats stats){
|
||||
//should be handled by the block
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ public class ConsumeItemFilter extends Consume{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void display(BlockStats stats){
|
||||
stats.add(booster ? BlockStat.booster : BlockStat.input, new ItemFilterValue(filter));
|
||||
public void display(Stats stats){
|
||||
stats.add(booster ? Stat.booster : Stat.input, new ItemFilterValue(filter));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ public class ConsumeItems extends Consume{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void display(BlockStats stats){
|
||||
stats.add(booster ? BlockStat.booster : BlockStat.input, new ItemListValue(items));
|
||||
public void display(Stats stats){
|
||||
stats.add(booster ? Stat.booster : Stat.input, new ItemListValue(items));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ public class ConsumeLiquid extends ConsumeLiquidBase{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void display(BlockStats stats){
|
||||
stats.add(booster ? BlockStat.booster : BlockStat.input, liquid, amount * timePeriod, timePeriod == 60);
|
||||
public void display(Stats stats){
|
||||
stats.add(booster ? Stat.booster : Stat.input, liquid, amount * timePeriod, timePeriod == 60);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ public class ConsumeLiquidFilter extends ConsumeLiquidBase{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void display(BlockStats stats){
|
||||
stats.add(booster ? BlockStat.booster : BlockStat.input, new LiquidFilterValue(filter, amount * timePeriod, timePeriod == 60f));
|
||||
public void display(Stats stats){
|
||||
stats.add(booster ? Stat.booster : Stat.input, new LiquidFilterValue(filter, amount * timePeriod, timePeriod == 60f));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,11 +54,11 @@ public class ConsumePower extends Consume{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void display(BlockStats stats){
|
||||
public void display(Stats stats){
|
||||
if(buffered){
|
||||
stats.add(BlockStat.powerCapacity, capacity, StatUnit.none);
|
||||
stats.add(Stat.powerCapacity, capacity, StatUnit.none);
|
||||
}else{
|
||||
stats.add(BlockStat.powerUse, usage * 60f, StatUnit.powerSecond);
|
||||
stats.add(Stat.powerUse, usage * 60f, StatUnit.powerSecond);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ public class Consumers{
|
||||
return optionalResults;
|
||||
}
|
||||
|
||||
public void display(BlockStats stats){
|
||||
public void display(Stats stats){
|
||||
for(Consume c : map){
|
||||
if(c != null){
|
||||
c.display(stats);
|
||||
|
||||
@@ -4,18 +4,22 @@ package mindustry.world.meta;
|
||||
public enum BlockFlag{
|
||||
/** Enemy core; primary target for all units. */
|
||||
core,
|
||||
/** Producer of important goods. */
|
||||
producer,
|
||||
/** A turret. */
|
||||
/** Something that generates power. */
|
||||
generator,
|
||||
/** Any turret. */
|
||||
turret,
|
||||
/** A block that transforms resources. */
|
||||
factory,
|
||||
/** Repair point. */
|
||||
repair,
|
||||
/** Rally point. */
|
||||
rally,
|
||||
/** Block that stored power for resupply. */
|
||||
powerRes,
|
||||
battery,
|
||||
/** Block used for resupply. */
|
||||
resupply,
|
||||
/** Any reactor block. */
|
||||
reactor,
|
||||
/** Any block that boosts unit capacity. */
|
||||
unitModifier;
|
||||
|
||||
|
||||
82
core/src/mindustry/world/meta/Stat.java
Normal file
82
core/src/mindustry/world/meta/Stat.java
Normal file
@@ -0,0 +1,82 @@
|
||||
package mindustry.world.meta;
|
||||
|
||||
import arc.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/** Describes one type of stat for content. */
|
||||
public enum Stat{
|
||||
health,
|
||||
size,
|
||||
displaySize,
|
||||
buildTime,
|
||||
buildCost,
|
||||
memoryCapacity,
|
||||
explosiveness,
|
||||
flammability,
|
||||
radioactivity,
|
||||
heatCapacity,
|
||||
viscosity,
|
||||
temperature,
|
||||
speed,
|
||||
buildSpeed,
|
||||
mineSpeed,
|
||||
mineTier,
|
||||
|
||||
itemCapacity(StatCat.items),
|
||||
itemsMoved(StatCat.items),
|
||||
launchTime(StatCat.items),
|
||||
maxConsecutive(StatCat.items),
|
||||
|
||||
liquidCapacity(StatCat.liquids),
|
||||
|
||||
powerCapacity(StatCat.power),
|
||||
powerUse(StatCat.power),
|
||||
powerDamage(StatCat.power),
|
||||
powerRange(StatCat.power),
|
||||
powerConnections(StatCat.power),
|
||||
basePowerGeneration(StatCat.power),
|
||||
|
||||
tiles(StatCat.crafting),
|
||||
input(StatCat.crafting),
|
||||
output(StatCat.crafting),
|
||||
productionTime(StatCat.crafting),
|
||||
drillTier(StatCat.crafting),
|
||||
drillSpeed(StatCat.crafting),
|
||||
maxUnits(StatCat.crafting),
|
||||
linkRange(StatCat.crafting),
|
||||
instructions(StatCat.crafting),
|
||||
|
||||
speedIncrease(StatCat.shooting),
|
||||
repairTime(StatCat.shooting),
|
||||
range(StatCat.shooting),
|
||||
shootRange(StatCat.shooting),
|
||||
inaccuracy(StatCat.shooting),
|
||||
shots(StatCat.shooting),
|
||||
reload(StatCat.shooting),
|
||||
powerShot(StatCat.shooting),
|
||||
targetsAir(StatCat.shooting),
|
||||
targetsGround(StatCat.shooting),
|
||||
damage(StatCat.shooting),
|
||||
ammo(StatCat.shooting),
|
||||
shieldHealth(StatCat.shooting),
|
||||
cooldownTime(StatCat.shooting),
|
||||
|
||||
booster(StatCat.optional),
|
||||
boostEffect(StatCat.optional),
|
||||
affinities(StatCat.optional);
|
||||
|
||||
public final StatCat category;
|
||||
|
||||
Stat(StatCat category){
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
Stat(){
|
||||
this.category = StatCat.general;
|
||||
}
|
||||
|
||||
public String localized(){
|
||||
return Core.bundle.get("stat." + name().toLowerCase(Locale.ROOT));
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ package mindustry.world.meta;
|
||||
import arc.*;
|
||||
|
||||
/** A specific category for a stat. */
|
||||
public enum StatCategory{
|
||||
public enum StatCat{
|
||||
general,
|
||||
power,
|
||||
liquids,
|
||||
@@ -2,54 +2,71 @@ package mindustry.world.meta;
|
||||
|
||||
import arc.struct.ObjectMap.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import mindustry.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.meta.values.*;
|
||||
|
||||
/** Hold and organizes a list of block stats. */
|
||||
public class BlockStats{
|
||||
private final OrderedMap<StatCategory, OrderedMap<BlockStat, Seq<StatValue>>> map = new OrderedMap<>();
|
||||
public class Stats{
|
||||
/** Whether to display stats with categories. If false, categories are completely ignored during display. */
|
||||
public boolean useCategories = false;
|
||||
/** Whether these stats are initialized yet. */
|
||||
public boolean intialized = false;
|
||||
|
||||
@Nullable
|
||||
private OrderedMap<StatCat, OrderedMap<Stat, Seq<StatValue>>> map;
|
||||
private boolean dirty;
|
||||
|
||||
/** Adds a single float value with this stat, formatted to 2 decimal places. */
|
||||
public void add(BlockStat stat, float value, StatUnit unit){
|
||||
public void add(Stat stat, float value, StatUnit unit){
|
||||
add(stat, new NumberValue(value, unit));
|
||||
}
|
||||
|
||||
/** Adds a single float value with this stat and no unit. */
|
||||
public void add(Stat stat, float value){
|
||||
add(stat, value, StatUnit.none);
|
||||
}
|
||||
|
||||
/** Adds an integer percent stat value. Value is assumed to be in the 0-1 range. */
|
||||
public void addPercent(Stat stat, float value){
|
||||
add(stat, new NumberValue((int)(value * 100), StatUnit.percent));
|
||||
}
|
||||
|
||||
/** Adds a single y/n boolean value. */
|
||||
public void add(BlockStat stat, boolean value){
|
||||
public void add(Stat stat, boolean value){
|
||||
add(stat, new BooleanValue(value));
|
||||
}
|
||||
|
||||
/** Adds an item value. */
|
||||
public void add(BlockStat stat, Item item){
|
||||
public void add(Stat stat, Item item){
|
||||
add(stat, new ItemListValue(new ItemStack(item, 1)));
|
||||
}
|
||||
|
||||
/** Adds an item value. */
|
||||
public void add(BlockStat stat, ItemStack item){
|
||||
public void add(Stat stat, ItemStack item){
|
||||
add(stat, new ItemListValue(item));
|
||||
}
|
||||
|
||||
/** Adds an item value. */
|
||||
public void add(BlockStat stat, Liquid liquid, float amount, boolean perSecond){
|
||||
public void add(Stat stat, Liquid liquid, float amount, boolean perSecond){
|
||||
add(stat, new LiquidValue(liquid, amount, perSecond));
|
||||
}
|
||||
|
||||
public void add(BlockStat stat, Attribute attr){
|
||||
public void add(Stat stat, Attribute attr){
|
||||
add(stat, attr, false, 1f);
|
||||
}
|
||||
|
||||
public void add(BlockStat stat, Attribute attr, float scale){
|
||||
public void add(Stat stat, Attribute attr, float scale){
|
||||
add(stat, attr, false, scale);
|
||||
}
|
||||
|
||||
public void add(BlockStat stat, Attribute attr, boolean floating){
|
||||
public void add(Stat stat, Attribute attr, boolean floating){
|
||||
add(stat, attr, floating, 1f);
|
||||
}
|
||||
|
||||
public void add(BlockStat stat, Attribute attr, boolean floating, float scale){
|
||||
public void add(Stat stat, Attribute attr, boolean floating, float scale){
|
||||
for(Block block : Vars.content.blocks()){
|
||||
if(!block.isFloor() || block.asFloor().attributes.get(attr) == 0 || (block.asFloor().isLiquid && !floating)) continue;
|
||||
add(stat, new FloorEfficiencyValue(block.asFloor(), block.asFloor().attributes.get(attr) * scale));
|
||||
@@ -57,12 +74,14 @@ public class BlockStats{
|
||||
}
|
||||
|
||||
/** Adds a single string value with this stat. */
|
||||
public void add(BlockStat stat, String format, Object... args){
|
||||
public void add(Stat stat, String format, Object... args){
|
||||
add(stat, new StringValue(format, args));
|
||||
}
|
||||
|
||||
/** Adds a stat value. */
|
||||
public void add(BlockStat stat, StatValue value){
|
||||
public void add(Stat stat, StatValue value){
|
||||
if(map == null) map = new OrderedMap<>();
|
||||
|
||||
if(!map.containsKey(stat.category)){
|
||||
map.put(stat.category, new OrderedMap<>());
|
||||
}
|
||||
@@ -73,7 +92,9 @@ public class BlockStats{
|
||||
}
|
||||
|
||||
/** Removes a stat, if it exists. */
|
||||
public void remove(BlockStat stat){
|
||||
public void remove(Stat stat){
|
||||
if(map == null) map = new OrderedMap<>();
|
||||
|
||||
if(!map.containsKey(stat.category) || !map.get(stat.category).containsKey(stat)){
|
||||
throw new RuntimeException("No stat entry found: \"" + stat + "\" in block.");
|
||||
}
|
||||
@@ -83,11 +104,13 @@ public class BlockStats{
|
||||
dirty = true;
|
||||
}
|
||||
|
||||
public OrderedMap<StatCategory, OrderedMap<BlockStat, Seq<StatValue>>> toMap(){
|
||||
public OrderedMap<StatCat, OrderedMap<Stat, Seq<StatValue>>> toMap(){
|
||||
if(map == null) map = new OrderedMap<>();
|
||||
|
||||
//sort stats by index if they've been modified
|
||||
if(dirty){
|
||||
map.orderedKeys().sort();
|
||||
for(Entry<StatCategory, OrderedMap<BlockStat, Seq<StatValue>>> entry : map.entries()){
|
||||
for(Entry<StatCat, OrderedMap<Stat, Seq<StatValue>>> entry : map.entries()){
|
||||
entry.value.orderedKeys().sort();
|
||||
}
|
||||
|
||||
37
core/src/mindustry/world/meta/values/BlockFilterValue.java
Normal file
37
core/src/mindustry/world/meta/values/BlockFilterValue.java
Normal file
@@ -0,0 +1,37 @@
|
||||
package mindustry.world.meta.values;
|
||||
|
||||
import arc.func.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.struct.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class BlockFilterValue implements StatValue{
|
||||
public final Boolf<Block> pred;
|
||||
|
||||
public BlockFilterValue(Boolf<Block> pred){
|
||||
this.pred = pred;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void display(Table table){
|
||||
Seq<Block> list = content.blocks().select(pred);
|
||||
|
||||
table.table(l -> {
|
||||
l.left();
|
||||
|
||||
for(int i = 0; i < list.size; i++){
|
||||
Block item = list.get(i);
|
||||
|
||||
l.image(item.icon(Cicon.small)).size(8 * 3).padRight(2).padLeft(2).padTop(3).padBottom(3);
|
||||
l.add(item.localizedName).left().padLeft(1).padRight(4);
|
||||
if(i % 5 == 4){
|
||||
l.row();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
33
core/src/mindustry/world/meta/values/BlockListValue.java
Normal file
33
core/src/mindustry/world/meta/values/BlockListValue.java
Normal file
@@ -0,0 +1,33 @@
|
||||
package mindustry.world.meta.values;
|
||||
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.struct.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
public class BlockListValue implements StatValue{
|
||||
public final Seq<Block> list;
|
||||
|
||||
public BlockListValue(Seq<Block> list){
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void display(Table table){
|
||||
|
||||
table.table(l -> {
|
||||
l.left();
|
||||
|
||||
for(int i = 0; i < list.size; i++){
|
||||
Block item = list.get(i);
|
||||
|
||||
l.image(item.icon(Cicon.small)).size(8 * 3).padRight(2).padLeft(2).padTop(3).padBottom(3);
|
||||
l.add(item.localizedName).left().padLeft(1).padRight(4);
|
||||
if(i % 5 == 4){
|
||||
l.row();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user