diff --git a/core/src/mindustry/content/UnitTypes.java b/core/src/mindustry/content/UnitTypes.java index d239c910d3..58c82161f1 100644 --- a/core/src/mindustry/content/UnitTypes.java +++ b/core/src/mindustry/content/UnitTypes.java @@ -96,7 +96,7 @@ public class UnitTypes implements ContentList{ flying = true; drag = 0.05f; mass = 2f; - speed = 3f; + speed = 4f; rotateSpeed = 12f; accel = 0.3f; range = 70f; diff --git a/core/src/mindustry/core/World.java b/core/src/mindustry/core/World.java index 15e03826be..86ec535142 100644 --- a/core/src/mindustry/core/World.java +++ b/core/src/mindustry/core/World.java @@ -7,6 +7,7 @@ import arc.math.geom.*; import arc.struct.*; import arc.util.ArcAnnotate.*; import arc.util.*; +import arc.util.noise.*; import mindustry.core.GameState.*; import mindustry.game.EventType.*; import mindustry.game.*; @@ -196,7 +197,7 @@ public class World{ public void loadSector(Sector sector){ state.rules.sector = sector; - int size = (int)(sector.rect.radius * 2500); + int size = (int)(sector.rect.radius * 3200); loadGenerator(size, size, tiles -> { TileGen gen = new TileGen(); @@ -352,6 +353,48 @@ public class World{ } } + public float getDarkness(int x, int y){ + int edgeBlend = 2; + + float dark = 0; + int edgeDst = Math.min(x, Math.min(y, Math.min(Math.abs(x - (world.width() - 1)), Math.abs(y - (world.height() - 1))))); + if(edgeDst <= edgeBlend){ + dark = Math.max((edgeBlend - edgeDst) * (4f / edgeBlend), dark); + } + + //TODO tweak noise and radius + if(world.isCampaign()){ + int circleBlend = 14; + //quantized angle + float offset = getSector().rect.rotation + 90; + float angle = Angles.angle(x, y, world.width()/2, world.height()/2) + offset; + //polygon sides, depends on sector + int sides = getSector().tile.corners.length; + float step = 360f / sides; + //prev and next angles of poly + float prev = Mathf.round(angle, step); + float next = prev + step; + //raw line length to be translated + float length = world.width()/2f; + float rawDst = Intersector.distanceLinePoint(Tmp.v1.trns(prev, length), Tmp.v2.trns(next, length), Tmp.v3.set(x - world.width()/2, y - world.height()/2).rotate(offset)) / Mathf.sqrt3 - 1; + + //noise + rawDst += Noise.nnoise(x, y, 11f, 7f) + Noise.nnoise(x, y, 22f, 15f); + + int circleDst = (int)(rawDst - (world.width() / 2 - circleBlend)); + if(circleDst > 0){ + dark = Math.max(circleDst / 0.8f, dark); + } + } + + Tile tile = world.rawTile(x, y); + if(tile.block().solid && tile.block().fillsTile && !tile.block().synthetic()){ + dark = Math.max(dark, tile.rotation()); + } + + return dark; + } + /** * 'Prepares' a tile array by:
* - setting up multiblocks
diff --git a/core/src/mindustry/graphics/BlockRenderer.java b/core/src/mindustry/graphics/BlockRenderer.java index 17197c43a6..66c1a22490 100644 --- a/core/src/mindustry/graphics/BlockRenderer.java +++ b/core/src/mindustry/graphics/BlockRenderer.java @@ -8,7 +8,6 @@ import arc.graphics.gl.*; import arc.math.*; import arc.struct.*; import arc.util.*; -import arc.util.noise.*; import mindustry.content.*; import mindustry.game.EventType.*; import mindustry.game.Teams.*; @@ -77,7 +76,7 @@ public class BlockRenderer implements Disposable{ for(int y = 0; y < world.height(); y++){ Tile tile = world.rawTile(x, y); - float darkness = getDarkness(x, y); + float darkness = world.getDarkness(x, y); if(darkness > 0){ Draw.color(0f, 0f, 0f, Math.min((darkness + 0.5f) / 4f, 1f)); @@ -105,33 +104,6 @@ public class BlockRenderer implements Disposable{ }); } - public float getDarkness(int x, int y){ - int edgeBlend = 2; - - float dark = 0; - int edgeDst = Math.min(x, Math.min(y, Math.min(Math.abs(x - (world.width() - 1)), Math.abs(y - (world.height() - 1))))); - if(edgeDst <= edgeBlend){ - dark = Math.max((edgeBlend - edgeDst) * (4f / edgeBlend), dark); - } - - //TODO tweak noise and radius - if(world.isCampaign()){ - int circleBlend = 14; - float rawDst = Mathf.dst(x, y, world.width() / 2, world.height() / 2) + Noise.nnoise(x, y, 7f, 7f) + Noise.nnoise(x, y, 20f, 15f); - int circleDst = (int)(rawDst - (world.width() / 2 - circleBlend)); - if(circleDst > 0){ - dark = Math.max(circleDst / 1.6f, dark); - } - } - - Tile tile = world.rawTile(x, y); - if(tile.block().solid && tile.block().fillsTile && !tile.block().synthetic()){ - dark = Math.max(dark, tile.rotation()); - } - - return dark; - } - public void drawFog(){ float ww = world.width() * tilesize, wh = world.height() * tilesize; float x = camera.position.x + tilesize / 2f, y = camera.position.y + tilesize / 2f; diff --git a/core/src/mindustry/graphics/MinimapRenderer.java b/core/src/mindustry/graphics/MinimapRenderer.java index f317cdfd47..0a9f816f93 100644 --- a/core/src/mindustry/graphics/MinimapRenderer.java +++ b/core/src/mindustry/graphics/MinimapRenderer.java @@ -162,7 +162,7 @@ public class MinimapRenderer implements Disposable{ return bc; } Color color = Tmp.c1.set(MapIO.colorFor(tile.floor(), tile.block(), tile.overlay(), tile.team())); - color.mul(1f - Mathf.clamp(renderer.blocks.getDarkness(tile.x, tile.y) / 4f)); + color.mul(1f - Mathf.clamp(world.getDarkness(tile.x, tile.y) / 4f)); return color.rgba(); } diff --git a/core/src/mindustry/graphics/PlanetRenderer.java b/core/src/mindustry/graphics/PlanetRenderer.java index a2543685b3..4f010a860d 100644 --- a/core/src/mindustry/graphics/PlanetRenderer.java +++ b/core/src/mindustry/graphics/PlanetRenderer.java @@ -18,7 +18,7 @@ import static mindustry.Vars.*; public class PlanetRenderer implements PlanetGenerator{ private final Color outlineColor = Pal.accent.cpy().a(0.7f); private final float camLength = 4f, outlineRad = 1.15f; - private final boolean drawRect = false; + private final boolean drawRect = true; private final PlanetMesh[] outlines = new PlanetMesh[10]; private final Camera3D cam = new Camera3D(); @@ -64,15 +64,18 @@ public class PlanetRenderer implements PlanetGenerator{ rect.right.scl(outlineRad); rect.top.scl(outlineRad); - batch.color(Pal.place); - batch.vertex(rect.project(0, 0)); - batch.color(Pal.place); - batch.vertex(rect.project(1, 0)); - batch.color(Pal.place); - batch.vertex(rect.project(1, 1)); - batch.color(Pal.place); - batch.vertex(rect.project(0, 1)); - batch.flush(cam.combined(), Gl.lineLoop); + batch.color(Color.red); + batch.vertex(rect.center); + batch.color(Color.red); + batch.vertex(sector.tile.corners[0].v); + + batch.color(Color.green); + batch.vertex(rect.center); + batch.color(Color.green); + batch.vertex(rect.top.cpy().add(rect.center)); + batch.flush(cam.combined(), Gl.lines); + + //Log.info((int)(sector.tile.corners[0].v.cpy().sub(rect.center).angle(rect.top))); rect.center.scl(1f / outlineRad); rect.right.scl(1f / outlineRad); diff --git a/core/src/mindustry/maps/planet/TestPlanetGenerator.java b/core/src/mindustry/maps/planet/TestPlanetGenerator.java index 553fea2b21..4d43833fe5 100644 --- a/core/src/mindustry/maps/planet/TestPlanetGenerator.java +++ b/core/src/mindustry/maps/planet/TestPlanetGenerator.java @@ -118,7 +118,7 @@ public class TestPlanetGenerator implements PlanetGenerator{ } tiles.each((x, y) -> tiles.get(x, y).setBlock(!read.get(x, y) ? Blocks.air : tiles.get(x, y).floor().wall)); - distort(0.01f, 8f); + distort(0.009f, 12f); tiles.get(tiles.width /2, tiles.height /2).setBlock(Blocks.coreShard, Team.sharded); } diff --git a/core/src/mindustry/type/Sector.java b/core/src/mindustry/type/Sector.java index 2bb9169a3d..a3ea26c5be 100644 --- a/core/src/mindustry/type/Sector.java +++ b/core/src/mindustry/type/Sector.java @@ -58,22 +58,28 @@ public class Sector{ Plane plane = new Plane(); plane.set(corners[0], corners[2], corners[4]); - Vec3 planeTop = plane.project(center.cpy().add(0f, 1f, 0f)).sub(center).setLength(radius).add(center); - Vec3 planeRight = plane.project(center.cpy().rotate(Vec3.Y, -4f)).sub(center).setLength(radius).add(center); + //relative vectors + Vec3 planeTop = plane.project(center.cpy().add(0f, 1f, 0f)).sub(center).setLength(radius); + Vec3 planeRight = plane.project(center.cpy().rotate(Vec3.Y, -4f)).sub(center).setLength(radius); - return new SectorRect(radius, center, planeTop.sub(center), planeRight.sub(center)); + //get angle from first corner to top vector + Vec3 first = corners[1].cpy().sub(center); //first vector relative to center + float angle = first.angle(planeTop); + + return new SectorRect(radius, center, planeTop, planeRight, angle); } public static class SectorRect{ public final Vec3 center, top, right; public final Vec3 result = new Vec3(); - public final float radius; + public final float radius, rotation; - public SectorRect(float radius, Vec3 center, Vec3 top, Vec3 right){ + public SectorRect(float radius, Vec3 center, Vec3 top, Vec3 right, float rotation){ this.center = center; this.top = top; this.right = right; this.radius = radius; + this.rotation = rotation; } /** Project a coordinate into 3D space. diff --git a/core/src/mindustry/world/Build.java b/core/src/mindustry/world/Build.java index a64d7187a2..ad6b7d255a 100644 --- a/core/src/mindustry/world/Build.java +++ b/core/src/mindustry/world/Build.java @@ -82,8 +82,8 @@ public class Build{ return false; } - //campaign circle check - if(world.isCampaign() && !Mathf.within(x, y, world.width()/2, world.height()/2, world.width()/2 - 8)){ + //ca check + if(world.getDarkness(x, y) >= 3){ return false; }