Dacite decoration block / Environmental renaming
This commit is contained in:
@@ -51,7 +51,7 @@ public class Edges{
|
||||
}
|
||||
|
||||
public static Tile getFacingEdge(Building tile, Building other){
|
||||
return getFacingEdge(tile.block(), tile.tileX(), tile.tileY(), other.tile());
|
||||
return getFacingEdge(tile.block, tile.tileX(), tile.tileY(), other.tile());
|
||||
}
|
||||
|
||||
public static Tile getFacingEdge(Tile tile, Tile other){
|
||||
|
||||
@@ -456,7 +456,7 @@ public class Tile implements Position, QuadTreeObject, Displayable{
|
||||
build.removeFromProximity();
|
||||
|
||||
//remove this tile's dangling entities
|
||||
if(build.block().isMultiblock()){
|
||||
if(build.block.isMultiblock()){
|
||||
int cx = build.tileX(), cy = build.tileY();
|
||||
int size = build.block.size;
|
||||
int offsetx = -(size - 1) / 2;
|
||||
@@ -521,7 +521,7 @@ public class Tile implements Position, QuadTreeObject, Displayable{
|
||||
//since the entity won't update proximity for us, update proximity for all nearby tiles manually
|
||||
for(Point2 p : Geometry.d4){
|
||||
Building tile = world.build(x + p.x, y + p.y);
|
||||
if(tile != null && !tile.tile().changing){
|
||||
if(tile != null && !tile.tile.changing){
|
||||
tile.onProximityUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,7 +104,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.getNearbyEntity(realDir) != null && !tile.getNearbyEntity(realDir).block.squareSprite)){
|
||||
blendresult[4] |= (1 << i);
|
||||
}
|
||||
}
|
||||
@@ -147,7 +147,7 @@ public interface Autotiler{
|
||||
|
||||
default boolean blends(Tile tile, int rotation, int direction){
|
||||
Building other = tile.getNearbyEntity(Mathf.mod(rotation - direction, 4));
|
||||
return other != null && other.team == tile.team() && blends(tile, rotation, other.tileX(), other.tileY(), other.rotation, other.block());
|
||||
return other != null && other.team == tile.team() && blends(tile, rotation, other.tileX(), other.tileY(), other.rotation, other.block);
|
||||
}
|
||||
|
||||
default boolean blendsArmored(Tile tile, int rotation, int otherx, int othery, int otherrot, Block otherblock){
|
||||
|
||||
@@ -77,7 +77,7 @@ public class MendProjector extends Block{
|
||||
|
||||
indexer.eachBlock(this, realRange, other -> other.damaged(), other -> {
|
||||
other.heal(other.maxHealth() * (healPercent + phaseHeat * phaseBoost) / 100f * efficiency());
|
||||
Fx.healBlockFull.at(other.x, other.y, other.block().size, Tmp.c1.set(baseColor).lerp(phaseColor, phaseHeat));
|
||||
Fx.healBlockFull.at(other.x, other.y, other.block.size, Tmp.c1.set(baseColor).lerp(phaseColor, phaseHeat));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ public class OverdriveProjector extends Block{
|
||||
public void drawSelect(){
|
||||
float realRange = range + phaseHeat * phaseRangeBoost;
|
||||
|
||||
indexer.eachBlock(this, realRange, other -> other.block().canOverdrive, other -> Drawf.selected(other, Tmp.c1.set(baseColor).a(Mathf.absin(4f, 1f))));
|
||||
indexer.eachBlock(this, realRange, other -> other.block.canOverdrive, other -> Drawf.selected(other, Tmp.c1.set(baseColor).a(Mathf.absin(4f, 1f))));
|
||||
|
||||
Drawf.dashCircle(x, y, realRange, baseColor);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ public class ArmoredConveyor extends Conveyor{
|
||||
public class ArmoredConveyorBuild extends ConveyorBuild{
|
||||
@Override
|
||||
public boolean acceptItem(Building source, Item item){
|
||||
return super.acceptItem(source, item) && (source.block() instanceof Conveyor || Edges.getFacingEdge(source.tile(), tile).relativeTo(tile) == rotation);
|
||||
return super.acceptItem(source, item) && (source.block instanceof Conveyor || Edges.getFacingEdge(source.tile(), tile).relativeTo(tile) == rotation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -289,9 +289,9 @@ public class Conveyor extends Block implements Autotiler{
|
||||
@Override
|
||||
public boolean acceptItem(Building source, Item item){
|
||||
if(len >= capacity) return false;
|
||||
Tile facing = Edges.getFacingEdge(source.tile(), tile);
|
||||
Tile facing = Edges.getFacingEdge(source.tile, tile);
|
||||
int direction = Math.abs(facing.relativeTo(tile.x, tile.y) - rotation);
|
||||
return (((direction == 0) && minitem >= itemSpace) || ((direction % 2 == 1) && minitem > 0.7f)) && !(source.block().rotate && (source.rotation + 2) % 4 == rotation);
|
||||
return (((direction == 0) && minitem >= itemSpace) || ((direction % 2 == 1) && minitem > 0.7f)) && !(source.block.rotate && (source.rotation + 2) % 4 == rotation);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -299,7 +299,7 @@ public class Conveyor extends Block implements Autotiler{
|
||||
if(len >= capacity) return;
|
||||
|
||||
int r = rotation;
|
||||
Tile facing = Edges.getFacingEdge(source.tile(), tile);
|
||||
Tile facing = Edges.getFacingEdge(source.tile, tile);
|
||||
int ang = ((facing.relativeTo(tile.x, tile.y) - r));
|
||||
float x = (ang == -1 || ang == 3) ? 1 : (ang == 1 || ang == -3) ? -1 : 0;
|
||||
|
||||
|
||||
@@ -214,7 +214,7 @@ public class ItemBridge extends Block{
|
||||
return true;
|
||||
}
|
||||
|
||||
if(linkValid(tile, other.tile())){
|
||||
if(linkValid(tile, other.tile)){
|
||||
if(link == other.pos()){
|
||||
configure(-1);
|
||||
}else{
|
||||
@@ -358,7 +358,7 @@ public class ItemBridge extends Block{
|
||||
}
|
||||
|
||||
protected boolean linked(Building source){
|
||||
return source instanceof ItemBridgeBuild && linkValid(source.tile(), tile) && ((ItemBridgeBuild)source).link == pos();
|
||||
return source instanceof ItemBridgeBuild && linkValid(source.tile, tile) && ((ItemBridgeBuild)source).link == pos();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -369,7 +369,7 @@ public class ItemBridge extends Block{
|
||||
protected boolean checkDump(Building to){
|
||||
Tile other = world.tile(link);
|
||||
if(!linkValid(tile, other)){
|
||||
Tile edge = Edges.getFacingEdge(to.tile(), tile);
|
||||
Tile edge = Edges.getFacingEdge(to.tile, tile);
|
||||
int i = relativeTo(edge.x, edge.y);
|
||||
|
||||
IntSetIterator it = incoming.iterator();
|
||||
|
||||
@@ -62,7 +62,7 @@ public class MassDriver extends Block{
|
||||
//check if a mass driver is selected while placing this driver
|
||||
if(!control.input.frag.config.isShown()) return;
|
||||
Building selected = control.input.frag.config.getSelectedTile();
|
||||
if(selected == null || !(selected.block() instanceof MassDriver) || !(selected.within(x * tilesize, y * tilesize, range))) return;
|
||||
if(selected == null || !(selected.block instanceof MassDriver) || !(selected.within(x * tilesize, y * tilesize, range))) return;
|
||||
|
||||
//if so, draw a dotted line towards it while it is in range
|
||||
float sin = Mathf.absin(Time.time(), 6f, 1f);
|
||||
@@ -155,7 +155,7 @@ public class MassDriver extends Block{
|
||||
|
||||
if(
|
||||
items.total() >= minDistribute && //must shoot minimum amount of items
|
||||
link.block().itemCapacity - link.items.total() >= minDistribute //must have minimum amount of space
|
||||
link.block.itemCapacity - link.items.total() >= minDistribute //must have minimum amount of space
|
||||
){
|
||||
MassDriverBuild other = (MassDriverBuild)link;
|
||||
other.waitingShooters.add(tile);
|
||||
@@ -225,7 +225,7 @@ public class MassDriver extends Block{
|
||||
if(link == other.pos()){
|
||||
configure(-1);
|
||||
return false;
|
||||
}else if(other.block() instanceof MassDriver && other.dst(tile) <= range && other.team == team){
|
||||
}else if(other.block instanceof MassDriver && other.dst(tile) <= range && other.team == team){
|
||||
configure(other.pos());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -91,14 +91,14 @@ public class OverflowGate extends Block{
|
||||
int from = relativeToEdge(src);
|
||||
if(from == -1) return null;
|
||||
Building to = nearby((from + 2) % 4);
|
||||
boolean canForward = to != null && to.acceptItem(this, item) && to.team == team && !(to.block() instanceof OverflowGate);
|
||||
boolean canForward = to != null && to.acceptItem(this, item) && to.team == team && !(to.block instanceof OverflowGate);
|
||||
boolean inv = invert == enabled;
|
||||
|
||||
if(!canForward || inv){
|
||||
Building a = nearby(Mathf.mod(from - 1, 4));
|
||||
Building b = nearby(Mathf.mod(from + 1, 4));
|
||||
boolean ac = a != null && a.acceptItem(this, item) && !(a.block() instanceof OverflowGate) && a.team == team;
|
||||
boolean bc = b != null && b.acceptItem(this, item) && !(b.block() instanceof OverflowGate) && b.team == team;
|
||||
boolean ac = a != null && a.acceptItem(this, item) && !(a.block instanceof OverflowGate) && a.team == team;
|
||||
boolean bc = b != null && b.acceptItem(this, item) && !(b.block instanceof OverflowGate) && b.team == team;
|
||||
|
||||
if(!ac && !bc){
|
||||
return inv && canForward ? to : null;
|
||||
|
||||
@@ -43,8 +43,8 @@ public class PayloadConveyor extends Block{
|
||||
|
||||
for(int i = 0; i < 4; i++){
|
||||
Building other = world.build(x + Geometry.d4x[i] * size, y + Geometry.d4y[i] * size);
|
||||
if(other != null && other.block().outputsPayload && other.block().size == size){
|
||||
Drawf.selected(other.tileX(), other.tileY(), other.block(), Pal.accent);
|
||||
if(other != null && other.block.outputsPayload && other.block.size == size){
|
||||
Drawf.selected(other.tileX(), other.tileY(), other.block, Pal.accent);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -71,13 +71,13 @@ public class PayloadConveyor extends Block{
|
||||
//next block must be aligned and of the same size
|
||||
if(accept != null && (
|
||||
//same size
|
||||
(accept.block().size == size && tileX() + Geometry.d4(rotation).x * size == accept.tileX() && tileY() + Geometry.d4(rotation).y * size == accept.tileY()) ||
|
||||
(accept.block.size == size && tileX() + Geometry.d4(rotation).x * size == accept.tileX() && tileY() + Geometry.d4(rotation).y * size == accept.tileY()) ||
|
||||
|
||||
//differing sizes
|
||||
(accept.block().size > size &&
|
||||
(accept.block.size > size &&
|
||||
(rotation % 2 == 0 ? //check orientation
|
||||
Math.abs(accept.y - y) <= (accept.block().size * tilesize - size * tilesize)/2f : //check Y alignment
|
||||
Math.abs(accept.x - x) <= (accept.block().size * tilesize - size * tilesize)/2f //check X alignment
|
||||
Math.abs(accept.y - y) <= (accept.block.size * tilesize - size * tilesize)/2f : //check Y alignment
|
||||
Math.abs(accept.x - x) <= (accept.block.size * tilesize - size * tilesize)/2f //check X alignment
|
||||
)))){
|
||||
next = accept;
|
||||
}else{
|
||||
|
||||
@@ -35,7 +35,7 @@ public class Router extends Block{
|
||||
time += 1f / speed * delta();
|
||||
Building target = getTileTarget(lastItem, lastInput, false);
|
||||
|
||||
if(target != null && (time >= 1f || !(target.block() instanceof Router || target.block().instantTransfer))){
|
||||
if(target != null && (time >= 1f || !(target.block instanceof Router || target.block.instantTransfer))){
|
||||
getTileTarget(lastItem, lastInput, true);
|
||||
target.handleItem(this, lastItem);
|
||||
items.remove(lastItem, 1);
|
||||
|
||||
@@ -88,7 +88,7 @@ public class Sorter extends Block{
|
||||
|
||||
public boolean isSame(Building other){
|
||||
// comment code below to allow sorter/gate chaining
|
||||
return other != null && other.block().instantTransfer;
|
||||
return other != null && other.block.instantTransfer;
|
||||
}
|
||||
|
||||
public Building getTileTarget(Item item, Building source, boolean flip){
|
||||
@@ -105,9 +105,9 @@ public class Sorter extends Block{
|
||||
}else{
|
||||
Building a = nearby(Mathf.mod(dir - 1, 4));
|
||||
Building b = nearby(Mathf.mod(dir + 1, 4));
|
||||
boolean ac = a != null && !(a.block().instantTransfer && source.block().instantTransfer) &&
|
||||
boolean ac = a != null && !(a.block.instantTransfer && source.block.instantTransfer) &&
|
||||
a.acceptItem(this, item);
|
||||
boolean bc = b != null && !(b.block().instantTransfer && source.block().instantTransfer) &&
|
||||
boolean bc = b != null && !(b.block.instantTransfer && source.block.instantTransfer) &&
|
||||
b.acceptItem(this, item);
|
||||
|
||||
if(ac && !bc){
|
||||
|
||||
@@ -7,10 +7,10 @@ import arc.math.Mathf;
|
||||
import mindustry.world.Block;
|
||||
import mindustry.world.Tile;
|
||||
|
||||
public class Rock extends Block{
|
||||
public class Boulder extends Block{
|
||||
protected int variants;
|
||||
|
||||
public Rock(String name){
|
||||
public Boulder(String name){
|
||||
super(name);
|
||||
breakable = true;
|
||||
alwaysReplace = true;
|
||||
@@ -112,7 +112,7 @@ public class Floor extends Block{
|
||||
if(wall == null) wall = Blocks.air;
|
||||
|
||||
if(decoration == Blocks.air){
|
||||
decoration = content.blocks().min(b -> b instanceof Rock && b.breakable ? mapColor.diff(b.mapColor) : Float.POSITIVE_INFINITY);
|
||||
decoration = content.blocks().min(b -> b instanceof Boulder && b.breakable ? mapColor.diff(b.mapColor) : Float.POSITIVE_INFINITY);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import mindustry.world.*;
|
||||
|
||||
import static mindustry.Vars.world;
|
||||
|
||||
public class StaticWall extends Rock{
|
||||
public class StaticWall extends Boulder{
|
||||
public @Load("@-large") TextureRegion large;
|
||||
public TextureRegion[][] split;
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ public class BlockLoader extends PayloadAcceptor{
|
||||
public boolean acceptPayload(Building source, Payload payload){
|
||||
return super.acceptPayload(source, payload) &&
|
||||
(payload instanceof BlockPayload) &&
|
||||
((((BlockPayload)payload).entity.block().hasItems && ((BlockPayload)payload).block().unloadable && ((BlockPayload)payload).block().itemCapacity >= 10)/* ||
|
||||
((((BlockPayload)payload).entity.block.hasItems && ((BlockPayload)payload).block().unloadable && ((BlockPayload)payload).block().itemCapacity >= 10)/* ||
|
||||
((BlockPayload)payload).entity.block().hasLiquids && ((BlockPayload)payload).block().liquidCapacity >= 10f)*/);
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ public class BlockLoader extends PayloadAcceptor{
|
||||
}
|
||||
|
||||
public float fraction(){
|
||||
return payload == null ? 0f : payload.entity.items.total() / (float)payload.entity.block().itemCapacity;
|
||||
return payload == null ? 0f : payload.entity.items.total() / (float)payload.entity.block.itemCapacity;
|
||||
}
|
||||
|
||||
public boolean shouldExport(){
|
||||
|
||||
@@ -56,7 +56,7 @@ public class BlockUnloader extends BlockLoader{
|
||||
|
||||
@Override
|
||||
public float fraction(){
|
||||
return payload == null ? 0f : 1f - payload.entity.items.total() / (float)payload.entity.block().itemCapacity;
|
||||
return payload == null ? 0f : 1f - payload.entity.items.total() / (float)payload.entity.block.itemCapacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -26,14 +26,14 @@ public class ArmoredConduit extends Conduit{
|
||||
|
||||
// draw the cap when a conduit would normally leak
|
||||
Building next = front();
|
||||
if(next != null && next.team == team && next.block().hasLiquids) return;
|
||||
if(next != null && next.team == team && next.block.hasLiquids) return;
|
||||
|
||||
Draw.rect(capRegion, x, y, rotdeg());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptLiquid(Building source, Liquid liquid, float amount){
|
||||
return super.acceptLiquid(source, liquid, amount) && (source.block() instanceof Conduit) ||
|
||||
return super.acceptLiquid(source, liquid, amount) && (source.block instanceof Conduit) ||
|
||||
Edges.getFacingEdge(source.tile(), tile).absoluteRelativeTo(tile.x, tile.y) == rotation;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class LiquidJunction extends LiquidBlock{
|
||||
int dir = source.relativeTo(tile.x, tile.y);
|
||||
dir = (dir + 4) % 4;
|
||||
Building next = nearby(dir);
|
||||
if(next == null || (!next.acceptLiquid(this, liquid, 0f) && !(next.block() instanceof LiquidJunction))){
|
||||
if(next == null || (!next.acceptLiquid(this, liquid, 0f) && !(next.block instanceof LiquidJunction))){
|
||||
return this;
|
||||
}
|
||||
return next.getLiquidDestination(this, liquid);
|
||||
|
||||
@@ -22,7 +22,7 @@ public class BlockPayload implements Payload{
|
||||
}
|
||||
|
||||
public Block block(){
|
||||
return entity.block();
|
||||
return entity.block;
|
||||
}
|
||||
|
||||
public void place(Tile tile){
|
||||
@@ -30,7 +30,7 @@ public class BlockPayload implements Payload{
|
||||
}
|
||||
|
||||
public void place(Tile tile, int rotation){
|
||||
tile.setBlock(entity.block(), entity.team, rotation, () -> entity);
|
||||
tile.setBlock(entity.block, entity.team, rotation, () -> entity);
|
||||
entity.dropped();
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public class BlockPayload implements Payload{
|
||||
@Override
|
||||
public void write(Writes write){
|
||||
write.b(payloadBlock);
|
||||
write.s(entity.block().id);
|
||||
write.s(entity.block.id);
|
||||
write.b(entity.version());
|
||||
entity.writeAll(write);
|
||||
}
|
||||
@@ -54,7 +54,7 @@ public class BlockPayload implements Payload{
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
Drawf.shadow(entity.x, entity.y, entity.block().size * tilesize * 2f);
|
||||
Draw.rect(entity.block().icon(Cicon.full), entity.x, entity.y);
|
||||
Drawf.shadow(entity.x, entity.y, entity.block.size * tilesize * 2f);
|
||||
Draw.rect(entity.block.icon(Cicon.full), entity.x, entity.y);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public class PowerDiode extends Block{
|
||||
|
||||
// battery % of the graph on either side, defaults to zero
|
||||
public float bar(Building tile){
|
||||
return (tile != null && tile.block().hasPower) ? tile.power.graph.getLastPowerStored() / tile.power.graph.getTotalBatteryCapacity() : 0f;
|
||||
return (tile != null && tile.block.hasPower) ? tile.power.graph.getLastPowerStored() / tile.power.graph.getTotalBatteryCapacity() : 0f;
|
||||
}
|
||||
|
||||
public class PowerDiodeBuild extends Building{
|
||||
@@ -54,7 +54,7 @@ public class PowerDiode extends Block{
|
||||
public void updateTile(){
|
||||
super.updateTile();
|
||||
|
||||
if(front() == null || back() == null || !back().block().hasPower || !front().block().hasPower || back().team != front().team) return;
|
||||
if(front() == null || back() == null || !back().block.hasPower || !front().block.hasPower || back().team != front().team) return;
|
||||
|
||||
PowerGraph backGraph = back().power.graph;
|
||||
PowerGraph frontGraph = front().power.graph;
|
||||
|
||||
@@ -74,7 +74,7 @@ public class PowerGraph{
|
||||
public float getPowerNeeded(){
|
||||
float powerNeeded = 0f;
|
||||
for(Building consumer : consumers){
|
||||
Consumers consumes = consumer.block().consumes;
|
||||
Consumers consumes = consumer.block.consumes;
|
||||
if(consumes.hasPower()){
|
||||
ConsumePower consumePower = consumes.getPower();
|
||||
if(otherConsumersAreValid(consumer, consumePower)){
|
||||
@@ -88,7 +88,7 @@ public class PowerGraph{
|
||||
public float getBatteryStored(){
|
||||
float totalAccumulator = 0f;
|
||||
for(Building battery : batteries){
|
||||
Consumers consumes = battery.block().consumes;
|
||||
Consumers consumes = battery.block.consumes;
|
||||
if(consumes.hasPower()){
|
||||
totalAccumulator += battery.power.status * consumes.getPower().capacity;
|
||||
}
|
||||
@@ -99,8 +99,8 @@ public class PowerGraph{
|
||||
public float getBatteryCapacity(){
|
||||
float totalCapacity = 0f;
|
||||
for(Building battery : batteries){
|
||||
if(battery.block().consumes.hasPower()){
|
||||
ConsumePower power = battery.block().consumes.getPower();
|
||||
if(battery.block.consumes.hasPower()){
|
||||
ConsumePower power = battery.block.consumes.getPower();
|
||||
totalCapacity += (1f - battery.power.status) * power.capacity;
|
||||
}
|
||||
}
|
||||
@@ -110,8 +110,8 @@ public class PowerGraph{
|
||||
public float getTotalBatteryCapacity(){
|
||||
float totalCapacity = 0f;
|
||||
for(Building battery : batteries){
|
||||
if(battery.block().consumes.hasPower()){
|
||||
totalCapacity += battery.block().consumes.getPower().capacity;
|
||||
if(battery.block.consumes.hasPower()){
|
||||
totalCapacity += battery.block.consumes.getPower().capacity;
|
||||
}
|
||||
}
|
||||
return totalCapacity;
|
||||
@@ -124,7 +124,7 @@ public class PowerGraph{
|
||||
float used = Math.min(stored, needed);
|
||||
float consumedPowerPercentage = Math.min(1.0f, needed / stored);
|
||||
for(Building battery : batteries){
|
||||
Consumers consumes = battery.block().consumes;
|
||||
Consumers consumes = battery.block.consumes;
|
||||
if(consumes.hasPower()){
|
||||
battery.power.status *= (1f-consumedPowerPercentage);
|
||||
}
|
||||
@@ -139,7 +139,7 @@ public class PowerGraph{
|
||||
if(Mathf.equal(capacity, 0f)) return 0f;
|
||||
|
||||
for(Building battery : batteries){
|
||||
Consumers consumes = battery.block().consumes;
|
||||
Consumers consumes = battery.block.consumes;
|
||||
if(consumes.hasPower()){
|
||||
ConsumePower consumePower = consumes.getPower();
|
||||
if(consumePower.capacity > 0f){
|
||||
@@ -154,7 +154,7 @@ public class PowerGraph{
|
||||
//distribute even if not needed. this is because some might be requiring power but not using it; it updates consumers
|
||||
float coverage = Mathf.zero(needed) && Mathf.zero(produced) ? 0f : Mathf.zero(needed) ? 1f : Math.min(1, produced / needed);
|
||||
for(Building consumer : consumers){
|
||||
Consumers consumes = consumer.block().consumes;
|
||||
Consumers consumes = consumer.block.consumes;
|
||||
if(consumes.hasPower()){
|
||||
ConsumePower consumePower = consumes.getPower();
|
||||
if(consumePower.buffered){
|
||||
@@ -237,14 +237,14 @@ public class PowerGraph{
|
||||
tile.power.graph = this;
|
||||
all.add(tile);
|
||||
|
||||
if(tile.block().outputsPower && tile.block().consumesPower && !tile.block().consumes.getPower().buffered){
|
||||
if(tile.block.outputsPower && tile.block.consumesPower && !tile.block.consumes.getPower().buffered){
|
||||
producers.add(tile);
|
||||
consumers.add(tile);
|
||||
}else if(tile.block().outputsPower && tile.block().consumesPower){
|
||||
}else if(tile.block.outputsPower && tile.block.consumesPower){
|
||||
batteries.add(tile);
|
||||
}else if(tile.block().outputsPower){
|
||||
}else if(tile.block.outputsPower){
|
||||
producers.add(tile);
|
||||
}else if(tile.block().consumesPower){
|
||||
}else if(tile.block.consumesPower){
|
||||
consumers.add(tile);
|
||||
}
|
||||
}
|
||||
@@ -311,7 +311,7 @@ public class PowerGraph{
|
||||
}
|
||||
|
||||
private boolean otherConsumersAreValid(Building tile, Consume consumePower){
|
||||
for(Consume cons : tile.block().consumes.all()){
|
||||
for(Consume cons : tile.block.consumes.all()){
|
||||
if(cons != consumePower && !cons.isOptional() && !cons.valid(tile)){
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -135,10 +135,10 @@ public class PowerNode extends PowerBlock{
|
||||
Drawf.circles(x * tilesize + offset, y * tilesize + offset, laserRange * tilesize);
|
||||
|
||||
getPotentialLinks(tile, other -> {
|
||||
Drawf.square(other.x, other.y, other.block().size * tilesize / 2f + 2f, Pal.place);
|
||||
Drawf.square(other.x, other.y, other.block.size * tilesize / 2f + 2f, Pal.place);
|
||||
|
||||
insulators(tile.x, tile.y, other.tileX(), other.tileY(), cause -> {
|
||||
Drawf.square(cause.x, cause.y, cause.block().size * tilesize / 2f + 2f, Pal.plastanium);
|
||||
Drawf.square(cause.x, cause.y, cause.block.size * tilesize / 2f + 2f, Pal.plastanium);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -185,9 +185,9 @@ public class PowerNode extends PowerBlock{
|
||||
|
||||
protected void getPotentialLinks(Tile tile, Cons<Building> others){
|
||||
Boolf<Building> valid = other -> other != null && other.tile() != tile && other.power != null &&
|
||||
((!other.block().outputsPower && other.block().consumesPower) || (other.block().outputsPower && !other.block().consumesPower) || other.block() instanceof PowerNode) &&
|
||||
((!other.block.outputsPower && other.block.consumesPower) || (other.block.outputsPower && !other.block.consumesPower) || other.block instanceof PowerNode) &&
|
||||
overlaps(tile.x * tilesize + offset, tile.y * tilesize + offset, other.tile(), laserRange * tilesize) && other.team == player.team()
|
||||
&& !other.proximity().contains(e -> e.tile() == tile) && !graphs.contains(other.power.graph);
|
||||
&& !other.proximity.contains(e -> e.tile == tile) && !graphs.contains(other.power.graph);
|
||||
|
||||
tempTileEnts.clear();
|
||||
graphs.clear();
|
||||
@@ -203,7 +203,7 @@ public class PowerNode extends PowerBlock{
|
||||
});
|
||||
|
||||
tempTileEnts.sort((a, b) -> {
|
||||
int type = -Boolean.compare(a.block() instanceof PowerNode, b.block() instanceof PowerNode);
|
||||
int type = -Boolean.compare(a.block instanceof PowerNode, b.block instanceof PowerNode);
|
||||
if(type != 0) return type;
|
||||
return Float.compare(a.dst2(tile), b.dst2(tile));
|
||||
});
|
||||
@@ -237,11 +237,11 @@ public class PowerNode extends PowerBlock{
|
||||
}
|
||||
|
||||
public boolean linkValid(Building tile, Building link, boolean checkMaxNodes){
|
||||
if(tile == link || link == null || !link.block().hasPower || tile.team != link.team) return false;
|
||||
if(tile == link || link == null || !link.block.hasPower || tile.team != link.team) return false;
|
||||
|
||||
if(overlaps(tile, link, laserRange * tilesize) || (link.block() instanceof PowerNode && overlaps(link, tile, ((PowerNode)link.block()).laserRange * tilesize))){
|
||||
if(checkMaxNodes && link.block() instanceof PowerNode){
|
||||
return link.power.links.size < ((PowerNode)link.block()).maxNodes || link.power.links.contains(tile.pos());
|
||||
if(overlaps(tile, link, laserRange * tilesize) || (link.block instanceof PowerNode && overlaps(link, tile, ((PowerNode)link.block).laserRange * tilesize))){
|
||||
if(checkMaxNodes && link.block instanceof PowerNode){
|
||||
return link.power.links.size < ((PowerNode)link.block).maxNodes || link.power.links.contains(tile.pos());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -266,7 +266,7 @@ public class PowerNode extends PowerBlock{
|
||||
world.raycastEach(x, y, x2, y2, (wx, wy) -> {
|
||||
|
||||
Building tile = world.build(wx, wy);
|
||||
if(tile != null && tile.block().insulated){
|
||||
if(tile != null && tile.block.insulated){
|
||||
iterator.get(tile);
|
||||
}
|
||||
|
||||
@@ -280,8 +280,8 @@ public class PowerNode extends PowerBlock{
|
||||
public void placed(){
|
||||
if(net.client()) return;
|
||||
|
||||
Boolf<Building> valid = other -> other != null && other != this && ((!other.block().outputsPower && other.block().consumesPower) ||
|
||||
(other.block().outputsPower && !other.block().consumesPower) || other.block() instanceof PowerNode) && linkValid(this, other)
|
||||
Boolf<Building> valid = other -> other != null && other != this && ((!other.block.outputsPower && other.block.consumesPower) ||
|
||||
(other.block.outputsPower && !other.block.consumesPower) || other.block instanceof PowerNode) && linkValid(this, other)
|
||||
&& !other.proximity().contains(this) && other.power.graph != power.graph;
|
||||
|
||||
tempTileEnts.clear();
|
||||
@@ -295,7 +295,7 @@ public class PowerNode extends PowerBlock{
|
||||
});
|
||||
|
||||
tempTileEnts.sort((a, b) -> {
|
||||
int type = -Boolean.compare(a.block() instanceof PowerNode, b.block() instanceof PowerNode);
|
||||
int type = -Boolean.compare(a.block instanceof PowerNode, b.block instanceof PowerNode);
|
||||
if(type != 0) return type;
|
||||
return Float.compare(a.dst2(tile), b.dst2(tile));
|
||||
});
|
||||
@@ -373,7 +373,7 @@ public class PowerNode extends PowerBlock{
|
||||
boolean linked = linked(link);
|
||||
|
||||
if(linked){
|
||||
Drawf.square(link.x, link.y, link.block().size * tilesize / 2f + 1f, Pal.place);
|
||||
Drawf.square(link.x, link.y, link.block.size * tilesize / 2f + 1f, Pal.place);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -395,7 +395,7 @@ public class PowerNode extends PowerBlock{
|
||||
|
||||
if(!linkValid(this, link)) continue;
|
||||
|
||||
if(link.block() instanceof PowerNode && !(link.pos() < tile.pos())) continue;
|
||||
if(link.block instanceof PowerNode && !(link.pos() < tile.pos())) continue;
|
||||
|
||||
drawLaserTo(link);
|
||||
}
|
||||
@@ -408,7 +408,7 @@ public class PowerNode extends PowerBlock{
|
||||
}
|
||||
|
||||
protected void drawLaserTo(Building target){
|
||||
drawLaser(team, x, y, target.x, target.y, power.graph.getSatisfaction(), size, target.block().size);
|
||||
drawLaser(team, x, y, target.x, target.y, power.graph.getSatisfaction(), size, target.block.size);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -28,22 +28,22 @@ public class PayloadAcceptor extends Block{
|
||||
}
|
||||
|
||||
public static boolean blends(Building tile, int direction){
|
||||
int size = tile.block().size;
|
||||
int size = tile.block.size;
|
||||
Building accept = tile.nearby(Geometry.d4(direction).x * size, Geometry.d4(direction).y * size);
|
||||
return accept != null &&
|
||||
accept.block().outputsPayload &&
|
||||
accept.block.outputsPayload &&
|
||||
|
||||
//if size is the same, block must either be facing this one, or not be rotating
|
||||
((accept.block().size == size &&
|
||||
((accept.block.size == size &&
|
||||
((accept.tileX() + Geometry.d4(accept.rotation).x * size == tile.tileX() && accept.tileY() + Geometry.d4(accept.rotation).y * size == tile.tileY())
|
||||
|| !accept.block().rotate || (accept.block().rotate && !accept.block().outputFacing))) ||
|
||||
|| !accept.block.rotate || (accept.block.rotate && !accept.block.outputFacing))) ||
|
||||
|
||||
//if the other block is smaller, check alignment
|
||||
(accept.block().size < size &&
|
||||
(accept.block.size < size &&
|
||||
(accept.rotation % 2 == 0 ? //check orientation; make sure it's aligned properly with this block.
|
||||
Math.abs(accept.y - tile.y) <= (size * tilesize - accept.block().size * tilesize)/2f : //check Y alignment
|
||||
Math.abs(accept.x - tile.x) <= (size * tilesize - accept.block().size * tilesize)/2f //check X alignment
|
||||
)) && (!accept.block().rotate || accept.front() == tile || !accept.block().outputFacing) //make sure it's facing this block
|
||||
Math.abs(accept.y - tile.y) <= (size * tilesize - accept.block.size * tilesize)/2f : //check Y alignment
|
||||
Math.abs(accept.x - tile.x) <= (size * tilesize - accept.block.size * tilesize)/2f //check X alignment
|
||||
)) && (!accept.block.rotate || accept.front() == tile || !accept.block.outputFacing) //make sure it's facing this block
|
||||
);
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ public class PayloadAcceptor extends Block{
|
||||
payVector.clamp(-size * tilesize / 2f, -size * tilesize / 2f, size * tilesize / 2f, size * tilesize / 2f);
|
||||
|
||||
Building front = front();
|
||||
if(front != null && front.block().outputsPayload){
|
||||
if(front != null && front.block.outputsPayload){
|
||||
if(movePayload(payload)){
|
||||
payload = null;
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@ public class CoreBlock extends StorageBlock{
|
||||
}
|
||||
state.teams.registerCore(this);
|
||||
|
||||
storageCapacity = itemCapacity + proximity().sum(e -> isContainer(e) && owns(e) ? e.block().itemCapacity : 0);
|
||||
storageCapacity = itemCapacity + proximity().sum(e -> isContainer(e) && owns(e) ? e.block.itemCapacity : 0);
|
||||
proximity.each(e -> isContainer(e) && owns(e), t -> {
|
||||
t.items = items;
|
||||
((StorageBuild)t).linkedCore = this;
|
||||
@@ -218,7 +218,7 @@ public class CoreBlock extends StorageBlock{
|
||||
|
||||
for(Building other : state.teams.cores(team)){
|
||||
if(other.tile() == tile) continue;
|
||||
storageCapacity += other.block().itemCapacity + other.proximity().sum(e -> isContainer(e) && owns(other, e) ? e.block().itemCapacity : 0);
|
||||
storageCapacity += other.block.itemCapacity + other.proximity().sum(e -> isContainer(e) && owns(other, e) ? e.block.itemCapacity : 0);
|
||||
}
|
||||
|
||||
if(!world.isGenerating()){
|
||||
@@ -238,7 +238,7 @@ public class CoreBlock extends StorageBlock{
|
||||
Cons<Building> outline = t -> {
|
||||
for(int i = 0; i < 4; i++){
|
||||
Point2 p = Geometry.d8edge[i];
|
||||
float offset = -Math.max(t.block().size - 1, 0) / 2f * tilesize;
|
||||
float offset = -Math.max(t.block.size - 1, 0) / 2f * tilesize;
|
||||
Draw.rect("block-select", t.x + offset * p.x, t.y + offset * p.y, i * 90);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -51,7 +51,7 @@ public class Unloader extends Block{
|
||||
public void updateTile(){
|
||||
if(timer(timerUnload, speed / timeScale())){
|
||||
for(Building other : proximity){
|
||||
if(other.interactable(team) && other.block().unloadable && other.block().hasItems
|
||||
if(other.interactable(team) && other.block.unloadable && other.block.hasItems
|
||||
&& ((sortItem == null && other.items.total() > 0) || (sortItem != null && other.items.has(sortItem)))){
|
||||
//make sure the item can't be dumped back into this block
|
||||
dumpingTo = other;
|
||||
@@ -99,7 +99,7 @@ public class Unloader extends Block{
|
||||
|
||||
@Override
|
||||
public boolean canDump(Building to, Item item){
|
||||
return !(to.block() instanceof StorageBlock) && to != dumpingTo;
|
||||
return !(to.block instanceof StorageBlock) && to != dumpingTo;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,6 +23,6 @@ public abstract class ConsumeLiquidBase extends Consume{
|
||||
}
|
||||
|
||||
protected float use(Building entity){
|
||||
return Math.min(amount * entity.delta(), entity.block().liquidCapacity);
|
||||
return Math.min(amount * entity.delta(), entity.block.liquidCapacity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public class ConsumeModule extends BlockModule{
|
||||
optionalValid = true;
|
||||
boolean docons = entity.shouldConsume() && entity.productionValid();
|
||||
|
||||
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)){
|
||||
@@ -47,7 +47,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);
|
||||
}
|
||||
@@ -57,7 +57,7 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user