Fixed FoW on campaign maps
This commit is contained in:
@@ -594,10 +594,10 @@ public class World{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** World context that applies filters after generation end. */
|
/** World context that applies filters after generation end. */
|
||||||
private class FilterContext extends Context{
|
public class FilterContext extends Context{
|
||||||
final Map map;
|
final Map map;
|
||||||
|
|
||||||
FilterContext(Map map){
|
public FilterContext(Map map){
|
||||||
this.map = map;
|
this.map = map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -398,7 +398,7 @@ public class BlockRenderer{
|
|||||||
|
|
||||||
boolean visible = (build == null || !build.inFogTo(pteam));
|
boolean visible = (build == null || !build.inFogTo(pteam));
|
||||||
|
|
||||||
//comment wasWasible part for hiding?
|
//comment wasVisible part for hiding?
|
||||||
if(block != Blocks.air && (visible || build.wasVisible)){
|
if(block != Blocks.air && (visible || build.wasVisible)){
|
||||||
block.drawBase(tile);
|
block.drawBase(tile);
|
||||||
Draw.reset();
|
Draw.reset();
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ public abstract class SaveVersion extends SaveFileReader{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(DataInputStream stream, CounterInputStream counter, WorldContext context) throws IOException{
|
public void read(DataInputStream stream, CounterInputStream counter, WorldContext context) throws IOException{
|
||||||
region("meta", stream, counter, this::readMeta);
|
region("meta", stream, counter, in -> readMeta(in, context));
|
||||||
region("content", stream, counter, this::readContentHeader);
|
region("content", stream, counter, this::readContentHeader);
|
||||||
|
|
||||||
try{
|
try{
|
||||||
@@ -143,7 +143,7 @@ public abstract class SaveVersion extends SaveFileReader{
|
|||||||
).merge(tags));
|
).merge(tags));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void readMeta(DataInput stream) throws IOException{
|
public void readMeta(DataInput stream, WorldContext context) throws IOException{
|
||||||
StringMap map = readStringMap(stream);
|
StringMap map = readStringMap(stream);
|
||||||
|
|
||||||
state.wave = map.getInt("wave");
|
state.wave = map.getInt("wave");
|
||||||
@@ -154,6 +154,11 @@ public abstract class SaveVersion extends SaveFileReader{
|
|||||||
if(state.rules.spawns.isEmpty()) state.rules.spawns = waves.get();
|
if(state.rules.spawns.isEmpty()) state.rules.spawns = waves.get();
|
||||||
lastReadBuild = map.getInt("build", -1);
|
lastReadBuild = map.getInt("build", -1);
|
||||||
|
|
||||||
|
state.rules.sector = context.getSector();
|
||||||
|
if(state.rules.sector != null){
|
||||||
|
state.rules.sector.planet.ruleSetter.get(state.rules);
|
||||||
|
}
|
||||||
|
|
||||||
if(!headless){
|
if(!headless){
|
||||||
Tmp.v1.tryFromString(map.get("viewpos"));
|
Tmp.v1.tryFromString(map.get("viewpos"));
|
||||||
Core.camera.position.set(Tmp.v1);
|
Core.camera.position.set(Tmp.v1);
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ public class LegacyRegionSaveVersion extends SaveVersion{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(DataInputStream stream, CounterInputStream counter, WorldContext context) throws IOException{
|
public void read(DataInputStream stream, CounterInputStream counter, WorldContext context) throws IOException{
|
||||||
region("meta", stream, counter, this::readMeta);
|
region("meta", stream, counter, in -> readMeta(in, context));
|
||||||
region("content", stream, counter, this::readContentHeader);
|
region("content", stream, counter, this::readContentHeader);
|
||||||
|
|
||||||
try{
|
try{
|
||||||
|
|||||||
@@ -37,7 +37,12 @@ public class FileMapGenerator implements WorldGenerator{
|
|||||||
Sector sector = state.rules.sector;
|
Sector sector = state.rules.sector;
|
||||||
|
|
||||||
world.setGenerating(false);
|
world.setGenerating(false);
|
||||||
SaveIO.load(map.file, world.filterContext(map));
|
SaveIO.load(map.file, world.new FilterContext(map){
|
||||||
|
@Override
|
||||||
|
public Sector getSector(){
|
||||||
|
return sector;
|
||||||
|
}
|
||||||
|
});
|
||||||
world.setGenerating(true);
|
world.setGenerating(true);
|
||||||
|
|
||||||
//make sure sector is maintained - don't reset it after map load.
|
//make sure sector is maintained - don't reset it after map load.
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public class Planet extends UnlockableContent{
|
|||||||
public boolean drawOrbit = true;
|
public boolean drawOrbit = true;
|
||||||
/** Atmosphere radius adjustment parameters. */
|
/** Atmosphere radius adjustment parameters. */
|
||||||
public float atmosphereRadIn = 0, atmosphereRadOut = 0.3f;
|
public float atmosphereRadIn = 0, atmosphereRadOut = 0.3f;
|
||||||
/** Frustrum sphere clip radius. */
|
/** Frustum sphere clip radius. */
|
||||||
public float clipRadius = -1f;
|
public float clipRadius = -1f;
|
||||||
/** Orbital radius around the sun. Do not change unless you know exactly what you are doing.*/
|
/** Orbital radius around the sun. Do not change unless you know exactly what you are doing.*/
|
||||||
public float orbitRadius;
|
public float orbitRadius;
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
package mindustry.world;
|
package mindustry.world;
|
||||||
|
|
||||||
|
import arc.util.*;
|
||||||
|
import mindustry.type.*;
|
||||||
|
|
||||||
public interface WorldContext{
|
public interface WorldContext{
|
||||||
|
|
||||||
/** Return a tile in the tile array.*/
|
/** Return a tile in the tile array.*/
|
||||||
@@ -23,4 +26,8 @@ public interface WorldContext{
|
|||||||
/** Called when a building is finished reading. */
|
/** Called when a building is finished reading. */
|
||||||
default void onReadBuilding(){}
|
default void onReadBuilding(){}
|
||||||
|
|
||||||
|
default @Nullable Sector getSector(){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user