diff options
Diffstat (limited to 'extractor')
-rw-r--r-- | extractor/gat_format.gd | 89 | ||||
-rw-r--r-- | extractor/sprite_layer_resource.gd | 10 | ||||
-rw-r--r-- | extractor/sprite_resource.gd | 5 |
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] |