Class: RuneRb::Database::PlayerLocation

Inherits:
Object
  • Object
show all
Defined in:
app/database/models/player/location.rb

Overview

Information related to the location of a player in the virtual game world

Models a row from the `player_locations` table

Since:

  • 0.9.3

Instance Method Summary collapse

Instance Method Details

#set(position) ⇒ Object

Updates the <:x, :y, :z> values to that of the passed position object.

Parameters:

Since:

  • 0.9.3


14
15
16
17
18
19
20
21
# File 'app/database/models/player/location.rb', line 14

def set(position)
  update(prev_x: self[:x],
         prev_y: self[:y],
         prev_z: self[:z],
         x: position[:x] || RuneRb::GLOBAL[:DEFAULT_MOB_X] || 3222,
         y: position[:y] || RuneRb::GLOBAL[:DEFAULT_MOB_Y] || 3222,
         z: position[:z] || RuneRb::GLOBAL[:DEFAULT_MOB_Z] || 0)
end

#to_positionRuneRb::Game::Map::Position

Constructs a <RuneRb::Game::Map::Position> from the location.

Returns:

Since:

  • 0.9.3


8
9
10
# File 'app/database/models/player/location.rb', line 8

def to_position
  RuneRb::Game::Map::Position.new(self[:x], self[:y], self[:z])
end