From e3c185e05823e30eccd7728ceda2ee57cc66fd4d Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Wed, 11 Dec 2024 12:55:08 +0100 Subject: next commit --- extractor/action.gd | 222 ---------------------------------------------------- 1 file changed, 222 deletions(-) delete mode 100644 extractor/action.gd (limited to 'extractor/action.gd') diff --git a/extractor/action.gd b/extractor/action.gd deleted file mode 100644 index 1865786..0000000 --- a/extractor/action.gd +++ /dev/null @@ -1,222 +0,0 @@ -class_name ActionFormat - - -## Byte Length: 2 [br] -## SP -var signature: String = "AC" - -## Byte Type: u8 [br] -## Byte Length: 2 -var version: Version - -## Byte Type: u16 [br] -## Byte Length: 2 -var action_count: int - -## Byte Type: u8 [br] -## Byte Length: 10 -var reserved: PackedByteArray - -## Length: [member action_count] -var actions: Array[Action] - -## Byte Type: u16 [br] -## Byte Length: 2 -var event_count: int - -## Length: [member event_count] -var events: Array[Event] - -## Byte Type: f32 [br] -## Byte Length: 4 -var frame_times: float - - -func get_byte_length() -> int: - var length := 22 - - for action in actions: - length += action.get_byte_length() - - length += Event.BYTE_LENGTH * event_count - - return length - - -static func from_bytes(bytes: PackedByteArray): - var action = ActionFormat.new() - - @warning_ignore("shadowed_variable") - var version = Version.new() - version.minor = bytes.decode_u8(2) - version.major = bytes.decode_u8(3) - action.version = version - - print(version) - - action.action_count = bytes.decode_u16(4) - action.reserved = bytes.slice(6, 6 + 10) - - # TODO - action.actions = [] as Array[Action] - - action.event_count = 0 - - action.frame_times = 0.0 - - print(inst_to_dict(action)) - - return action - - -class Action: - ## Byte Type: u32 [br] - ## Byte Length: 4 - var motion_count: int - - ## Length: [member motion_count] - var motions: Array[Motion] - - - func get_byte_length() -> int: - var length := 4 - for motion in motions: - length += motion.get_byte_length() - - return length - - -class Motion: - ## Byte Type: u8 [br] - ## Byte Length: 32 - var unused: PackedByteArray - - ## Byte Type: u32 [br] - ## Byte Length: 4 - var sprite_layer_count: int - - ## Length: [member sprite_layer_count] - var sprite_layers: Array[SpriteLayer] - - ## Byte Type: i32 [br] - ## Byte Length: 4 - var event_id: int - - ## Byte Type: u32 [br] - ## Byte Length: 4 - var sprite_anchor_count: int - - ## Length: [member sprite_anchor_count] - var sprite_anchors: Array[SpriteAnchor] - - - func get_byte_length() -> int: - return 44 + SpriteLayer.BYTE_LENGTH * sprite_layer_count + SpriteAnchor.BYTE_LENGTH * sprite_anchor_count - - -class SpriteLayer: - const BYTE_LENGTH := 48 - - ## Byte Type: i32 [br] - ## Byte Length: 4 - var position_u: int - - ## Byte Type: i32 [br] - ## Byte Length: 4 - var position_v: int - - ## Byte Type: i32 [br] - ## Byte Length: 4 - var sprite_index: int - - ## Byte Type: u32 [br] - ## Byte Length: 4 - var is_flipped_vertical: int - - ## Byte Type: u8 [br] - ## Byte Length: 1 - var color_r: int - - ## Byte Type: u8 [br] - ## Byte Length: 1 - var color_g: int - - ## Byte Type: u8 [br] - ## Byte Length: 1 - var color_b: int - - ## Byte Type: u8 [br] - ## Byte Length: 1 - var color_a: int - - ## Byte Type: f32 [br] - ## Byte Length: 4 - var scale_u: float - - ## Byte Type: f32 [br] - ## Byte Length: 4 - var scale_v: float - - ## Byte Type: i32 [br] - ## Byte Length: 4 - var rotation_degrees: int - - ## Byte Type: u32 [br] - ## Byte Length: 4 - var sprite_type: int - - ## Byte Type: u32 [br] - ## Byte Length: 4 - var sprite_width: int - - ## Byte Type: u32 [br] - ## Byte Length: 4 - var sprite_height: int - - - func get_position() -> Vector2: - return Vector2(position_u, position_v) - - - func get_color() -> Color: - return Color8(color_r, color_g, color_b, color_a) - - - func get_scale() -> Vector2: - return Vector2(scale_u, scale_v) - - - func get_size() -> Vector2: - return Vector2(sprite_width, sprite_height) - - -class SpriteAnchor: - const BYTE_LENGTH := 16 - - ## Byte Type: u8 [br] - ## Byte Length: 4 - var unused: PackedByteArray - - ## Byte Type: i32 [br] - ## Byte Length: 4 - var position_u: int - - ## Byte Type: i32 [br] - ## Byte Length: 4 - var position_v: int - - ## Byte Type: u32 [br] - ## Byte Length: 4 - var flag: int - - - func get_position() -> Vector2: - return Vector2(position_u, position_v) - - -class Event: - const BYTE_LENGTH := 40 - - ## Byte Type: u8 [br] - ## Byte Length: 40 - var name: String -- cgit v1.2.3