c l e a n u p
This commit is contained in:
@@ -38,7 +38,7 @@ public class Build{
|
||||
|
||||
tile.set(sub, team, rotation);
|
||||
tile.<BuildEntity>ent().setDeconstruct(previous);
|
||||
tile.entity.health = tile.entity.maxHealth() * prevPercent;
|
||||
tile.entity.health(tile.entity.maxHealth() * prevPercent);
|
||||
|
||||
Core.app.post(() -> Events.fire(new BlockBuildBeginEvent(tile, team, true)));
|
||||
}
|
||||
@@ -78,7 +78,7 @@ public class Build{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(state.teams.eachEnemyCore(team, core -> Mathf.dst(x * tilesize + type.offset(), y * tilesize + type.offset(), core.x, core.y) < state.rules.enemyCoreBuildRadius + type.size * tilesize / 2f)){
|
||||
if(state.teams.eachEnemyCore(team, core -> Mathf.dst(x * tilesize + type.offset(), y * tilesize + type.offset(), core.x(), core.y()) < state.rules.enemyCoreBuildRadius + type.size * tilesize / 2f)){
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,12 +33,12 @@ public class CachedTile extends Tile{
|
||||
|
||||
if(block.hasEntity()){
|
||||
Tilec n = block.newEntity();
|
||||
n.cons = new ConsumeModule(entity);
|
||||
n.tile = this;
|
||||
n.block = block;
|
||||
if(block.hasItems) n.items = new ItemModule();
|
||||
if(block.hasLiquids) n.liquids = new LiquidModule();
|
||||
if(block.hasPower) n.power = new PowerModule();
|
||||
n.cons(new ConsumeModule(entity));
|
||||
n.tile(this);
|
||||
n.block(block);
|
||||
if(block.hasItems) n.items(new ItemModule());
|
||||
if(block.hasLiquids) n.liquids(new LiquidModule());
|
||||
if(block.hasPower) n.power(new PowerModule());
|
||||
entity = n;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
package mindustry.world.blocks;
|
||||
|
||||
import arc.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import arc.Graphics.*;
|
||||
import arc.Graphics.Cursor.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.util.ArcAnnotate.*;
|
||||
import arc.util.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.ui.*;
|
||||
@@ -66,10 +64,10 @@ public class BuildBlock extends Block{
|
||||
float healthf = tile.entity == null ? 1f : tile.entity.healthf();
|
||||
tile.set(block, team, rotation);
|
||||
if(tile.entity != null){
|
||||
tile.entity.health = block.health * healthf;
|
||||
tile.entity.health(block.health * healthf);
|
||||
}
|
||||
//last builder was this local client player, call placed()
|
||||
if(!headless && builderID == player.id){
|
||||
if(!headless && builderID == player.id()){
|
||||
if(!skipConfig){
|
||||
tile.block().playerPlaced(tile);
|
||||
}
|
||||
@@ -141,6 +139,8 @@ public class BuildBlock extends Block{
|
||||
public void tapped(Tile tile, Playerc player){
|
||||
BuildEntity entity = tile.ent();
|
||||
|
||||
//TODO building
|
||||
/*
|
||||
//if the target is constructible, begin constructing
|
||||
if(entity.cblock != null){
|
||||
if(player.buildWasAutoPaused && !player.isBuilding){
|
||||
@@ -148,7 +148,7 @@ public class BuildBlock extends Block{
|
||||
}
|
||||
//player.clearBuilding();
|
||||
player.addBuildRequest(new BuildRequest(tile.x, tile.y, tile.rotation(), entity.cblock), false);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -156,7 +156,8 @@ public class BuildBlock extends Block{
|
||||
Fx.blockExplosionSmoke.at(tile);
|
||||
|
||||
if(!tile.floor().solid && !tile.floor().isLiquid){
|
||||
RubbleDecal.create(tile.drawx(), tile.drawy(), size);
|
||||
//TODO implement
|
||||
// RubbleDecal.create(tile.drawx(), tile.drawy(), size);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,7 +238,7 @@ public class BuildBlock extends Block{
|
||||
maxProgress = core == null ? maxProgress : checkRequired(core.items(), maxProgress, true);
|
||||
|
||||
progress = Mathf.clamp(progress + maxProgress);
|
||||
builderID = builder.getId();
|
||||
builderID = builder.id();
|
||||
|
||||
if(progress >= 1f || state.rules.infiniteResources){
|
||||
constructed(tile, cblock, builderID, tile.rotation(), builder.team(), configured);
|
||||
@@ -267,8 +268,8 @@ public class BuildBlock extends Block{
|
||||
|
||||
if(clampedAmount > 0 && accumulated > 0){ //if it's positive, add it to the core
|
||||
if(core != null){
|
||||
int accepting = core.tile.block().acceptStack(requirements[i].item, accumulated, core.tile, builder);
|
||||
core.tile.block().handleStack(requirements[i].item, accepting, core.tile, builder);
|
||||
int accepting = core.tile().block().acceptStack(requirements[i].item, accumulated, core.tile(), builder);
|
||||
core.tile().block().handleStack(requirements[i].item, accepting, core.tile(), builder);
|
||||
accumulator[i] -= accepting;
|
||||
}else{
|
||||
accumulator[i] -= accumulated;
|
||||
@@ -280,7 +281,7 @@ public class BuildBlock extends Block{
|
||||
progress = Mathf.clamp(progress - amount);
|
||||
|
||||
if(builder instanceof Playerc){
|
||||
builderID = builder.getID();
|
||||
builderID = builder.id();
|
||||
}
|
||||
|
||||
if(progress <= 0 || state.rules.infiniteResources){
|
||||
|
||||
@@ -89,7 +89,7 @@ public class OverdriveProjector extends Block{
|
||||
float realBoost = (speedBoost + entity.phaseHeat * speedBoostPhase) * entity.efficiency();
|
||||
|
||||
entity.charge = 0f;
|
||||
indexer.eachBlock(entity, realRange, other -> other.entity.timeScale <= realBoost, other -> other.entity.applyBoost(realBoost, reload + 1f));
|
||||
indexer.eachBlock(entity, realRange, other -> other.entity.timeScale() <= realBoost, other -> other.entity.applyBoost(realBoost, reload + 1f));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ public class ArtilleryTurret extends ItemTurret{
|
||||
float maxTraveled = type.lifetime * type.speed;
|
||||
|
||||
for(int i = 0; i < shots; i++){
|
||||
Bullet.create(ammo, tile.entity, tile.team(), tile.drawx() + tr.x, tile.drawy() + tr.y,
|
||||
ammo.create(tile.entity, tile.team(), tile.drawx() + tr.x, tile.drawy() + tr.y,
|
||||
entity.rotation + Mathf.range(inaccuracy + type.inaccuracy), 1f + Mathf.range(velocityInaccuracy), (dst / maxTraveled));
|
||||
}
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ public class ItemTurret extends CooledTurret{
|
||||
}
|
||||
|
||||
@Override
|
||||
public int acceptStack(Item item, int amount, Tile tile, Unitc source){
|
||||
public int acceptStack(Item item, int amount, Tile tile, Teamc source){
|
||||
TurretEntity entity = tile.ent();
|
||||
|
||||
BulletType type = ammo.get(item);
|
||||
@@ -97,7 +97,7 @@ public class ItemTurret extends CooledTurret{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleStack(Item item, int amount, Tile tile, Unitc source){
|
||||
public void handleStack(Item item, int amount, Tile tile, Teamc source){
|
||||
for(int i = 0; i < amount; i++){
|
||||
handleItem(item, tile, null);
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public class LaserTurret extends PowerTurret{
|
||||
|
||||
if(entity.bulletLife > 0 && entity.bullet != null){
|
||||
tr.trns(entity.rotation, size * tilesize / 2f, 0f);
|
||||
entity.bullet.rot(entity.rotation);
|
||||
entity.bullet.rotation(entity.rotation);
|
||||
entity.bullet.set(tile.drawx() + tr.x, tile.drawy() + tr.y);
|
||||
entity.bullet.time(0f);
|
||||
entity.heat = 1f;
|
||||
@@ -95,7 +95,7 @@ public class LaserTurret extends PowerTurret{
|
||||
protected void bullet(Tile tile, BulletType type, float angle){
|
||||
LaserTurretEntity entity = tile.ent();
|
||||
|
||||
entity.bullet = Bullet.create(type, tile.entity, tile.team(), tile.drawx() + tr.x, tile.drawy() + tr.y, angle);
|
||||
entity.bullet = type.create(tile.entity, tile.team(), tile.drawx() + tr.x, tile.drawy() + tr.y, angle);
|
||||
entity.bulletLife = shootDuration;
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,8 @@ public class LiquidTurret extends Turret{
|
||||
protected boolean validateTarget(Tile tile){
|
||||
TurretEntity entity = tile.ent();
|
||||
if(entity.liquids().current().canExtinguish() && entity.target instanceof Tile){
|
||||
return Fire.has(((Tile)entity.target).x, ((Tile)entity.target).y);
|
||||
//TODO fix
|
||||
//return Fire.has(((Tile)entity.target).x, ((Tile)entity.target).y);
|
||||
}
|
||||
return super.validateTarget(tile);
|
||||
}
|
||||
@@ -83,10 +84,10 @@ public class LiquidTurret extends Turret{
|
||||
int tr = (int)(range / tilesize);
|
||||
for(int x = -tr; x <= tr; x++){
|
||||
for(int y = -tr; y <= tr; y++){
|
||||
if(Fire.has(x + tile.x, y + tile.y)){
|
||||
entity.target = world.tile(x + tile.x, y + tile.y);
|
||||
return;
|
||||
}
|
||||
//if(Fire.has(x + tile.x, y + tile.y)){
|
||||
// entity.target = world.tile(x + tile.x, y + tile.y);
|
||||
// return;
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,9 +191,9 @@ public abstract class Turret extends Block{
|
||||
TurretEntity entity = tile.ent();
|
||||
|
||||
if(targetAir && !targetGround){
|
||||
entity.target = Units.closestEnemy(tile.team(), tile.drawx(), tile.drawy(), range, e -> !e.dead() && e.isFlying());
|
||||
entity.target = Units.closestEnemy(tile.team(), tile.drawx(), tile.drawy(), range, e -> !e.dead() && !e.isGrounded());
|
||||
}else{
|
||||
entity.target = Units.closestTarget(tile.team(), tile.drawx(), tile.drawy(), range, e -> !e.dead() && (!e.isFlying() || targetAir) && (e.isFlying() || targetGround));
|
||||
entity.target = Units.closestTarget(tile.team(), tile.drawx(), tile.drawy(), range, e -> !e.dead() && (e.isGrounded() || targetAir) && (!e.isGrounded() || targetGround));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -267,7 +267,7 @@ public abstract class Turret extends Block{
|
||||
}
|
||||
|
||||
protected void bullet(Tile tile, BulletType type, float angle){
|
||||
Bullet.create(type, tile.entity, tile.team(), tile.drawx() + tr.x, tile.drawy() + tr.y, angle);
|
||||
type.create(tile.entity, tile.team(), tile.drawx() + tr.x, tile.drawy() + tr.y, angle);
|
||||
}
|
||||
|
||||
protected void effects(Tile tile){
|
||||
@@ -329,10 +329,8 @@ public abstract class Turret extends Block{
|
||||
@Override
|
||||
public void read(DataInput stream) throws IOException{
|
||||
super.read(stream);
|
||||
if(revision == 1){
|
||||
reload = stream.readFloat();
|
||||
rotation = stream.readFloat();
|
||||
}
|
||||
reload = stream.readFloat();
|
||||
rotation = stream.readFloat();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -72,7 +72,7 @@ public class Conveyor extends Block implements Autotiler{
|
||||
ConveyorEntity entity = tile.ent();
|
||||
byte rotation = tile.rotation();
|
||||
|
||||
int frame = entity.clogHeat <= 0.5f ? (int)(((Time.time() * speed * 8f * entity.timeScale)) % 4) : 0;
|
||||
int frame = entity.clogHeat <= 0.5f ? (int)(((Time.time() * speed * 8f * entity.timeScale())) % 4) : 0;
|
||||
Draw.rect(regions[Mathf.clamp(entity.blendbits, 0, regions.length - 1)][Mathf.clamp(frame, 0, regions[0].length - 1)], tile.drawx(), tile.drawy(),
|
||||
tilesize * entity.blendsclx, tilesize * entity.blendscly, rotation * 90);
|
||||
}
|
||||
@@ -96,7 +96,7 @@ public class Conveyor extends Block implements Autotiler{
|
||||
if(tile.front() != null && tile.front().entity != null){
|
||||
entity.next = tile.front().entity;
|
||||
entity.nextc = entity.next instanceof ConveyorEntity && entity.next.team() == tile.team() ? (ConveyorEntity)entity.next : null;
|
||||
entity.aligned = entity.nextc != null && tile.rotation() == entity.next.tile.rotation();
|
||||
entity.aligned = entity.nextc != null && tile.rotation() == entity.next.tile().rotation();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,11 +154,11 @@ public class Conveyor extends Block implements Autotiler{
|
||||
float centerx = 0f, centery = 0f;
|
||||
|
||||
if(Math.abs(tx) > Math.abs(ty)){
|
||||
centery = Mathf.clamp((tile.worldy() - unit.y) / centerDstScl, -centerSpeed, centerSpeed);
|
||||
if(Math.abs(tile.worldy() - unit.y) < 1f) centery = 0f;
|
||||
centery = Mathf.clamp((tile.worldy() - unit.y()) / centerDstScl, -centerSpeed, centerSpeed);
|
||||
if(Math.abs(tile.worldy() - unit.y()) < 1f) centery = 0f;
|
||||
}else{
|
||||
centerx = Mathf.clamp((tile.worldx() - unit.x) / centerDstScl, -centerSpeed, centerSpeed);
|
||||
if(Math.abs(tile.worldx() - unit.x) < 1f) centerx = 0f;
|
||||
centerx = Mathf.clamp((tile.worldx() - unit.x()) / centerDstScl, -centerSpeed, centerSpeed);
|
||||
if(Math.abs(tile.worldx() - unit.x()) < 1f) centerx = 0f;
|
||||
}
|
||||
|
||||
if(entity.len * itemSpace < 0.9f){
|
||||
@@ -179,7 +179,7 @@ public class Conveyor extends Block implements Autotiler{
|
||||
return;
|
||||
}
|
||||
|
||||
float nextMax = e.nextc != null && tile.rotation() == e.nextc.tile().rotation() ? 1f - Math.max(itemSpace - e.nextc.minitem, 0) : 1f;
|
||||
float nextMax = e.aligned ? 1f - Math.max(itemSpace - e.nextc.minitem, 0) : 1f;
|
||||
|
||||
for(int i = e.len - 1; i >= 0; i--){
|
||||
float nextpos = (i == e.len - 1 ? 100f : e.ys[i + 1]) - itemSpace;
|
||||
|
||||
@@ -30,7 +30,7 @@ public class Junction extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public int acceptStack(Item item, int amount, Tile tile, Unitc source){
|
||||
public int acceptStack(Item item, int amount, Tile tile, Teamc source){
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
package mindustry.world.blocks.distribution;
|
||||
|
||||
import arc.math.Mathf;
|
||||
import arc.util.Time;
|
||||
import arc.math.*;
|
||||
import arc.util.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.type.Item;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.meta.BlockGroup;
|
||||
|
||||
import java.io.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
public class OverflowGate extends Block{
|
||||
public float speed = 1f;
|
||||
@@ -117,23 +115,5 @@ public class OverflowGate extends Block{
|
||||
Item lastItem;
|
||||
Tile lastInput;
|
||||
float time;
|
||||
|
||||
@Override
|
||||
public byte version(){
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(DataOutput stream) throws IOException{
|
||||
super.write(stream);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(DataInput stream) throws IOException{
|
||||
super.read(stream);
|
||||
if(revision == 1){
|
||||
new DirectionalItemBuffer(25, 50f).read(stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,9 +162,6 @@ public class Sorter extends Block{
|
||||
public void read(DataInput stream) throws IOException{
|
||||
super.read(stream);
|
||||
sortItem = content.item(stream.readShort());
|
||||
if(revision == 1){
|
||||
new DirectionalItemBuffer(20, 45f).read(stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ public class Conduit extends LiquidBlock implements Autotiler{
|
||||
@Override
|
||||
public void update(Tile tile){
|
||||
ConduitEntity entity = tile.ent();
|
||||
entity.smoothLiquid = Mathf.lerpDelta(entity.smoothLiquid, entity.getLiquids().currentAmount() / liquidCapacity, 0.05f);
|
||||
entity.smoothLiquid = Mathf.lerpDelta(entity.smoothLiquid, entity.liquids().currentAmount() / liquidCapacity, 0.05f);
|
||||
|
||||
if(tile.entity.liquids().total() > 0.001f && tile.entity.timer(timerFlow, 1)){
|
||||
tryMoveLiquid(tile, tile.getNearby(tile.rotation()), leakResistance, tile.entity.liquids().current());
|
||||
|
||||
@@ -28,7 +28,7 @@ public class LiquidBridge extends ItemBridge{
|
||||
|
||||
Tile other = world.tile(entity.link);
|
||||
if(!linkValid(tile, other)){
|
||||
tryDumpLiquid(tile, entity.getLiquids().current());
|
||||
tryDumpLiquid(tile, entity.liquids().current());
|
||||
}else{
|
||||
((ItemBridgeEntity)world.tile(entity.link).entity).incoming.add(tile.pos());
|
||||
|
||||
@@ -44,7 +44,7 @@ public class LiquidBridge extends ItemBridge{
|
||||
|
||||
if(entity.uptime >= 0.5f){
|
||||
|
||||
if(tryMoveLiquid(tile, other, false, entity.getLiquids().current()) > 0.1f){
|
||||
if(tryMoveLiquid(tile, other, false, entity.liquids().current()) > 0.1f){
|
||||
entity.cycleSpeed = Mathf.lerpDelta(entity.cycleSpeed, 4f, 0.05f);
|
||||
}else{
|
||||
entity.cycleSpeed = Mathf.lerpDelta(entity.cycleSpeed, 1f, 0.01f);
|
||||
|
||||
@@ -28,7 +28,7 @@ public class LiquidExtendingBridge extends ExtendingItemBridge{
|
||||
|
||||
Tile other = world.tile(entity.link);
|
||||
if(!linkValid(tile, other)){
|
||||
tryDumpLiquid(tile, entity.getLiquids().current());
|
||||
tryDumpLiquid(tile, entity.liquids().current());
|
||||
}else{
|
||||
((ItemBridgeEntity)world.tile(entity.link).entity).incoming.add(tile.pos());
|
||||
|
||||
@@ -40,7 +40,7 @@ public class LiquidExtendingBridge extends ExtendingItemBridge{
|
||||
|
||||
if(entity.uptime >= 0.5f){
|
||||
|
||||
if(tryMoveLiquid(tile, other, false, entity.getLiquids().current()) > 0.1f){
|
||||
if(tryMoveLiquid(tile, other, false, entity.liquids().current()) > 0.1f){
|
||||
entity.cycleSpeed = Mathf.lerpDelta(entity.cycleSpeed, 4f, 0.05f);
|
||||
}else{
|
||||
entity.cycleSpeed = Mathf.lerpDelta(entity.cycleSpeed, 1f, 0.01f);
|
||||
|
||||
@@ -53,7 +53,7 @@ public class ImpactReactor extends PowerGenerator{
|
||||
|
||||
bars.add("poweroutput", entity -> new Bar(() ->
|
||||
Core.bundle.format("bar.poweroutput",
|
||||
Strings.fixed(Math.max(entity.block.getPowerProduction(entity.tile) - consumes.getPower().usage, 0) * 60 * entity.timeScale, 1)),
|
||||
Strings.fixed(Math.max(entity.block().getPowerProduction(entity.tile()) - consumes.getPower().usage, 0) * 60 * entity.timeScale(), 1)),
|
||||
() -> Pal.powerBar,
|
||||
() -> ((GeneratorEntity)entity).productionEfficiency));
|
||||
}
|
||||
@@ -83,7 +83,7 @@ public class ImpactReactor extends PowerGenerator{
|
||||
Events.fire(Trigger.impactPower);
|
||||
}
|
||||
|
||||
if(entity.timer(timerUse, itemDuration / entity.timeScale)){
|
||||
if(entity.timer(timerUse, itemDuration / entity.timeScale())){
|
||||
entity.consume();
|
||||
}
|
||||
}else{
|
||||
|
||||
@@ -86,7 +86,7 @@ public class NuclearReactor extends PowerGenerator{
|
||||
if(fuel > 0){
|
||||
entity.heat += fullness * heating * Math.min(entity.delta(), 4f);
|
||||
|
||||
if(entity.timer(timerFuel, itemDuration / entity.timeScale)){
|
||||
if(entity.timer(timerFuel, itemDuration / entity.timeScale())){
|
||||
entity.consume();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,8 +58,8 @@ public class PowerDiode extends Block{
|
||||
public void setBars(){
|
||||
super.setBars();
|
||||
|
||||
bars.add("back", entity -> new Bar("bar.input", Pal.powerBar, () -> bar(entity.tile.back())));
|
||||
bars.add("front", entity -> new Bar("bar.output", Pal.powerBar, () -> bar(entity.tile.front())));
|
||||
bars.add("back", entity -> new Bar("bar.input", Pal.powerBar, () -> bar(entity.tile().back())));
|
||||
bars.add("front", entity -> new Bar("bar.output", Pal.powerBar, () -> bar(entity.tile().front())));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -37,7 +37,7 @@ public class PowerGenerator extends PowerDistributor{
|
||||
if(hasPower && outputsPower && !consumes.hasPower()){
|
||||
bars.add("power", entity -> new Bar(() ->
|
||||
Core.bundle.format("bar.poweroutput",
|
||||
Strings.fixed(entity.block.getPowerProduction(entity.tile) * 60 * entity.timeScale, 1)),
|
||||
Strings.fixed(entity.block().getPowerProduction(entity.tile()) * 60 * entity.timeScale(), 1)),
|
||||
() -> Pal.powerBar,
|
||||
() -> ((GeneratorEntity)entity).productionEfficiency));
|
||||
}
|
||||
|
||||
@@ -41,11 +41,11 @@ public class PowerNode extends PowerBlock{
|
||||
public void configured(Tile tile, Playerc player, int value){
|
||||
Tilec entity = tile.entity;
|
||||
Tile other = world.tile(value);
|
||||
boolean contains = entity.getPower().links.contains(value), valid = other != null && other.entity != null && other.entity.power() != null;
|
||||
boolean contains = entity.power().links.contains(value), valid = other != null && other.entity != null && other.entity.power() != null;
|
||||
|
||||
if(contains){
|
||||
//unlink
|
||||
entity.getPower().links.removeValue(value);
|
||||
entity.power().links.removeValue(value);
|
||||
if(valid) other.entity.power().links.removeValue(tile.pos());
|
||||
|
||||
PowerGraph newgraph = new PowerGraph();
|
||||
@@ -59,10 +59,10 @@ public class PowerNode extends PowerBlock{
|
||||
//reflow from other end
|
||||
og.reflow(other);
|
||||
}
|
||||
}else if(linkValid(tile, other) && valid && entity.getPower().links.size < maxNodes){
|
||||
}else if(linkValid(tile, other) && valid && entity.power().links.size < maxNodes){
|
||||
|
||||
if(!entity.getPower().links.contains(other.pos())){
|
||||
entity.getPower().links.add(other.pos());
|
||||
if(!entity.power().links.contains(other.pos())){
|
||||
entity.power().links.add(other.pos());
|
||||
}
|
||||
|
||||
if(other.getTeamID() == tile.getTeamID()){
|
||||
@@ -72,7 +72,7 @@ public class PowerNode extends PowerBlock{
|
||||
}
|
||||
}
|
||||
|
||||
entity.getPower().graph.add(other.entity.power().graph);
|
||||
entity.power().graph.add(other.entity.power().graph);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,8 +189,8 @@ public class PowerNode extends PowerBlock{
|
||||
}
|
||||
});
|
||||
}else{
|
||||
while(entity.getPower().links.size > 0){
|
||||
tile.configure(entity.getPower().links.get(0));
|
||||
while(entity.power().links.size > 0){
|
||||
tile.configure(entity.power().links.get(0));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@@ -267,8 +267,8 @@ public class PowerNode extends PowerBlock{
|
||||
|
||||
Tilec entity = tile.ent();
|
||||
|
||||
for(int i = 0; i < entity.getPower().links.size; i++){
|
||||
Tile link = world.tile(entity.getPower().links.get(i));
|
||||
for(int i = 0; i < entity.power().links.size; i++){
|
||||
Tile link = world.tile(entity.power().links.get(i));
|
||||
|
||||
if(!linkValid(tile, link)) continue;
|
||||
|
||||
|
||||
@@ -47,7 +47,8 @@ public class LaunchPad extends StorageBlock{
|
||||
public void draw(Tile tile){
|
||||
super.draw(tile);
|
||||
|
||||
float progress = Mathf.clamp(Mathf.clamp((tile.entity.items().total() / (float)itemCapacity)) * ((tile.entity.timerTime(timerLaunch) / (launchTime / tile.entity.timeScale))));
|
||||
//TODO broken
|
||||
float progress = Mathf.clamp(Mathf.clamp((tile.entity.items().total() / (float)itemCapacity)) * ((tile.entity.timer().getTime(timerLaunch) / (launchTime / tile.entity.timeScale()))));
|
||||
float scale = size / 3f;
|
||||
|
||||
Lines.stroke(2f);
|
||||
@@ -72,7 +73,7 @@ public class LaunchPad extends StorageBlock{
|
||||
public void update(Tile tile){
|
||||
Tilec entity = tile.entity;
|
||||
|
||||
if(world.isZone() && entity.consValid() && entity.items().total() >= itemCapacity && entity.timer(timerLaunch, launchTime / entity.timeScale)){
|
||||
if(world.isZone() && entity.consValid() && entity.items().total() >= itemCapacity && entity.timer(timerLaunch, launchTime / entity.timeScale())){
|
||||
for(Item item : Vars.content.items()){
|
||||
Events.fire(Trigger.itemLaunch);
|
||||
Fx.padlaunch.at(tile);
|
||||
|
||||
@@ -63,7 +63,7 @@ public class Unloader extends Block{
|
||||
public void update(Tile tile){
|
||||
UnloaderEntity entity = tile.ent();
|
||||
|
||||
if(tile.entity.timer(timerUnload, speed / entity.timeScale) && tile.entity.items().total() == 0){
|
||||
if(tile.entity.timer(timerUnload, speed / entity.timeScale()) && tile.entity.items().total() == 0){
|
||||
for(Tile other : tile.entity.proximity()){
|
||||
if(other.interactable(tile.team()) && other.block().unloadable && other.block().hasItems && entity.items().total() == 0 &&
|
||||
((entity.sortItem == null && other.entity.items().total() > 0) || hasItem(other, entity.sortItem))){
|
||||
|
||||
@@ -57,7 +57,7 @@ public class CommandCenter extends Block{
|
||||
ObjectSet<Tile> set = indexer.getAllied(tile.team(), BlockFlag.comandCenter);
|
||||
|
||||
if(set.size == 1){
|
||||
Groups.unit.each(t -> t.team() == tile.team(), u -> u.onCommand(UnitCommand.all[0]));
|
||||
Groups.unit.each(t -> t.team() == tile.team(), u -> u.controller().command(UnitCommand.all[0]));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ public class CommandCenter extends Block{
|
||||
}
|
||||
}
|
||||
|
||||
Groups.unit.each(t -> t.team() == tile.team(), u -> u.onCommand(command));
|
||||
Groups.unit.each(t -> t.team() == tile.team(), u -> u.controller().command(command));
|
||||
Events.fire(new CommandIssueEvent(tile, command));
|
||||
}
|
||||
|
||||
@@ -132,8 +132,8 @@ public class CommandCenter extends Block{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(DataInput stream, byte version) throws IOException{
|
||||
super.read(stream, version);
|
||||
public void read(DataInput stream) throws IOException{
|
||||
super.read(stream);
|
||||
command = UnitCommand.all[stream.readByte()];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,27 +1,24 @@
|
||||
package mindustry.world.blocks.units;
|
||||
|
||||
import arc.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import arc.struct.EnumSet;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.util.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.ArcAnnotate.*;
|
||||
import arc.util.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
//TODO remove
|
||||
public class MechPad extends Block{
|
||||
public @NonNull UnitDef mech;
|
||||
public float buildTime = 60 * 5;
|
||||
@@ -50,7 +47,7 @@ public class MechPad extends Block{
|
||||
MechFactoryEntity entity = tile.ent();
|
||||
|
||||
if(!entity.consValid()) return;
|
||||
player.beginRespawning(entity);
|
||||
//player.beginRespawning(entity);
|
||||
entity.sameMech = false;
|
||||
}
|
||||
|
||||
@@ -63,24 +60,24 @@ public class MechPad extends Block{
|
||||
Fx.spawn.at(entity);
|
||||
|
||||
if(entity.player == null) return;
|
||||
Mech mech = ((MechPad)tile.block()).mech;
|
||||
boolean resetSpawner = !entity.sameMech && entity.player.mech == mech;
|
||||
entity.player.mech = !entity.sameMech && entity.player.mech == mech ? UnitTypes.starter : mech;
|
||||
//Mech mech = ((MechPad)tile.block()).mech;
|
||||
//boolean resetSpawner = !entity.sameMech && entity.player.mech == mech;
|
||||
//entity.player.mech = !entity.sameMech && entity.player.mech == mech ? UnitTypes.starter : mech;
|
||||
|
||||
Playerc player = entity.player;
|
||||
|
||||
entity.progress = 0;
|
||||
entity.player.onRespawn(tile);
|
||||
if(resetSpawner) entity.player.lastSpawner = null;
|
||||
entity.player = null;
|
||||
//entity.progress = 0;
|
||||
//entity.player.onRespawn(tile);
|
||||
//if(resetSpawner) entity.player.lastSpawner = null;
|
||||
//entity.player = null;
|
||||
|
||||
Events.fire(new MechChangeEvent(player, player.mech));
|
||||
//Events.fire(new MechChangeEvent(player, player.mech));
|
||||
}
|
||||
|
||||
protected static boolean checkValidTap(Tile tile, Playerc player){
|
||||
MechFactoryEntity entity = tile.ent();
|
||||
return !player.dead() && tile.interactable(player.team()) && Math.abs(player.x - tile.drawx()) <= tile.block().size * tilesize &&
|
||||
Math.abs(player.y - tile.drawy()) <= tile.block().size * tilesize && entity.consValid() && entity.player == null;
|
||||
return false;//!player.dead() && tile.interactable(player.team()) && Math.abs(player.x - tile.drawx()) <= tile.block().size * tilesize &&
|
||||
//Math.abs(player.y - tile.drawy()) <= tile.block().size * tilesize && entity.consValid() && entity.player == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -101,7 +98,8 @@ public class MechPad extends Block{
|
||||
Call.onMechFactoryTap(player, tile);
|
||||
}else if(player.isLocal() && mobile && !player.dead() && entity.consValid() && entity.player == null){
|
||||
//deselect on double taps
|
||||
player.moveTarget = player.moveTarget == tile.entity ? null : tile.entity;
|
||||
//TODO remove
|
||||
//player.moveTarget = player.moveTarget == tile.entity ? null : tile.entity;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,7 +108,8 @@ public class MechPad extends Block{
|
||||
MechFactoryEntity entity = tile.ent();
|
||||
|
||||
if(entity.player != null){
|
||||
RespawnBlock.drawRespawn(tile, entity.heat, entity.progress, entity.time, entity.player, (!entity.sameMech && entity.player.mech == mech ? UnitTypes.starter : mech));
|
||||
//TODO remove
|
||||
//RespawnBlock.drawRespawn(tile, entity.heat, entity.progress, entity.time, entity.player, (!entity.sameMech && entity.player.mech == mech ? UnitTypes.starter : mech));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
package mindustry.world.blocks.units;
|
||||
|
||||
import arc.struct.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
public class RallyPoint extends Block{
|
||||
|
||||
public RallyPoint(String name){
|
||||
super(name);
|
||||
update = solid = true;
|
||||
flags = EnumSet.of(BlockFlag.rally);
|
||||
}
|
||||
}
|
||||
@@ -95,7 +95,7 @@ public class RepairPoint extends Block{
|
||||
Draw.color(Color.valueOf("e8ffd7"));
|
||||
Drawf.laser(laser, laserEnd,
|
||||
tile.drawx() + Angles.trnsx(ang, len), tile.drawy() + Angles.trnsy(ang, len),
|
||||
entity.target.x, entity.target.y, entity.strength);
|
||||
entity.target.x(), entity.target.y(), entity.strength);
|
||||
Draw.color();
|
||||
}
|
||||
}
|
||||
@@ -110,11 +110,10 @@ public class RepairPoint extends Block{
|
||||
RepairPointEntity entity = tile.ent();
|
||||
|
||||
boolean targetIsBeingRepaired = false;
|
||||
if(entity.target != null && (entity.target.dead() || entity.target.dst(tile) > repairRadius || entity.target.health >= entity.target.maxHealth())){
|
||||
if(entity.target != null && (entity.target.dead() || entity.target.dst(tile) > repairRadius || entity.target.health() >= entity.target.maxHealth())){
|
||||
entity.target = null;
|
||||
}else if(entity.target != null && entity.consValid()){
|
||||
entity.target.health += repairSpeed * Time.delta() * entity.strength * entity.efficiency();
|
||||
entity.target.clampHealth();
|
||||
entity.target.heal(repairSpeed * Time.delta() * entity.strength * entity.efficiency());
|
||||
entity.rotation = Mathf.slerpDelta(entity.rotation, entity.angleTo(entity.target), 0.5f);
|
||||
targetIsBeingRepaired = true;
|
||||
}
|
||||
@@ -127,8 +126,7 @@ public class RepairPoint extends Block{
|
||||
|
||||
if(entity.timer(timerTarget, 20)){
|
||||
rect.setSize(repairRadius * 2).setCenter(tile.drawx(), tile.drawy());
|
||||
entity.target = Units.closest(tile.team(), tile.drawx(), tile.drawy(), repairRadius,
|
||||
unit -> unit.health < unit.maxHealth());
|
||||
entity.target = Units.closest(tile.team(), tile.drawx(), tile.drawy(), repairRadius, Unitc::damaged);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,12 +39,12 @@ public class ConsumeLiquid extends ConsumeLiquidBase{
|
||||
|
||||
@Override
|
||||
public void update(Tilec entity){
|
||||
entity.getLiquids().remove(liquid, Math.min(use(entity), entity.getLiquids().get(liquid)));
|
||||
entity.liquids().remove(liquid, Math.min(use(entity), entity.liquids().get(liquid)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean valid(Tilec entity){
|
||||
return entity != null && entity.getLiquids() != null && entity.getLiquids().get(liquid) >= use(entity);
|
||||
return entity != null && entity.liquids() != null && entity.liquids().get(liquid) >= use(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,6 +23,6 @@ public abstract class ConsumeLiquidBase extends Consume{
|
||||
}
|
||||
|
||||
protected float use(Tilec entity){
|
||||
return Math.min(amount * entity.delta(), entity.block.liquidCapacity);
|
||||
return Math.min(amount * entity.delta(), entity.block().liquidCapacity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public class ConsumePower extends Consume{
|
||||
|
||||
@Override
|
||||
public void update(Tilec entity){
|
||||
// Nothing to do since PowerGraph directly updates entity.getPower().status
|
||||
// Nothing to do since PowerGraph directly updates entity.power().status
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,7 +15,7 @@ public class ConsumeModule extends BlockModule{
|
||||
|
||||
public void update(){
|
||||
//everything is valid here
|
||||
if(entity.tile.isEnemyCheat()){
|
||||
if(entity.tile().isEnemyCheat()){
|
||||
valid = optionalValid = true;
|
||||
return;
|
||||
}
|
||||
@@ -23,9 +23,9 @@ public class ConsumeModule extends BlockModule{
|
||||
boolean prevValid = valid();
|
||||
valid = true;
|
||||
optionalValid = true;
|
||||
boolean docons = entity.block.shouldConsume(entity.tile) && entity.block.productionValid(entity.tile);
|
||||
boolean docons = entity.block().shouldConsume(entity.tile()) && entity.block().productionValid(entity.tile());
|
||||
|
||||
for(Consume cons : entity.block.consumes.all()){
|
||||
for(Consume cons : entity.block().consumes.all()){
|
||||
if(cons.isOptional()) continue;
|
||||
|
||||
if(docons && cons.isUpdate() && prevValid && cons.valid(entity)){
|
||||
@@ -35,7 +35,7 @@ public class ConsumeModule extends BlockModule{
|
||||
valid &= cons.valid(entity);
|
||||
}
|
||||
|
||||
for(Consume cons : entity.block.consumes.optionals()){
|
||||
for(Consume cons : entity.block().consumes.optionals()){
|
||||
if(docons && cons.isUpdate() && prevValid && cons.valid(entity)){
|
||||
cons.update(entity);
|
||||
}
|
||||
@@ -45,13 +45,13 @@ public class ConsumeModule extends BlockModule{
|
||||
}
|
||||
|
||||
public void trigger(){
|
||||
for(Consume cons : entity.block.consumes.all()){
|
||||
for(Consume cons : entity.block().consumes.all()){
|
||||
cons.trigger(entity);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean valid(){
|
||||
return valid && entity.block.shouldConsume(entity.tile);
|
||||
return valid && entity.block().shouldConsume(entity.tile());
|
||||
}
|
||||
|
||||
public boolean optionalValid(){
|
||||
|
||||
@@ -12,6 +12,9 @@ public class ItemModule extends BlockModule{
|
||||
private int[] items = new int[content.items().size];
|
||||
private int total;
|
||||
|
||||
// Make the take() loop persistent so it does not return the same item twice in a row unless there is nothing else to return.
|
||||
protected int takeRotation;
|
||||
|
||||
public void forEach(ItemConsumer cons){
|
||||
for(int i = 0; i < items.length; i++){
|
||||
if(items[i] > 0){
|
||||
@@ -68,10 +71,13 @@ public class ItemModule extends BlockModule{
|
||||
|
||||
public Item take(){
|
||||
for(int i = 0; i < items.length; i++){
|
||||
if(items[i] > 0){
|
||||
items[i]--;
|
||||
total--;
|
||||
return content.item(i);
|
||||
int index = (i + takeRotation);
|
||||
if(index >= items.length) index -= items.length; //conditional instead of mod
|
||||
if(items[index] > 0){
|
||||
items[index] --;
|
||||
total --;
|
||||
takeRotation = index + 1;
|
||||
return content.item(index % items.length);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user