Zone requirement changes / Bugfixes

This commit is contained in:
Anuken
2019-04-20 19:57:20 -04:00
parent af91979d4c
commit 75dcceff43
23 changed files with 2255 additions and 2077 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@@ -618,6 +618,7 @@ block.grass.name = Grass
block.salt.name = Salt block.salt.name = Salt
block.saltrocks.name = Salt Rocks block.saltrocks.name = Salt Rocks
block.pebbles.name = Pebbles block.pebbles.name = Pebbles
block.tendrils.name = Tendrils
block.sandrocks.name = Sand Rocks block.sandrocks.name = Sand Rocks
block.spore-pine.name = Spore Pine block.spore-pine.name = Spore Pine
block.sporerocks.name = Spore Rocks block.sporerocks.name = Spore Rocks

Binary file not shown.

Before

Width:  |  Height:  |  Size: 500 B

After

Width:  |  Height:  |  Size: 501 B

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 MiB

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 279 KiB

After

Width:  |  Height:  |  Size: 280 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

After

Width:  |  Height:  |  Size: 1.2 MiB

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 386 KiB

After

Width:  |  Height:  |  Size: 382 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 332 KiB

After

Width:  |  Height:  |  Size: 340 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 344 KiB

After

Width:  |  Height:  |  Size: 373 KiB

View File

@@ -36,7 +36,7 @@ public class Blocks implements ContentList{
metalFloor, metalFloorDamaged, metalFloor2, metalFloor3, metalFloor5, ignarock, magmarock, hotrock, snowrocks, rock, snowrock, saltRocks, metalFloor, metalFloorDamaged, metalFloor2, metalFloor3, metalFloor5, ignarock, magmarock, hotrock, snowrocks, rock, snowrock, saltRocks,
creeptree, creeptree,
darkPanel1, darkPanel2, darkPanel3, darkPanel4, darkPanel5, darkPanel6, darkMetal, darkPanel1, darkPanel2, darkPanel3, darkPanel4, darkPanel5, darkPanel6, darkMetal,
pebbles, pebbles, tendrils,
//ores //ores
oreCopper, oreLead, oreScrap, oreCoal, oreTitanium, oreThorium, oreCopper, oreLead, oreScrap, oreCoal, oreTitanium, oreThorium,
@@ -379,6 +379,8 @@ public class Blocks implements ContentList{
pebbles = new OverlayFloor("pebbles"); pebbles = new OverlayFloor("pebbles");
tendrils = new OverlayFloor("tendrils");
//endregion //endregion
//region ore //region ore

View File

@@ -36,7 +36,7 @@ public class Zones implements ContentList{
desertWastes = new Zone("desertWastes", new DesertWastesGenerator(260, 260)){{ desertWastes = new Zone("desertWastes", new DesertWastesGenerator(260, 260)){{
startingItems = ItemStack.list(Items.copper, 200); startingItems = ItemStack.list(Items.copper, 200);
conditionWave = 10; conditionWave = 10;
zoneRequirements = ZoneRequirement.with(groundZero, 10); zoneRequirements = ZoneRequirement.with(groundZero, 15);
blockRequirements = new Block[]{Blocks.router}; blockRequirements = new Block[]{Blocks.router};
resources = new Item[]{Items.copper, Items.lead, Items.coal, Items.sand}; resources = new Item[]{Items.copper, Items.lead, Items.coal, Items.sand};
rules = () -> new Rules(){{ rules = () -> new Rules(){{
@@ -49,7 +49,7 @@ public class Zones implements ContentList{
saltFlats = new Zone("saltFlats", new DesertWastesGenerator(260, 260)){{ saltFlats = new Zone("saltFlats", new DesertWastesGenerator(260, 260)){{
startingItems = ItemStack.list(Items.copper, 200); startingItems = ItemStack.list(Items.copper, 200);
conditionWave = 10; conditionWave = 10;
zoneRequirements = ZoneRequirement.with(groundZero, 10); zoneRequirements = ZoneRequirement.with(desertWastes, 25);
blockRequirements = new Block[]{Blocks.router}; blockRequirements = new Block[]{Blocks.router};
resources = new Item[]{Items.copper, Items.lead, Items.coal, Items.sand}; resources = new Item[]{Items.copper, Items.lead, Items.coal, Items.sand};
rules = () -> new Rules(){{ rules = () -> new Rules(){{
@@ -62,7 +62,7 @@ public class Zones implements ContentList{
overgrowth = new Zone("overgrowth", new OvergrowthGenerator(320, 320)){{ overgrowth = new Zone("overgrowth", new OvergrowthGenerator(320, 320)){{
startingItems = ItemStack.list(Items.copper, 200); startingItems = ItemStack.list(Items.copper, 200);
conditionWave = 10; conditionWave = 10;
zoneRequirements = ZoneRequirement.with(groundZero, 10); zoneRequirements = ZoneRequirement.with(craters, 15);
blockRequirements = new Block[]{Blocks.router}; blockRequirements = new Block[]{Blocks.router};
resources = new Item[]{Items.copper, Items.lead, Items.coal}; resources = new Item[]{Items.copper, Items.lead, Items.coal};
rules = () -> new Rules(){{ rules = () -> new Rules(){{
@@ -106,7 +106,7 @@ public class Zones implements ContentList{
startingItems = ItemStack.list(Items.copper, 400); startingItems = ItemStack.list(Items.copper, 400);
conditionWave = 20; conditionWave = 20;
launchPeriod = 20; launchPeriod = 20;
zoneRequirements = ZoneRequirement.with(frozenForest, 10, craters, 15); zoneRequirements = ZoneRequirement.with(desertWastes, 10, craters, 15);
blockRequirements = new Block[]{Blocks.graphitePress, Blocks.combustionGenerator}; blockRequirements = new Block[]{Blocks.graphitePress, Blocks.combustionGenerator};
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};
rules = () -> new Rules(){{ rules = () -> new Rules(){{

View File

@@ -86,6 +86,7 @@ public class Damage{
tr.trns(angle, length); tr.trns(angle, length);
world.raycastEachWorld(x, y, x + tr.x, y + tr.y, (cx, cy) -> { world.raycastEachWorld(x, y, x + tr.x, y + tr.y, (cx, cy) -> {
Tile tile = world.tile(cx, cy); Tile tile = world.tile(cx, cy);
if(tile != null) tile = tile.target();
if(tile != null && tile.entity != null && tile.target().getTeamID() != team.ordinal() && tile.entity.collide(hitter)){ if(tile != null && tile.entity != null && tile.target().getTeamID() != team.ordinal() && tile.entity.collide(hitter)){
tile.entity.collision(hitter); tile.entity.collision(hitter);
hitter.getBulletType().hit(hitter, tile.worldx(), tile.worldy()); hitter.getBulletType().hit(hitter, tile.worldx(), tile.worldy());
@@ -113,7 +114,7 @@ public class Damage{
rect.width += expand * 2; rect.width += expand * 2;
rect.height += expand * 2; rect.height += expand * 2;
Consumer<io.anuke.mindustry.entities.type.Unit> cons = e -> { Consumer<Unit> cons = e -> {
e.hitbox(hitrect); e.hitbox(hitrect);
Rectangle other = hitrect; Rectangle other = hitrect;
other.y -= expand; other.y -= expand;
@@ -134,8 +135,8 @@ public class Damage{
} }
/** Damages all entities and blocks in a radius that are enemies of the team. */ /** Damages all entities and blocks in a radius that are enemies of the team. */
public static void damageUnits(Team team, float x, float y, float size, float damage, Predicate<io.anuke.mindustry.entities.type.Unit> predicate, Consumer<io.anuke.mindustry.entities.type.Unit> acceptor){ public static void damageUnits(Team team, float x, float y, float size, float damage, Predicate<Unit> predicate, Consumer<Unit> acceptor){
Consumer<io.anuke.mindustry.entities.type.Unit> cons = entity -> { Consumer<Unit> cons = entity -> {
if(!predicate.test(entity)) return; if(!predicate.test(entity)) return;
entity.hitbox(hitrect); entity.hitbox(hitrect);

View File

@@ -24,7 +24,6 @@ public class Zone extends UnlockableContent{
public final Generator generator; public final Generator generator;
public Block[] blockRequirements = {}; public Block[] blockRequirements = {};
public ZoneRequirement[] zoneRequirements = {}; public ZoneRequirement[] zoneRequirements = {};
//TODO debug verify resources.
public Item[] resources = {}; public Item[] resources = {};
public Supplier<Rules> rules = Rules::new; public Supplier<Rules> rules = Rules::new;
public boolean alwaysUnlocked; public boolean alwaysUnlocked;

View File

@@ -3,6 +3,7 @@ package io.anuke.mindustry.ui.dialogs;
import io.anuke.arc.Core; import io.anuke.arc.Core;
import io.anuke.arc.collection.Array; import io.anuke.arc.collection.Array;
import io.anuke.arc.collection.ObjectSet; import io.anuke.arc.collection.ObjectSet;
import io.anuke.arc.collection.ObjectSet.ObjectSetIterator;
import io.anuke.arc.graphics.g2d.Draw; import io.anuke.arc.graphics.g2d.Draw;
import io.anuke.arc.graphics.g2d.Lines; import io.anuke.arc.graphics.g2d.Lines;
import io.anuke.arc.scene.Group; import io.anuke.arc.scene.Group;
@@ -10,6 +11,7 @@ import io.anuke.arc.scene.ui.TextButton;
import io.anuke.arc.scene.ui.layout.Table; import io.anuke.arc.scene.ui.layout.Table;
import io.anuke.arc.scene.ui.layout.Unit; import io.anuke.arc.scene.ui.layout.Unit;
import io.anuke.arc.util.Align; import io.anuke.arc.util.Align;
import io.anuke.arc.util.Structs;
import io.anuke.mindustry.content.Zones; import io.anuke.mindustry.content.Zones;
import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.game.Saves.SaveSlot; import io.anuke.mindustry.game.Saves.SaveSlot;
@@ -97,6 +99,17 @@ public class DeployDialog extends FloatingDialog{
}).growX().height(50f).pad(-12).padTop(10); }).growX().height(50f).pad(-12).padTop(10);
}}, new ItemsDisplay()).grow(); }}, new ItemsDisplay()).grow();
//set up direct and indirect children
for(ZoneNode node : nodes){
node.allChildren.clear();
node.allChildren.addAll(node.children);
for(ZoneNode other : new ObjectSetIterator<>(nodes)){
if(Structs.contains(other.zone.zoneRequirements, req -> req.zone == node.zone)){
node.allChildren.add(other);
}
}
}
} }
boolean hidden(Zone zone){ boolean hidden(Zone zone){
@@ -155,7 +168,7 @@ public class DeployDialog extends FloatingDialog{
float offsetX = panX + width / 2f + x, offsetY = panY + height / 2f + y; float offsetX = panX + width / 2f + x, offsetY = panY + height / 2f + y;
for(ZoneNode node : nodes){ for(ZoneNode node : nodes){
for(ZoneNode child : node.children){ for(ZoneNode child : node.allChildren){
Lines.stroke(Unit.dp.scl(3f), node.zone.locked() || child.zone.locked() ? Pal.locked : Pal.accent); Lines.stroke(Unit.dp.scl(3f), node.zone.locked() || child.zone.locked() ? Pal.locked : Pal.accent);
Lines.line(node.x + offsetX, node.y + offsetY, child.x + offsetX, child.y + offsetY); Lines.line(node.x + offsetX, node.y + offsetY, child.x + offsetX, child.y + offsetY);
} }
@@ -168,6 +181,7 @@ public class DeployDialog extends FloatingDialog{
class ZoneNode extends TreeNode<ZoneNode>{ class ZoneNode extends TreeNode<ZoneNode>{
final Array<Zone> arr = new Array<>(); final Array<Zone> arr = new Array<>();
final Array<ZoneNode> allChildren = new Array<>();
final Zone zone; final Zone zone;
ZoneNode(Zone zone, ZoneNode parent){ ZoneNode(Zone zone, ZoneNode parent){

View File

@@ -45,7 +45,8 @@ public class StaticWall extends Rock{
} }
boolean eq(int rx, int ry){ boolean eq(int rx, int ry){
return world.tile(rx + 1, ry).block() == this return rx < world.width() - 1 && ry < world.height() - 1
&& world.tile(rx + 1, ry).block() == this
&& world.tile(rx, ry + 1).block() == this && world.tile(rx, ry + 1).block() == this
&& world.tile(rx, ry).block() == this && world.tile(rx, ry).block() == this
&& world.tile(rx + 1, ry + 1).block() == this; && world.tile(rx + 1, ry + 1).block() == this;

View File

@@ -52,7 +52,7 @@ public class OverdriveProjector extends Block{
@Override @Override
public void drawPlace(int x, int y, int rotation, boolean valid){ public void drawPlace(int x, int y, int rotation, boolean valid){
Draw.color(Pal.accent); Draw.color(Pal.accent);
Lines.dashCircle(x * tilesize, y * tilesize, range); Lines.dashCircle(x * tilesize + offset(), y * tilesize + offset(), range);
Draw.color(); Draw.color();
} }
@@ -90,7 +90,7 @@ public class OverdriveProjector extends Block{
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) > realRange) continue; if(Mathf.dst(x, y, tile.x, tile.y) > tileRange) continue;
Tile other = world.tile(x, y); Tile other = world.tile(x, y);

View File

@@ -152,7 +152,7 @@ public class MassDriver extends Block{
entity.rotation = Mathf.slerpDelta(entity.rotation, tile.angleTo(waiter), rotateSpeed); entity.rotation = Mathf.slerpDelta(entity.rotation, tile.angleTo(waiter), rotateSpeed);
}else if(tile.entity.items.total() >= minDistribute && }else if(tile.entity.items.total() >= minDistribute &&
linkValid(tile) && //only fire when at 100% power capacity linkValid(tile) &&
tile.entity.power.satisfaction >= powerPercentageUsed && tile.entity.power.satisfaction >= powerPercentageUsed &&
link.block().itemCapacity - link.entity.items.total() >= minDistribute && entity.reload <= 0.0001f){ link.block().itemCapacity - link.entity.items.total() >= minDistribute && entity.reload <= 0.0001f){
@@ -187,6 +187,13 @@ public class MassDriver extends Block{
tile.drawy() + Angles.trnsy(entity.rotation + 180f, entity.reload * knockback), entity.rotation - 90); tile.drawy() + Angles.trnsy(entity.rotation + 180f, entity.reload * knockback), entity.rotation - 90);
} }
@Override
public void drawPlace(int x, int y, int rotation, boolean valid){
Draw.color(Pal.accent);
Lines.dashCircle(x * tilesize, y*tilesize, range);
Draw.color();
}
@Override @Override
public void drawConfigure(Tile tile){ public void drawConfigure(Tile tile){
float sin = Mathf.absin(Time.time(), 6f, 1f); float sin = Mathf.absin(Time.time(), 6f, 1f);

View File

@@ -86,6 +86,52 @@ def antialias = { File file ->
ImageIO.write(out, "png", file) ImageIO.write(out, "png", file)
} }
def scaleImage = { File file ->
def image = ImageIO.read(file)
for(int iteration in 0..1){
def scaled = new BufferedImage(image.getWidth() * 2, image.getHeight() * 2, BufferedImage.TYPE_INT_ARGB)
def getRGB = { int ix, int iy ->
//if(ix <= 0 || iy <= 0 || ix >= image.width || iy >= image.height) return 0
return image.getRGB(Math.max(Math.min(ix, image.width - 1), 0), Math.max(Math.min(iy, image.height - 1), 0))
}
for(int x = 0; x < image.getWidth(); x++){
for(int y = 0; y < image.getHeight(); y++){
int p = image.getRGB(x, y)
int p1 = p, p2 = p, p3 = p, p4 = p
int A = getRGB(x - 1, y + 1),
B = getRGB(x, y + 1),
C = getRGB(x + 1, y + 1),
D = getRGB(x - 1, y),
E = getRGB(x, y),
F = getRGB(x + 1, y),
G = getRGB(x - 1, y - 1),
H = getRGB(x, y - 1),
I = getRGB(x + 1, y - 1),
J = getRGB(x, y + 2),
K = getRGB(x - 2, y),
L = getRGB(x + 2, y),
M = getRGB(x, y - 2)
if(B == D && B != F && D != H && (E != A || E == C || E == G || A == J || A == K)) p1 = B
if(B == F & B != D & F != H && (E != C || E == A || E == I || C == J || C == L)) p2 = F
if(D == H & B != D & F != H && (E != G || E == A || E == I || G == K || G == M)) p3 = D
if(F == H & B != F & D != H && (E != I || E == C || E == G || I == L || I == M)) p4 = H
scaled.setRGB(x * 2, y * 2 + 1, p1)
scaled.setRGB(x * 2 + 1, y * 2 + 1, p2)
scaled.setRGB(x * 2, y * 2, p3)
scaled.setRGB(x * 2 + 1, y * 2, p4)
}
}
image = scaled
}
ImageIO.write(image, "png", file)
}
task swapColors(){ task swapColors(){
doLast{ doLast{
if(project.hasProperty("colors")){ if(project.hasProperty("colors")){
@@ -124,49 +170,7 @@ task scaleSprites4x(){
fileTree(dir: '../core/assets-raw/sprites_out/', include: "**/*.png").visit{ file -> fileTree(dir: '../core/assets-raw/sprites_out/', include: "**/*.png").visit{ file ->
if(file.isDirectory() || file.toString().contains("/ui/")) return if(file.isDirectory() || file.toString().contains("/ui/")) return
for(int iteration in 0..1){ scaleImage(file.file)
def image = ImageIO.read(file.file)
def scaled = new BufferedImage(image.getWidth() * 2, image.getHeight() * 2, BufferedImage.TYPE_INT_ARGB)
def getRGB = { int ix, int iy ->
//if(ix <= 0 || iy <= 0 || ix >= image.width || iy >= image.height) return 0
return image.getRGB(Math.max(Math.min(ix, image.width - 1), 0), Math.max(Math.min(iy, image.height - 1), 0))
}
for(int x = 0; x < image.getWidth(); x++){
for(int y = 0; y < image.getHeight(); y++){
int p = image.getRGB(x, y)
int p1 = p, p2 = p, p3 = p, p4 = p
int A = getRGB(x - 1, y + 1),
B = getRGB(x, y + 1),
C = getRGB(x + 1, y + 1),
D = getRGB(x - 1, y),
E = getRGB(x, y),
F = getRGB(x + 1, y),
G = getRGB(x - 1, y - 1),
H = getRGB(x, y - 1),
I = getRGB(x + 1, y - 1),
J = getRGB(x, y + 2),
K = getRGB(x - 2, y),
L = getRGB(x + 2, y),
M = getRGB(x, y - 2)
if(B == D && B != F && D != H && (E != A || E == C || E == G || A == J || A == K)) p1 = B
if(B == F & B != D & F != H && (E != C || E == A || E == I || C == J || C == L)) p2 = F
if(D == H & B != D & F != H && (E != G || E == A || E == I || G == K || G == M)) p3 = D
if(F == H & B != F & D != H && (E != I || E == C || E == G || I == L || I == M)) p4 = H
scaled.setRGB(x * 2, y * 2 + 1, p1)
scaled.setRGB(x * 2 + 1, y * 2 + 1, p2)
scaled.setRGB(x * 2, y * 2, p3)
scaled.setRGB(x * 2 + 1, y * 2, p4)
}
}
ImageIO.write(scaled, "png", file.file)
}
antialias(file.file) antialias(file.file)
} }
} }
@@ -185,6 +189,15 @@ task scaleSprites(){
dependsOn 'scaleSprites4x' dependsOn 'scaleSprites4x'
} }
task scaleImages(){
doLast{
for(def img : project.getProperty("images").split(",")){
println(project.getProperty("startdir") + "/" + img)
scaleImage(new File(project.getProperty("startdir") + "/" + img))
}
}
}
task pack(){ task pack(){
dependsOn 'cleanSprites', 'scaleSprites' dependsOn 'cleanSprites', 'scaleSprites'
//finalizedBy 'cleanup' //finalizedBy 'cleanup'