Class: GameMachine::Navigation::DetourNavmesh
- Inherits:
-
Object
- Object
- GameMachine::Navigation::DetourNavmesh
- Defined in:
- lib/game_machine/navigation/detour_navmesh.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#loaded ⇒ Object
readonly
Returns the value of attribute loaded.
-
#meshfile ⇒ Object
readonly
Returns the value of attribute meshfile.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(id, meshfile) ⇒ DetourNavmesh
constructor
A new instance of DetourNavmesh.
- #load_mesh! ⇒ Object
- #loaded? ⇒ Boolean
Constructor Details
#initialize(id, meshfile) ⇒ DetourNavmesh
Returns a new instance of DetourNavmesh.
25 26 27 28 29 30 31 32 |
# File '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
#id ⇒ Object (readonly)
Returns the value of attribute id.
24 25 26 |
# File 'lib/game_machine/navigation/detour_navmesh.rb', line 24 def id @id end |
#loaded ⇒ Object (readonly)
Returns the value of attribute loaded.
24 25 26 |
# File 'lib/game_machine/navigation/detour_navmesh.rb', line 24 def loaded @loaded end |
#meshfile ⇒ Object (readonly)
Returns the value of attribute meshfile.
24 25 26 |
# File '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 '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 'lib/game_machine/navigation/detour_navmesh.rb', line 20 def self.find(id) meshes.fetch(id,nil) end |
.meshes ⇒ Object
5 6 7 8 9 10 11 |
# File '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 '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
34 35 36 |
# File 'lib/game_machine/navigation/detour_navmesh.rb', line 34 def loaded? loaded end |