From cacb75ac6220013a8065968c1d4d86f8c169b151 Mon Sep 17 00:00:00 2001 From: ChillerDragon Date: Wed, 21 Feb 2024 14:44:49 +0800 Subject: [PATCH] Add type to snap items --- lib/snapshot/events/damage.rb | 1 + lib/snapshot/events/death.rb | 1 + lib/snapshot/events/explosion.rb | 1 + lib/snapshot/events/hammer_hit.rb | 1 + lib/snapshot/events/sound_world.rb | 1 + lib/snapshot/events/spawn.rb | 1 + lib/snapshot/items/character.rb | 1 + lib/snapshot/items/client_info.rb | 1 + lib/snapshot/items/flag.rb | 1 + lib/snapshot/items/game_data.rb | 1 + lib/snapshot/items/game_data_flag.rb | 1 + lib/snapshot/items/game_data_team.rb | 1 + lib/snapshot/items/laser.rb | 1 + lib/snapshot/items/pickup.rb | 1 + lib/snapshot/items/player_info.rb | 1 + lib/snapshot/items/player_input.rb | 1 + lib/snapshot/items/projectile.rb | 1 + lib/snapshot/items/spectator_info.rb | 1 + lib/snapshot/snap_item_base.rb | 2 +- 19 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/snapshot/events/damage.rb b/lib/snapshot/events/damage.rb index 0508901..ba5854b 100644 --- a/lib/snapshot/events/damage.rb +++ b/lib/snapshot/events/damage.rb @@ -7,6 +7,7 @@ class NetEvent attr_accessor :client_id, :angle, :health_ammount, :armor_amount, :self def initialize(hash_or_raw) + @type = NETEVENTTYPE_DAMAGE @field_names = %i[ client_id angle diff --git a/lib/snapshot/events/death.rb b/lib/snapshot/events/death.rb index e513573..9e7e1fb 100644 --- a/lib/snapshot/events/death.rb +++ b/lib/snapshot/events/death.rb @@ -7,6 +7,7 @@ class NetEvent attr_accessor :client_id def initialize(hash_or_raw) + @type = NETEVENTTYPE_DEATH @field_names = %i[ client_id ] diff --git a/lib/snapshot/events/explosion.rb b/lib/snapshot/events/explosion.rb index a3a4874..23ac539 100644 --- a/lib/snapshot/events/explosion.rb +++ b/lib/snapshot/events/explosion.rb @@ -5,6 +5,7 @@ require_relative '../snap_item_base' class NetEvent class Explosion < SnapEventBase def initialize(hash_or_raw) + @type = NETEVENTTYPE_EXPLOSION @field_names = [] super end diff --git a/lib/snapshot/events/hammer_hit.rb b/lib/snapshot/events/hammer_hit.rb index 689dc56..a5b3625 100644 --- a/lib/snapshot/events/hammer_hit.rb +++ b/lib/snapshot/events/hammer_hit.rb @@ -5,6 +5,7 @@ require_relative '../snap_item_base' class NetEvent class HammerHit < SnapEventBase def initialize(hash_or_raw) + @type = NETEVENTTYPE_HAMMERHIT @field_names = [] super end diff --git a/lib/snapshot/events/sound_world.rb b/lib/snapshot/events/sound_world.rb index ac4438e..3497dd7 100644 --- a/lib/snapshot/events/sound_world.rb +++ b/lib/snapshot/events/sound_world.rb @@ -7,6 +7,7 @@ class NetEvent attr_accessor :sound_id def initialize(hash_or_raw) + @type = NETEVENTTYPE_SOUNDWORLD @field_names = %i[ sound_id ] diff --git a/lib/snapshot/events/spawn.rb b/lib/snapshot/events/spawn.rb index 01e8811..29418d2 100644 --- a/lib/snapshot/events/spawn.rb +++ b/lib/snapshot/events/spawn.rb @@ -5,6 +5,7 @@ require_relative '../snap_item_base' class NetEvent class Spawn < SnapEventBase def initialize(hash_or_raw) + @type = NETEVENTTYPE_SPAWN @field_names = [] super end diff --git a/lib/snapshot/items/character.rb b/lib/snapshot/items/character.rb index cee67a2..b3c34e2 100644 --- a/lib/snapshot/items/character.rb +++ b/lib/snapshot/items/character.rb @@ -9,6 +9,7 @@ class NetObj :health, :armor, :ammo_count, :weapon, :emote, :attack_tick, :triggered_events def initialize(hash_or_raw) + @type = NETOBJTYPE_CHARACTER @field_names = %i[ tick x diff --git a/lib/snapshot/items/client_info.rb b/lib/snapshot/items/client_info.rb index 6063291..e3fb41a 100644 --- a/lib/snapshot/items/client_info.rb +++ b/lib/snapshot/items/client_info.rb @@ -7,6 +7,7 @@ class NetObj attr_accessor :local, :team def initialize(hash_or_raw) + @type = NETOBJTYPE_DE_CLIENTINFO @field_names = %i[ local team diff --git a/lib/snapshot/items/flag.rb b/lib/snapshot/items/flag.rb index 5c85735..2df6878 100644 --- a/lib/snapshot/items/flag.rb +++ b/lib/snapshot/items/flag.rb @@ -7,6 +7,7 @@ class NetObj attr_accessor :x, :y, :team def initialize(hash_or_raw) + @type = NETOBJTYPE_FLAG @field_names = %i[ x y diff --git a/lib/snapshot/items/game_data.rb b/lib/snapshot/items/game_data.rb index 95d4d2b..c6dfecf 100644 --- a/lib/snapshot/items/game_data.rb +++ b/lib/snapshot/items/game_data.rb @@ -7,6 +7,7 @@ class NetObj attr_accessor :game_start_tick, :game_state_flags, :game_state_end_tick def initialize(hash_or_raw) + @type = NETOBJTYPE_GAMEDATA @field_names = %i[ game_start_tick game_state_flags diff --git a/lib/snapshot/items/game_data_flag.rb b/lib/snapshot/items/game_data_flag.rb index b214703..4faedc7 100644 --- a/lib/snapshot/items/game_data_flag.rb +++ b/lib/snapshot/items/game_data_flag.rb @@ -8,6 +8,7 @@ class NetObj :flag_drop_tick_red, :flag_drop_tick_blue def initialize(hash_or_raw) + @type = NETOBJTYPE_GAMEDATAFLAG @field_names = %i[ flag_carrier_red flag_carrier_blue diff --git a/lib/snapshot/items/game_data_team.rb b/lib/snapshot/items/game_data_team.rb index 3d338c7..8027e2f 100644 --- a/lib/snapshot/items/game_data_team.rb +++ b/lib/snapshot/items/game_data_team.rb @@ -7,6 +7,7 @@ class NetObj attr_accessor :teamscore_red, :teamscore_blue def initialize(hash_or_raw) + @type = NETOBJTYPE_GAMEDATATEAM @field_names = %i[ teamscore_red teamscore_blue diff --git a/lib/snapshot/items/laser.rb b/lib/snapshot/items/laser.rb index 0a338c1..8392ece 100644 --- a/lib/snapshot/items/laser.rb +++ b/lib/snapshot/items/laser.rb @@ -7,6 +7,7 @@ class NetObj attr_accessor :x, :y, :from_x, :from_y, :start_tick def initialize(hash_or_raw) + @type = NETOBJTYPE_LASER @field_names = %i[ x y diff --git a/lib/snapshot/items/pickup.rb b/lib/snapshot/items/pickup.rb index 10d2908..240ccf9 100644 --- a/lib/snapshot/items/pickup.rb +++ b/lib/snapshot/items/pickup.rb @@ -7,6 +7,7 @@ class NetObj attr_accessor :x, :y, :type def initialize(hash_or_raw) + @type = NETOBJTYPE_PICKUP @field_names = %i[ x y diff --git a/lib/snapshot/items/player_info.rb b/lib/snapshot/items/player_info.rb index ff619e1..2be5fb2 100644 --- a/lib/snapshot/items/player_info.rb +++ b/lib/snapshot/items/player_info.rb @@ -7,6 +7,7 @@ class NetObj attr_accessor :player_flags, :score, :latency def initialize(hash_or_raw) + @type = NETOBJTYPE_PLAYERINFO @field_names = %i[ player_flags score diff --git a/lib/snapshot/items/player_input.rb b/lib/snapshot/items/player_input.rb index 4b90a47..9cae49f 100644 --- a/lib/snapshot/items/player_input.rb +++ b/lib/snapshot/items/player_input.rb @@ -10,6 +10,7 @@ class NetObj :next_weapon, :prev_weapon def initialize(hash_or_raw) + @type = NETOBJTYPE_PLAYERINPUT @field_names = %i[ direction target_x diff --git a/lib/snapshot/items/projectile.rb b/lib/snapshot/items/projectile.rb index 764a9a9..155a794 100644 --- a/lib/snapshot/items/projectile.rb +++ b/lib/snapshot/items/projectile.rb @@ -7,6 +7,7 @@ class NetObj attr_accessor :x, :y, :vel_x, :vel_y, :type, :start_tick def initialize(hash_or_raw) + @type = NETOBJTYPE_PROJECTILE @field_names = %i[ x y diff --git a/lib/snapshot/items/spectator_info.rb b/lib/snapshot/items/spectator_info.rb index 66b64ed..56ed703 100644 --- a/lib/snapshot/items/spectator_info.rb +++ b/lib/snapshot/items/spectator_info.rb @@ -7,6 +7,7 @@ class NetObj attr_accessor :spec_mode, :spectator_id, :x, :y def initialize(hash_or_raw) + @type = NETOBJTYPE_SPECTATORINFO @field_names = %i[ spec_mode spectator_id diff --git a/lib/snapshot/snap_item_base.rb b/lib/snapshot/snap_item_base.rb index 486edde..a8f3073 100644 --- a/lib/snapshot/snap_item_base.rb +++ b/lib/snapshot/snap_item_base.rb @@ -3,7 +3,7 @@ require_relative '../packer' class SnapItemBase - attr_reader :notes, :name, :id + attr_reader :notes, :name, :type, :id def initialize(hash_or_raw) @fields = @field_names.map do |_|