class Rsrb::Doors::DoubleDoor

Attributes

r_door_face[RW]
r_door_id[RW]
r_door_location[RW]
r_door_orig_face[R]
r_door_orig_id[R]
r_door_orig_location[R]

Public Class Methods

new(data, open = true) click to toggle source
Calls superclass method Rsrb::Doors::Door::new
# File lib/rsrb/services/doors.rb, line 264
def initialize(data, open = true) 
  super(data, open) # Temp until it's changed below
  
  l_id_off = -3
  r_id_off = 3
  l_x_off = 0
  r_x_off = 0
  l_y_off = 0
  r_y_off = 0
  
  if open
    if data[:face] == 0
      l_x_off = -1
      r_x_off = 1
    elsif data[:face] == 1
      l_y_off = 1
      r_y_off = -1
    elsif data[:face] == 2
      l_x_off = -1
      r_y_off = -1
    elsif data[:face] == 3
      l_y_off = 1
      r_y_off = -1
    end
  else
    if data[:face] == 0
      l_y_off = -1
      r_y_off = 1
    elsif data[:face] == 1
      l_x_off = -1
      r_x_off = 1
    elsif data[:face] == 2
      l_y_off = 1
      r_y_off = -1
    elsif data[:face] == 3
      l_id_off = 3
      r_id_off = -3
      l_x_off = -1
      r_x_off = 1
    end
  end
  
  temp_l = Rsrb::Model::Location.new(data[:location].x+l_x_off, data[:location].y+l_y_off, data[:location].z)
  temp_r = Rsrb::Model::Location.new(data[:location].x+r_x_off, data[:location].y+r_y_off, data[:location].z)
  
  l_data = DoorManager.get_double_data((data[:id]+l_id_off), temp_l)
  r_data = DoorManager.get_double_data((data[:id]+r_id_off), temp_r)

  if l_data != nil
    @id = l_data[:id]
    @location = l_data[:location]
    @face = l_data[:face]
      
    @orig_id = @id
    @orig_location = Rsrb::Model::Location.new(@location.x, @location.y, @location.z)
    @orig_face = @face
    
    # HACKS
    @r_door_id = data[:id]
    @r_door_location = data[:location]
    @r_door_face = data[:face]
      
    @r_door_orig_id = @r_door_id
    @r_door_orig_location = Rsrb::Model::Location.new(@r_door_location.x, @r_door_location.y, @r_door_location.z)
    @r_door_orig_face = @r_door_face
    
    DoorManager.change_double_state self
  end
  
  if r_data != nil
    # HACKS
    @id = data[:id]
    @location = data[:location]
    @face = data[:face]
      
    @orig_id = @id
    @orig_location = Rsrb::Model::Location.new(@location.x, @location.y, @location.z)
    @orig_face = @face
            
    @r_door_id = r_data[:id]
    @r_door_location = r_data[:location]
    @r_door_face = r_data[:face]
      
    @r_door_orig_id = @r_door_id
    @r_door_orig_location = Rsrb::Model::Location.new(@r_door_location.x, @r_door_location.y, @r_door_location.z)
    @r_door_orig_face = @r_door_face
    
    DoorManager.change_double_state self
  end
end

Public Instance Methods

change(player) click to toggle source
# File lib/rsrb/services/doors.rb, line 355
def change(player)
 return unless player != nil
  
 # Delete if the new door has moved
 if @location != @orig_location
   player.io.send_replace_object(@orig_location, player.last_location, -1, 0, 0)
   player.io.send_replace_object(@r_door_orig_location, player.last_location, -1, 0, 0)
 end
 
 player.io.send_replace_object(@location, player.last_location, @id, @face, 0)
 
 player.io.send_replace_object(@r_door_location, player.last_location, @r_door_id, @r_door_face, 0)
end
id() click to toggle source
# File lib/rsrb/services/doors.rb, line 393
def id
  @id
end
reset() click to toggle source
# File lib/rsrb/services/doors.rb, line 369
def reset
  if @location != @orig_location
    # Remove the old replaced doors if they moved
    WORLD.region_manager.get_local_players(@location, false).each {|p|
      p.io.send_replace_object(@location, p.last_location, -1, 0, 0)
      p.io.send_replace_object(@r_door_location, p.last_location, -1, 0, 0)
    }
  end
  
  # Reset ids/positions/rotations
  @id = @orig_id
  @r_door_id = @r_door_orig_id
  @location = @orig_location
  @r_door_location = @r_door_orig_location
  @face = @orig_face
  @r_door_face = @r_door_orig_face
  
  # Add back to original locations
  WORLD.region_manager.get_local_players(@location, false).each {|p|
    p.io.send_replace_object(@location, p.last_location, @id, @face, 0)
    p.io.send_replace_object(@r_door_location, p.last_location, @r_door_id, @r_door_face, 0)
  }
end