mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 03:38:01 +00:00
Adventure mode PoI refactor.
Renamed, re-set and cherry-picked a few of the various PoIs and reverted placement behavior.
This commit is contained in:
@@ -1,14 +1,11 @@
|
||||
package forge.adventure.data;
|
||||
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.Json;
|
||||
import forge.adventure.util.Config;
|
||||
import forge.adventure.util.Paths;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Data class that will be used to read Json configuration files
|
||||
* BiomeData
|
||||
@@ -39,13 +36,9 @@ public class PointOfInterestData {
|
||||
}
|
||||
return pointOfInterestList;
|
||||
}
|
||||
public static PointOfInterestData getPointOfInterest(String name, Vector2 index) {
|
||||
ArrayList<PointOfInterestData> candidates = new ArrayList<PointOfInterestData>();
|
||||
public static PointOfInterestData getPointOfInterest(String name) {
|
||||
for(PointOfInterestData data: new Array.ArrayIterator<>(getAllPointOfInterest())){
|
||||
if(data.name.equals(name)) candidates.add(data); //Populate candidates with specified name.
|
||||
}
|
||||
if(candidates.size() > 0){ //If we got any candidates, return a random one.
|
||||
return candidates.get(((int)(index.x*6719+index.y)%candidates.size()));//6719 is just a big prime to avoid collisions
|
||||
if(data.name.equals(name)) return data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ public class PointOfInterest implements SaveFileContent {
|
||||
public void load(SaveFileData saveFileData) {
|
||||
|
||||
position.set(saveFileData.readVector2("position"));
|
||||
data=PointOfInterestData.getPointOfInterest(saveFileData.readString("name"),position);
|
||||
data=PointOfInterestData.getPointOfInterest(saveFileData.readString("name"));
|
||||
rectangle.set(saveFileData.readRectangle("rectangle"));
|
||||
spriteIndex=saveFileData.readInt("spriteIndex");
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import forge.adventure.util.Config;
|
||||
import forge.adventure.util.Paths;
|
||||
import forge.adventure.util.SaveFileContent;
|
||||
import forge.adventure.util.SaveFileData;
|
||||
import forge.util.MyRandom;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -43,7 +44,7 @@ public class World implements Disposable, SaveFileContent {
|
||||
private PointOfInterestMap mapPoiIds;
|
||||
private BiomeTexture[] biomeTexture;
|
||||
private long seed;
|
||||
private final Random random = new Random();
|
||||
private final Random random = MyRandom.getRandom();
|
||||
private boolean worldDataLoaded=false;
|
||||
|
||||
public Random getRandom()
|
||||
|
||||
Reference in New Issue
Block a user