Add first snap event sound world
This commit is contained in:
parent
e203f09fe4
commit
dd714e51aa
20
lib/snapshot/events/sound_world.rb
Normal file
20
lib/snapshot/events/sound_world.rb
Normal 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
|
14
lib/snapshot/snap_event_base.rb
Normal file
14
lib/snapshot/snap_event_base.rb
Normal 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
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue