Correct storage graphs

This commit is contained in:
Anuken 2018-10-21 17:20:08 -04:00
parent 80f5b4c3b7
commit f9b70a37aa
5 changed files with 22 additions and 18 deletions

View File

@ -157,9 +157,7 @@ public class TileEntity extends BaseEntity implements TargetTrait, HealthTrait{
}
public void removeFromProximity(){
if(power != null){
tile.block().powerGraphRemoved(tile);
}
tile.block().onProximityRemoved(tile);
GridPoint2[] nearby = Edges.getEdges(tile.block().size);
for(GridPoint2 point : nearby){
@ -202,7 +200,7 @@ public class TileEntity extends BaseEntity implements TargetTrait, HealthTrait{
proximity.add(tile);
}
if(tile.block().hasPower) tile.block().updatePowerGraph(tile);
tile.block().onProximityAdded(tile);
tile.block().onProximityUpdate(tile);
}

View File

@ -139,7 +139,17 @@ public class Block extends BaseBlock {
return drops != null && drops.item == item;
}
public void updatePowerGraph(Tile tile){
public void onProximityRemoved(Tile tile){
if(tile.entity.power != null){
tile.block().powerGraphRemoved(tile);
}
}
public void onProximityAdded(Tile tile){
if(tile.block().hasPower) tile.block().updatePowerGraph(tile);
}
protected void updatePowerGraph(Tile tile){
TileEntity entity = tile.entity();
for(Tile other : getPowerConnections(tile, tempTiles)){
@ -149,7 +159,7 @@ public class Block extends BaseBlock {
}
}
public void powerGraphRemoved(Tile tile){
protected void powerGraphRemoved(Tile tile){
tile.entity.power.graph.remove(tile);
for(int i = 0; i < tile.entity.power.links.size; i++){
Tile other = world.tile(tile.entity.power.links.get(i));

View File

@ -19,8 +19,7 @@ public abstract class StorageBlock extends Block{
}
@Override
public void onProximityUpdate(Tile tile){
super.onProximityUpdate(tile);
public void onProximityAdded(Tile tile){
StorageEntity entity = tile.entity();
entity.graph.add(tile);
@ -33,8 +32,7 @@ public abstract class StorageBlock extends Block{
}
@Override
public void removed(Tile tile){
super.removed(tile);
public void onProximityRemoved(Tile tile){
StorageEntity entity = tile.entity();
entity.graph.remove(tile);
}

View File

@ -26,15 +26,13 @@ public class StorageGraph{
other.<StorageEntity>entity().graph = null;
}
if(tiles.remove(tile) && tile.block() instanceof CoreBlock){
cores --;
}
cores = 0;
for(Tile other : tile.entity.proximity()){
if(other.block() instanceof StorageBlock){
reflow(tile, other);
if(other.block() instanceof StorageBlock && other.<StorageEntity>entity().graph == null){
StorageGraph graph = new StorageGraph();
other.<StorageEntity>entity().graph = graph;
graph.reflow(tile, other);
}
}
}
@ -58,7 +56,7 @@ public class StorageGraph{
}
public void merge(StorageGraph other){
if(this == other) return;
if(this == other || other == null) return;
for(Tile tile : other.tiles){
StorageEntity e = tile.entity();

View File

@ -97,7 +97,7 @@ public class ServerControl extends Module{
world.sectors.save();
gameOvers = 0;
inExtraRound = true;
Settings.putInt("sector_x", world.getSector().x + world.getSector().width);
Settings.putInt("sector_x", world.getSector().x + 1);
Settings.save();
Call.onInfoMessage("[accent]Sector conquered![]\n" + roundExtraTime + " seconds until deployment in next sector.");