Fixed conduits not reacting with each other

This commit is contained in:
Anuken
2020-08-23 13:25:47 -04:00
parent 5e6465e8f3
commit 2f19cab144
27 changed files with 71 additions and 74 deletions

View File

@@ -185,7 +185,7 @@ public class BlockIndexer{
if(other == null) continue;
if(other.team() == team && pred.get(other) && intSet.add(other.pos())){
if(other.team == team && pred.get(other) && intSet.add(other.pos())){
cons.get(other);
any = true;
}
@@ -212,11 +212,11 @@ public class BlockIndexer{
}
public void notifyTileDamaged(Building entity){
if(damagedTiles[entity.team().id] == null){
damagedTiles[entity.team().id] = new BuildingArray();
if(damagedTiles[entity.team.id] == null){
damagedTiles[entity.team.id] = new BuildingArray();
}
damagedTiles[entity.team().id].add(entity);
damagedTiles[entity.team.id].add(entity);
}
public Building findEnemyTile(Team team, float x, float y, float range, Boolf<Building> pred){
@@ -251,7 +251,7 @@ public class BlockIndexer{
if(e == null) continue;
if(e.team() != team || !pred.get(e) || !e.block().targetable)
if(e.team != team || !pred.get(e) || !e.block().targetable)
continue;
float ndst = e.dst2(x, y);
@@ -390,7 +390,7 @@ public class BlockIndexer{
for(int y = quadrantY * quadrantSize; y < world.height() && y < (quadrantY + 1) * quadrantSize; y++){
Building result = world.build(x, y);
//when a targetable block is found, mark this quadrant as occupied and stop searching
if(result != null && result.team() == team){
if(result != null && result.team == team){
bits.set(quadrantX, quadrantY);
break outer;
}

View File

@@ -39,7 +39,7 @@ public class SuicideAI extends GroundAI{
boolean blocked = Vars.world.raycast(unit.tileX(), unit.tileY(), target.tileX(), target.tileY(), (x, y) -> {
Tile tile = Vars.world.tile(x, y);
if(tile != null && tile.build == target) return false;
if(tile != null && tile.build != null && tile.build.team() != unit.team()){
if(tile != null && tile.build != null && tile.build.team != unit.team()){
blockedByBlock = true;
return true;
}else{

View File

@@ -87,7 +87,7 @@ public class Damage{
tr.trns(angle, length);
Intc2 collider = (cx, cy) -> {
Building tile = world.build(cx, cy);
if(tile != null && !collidedBlocks.contains(tile.pos()) && tile.team() != team && tile.collide(hitter)){
if(tile != null && !collidedBlocks.contains(tile.pos()) && tile.team != team && tile.collide(hitter)){
tile.collision(hitter);
collidedBlocks.add(tile.pos());
hitter.type.hit(hitter, tile.x, tile.y);

View File

@@ -29,7 +29,7 @@ public class HealBulletType extends BulletType{
@Override
public boolean collides(Bullet b, Building tile){
return tile.team() != b.team || tile.healthf() < 1f;
return tile.team != b.team || tile.healthf() < 1f;
}
@Override
@@ -46,7 +46,7 @@ public class HealBulletType extends BulletType{
public void hitTile(Bullet b, Building tile){
super.hit(b);
if(tile.team() == b.team && !(tile.block() instanceof BuildBlock)){
if(tile.team == b.team && !(tile.block() instanceof BuildBlock)){
Fx.healBlockFull.at(tile.x, tile.y, tile.block().size, Pal.heal);
tile.heal(healPercent / 100f * tile.maxHealth());
}

View File

@@ -27,7 +27,7 @@ abstract class BlockUnitComp implements Unitc{
@Override
public void update(){
if(tile != null){
team = tile.team();
team = tile.team;
}
}
@@ -61,7 +61,7 @@ abstract class BlockUnitComp implements Unitc{
public void team(Team team){
if(tile != null && this.team != team){
this.team = team;
if(tile.team() != team){
if(tile.team != team){
tile.team(team);
}
}

View File

@@ -410,7 +410,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
int trns = block.size/2 + 1;
Tile next = tile.getNearby(Geometry.d4(rotation).x * trns, Geometry.d4(rotation).y * trns);
if(next != null && next.build != null && next.build.team() == team && next.build.acceptPayload(base(), todump)){
if(next != null && next.build != null && next.build.team == team && next.build.acceptPayload(base(), todump)){
next.build.handlePayload(base(), todump);
return true;
}
@@ -431,7 +431,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
for(int i = 0; i < proximity.size; i++){
Building other = proximity.get((i + dump) % proximity.size);
if(other.team() == team && other.acceptPayload(base(), todump)){
if(other.team == team && other.acceptPayload(base(), todump)){
other.handlePayload(base(), todump);
incrementDump(proximity.size);
return true;
@@ -510,34 +510,31 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
next = next.getLiquidDestination(base(), liquid);
if(next.team() == team && next.block.hasLiquids && liquids.get(liquid) > 0f){
if(next.team == team && next.block.hasLiquids && liquids.get(liquid) > 0f){
float ofract = next.liquids.get(liquid) / next.block.liquidCapacity;
float fract = liquids.get(liquid) / block.liquidCapacity * block.liquidPressure;
float flow = Math.min(Mathf.clamp((fract - ofract) * (1f)) * (block.liquidCapacity), liquids.get(liquid));
flow = Math.min(flow, next.block.liquidCapacity - next.liquids.get(liquid) - 0.001f);
if(next.acceptLiquid(base(), liquid, 0f)){
float ofract = next.liquids().get(liquid) / next.block.liquidCapacity;
float fract = liquids.get(liquid) / block.liquidCapacity * block.liquidPressure;
float flow = Math.min(Mathf.clamp((fract - ofract) * (1f)) * (block.liquidCapacity), liquids.get(liquid));
flow = Math.min(flow, next.block.liquidCapacity - next.liquids().get(liquid) - 0.001f);
if(flow > 0f && ofract <= fract && next.acceptLiquid(base(), liquid, flow)){
next.handleLiquid(base(), liquid, flow);
liquids.remove(liquid, flow);
return flow;
}else if(next.liquids.currentAmount() / next.block.liquidCapacity > 0.1f && fract > 0.1f){
//TODO these are incorrect effect positions
float fx = (x + next.x) / 2f, fy = (y + next.y) / 2f;
if(flow > 0f && ofract <= fract && next.acceptLiquid(base(), liquid, flow)){
next.handleLiquid(base(), liquid, flow);
liquids.remove(liquid, flow);
return flow;
}else if(ofract > 0.1f && fract > 0.1f){
//TODO these are incorrect effect positions
float fx = (x + next.x) / 2f, fy = (y + next.y) / 2f;
Liquid other = next.liquids().current();
if((other.flammability > 0.3f && liquid.temperature > 0.7f) || (liquid.flammability > 0.3f && other.temperature > 0.7f)){
damage(1 * Time.delta);
next.damage(1 * Time.delta);
if(Mathf.chance(0.1 * Time.delta)){
Fx.fire.at(fx, fy);
}
}else if((liquid.temperature > 0.7f && other.temperature < 0.55f) || (other.temperature > 0.7f && liquid.temperature < 0.55f)){
liquids.remove(liquid, Math.min(liquids.get(liquid), 0.7f * Time.delta));
if(Mathf.chance(0.2f * Time.delta)){
Fx.steam.at(fx, fy);
}
Liquid other = next.liquids.current();
if((other.flammability > 0.3f && liquid.temperature > 0.7f) || (liquid.flammability > 0.3f && other.temperature > 0.7f)){
damage(1 * Time.delta);
next.damage(1 * Time.delta);
if(Mathf.chance(0.1 * Time.delta)){
Fx.fire.at(fx, fy);
}
}else if((liquid.temperature > 0.7f && other.temperature < 0.55f) || (other.temperature > 0.7f && liquid.temperature < 0.55f)){
liquids.remove(liquid, Math.min(liquids.get(liquid), 0.7f * Time.delta));
if(Mathf.chance(0.2f * Time.delta)){
Fx.steam.at(fx, fy);
}
}
}
@@ -568,7 +565,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
for(int i = 0; i < proximity.size; i++){
incrementDump(proximity.size);
Building other = proximity.get((i + dump) % proximity.size);
if(other.team() == team && other.acceptItem(base(), item) && canDump(other, item)){
if(other.team == team && other.acceptItem(base(), item) && canDump(other, item)){
other.handleItem(base(), item);
return;
}
@@ -586,7 +583,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
for(int i = 0; i < proximity.size; i++){
incrementDump(proximity.size);
Building other = proximity.get((i + dump) % proximity.size);
if(other.team() == team && other.acceptItem(base(), item) && canDump(other, item)){
if(other.team == team && other.acceptItem(base(), item) && canDump(other, item)){
other.handleItem(base(), item);
return true;
}
@@ -619,7 +616,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
for(int ii = 0; ii < content.items().size; ii++){
Item item = content.item(ii);
if(other.team() == team && items.has(item) && other.acceptItem(base(), item) && canDump(other, item)){
if(other.team == team && items.has(item) && other.acceptItem(base(), item) && canDump(other, item)){
other.handleItem(base(), item);
items.remove(item, 1);
incrementDump(proximity.size);
@@ -627,7 +624,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
}
}
}else{
if(other.team() == team && other.acceptItem(base(), todump) && canDump(other, todump)){
if(other.team == team && other.acceptItem(base(), todump) && canDump(other, todump)){
other.handleItem(base(), todump);
items.remove(todump, 1);
incrementDump(proximity.size);
@@ -653,7 +650,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
/** Try offloading an item to a nearby container in its facing direction. Returns true if success. */
public boolean moveForward(Item item){
Building other = front();
if(other != null && other.team() == team && other.acceptItem(base(), item)){
if(other != null && other.team == team && other.acceptItem(base(), item)){
other.handleItem(base(), item);
return true;
}

View File

@@ -95,7 +95,7 @@ abstract class PayloadComp implements Posc, Rotc, Hitboxc{
Building tile = payload.entity;
int tx = Vars.world.toTile(x - tile.block().offset), ty = Vars.world.toTile(y - tile.block().offset);
Tile on = Vars.world.tile(tx, ty);
if(on != null && Build.validPlace(tile.block(), tile.team(), tx, ty, tile.rotation)){
if(on != null && Build.validPlace(tile.block(), tile.team, tx, ty, tile.rotation)){
int rot = (int)((rotation + 45f) / 90f) % 4;
payload.place(on, rot);

View File

@@ -102,7 +102,7 @@ public class Teams{
}
public void registerCore(CoreBuild core){
TeamData data = get(core.team());
TeamData data = get(core.team);
//add core if not present
if(!data.cores.contains(core)){
data.cores.add(core);
@@ -117,7 +117,7 @@ public class Teams{
}
public void unregisterCore(CoreBuild entity){
TeamData data = get(entity.team());
TeamData data = get(entity.team);
//remove core
data.cores.remove(entity);
//unregister in active list

View File

@@ -249,7 +249,7 @@ public class BlockRenderer implements Disposable{
Draw.z(Layer.block);
}
if(entity.team() != player.team()){
if(entity.team != player.team()){
entity.drawTeam();
Draw.z(Layer.block);
}

View File

@@ -111,7 +111,7 @@ public class OverlayRenderer{
if(dst < state.rules.enemyCoreBuildRadius * 2.2f){
Draw.color(Color.darkGray);
Lines.circle(core.x, core.y - 2, state.rules.enemyCoreBuildRadius);
Draw.color(Pal.accent, core.team().color, 0.5f + Mathf.absin(Time.time(), 10f, 0.5f));
Draw.color(Pal.accent, core.team.color, 0.5f + Mathf.absin(Time.time(), 10f, 0.5f));
Lines.circle(core.x, core.y, state.rules.enemyCoreBuildRadius);
}
});
@@ -134,7 +134,7 @@ public class OverlayRenderer{
Vec2 vec = Core.input.mouseWorld(input.getMouseX(), input.getMouseY());
Building tile = world.buildWorld(vec.x, vec.y);
if(tile != null && tile.team() == player.team()){
if(tile != null && tile.team == player.team()){
tile.drawSelect();
if(!tile.enabled && tile.block.drawDisabled){
tile.drawDisabled();

View File

@@ -126,7 +126,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
Unit unit = player.unit();
Payloadc pay = (Payloadc)unit;
if(tile != null && tile.team() == unit.team && pay.payloads().size < unit.type().payloadCapacity
if(tile != null && tile.team == unit.team && pay.payloads().size < unit.type().payloadCapacity
&& unit.within(tile, tilesize * tile.block.size * 1.2f)){
//pick up block directly
if(tile.block().buildVisibility != BuildVisibility.hidden && tile.block().size <= 2 && tile.canPickup()){
@@ -869,7 +869,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
}
Building tile = world.buildWorld(Core.input.mouseWorld().x, Core.input.mouseWorld().y);
if(tile instanceof ControlBlock && tile.team() == player.team()){
if(tile instanceof ControlBlock && tile.team == player.team()){
return ((ControlBlock)tile).unit();
}

View File

@@ -77,7 +77,7 @@ public class MobileInput extends InputHandler implements GestureListener{
}else{
Building tile = world.buildWorld(x, y);
if(tile != null && player.team().isEnemy(tile.team())){
if(tile != null && player.team().isEnemy(tile.team)){
player.miner().mineTile(null);
target = tile;
}else if(tile != null && player.unit().type().canHeal && tile.team == player.team() && tile.damaged()){

View File

@@ -150,7 +150,7 @@ public class Tile implements Position, QuadTreeObject, Displayable{
}
public Team team(){
return build == null ? Team.derelict : build.team();
return build == null ? Team.derelict : build.team;
}
public void setTeam(Team team){

View File

@@ -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){

View File

@@ -91,7 +91,7 @@ public class Wall extends Block{
//create lightning if necessary
if(lightningChance > 0){
if(Mathf.chance(lightningChance)){
Lightning.create(team(), Pal.surge, lightningDamage, x, y, bullet.rotation() + 180f, lightningLength);
Lightning.create(team, Pal.surge, lightningDamage, x, y, bullet.rotation() + 180f, lightningLength);
}
}

View File

@@ -65,7 +65,7 @@ public class LaserTurret extends PowerTurret{
bullet = null;
}
}else if(reload > 0){
Liquid liquid = liquids().current();
Liquid liquid = liquids.current();
float maxUsed = consumes.<ConsumeLiquidBase>get(ConsumeType.liquid).amount;
float used = (cheating() ? maxUsed * Time.delta : Math.min(liquids.get(liquid), maxUsed * Time.delta)) * liquid.heatCapacity * coolantMultiplier;

View File

@@ -163,7 +163,7 @@ public class Conveyor extends Block implements Autotiler{
if(front() != null && front() != null){
next = front();
nextc = next instanceof ConveyorBuild && next.team() == team ? (ConveyorBuild)next : null;
nextc = next instanceof ConveyorBuild && next.team == team ? (ConveyorBuild)next : null;
aligned = nextc != null && rotation == next.rotation;
}
}

View File

@@ -341,7 +341,7 @@ public class ItemBridge extends Block{
@Override
public boolean acceptLiquid(Building source, Liquid liquid, float amount){
if(team != source.team() || !hasLiquids) return false;
if(team != source.team || !hasLiquids) return false;
Tile other = world.tile(link);

View File

@@ -49,7 +49,7 @@ public class Junction extends Block{
Building dest = nearby(i);
//skip blocks that don't want the item, keep waiting until they do
if(dest == null || !dest.acceptItem(this, item) || dest.team() != team){
if(dest == null || !dest.acceptItem(this, item) || dest.team != team){
continue;
}
@@ -73,7 +73,7 @@ public class Junction extends Block{
if(relative == -1 || !buffer.accepts(relative)) return false;
Building to = nearby(relative);
return to != null && to.team() == team;
return to != null && to.team == team;
}
@Override

View File

@@ -223,7 +223,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;
}
@@ -254,7 +254,7 @@ public class MassDriver extends Block{
float angle = tile.angleTo(target);
Bullets.driverBolt.create(this, team(),
Bullets.driverBolt.create(this, team,
x + Angles.trnsx(angle, translation), y + Angles.trnsy(angle, translation),
angle, -1f, bulletSpeed, bulletLifetime, data);

View File

@@ -76,7 +76,7 @@ public class OverflowGate extends Block{
@Override
public boolean acceptItem(Building source, Item item){
return team == source.team() && lastItem == null && items.total() == 0;
return team == source.team && lastItem == null && items.total() == 0;
}
@Override
@@ -91,7 +91,7 @@ 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);
if(!canForward || invert){
Building a = nearby(Mathf.mod(from - 1, 4));

View File

@@ -51,7 +51,7 @@ public class Router extends Block{
@Override
public boolean acceptItem(Building source, Item item){
return team == source.team() && lastItem == null && items.total() == 0;
return team == source.team && lastItem == null && items.total() == 0;
}
@Override

View File

@@ -76,7 +76,7 @@ public class Sorter extends Block{
public boolean acceptItem(Building source, Item item){
Building to = getTileTarget(item, source, false);
return to != null && to.acceptItem(this, item) && to.team() == team;
return to != null && to.acceptItem(this, item) && to.team == team;
}
@Override

View File

@@ -26,7 +26,7 @@ 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());
}

View File

@@ -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();
}

View File

@@ -53,7 +53,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;

View File

@@ -68,7 +68,7 @@ public class PowerNode extends PowerBlock{
power.links.add(other.pos());
}
if(other.team() == entity.team()){
if(other.team == entity.team){
if(!other.power.links.contains(entity.pos())){
other.power.links.add(entity.pos());
@@ -184,7 +184,7 @@ 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) &&
overlaps(tile.x * tilesize + offset, tile.y * tilesize + offset, other.tile(), laserRange * tilesize) && other.team() == player.team()
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);
tempTileEnts.clear();
@@ -235,7 +235,7 @@ 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){