Sector darkness boundaries
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user