class Rsrb::Objects::Object

Attributes

delay[RW]
face[RW]
id[RW]
location[RW]
orig_face[R]
orig_id[R]
orig_location[R]
type[R]

Public Class Methods

new(id, location, face, type, orig_id, orig_location, orig_face, delay) click to toggle source
# File lib/rsrb/services/objects.rb, line 13
def initialize(id, location, face, type, orig_id, orig_location, orig_face, delay)
  @id = id
  @location = location
  @face = face
  @type = type

  @orig_id = orig_id
  @orig_location = orig_location
  @orig_face = orig_face

  @delay = delay
end

Public Instance Methods

change(player = nil) click to toggle source
# File lib/rsrb/services/objects.rb, line 26
def change(player = nil)
  unless player.nil?
    # Remove old object if the new object is in a new location
    if @location != @orig_location
      player.io.send_replace_object(@orig_location, player.last_location, -1, @face, @type)
    end

    # Create the new object for the specific player
    player.io.send_replace_object(@location, player.last_location, @id, @face, @type)
    return
  end

  WORLD.region_manager.get_local_players(@location).each {|p|
    # Remove old object if the new object is in a new location
    if @location != @orig_location
      p.io.send_replace_object(@orig_location, p.last_location, -1, @face, @type)
    end

    # Create the new object for all local players
    p.io.send_replace_object(@location, p.last_location, @id, @face, @type)
  }
end
reset(player = nil) click to toggle source
# File lib/rsrb/services/objects.rb, line 49
def reset(player = nil)
  unless player.nil?
    # Remove object if the object was in a new location
    if @location != @orig_location
      player.io.send_replace_object(@location, player.last_location, -1, @orig_face, @type)
    end

    # Reset the object back to it's original state
    player.io.send_replace_object(@orig_location, player.last_location, @orig_id, @orig_face, @type)
    return
  end


  WORLD.region_manager.get_local_players(@location).each {|p|
    # Remove object if the object was in a new location
    if @location != @orig_location
      p.io.send_replace_object(@location, p.last_location, -1, @orig_face, @type)
    end

    # Create the new object for all local players
    p.io.send_replace_object(@orig_location, p.last_location, @orig_id, @orig_face, @type)
  }
end