Class: GameMachine::Commands::GridCommands

Inherits:
Object
  • Object
show all
Defined in:
lib/game_machine/commands/grid_commands.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeGridCommands

Returns a new instance of GridCommands.



6
7
8
9
# File 'lib/game_machine/commands/grid_commands.rb', line 6

def initialize
  @aoe_grid = Grid.find_or_create('aoe')
  @grid = Grid.find_or_create('default')
end

Instance Attribute Details

#aoe_gridObject (readonly)

Returns the value of attribute aoe_grid.



5
6
7
# File 'lib/game_machine/commands/grid_commands.rb', line 5

def aoe_grid
  @aoe_grid
end

#gridObject (readonly)

Returns the value of attribute grid.



5
6
7
# File 'lib/game_machine/commands/grid_commands.rb', line 5

def grid
  @grid
end

Instance Method Details

#find_by_id(id) ⇒ Object



11
12
13
# File 'lib/game_machine/commands/grid_commands.rb', line 11

def find_by_id(id)
  grid.get(id)
end

#get_neighbors_for(id, entity_type = 'player') ⇒ Object



15
16
17
# File 'lib/game_machine/commands/grid_commands.rb', line 15

def get_neighbors_for(id,entity_type='player')
  grid.getNeighborsFor(id,entity_type)
end

#neighbors(x, y, type = 'player') ⇒ Object



19
20
21
# File 'lib/game_machine/commands/grid_commands.rb', line 19

def neighbors(x,y,type='player')
  grid.neighbors(x,y,type)
end

#remove(id) ⇒ Object



23
24
25
26
# File 'lib/game_machine/commands/grid_commands.rb', line 23

def remove(id)
  grid.remove(id)
  aoe_grid.remove(id)
end

#track(id, x, y, z, entity_type = 'npc') ⇒ Object



28
29
30
31
# File 'lib/game_machine/commands/grid_commands.rb', line 28

def track(id,x,y,z,entity_type='npc')
  grid.set(id,x,y,z,entity_type)
  aoe_grid.set(id,x,y,z,entity_type)
end