Misc fog of war fixes
This commit is contained in:
@@ -17,7 +17,6 @@ import java.io.*;
|
|||||||
|
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
//TODO bitset + dynamic FoW
|
|
||||||
public class FogControl implements CustomChunk{
|
public class FogControl implements CustomChunk{
|
||||||
private static volatile int ww, wh;
|
private static volatile int ww, wh;
|
||||||
private static final int staticUpdateInterval = 1000 / 25; //25 FPS
|
private static final int staticUpdateInterval = 1000 / 25; //25 FPS
|
||||||
@@ -34,7 +33,7 @@ public class FogControl implements CustomChunk{
|
|||||||
private @Nullable Thread staticFogThread;
|
private @Nullable Thread staticFogThread;
|
||||||
private @Nullable Thread dynamicFogThread;
|
private @Nullable Thread dynamicFogThread;
|
||||||
|
|
||||||
private boolean read = false, justLoaded = false;
|
private boolean justLoaded = false;
|
||||||
|
|
||||||
public FogControl(){
|
public FogControl(){
|
||||||
Events.on(ResetEvent.class, e -> {
|
Events.on(ResetEvent.class, e -> {
|
||||||
@@ -49,14 +48,14 @@ public class FogControl implements CustomChunk{
|
|||||||
wh = world.height();
|
wh = world.height();
|
||||||
|
|
||||||
//all old buildings have static light scheduled around them
|
//all old buildings have static light scheduled around them
|
||||||
if(state.rules.fog && read){
|
if(state.rules.fog){
|
||||||
for(var build : Groups.build){
|
synchronized(staticEvents){
|
||||||
synchronized(staticEvents){
|
for(var build : Groups.build){
|
||||||
staticEvents.add(FogEvent.get(build.tile.x, build.tile.y, build.block.size, build.team.id));
|
if(build.block.flags.contains(BlockFlag.hasFogRadius)){
|
||||||
|
staticEvents.add(FogEvent.get(build.tile.x, build.tile.y, build.block.fogRadius, build.team.id));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
read = false;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -121,7 +120,6 @@ public class FogControl implements CustomChunk{
|
|||||||
if(dynamicFogThread != null){
|
if(dynamicFogThread != null){
|
||||||
dynamicFogThread.interrupt();
|
dynamicFogThread.interrupt();
|
||||||
dynamicFogThread = null;
|
dynamicFogThread = null;
|
||||||
Log.info("end dynamic fog");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,7 +135,7 @@ public class FogControl implements CustomChunk{
|
|||||||
fog = new FogData[256];
|
fog = new FogData[256];
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO should it be clientside...?
|
//not run clientside, the CPU side isn't needed here.
|
||||||
if(staticFogThread == null && !net.client()){
|
if(staticFogThread == null && !net.client()){
|
||||||
staticFogThread = new StaticFogThread();
|
staticFogThread = new StaticFogThread();
|
||||||
staticFogThread.setDaemon(true);
|
staticFogThread.setDaemon(true);
|
||||||
@@ -150,10 +148,6 @@ public class FogControl implements CustomChunk{
|
|||||||
dynamicFogThread.start();
|
dynamicFogThread.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO force update all fog on world load
|
|
||||||
|
|
||||||
//TODO dynamic fog initialization
|
|
||||||
|
|
||||||
//clear to prepare for queuing fog radius from units and buildings
|
//clear to prepare for queuing fog radius from units and buildings
|
||||||
dynamicEventQueue.clear();
|
dynamicEventQueue.clear();
|
||||||
|
|
||||||
@@ -194,7 +188,7 @@ public class FogControl implements CustomChunk{
|
|||||||
|
|
||||||
//add building updates
|
//add building updates
|
||||||
for(var build : indexer.getFlagged(team.team, BlockFlag.hasFogRadius)){
|
for(var build : indexer.getFlagged(team.team, BlockFlag.hasFogRadius)){
|
||||||
dynamicEventQueue.add(FogEvent.get(build.tile.x, build.tile.y, build.block.fogRadius, 0));
|
dynamicEventQueue.add(FogEvent.get(build.tile.x, build.tile.y, build.block.fogRadius, build.team.id));
|
||||||
}
|
}
|
||||||
|
|
||||||
//add unit updates
|
//add unit updates
|
||||||
@@ -413,8 +407,6 @@ public class FogControl implements CustomChunk{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
read = true;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ public class FogRenderer{
|
|||||||
}
|
}
|
||||||
|
|
||||||
void poly(Rect check, float x, float y, float rad){
|
void poly(Rect check, float x, float y, float rad){
|
||||||
if(check.overlaps(x - rad / 2f, y - rad / 2f, rad * 2f, rad * 2f)){
|
if(check.overlaps(x - rad, y - rad, rad * 2f, rad * 2f)){
|
||||||
Fill.poly(x, y, 20, rad);
|
Fill.poly(x, y, 20, rad);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ public class CoreBlock extends StorageBlock{
|
|||||||
public void init(){
|
public void init(){
|
||||||
//assign to update clipSize internally
|
//assign to update clipSize internally
|
||||||
lightRadius = 30f + 20f * size;
|
lightRadius = 30f + 20f * size;
|
||||||
fogRadius = Math.max(fogRadius, (int)(lightRadius / 8f * 2f));
|
fogRadius = Math.max(fogRadius, (int)(lightRadius / 8f * 2.5f));
|
||||||
emitLight = true;
|
emitLight = true;
|
||||||
|
|
||||||
super.init();
|
super.init();
|
||||||
|
|||||||
Reference in New Issue
Block a user