class Rsrb::Item::Spawn
Attributes
item[R]
location[R]
on_table[R]
orig_respawn[R]
picked_up[R]
respawn[RW]
Public Class Methods
new(data)
click to toggle source
# File lib/rsrb/model/item.rb, line 29 def initialize(data) @item = Item.new(data['id'].to_i, (data.include?('amount') ? data['amount'].to_i : 1)) @location = Rsrb::Model::Location.new(data['x'].to_i, data['y'].to_i, data['z'].to_i) @respawn = data.include?('respawn') ? data['respawn'].to_i : 300 # Number of seconds before it will respawn @orig_respawn = @respawn @picked_up = false @on_table = data.include?('ontable') && data['ontable'] == 'true' end
Public Instance Methods
available()
click to toggle source
# File lib/rsrb/model/item.rb, line 62 def available true end
remove()
click to toggle source
# File lib/rsrb/model/item.rb, line 38 def remove @picked_up = true WORLD.region_manager.get_local_players(@location).each {|player| player.io.send_grounditem_removal(self) } end
spawn(player = nil)
click to toggle source
# File lib/rsrb/model/item.rb, line 46 def spawn(player = nil) @picked_up = false @respawn = @orig_respawn if player != nil player.io.send_grounditem_creation(self) return end WORLD.region_manager.get_local_players(@location).each { |p| p.io.send_grounditem_creation(self) } end
within_distance?(player)
click to toggle source
# File lib/rsrb/model/item.rb, line 58 def within_distance?(player) player.location.within_distance? @location end