Zone improvements

This commit is contained in:
Anuken
2019-08-06 13:01:54 -04:00
parent 5c6bcbf9cd
commit 282aab5939
11 changed files with 20 additions and 13 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -78,14 +78,14 @@ public class Zones implements ContentList{
}}; }};
saltFlats = new Zone("saltFlats", new MapGenerator("saltFlats")){{ saltFlats = new Zone("saltFlats", new MapGenerator("saltFlats")){{
startingItems = ItemStack.list(Items.copper, 200, Items.silicon, 100, Items.lead, 200); startingItems = ItemStack.list(Items.copper, 200, Items.silicon, 200, Items.lead, 200);
alwaysUnlocked = true; alwaysUnlocked = true;
conditionWave = 5; conditionWave = 5;
launchPeriod = 5; launchPeriod = 5;
loadout = Loadouts.basicFoundation; loadout = Loadouts.basicFoundation;
zoneRequirements = ZoneRequirement.with(desertWastes, 60); zoneRequirements = ZoneRequirement.with(desertWastes, 60);
blockRequirements = new Block[]{Blocks.daggerFactory, Blocks.draugFactory}; blockRequirements = new Block[]{Blocks.daggerFactory, Blocks.draugFactory, Blocks.door};
resources = new Item[]{Items.copper, Items.scrap, Items.lead, Items.coal, Items.sand}; resources = new Item[]{Items.copper, Items.scrap, Items.lead, Items.coal, Items.sand, Items.titanium};
}}; }};
frozenForest = new Zone("frozenForest", new MapGenerator("frozenForest", 1) frozenForest = new Zone("frozenForest", new MapGenerator("frozenForest", 1)
@@ -170,7 +170,7 @@ public class DeployDialog extends FloatingDialog{
button.setDisabled(() -> hidden(zone)); button.setDisabled(() -> hidden(zone));
button.clicked(() -> info.show(zone)); button.clicked(() -> info.show(zone));
if(zone.unlocked()){ if(zone.unlocked() && !hidden(zone)){
button.labelWrap(zone.localizedName()).style("outline").width(140).growX().get().setAlignment(Align.center); button.labelWrap(zone.localizedName()).style("outline").width(140).growX().get().setAlignment(Align.center);
}else{ }else{
button.addImage("icon-locked"); button.addImage("icon-locked");
@@ -5,7 +5,6 @@ import io.anuke.arc.graphics.g2d.*;
import io.anuke.arc.math.*; import io.anuke.arc.math.*;
import io.anuke.arc.scene.*; import io.anuke.arc.scene.*;
import io.anuke.arc.scene.event.*; import io.anuke.arc.scene.event.*;
import io.anuke.arc.util.*;
/** Fades in a black overlay.*/ /** Fades in a black overlay.*/
public class FadeInFragment extends Fragment{ public class FadeInFragment extends Fragment{
@@ -30,7 +29,7 @@ public class FadeInFragment extends Fragment{
@Override @Override
public void act(float delta){ public void act(float delta){
super.act(delta); super.act(delta);
time += Time.delta() / duration; time += 1f / duration;
if(time > 1){ if(time > 1){
remove(); remove();
} }
@@ -78,12 +78,12 @@ public class MendProjector extends Block{
float realRange = range + entity.phaseHeat * phaseRangeBoost; float realRange = range + entity.phaseHeat * phaseRangeBoost;
entity.charge = 0f; entity.charge = 0f;
int tileRange = (int)(realRange / tilesize); int tileRange = (int)(realRange / tilesize + 1);
healed.clear(); healed.clear();
for(int x = -tileRange + tile.x; x <= tileRange + tile.x; x++){ for(int x = -tileRange + tile.x; x <= tileRange + tile.x; x++){
for(int y = -tileRange + tile.y; y <= tileRange + tile.y; y++){ for(int y = -tileRange + tile.y; y <= tileRange + tile.y; y++){
if(Mathf.dst(x, y, tile.x, tile.y) > tileRange) continue; if(!Mathf.within(x * tilesize, y * tilesize, tile.drawx(), tile.drawy(), realRange)) continue;
Tile other = world.ltile(x, y); Tile other = world.ltile(x, y);
@@ -84,12 +84,12 @@ public class OverdriveProjector extends Block{
entity.charge = 0f; entity.charge = 0f;
int tileRange = (int)(realRange / tilesize); int tileRange = (int)(realRange / tilesize + 1);
healed.clear(); healed.clear();
for(int x = -tileRange + tile.x; x <= tileRange + tile.x; x++){ for(int x = -tileRange + tile.x; x <= tileRange + tile.x; x++){
for(int y = -tileRange + tile.y; y <= tileRange + tile.y; y++){ for(int y = -tileRange + tile.y; y <= tileRange + tile.y; y++){
if(Mathf.dst(x, y, tile.x, tile.y) > tileRange) continue; if(!Mathf.within(x * tilesize, y * tilesize, tile.drawx(), tile.drawy(), realRange)) continue;
Tile other = world.ltile(x, y); Tile other = world.ltile(x, y);
@@ -209,6 +209,7 @@ public class PowerGraph{
} }
public void add(Tile tile){ public void add(Tile tile){
if(tile.entity == null || tile.entity.power == null) return;
tile.entity.power.graph = this; tile.entity.power.graph = this;
all.add(tile); all.add(tile);
@@ -2,6 +2,7 @@ package io.anuke.mindustry.world.blocks.power;
import io.anuke.annotations.Annotations.*; import io.anuke.annotations.Annotations.*;
import io.anuke.arc.*; import io.anuke.arc.*;
import io.anuke.arc.function.*;
import io.anuke.arc.graphics.*; import io.anuke.arc.graphics.*;
import io.anuke.arc.graphics.g2d.*; import io.anuke.arc.graphics.g2d.*;
import io.anuke.arc.math.*; import io.anuke.arc.math.*;
@@ -105,14 +106,20 @@ public class PowerNode extends PowerBlock{
Call.linkPowerNodes(null, tile, before); Call.linkPowerNodes(null, tile, before);
} }
Predicate<Tile> valid = other -> other != null && other != tile && ((!other.block().outputsPower && other.block().consumesPower) || (other.block().outputsPower && !other.block().consumesPower)) && linkValid(tile, other)
&& !other.entity.proximity().contains(tile) && other.entity.power.graph != tile.entity.power.graph;
tempTiles.clear();
Geometry.circle(tile.x, tile.y, (int)(laserRange + 1), (x, y) -> { Geometry.circle(tile.x, tile.y, (int)(laserRange + 1), (x, y) -> {
Tile other = world.ltile(x, y); Tile other = world.ltile(x, y);
if(other != null && other != tile && ((!other.block().outputsPower && other.block().consumesPower) || (other.block().outputsPower && !other.block().consumesPower)) && linkValid(tile, other) if(valid.test(other)){
&& !other.entity.proximity().contains(tile) && other.entity.power.graph != tile.entity.power.graph){ tempTiles.add(other);
Call.linkPowerNodes(null, tile, other);
} }
}); });
tempTiles.sort(Structs.comparingFloat(t -> t.dst2(tile)));
tempTiles.each(valid, other -> Call.linkPowerNodes(null, tile, other));
lastPlaced = tile.pos(); lastPlaced = tile.pos();
super.playerPlaced(tile); super.playerPlaced(tile);
} }