Add first snap event sound world

This commit is contained in:
ChillerDragon 2022-11-19 10:39:29 +01:00
parent e203f09fe4
commit dd714e51aa
3 changed files with 38 additions and 1 deletions

View file

@ -0,0 +1,20 @@
# frozen_string_literal: true
require_relative '../snap_event_base'
class NetEvent
class SoundWorld < SnapEventBase
attr_accessor :sound_id
def initialize(hash_or_raw)
@field_names = %i[
sound_id
]
super
end
def self.match_type?(type)
type == NETEVENTTYPE_SOUNDWORLD
end
end
end

View file

@ -0,0 +1,14 @@
# frozen_string_literal: true
require_relative '../packer'
require_relative 'snap_item_base'
class SnapEventBase < SnapItemBase
attr_reader :x, :y
def initialize(hash_or_raw)
@field_names.prepend(:x)
@field_names.prepend(:y)
super
end
end

View file

@ -4,6 +4,7 @@ require_relative 'items/game_data'
require_relative 'items/character'
require_relative 'items/player_info'
require_relative 'items/projectile'
require_relative 'events/sound_world'
require_relative '../packer'
class SnapshotUnpacker
@ -100,6 +101,8 @@ class SnapshotUnpacker
obj = NetObj::PlayerInfo.new(u)
elsif NetObj::Projectile.match_type?(item_type)
obj = NetObj::Projectile.new(u)
elsif NetEvent::SoundWorld.match_type?(item_type)
obj = NetEvent::SoundWorld.new(u)
elsif @verbose
puts "no match #{item_type}"
end
@ -128,7 +131,7 @@ class SnapshotUnpacker
puts " #{hex}"
end
# exit 1 if invalid
exit 1 if invalid
game_tick
end