summaryrefslogtreecommitdiff
path: root/extractor
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2024-12-13 14:53:38 +0100
committerDaniel Weipert <git@mail.dweipert.de>2024-12-13 14:53:38 +0100
commitca4d1945598863d0ce297f4272317e5dd5797f88 (patch)
treec2675b394140a71c7eee04034f087c107dcd7c9c /extractor
parenta22381eff3bf2286ee27f4d15ddf4c431ea063be (diff)
next commit
Diffstat (limited to 'extractor')
-rw-r--r--extractor/gat_format.gd89
-rw-r--r--extractor/sprite_layer_resource.gd10
-rw-r--r--extractor/sprite_resource.gd5
3 files changed, 89 insertions, 15 deletions
diff --git a/extractor/gat_format.gd b/extractor/gat_format.gd
new file mode 100644
index 0000000..213972a
--- /dev/null
+++ b/extractor/gat_format.gd
@@ -0,0 +1,89 @@
+class_name GATFormat
+
+
+## Byte Length: 4 [br]
+## GRAT
+var signature: String = "GRAT"
+
+## Byte Type: u8 [br]
+## Byte Length: 2
+var version: Version
+
+## Byte Type: i32 [br]
+## Byte Length: 4
+var map_width: int
+
+## Byte Type: i32 [br]
+## Byte Length: 4
+var map_height: int
+
+## Byte Length: [member map_width] * [member map_height]
+var tiles: Array[Tile]
+
+
+static func from_bytes(bytes: ByteStream) -> GATFormat:
+ var gat_format = GATFormat.new()
+
+ bytes.advance(gat_format.signature.length())
+
+ @warning_ignore("shadowed_variable")
+ var version = Version.new()
+ version.major = bytes.decode_u8()
+ version.minor = bytes.decode_u8()
+ gat_format.version = version
+
+ gat_format.map_width = bytes.decode_s32()
+ gat_format.map_height = bytes.decode_s32()
+
+ gat_format.tiles = [] as Array[Tile]
+ for _n in gat_format.map_width * gat_format.map_height:
+ gat_format.tiles.append(Tile.from_bytes(bytes))
+
+ return gat_format
+
+
+class Tile:
+ ## Byte Type: f32 [br]
+ ## Byte Length: 4 [br]
+ ## Orignal Coordinates_ (0, 0)
+ var bottom_left_altitude: int
+
+ ## Byte Type: f32 [br]
+ ## Byte Length: 4 [br]
+ ## Orignal Coordinates_ (1, 0)
+ var bottom_right_altitude: int
+
+ ## Byte Type: f32 [br]
+ ## Byte Length: 4 [br]
+ ## Orignal Coordinates_ (0, 1)
+ var top_left_altitude: int
+
+ ## Byte Type: f32 [br]
+ ## Byte Length: 4 [br]
+ ## Orignal Coordinates_ (1, 1)
+ var top_right_altitude: int
+
+ ## Byte Type: u32 ?[br]
+ ## Byte Length: 4 ?
+ var terrain_type: int
+
+
+ func get_height_map() -> Dictionary: # Dictionary[Vector2, int]
+ return {
+ Vector2(0, 0): top_left_altitude,
+ Vector2(1, 0): top_right_altitude,
+ Vector2(0, 1): bottom_left_altitude,
+ Vector2(1, 1): bottom_right_altitude,
+ }
+
+
+ static func from_bytes(bytes: ByteStream) -> Tile:
+ var tile = Tile.new()
+
+ tile.bottom_left_altitude = bytes.decode_float()
+ tile.bottom_right_altitude = bytes.decode_float()
+ tile.top_left_altitude = bytes.decode_float()
+ tile.top_right_altitude = bytes.decode_float()
+ tile.terrain_type = bytes.decode_u32()
+
+ return tile
diff --git a/extractor/sprite_layer_resource.gd b/extractor/sprite_layer_resource.gd
deleted file mode 100644
index d67707e..0000000
--- a/extractor/sprite_layer_resource.gd
+++ /dev/null
@@ -1,10 +0,0 @@
-class_name SpriteLayerResource
-extends Resource
-
-
-@export var index: int
-@export var position: Vector2
-@export var color: Color
-@export var scale: Vector2
-@export var rotation_degrees: float
-@export var flip_h: bool
diff --git a/extractor/sprite_resource.gd b/extractor/sprite_resource.gd
deleted file mode 100644
index 380fac4..0000000
--- a/extractor/sprite_resource.gd
+++ /dev/null
@@ -1,5 +0,0 @@
-class_name SpriteResource
-extends Resource
-
-
-@export var images: Array[Texture2D]