Merge remote-tracking branch 'upstream/master' into wall-stats
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user