Stein Tool ein wenig überarbeitet
This commit is contained in:
@@ -11,7 +11,9 @@ public record PlacedStone(
|
||||
float x,
|
||||
float z,
|
||||
float radius,
|
||||
float rotX,
|
||||
float rotY,
|
||||
float rotZ,
|
||||
int textureSlot,
|
||||
float sinkFraction,
|
||||
int noiseSeed
|
||||
|
||||
@@ -9,19 +9,20 @@ import java.util.zip.*;
|
||||
* Liest und schreibt platzierte Steine als komprimierte Binärdatei
|
||||
* ({@code blight_stones.bls}) neben der Kartendatei.
|
||||
*
|
||||
* Format v1:
|
||||
* Format v3:
|
||||
* int MAGIC 0x53544E53 ("STNS")
|
||||
* int VERSION 1
|
||||
* int VERSION 3
|
||||
* int SLOT_COUNT 3
|
||||
* 3× UTF Texturpfad pro Slot ("" = kein)
|
||||
* float roughness (v2+; 0..1)
|
||||
* int stoneCount
|
||||
* N× float x, float z, float radius, float rotY,
|
||||
* N× float x, float z, float radius, float rotX, float rotY, float rotZ,
|
||||
* byte textureSlot, float sinkFraction, int noiseSeed
|
||||
*/
|
||||
public final class PlacedStoneIO {
|
||||
|
||||
private static final int MAGIC = 0x53544E53;
|
||||
private static final int VERSION = 1;
|
||||
private static final int VERSION = 3;
|
||||
public static final int SLOT_COUNT = 3;
|
||||
|
||||
private PlacedStoneIO() {}
|
||||
@@ -30,7 +31,7 @@ public final class PlacedStoneIO {
|
||||
return MapIO.getMapPath().resolveSibling("blight_stones.bls");
|
||||
}
|
||||
|
||||
public record StoneData(String[] slotPaths, List<PlacedStone> stones) {}
|
||||
public record StoneData(String[] slotPaths, float roughness, List<PlacedStone> stones) {}
|
||||
|
||||
public static void save(StoneData data) throws IOException {
|
||||
Path p = getPath();
|
||||
@@ -45,13 +46,16 @@ public final class PlacedStoneIO {
|
||||
String s = (i < paths.length && paths[i] != null) ? paths[i] : "";
|
||||
out.writeUTF(s);
|
||||
}
|
||||
out.writeFloat(data.roughness());
|
||||
List<PlacedStone> stones = data.stones() != null ? data.stones() : List.of();
|
||||
out.writeInt(stones.size());
|
||||
for (PlacedStone s : stones) {
|
||||
out.writeFloat(s.x());
|
||||
out.writeFloat(s.z());
|
||||
out.writeFloat(s.radius());
|
||||
out.writeFloat(s.rotX());
|
||||
out.writeFloat(s.rotY());
|
||||
out.writeFloat(s.rotZ());
|
||||
out.writeByte(s.textureSlot());
|
||||
out.writeFloat(s.sinkFraction());
|
||||
out.writeInt(s.noiseSeed());
|
||||
@@ -74,19 +78,22 @@ public final class PlacedStoneIO {
|
||||
String s = in.readUTF();
|
||||
if (i < SLOT_COUNT) paths[i] = s;
|
||||
}
|
||||
float roughness = (ver >= 2) ? in.readFloat() : 0.40f;
|
||||
int count = in.readInt();
|
||||
List<PlacedStone> stones = new ArrayList<>(count);
|
||||
for (int i = 0; i < count; i++) {
|
||||
float x = in.readFloat();
|
||||
float z = in.readFloat();
|
||||
float r = in.readFloat();
|
||||
float rotX = (ver >= 3) ? in.readFloat() : 0f;
|
||||
float rotY = in.readFloat();
|
||||
float rotZ = (ver >= 3) ? in.readFloat() : 0f;
|
||||
int slot = in.readUnsignedByte();
|
||||
float sink = in.readFloat();
|
||||
int seed = in.readInt();
|
||||
stones.add(new PlacedStone(x, z, r, rotY, slot, sink, seed));
|
||||
stones.add(new PlacedStone(x, z, r, rotX, rotY, rotZ, slot, sink, seed));
|
||||
}
|
||||
return new StoneData(paths, stones);
|
||||
return new StoneData(paths, roughness, stones);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user