Studio scene pack contract for runtime SCENE binary payload
This commit is contained in:
+37
@@ -0,0 +1,37 @@
|
||||
package p.packer.messages.assets;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public record ScenePackLayerRequest(
|
||||
boolean active,
|
||||
int glyphAssetId,
|
||||
int tileSize,
|
||||
float parallaxFactorX,
|
||||
float parallaxFactorY,
|
||||
int width,
|
||||
int height,
|
||||
List<ScenePackTileRequest> tiles) {
|
||||
|
||||
public ScenePackLayerRequest {
|
||||
tiles = List.copyOf(Objects.requireNonNull(tiles, "tiles"));
|
||||
if (glyphAssetId < 0) {
|
||||
throw new IllegalArgumentException("glyphAssetId must be non-negative");
|
||||
}
|
||||
if (tileSize < 0) {
|
||||
throw new IllegalArgumentException("tileSize must be non-negative");
|
||||
}
|
||||
if (width <= 0 || height <= 0) {
|
||||
throw new IllegalArgumentException("width and height must be positive");
|
||||
}
|
||||
if (!Float.isFinite(parallaxFactorX) || parallaxFactorX < 0.0f) {
|
||||
throw new IllegalArgumentException("parallaxFactorX must be finite and non-negative");
|
||||
}
|
||||
if (!Float.isFinite(parallaxFactorY) || parallaxFactorY < 0.0f) {
|
||||
throw new IllegalArgumentException("parallaxFactorY must be finite and non-negative");
|
||||
}
|
||||
if (tiles.size() != width * height) {
|
||||
throw new IllegalArgumentException("tiles size must match width * height");
|
||||
}
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package p.packer.messages.assets;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public record ScenePackRequest(
|
||||
int version,
|
||||
List<ScenePackLayerRequest> layers) {
|
||||
|
||||
public ScenePackRequest {
|
||||
layers = List.copyOf(Objects.requireNonNull(layers, "layers"));
|
||||
if (version <= 0) {
|
||||
throw new IllegalArgumentException("version must be positive");
|
||||
}
|
||||
if (layers.size() != 4) {
|
||||
throw new IllegalArgumentException("layers must contain exactly 4 entries");
|
||||
}
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package p.packer.messages.assets;
|
||||
|
||||
public record ScenePackTileRequest(
|
||||
boolean active,
|
||||
int glyphId,
|
||||
int paletteId,
|
||||
boolean flipX,
|
||||
boolean flipY) {
|
||||
|
||||
public ScenePackTileRequest {
|
||||
if (glyphId < 0) {
|
||||
throw new IllegalArgumentException("glyphId must be non-negative");
|
||||
}
|
||||
if (paletteId < 0) {
|
||||
throw new IllegalArgumentException("paletteId must be non-negative");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user