mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-11 03:08:38 +07:00
Correct storage graphs
This commit is contained in:
parent
80f5b4c3b7
commit
f9b70a37aa
@ -157,9 +157,7 @@ public class TileEntity extends BaseEntity implements TargetTrait, HealthTrait{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void removeFromProximity(){
|
public void removeFromProximity(){
|
||||||
if(power != null){
|
tile.block().onProximityRemoved(tile);
|
||||||
tile.block().powerGraphRemoved(tile);
|
|
||||||
}
|
|
||||||
|
|
||||||
GridPoint2[] nearby = Edges.getEdges(tile.block().size);
|
GridPoint2[] nearby = Edges.getEdges(tile.block().size);
|
||||||
for(GridPoint2 point : nearby){
|
for(GridPoint2 point : nearby){
|
||||||
@ -202,7 +200,7 @@ public class TileEntity extends BaseEntity implements TargetTrait, HealthTrait{
|
|||||||
proximity.add(tile);
|
proximity.add(tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tile.block().hasPower) tile.block().updatePowerGraph(tile);
|
tile.block().onProximityAdded(tile);
|
||||||
tile.block().onProximityUpdate(tile);
|
tile.block().onProximityUpdate(tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,7 +139,17 @@ public class Block extends BaseBlock {
|
|||||||
return drops != null && drops.item == item;
|
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();
|
TileEntity entity = tile.entity();
|
||||||
|
|
||||||
for(Tile other : getPowerConnections(tile, tempTiles)){
|
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);
|
tile.entity.power.graph.remove(tile);
|
||||||
for(int i = 0; i < tile.entity.power.links.size; i++){
|
for(int i = 0; i < tile.entity.power.links.size; i++){
|
||||||
Tile other = world.tile(tile.entity.power.links.get(i));
|
Tile other = world.tile(tile.entity.power.links.get(i));
|
||||||
|
@ -19,8 +19,7 @@ public abstract class StorageBlock extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onProximityUpdate(Tile tile){
|
public void onProximityAdded(Tile tile){
|
||||||
super.onProximityUpdate(tile);
|
|
||||||
StorageEntity entity = tile.entity();
|
StorageEntity entity = tile.entity();
|
||||||
entity.graph.add(tile);
|
entity.graph.add(tile);
|
||||||
|
|
||||||
@ -33,8 +32,7 @@ public abstract class StorageBlock extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removed(Tile tile){
|
public void onProximityRemoved(Tile tile){
|
||||||
super.removed(tile);
|
|
||||||
StorageEntity entity = tile.entity();
|
StorageEntity entity = tile.entity();
|
||||||
entity.graph.remove(tile);
|
entity.graph.remove(tile);
|
||||||
}
|
}
|
||||||
|
@ -26,15 +26,13 @@ public class StorageGraph{
|
|||||||
other.<StorageEntity>entity().graph = null;
|
other.<StorageEntity>entity().graph = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tiles.remove(tile) && tile.block() instanceof CoreBlock){
|
|
||||||
cores --;
|
|
||||||
}
|
|
||||||
|
|
||||||
cores = 0;
|
cores = 0;
|
||||||
|
|
||||||
for(Tile other : tile.entity.proximity()){
|
for(Tile other : tile.entity.proximity()){
|
||||||
if(other.block() instanceof StorageBlock){
|
if(other.block() instanceof StorageBlock && other.<StorageEntity>entity().graph == null){
|
||||||
reflow(tile, other);
|
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){
|
public void merge(StorageGraph other){
|
||||||
if(this == other) return;
|
if(this == other || other == null) return;
|
||||||
|
|
||||||
for(Tile tile : other.tiles){
|
for(Tile tile : other.tiles){
|
||||||
StorageEntity e = tile.entity();
|
StorageEntity e = tile.entity();
|
||||||
|
@ -97,7 +97,7 @@ public class ServerControl extends Module{
|
|||||||
world.sectors.save();
|
world.sectors.save();
|
||||||
gameOvers = 0;
|
gameOvers = 0;
|
||||||
inExtraRound = true;
|
inExtraRound = true;
|
||||||
Settings.putInt("sector_x", world.getSector().x + world.getSector().width);
|
Settings.putInt("sector_x", world.getSector().x + 1);
|
||||||
Settings.save();
|
Settings.save();
|
||||||
|
|
||||||
Call.onInfoMessage("[accent]Sector conquered![]\n" + roundExtraTime + " seconds until deployment in next sector.");
|
Call.onInfoMessage("[accent]Sector conquered![]\n" + roundExtraTime + " seconds until deployment in next sector.");
|
||||||
|
Loading…
Reference in New Issue
Block a user