Class: GameMachine::Navigation::DetourNavmesh

Inherits:
Object
  • Object
show all
Defined in:
server/lib/game_machine/navigation/detour_navmesh.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, meshfile) ⇒ DetourNavmesh

Returns a new instance of DetourNavmesh


25
26
27
28
29
30
31
32
# File 'server/lib/game_machine/navigation/detour_navmesh.rb', line 25

def initialize(id,meshfile)
  @id = id
  @meshfile = meshfile
  unless File.exists?(meshfile)
    raise "Navigation mesh file does not exist (#{meshfile})"
  end
  @loaded = false
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id


24
25
26
# File 'server/lib/game_machine/navigation/detour_navmesh.rb', line 24

def id
  @id
end

#loadedObject (readonly)

Returns the value of attribute loaded


24
25
26
# File 'server/lib/game_machine/navigation/detour_navmesh.rb', line 24

def loaded
  @loaded
end

#meshfileObject (readonly)

Returns the value of attribute meshfile


24
25
26
# File 'server/lib/game_machine/navigation/detour_navmesh.rb', line 24

def meshfile
  @meshfile
end

Class Method Details

.create(id, meshfile) ⇒ Object


13
14
15
16
17
18
# File 'server/lib/game_machine/navigation/detour_navmesh.rb', line 13

def self.create(id,meshfile)
  if meshes.has_key?(id)
    return false
  end
  meshes[id] = new(id,meshfile)
end

.find(id) ⇒ Object


20
21
22
# File 'server/lib/game_machine/navigation/detour_navmesh.rb', line 20

def self.find(id)
  meshes.fetch(id,nil)
end

.meshesObject


5
6
7
8
9
10
11
# File 'server/lib/game_machine/navigation/detour_navmesh.rb', line 5

def self.meshes
  if @meshes
    @meshes
  else
    @meshes = java.util.concurrent.ConcurrentHashMap.new
  end
end

Instance Method Details

#load_mesh!Object


38
39
40
41
42
43
44
45
46
47
48
49
# File 'server/lib/game_machine/navigation/detour_navmesh.rb', line 38

def load_mesh!
  if loaded?
    raise "DetourNavmesh #{id} already loaded"
  end

  load_res = Detour.loadNavMesh(id,meshfile)
  unless load_res == 1
    raise "DetourNavmesh #{id} failed to load (#{load_res})"
  end
  @loaded = true
  load_res
end

#loaded?Boolean

Returns:

  • (Boolean)

34
35
36
# File 'server/lib/game_machine/navigation/detour_navmesh.rb', line 34

def loaded?
  loaded
end