Module: SDCMeta::AIBackend
- Included in:
- SDC::Entity, SDC::Map
- Defined in:
- lib/include/AIBackend.rb
Instance Method Summary collapse
- #add_ai_page(method_symbol, index) ⇒ Object
- #ai_running? ⇒ Boolean
- #ai_script ⇒ Object
- #current_ai ⇒ Object
-
#master_ai_running? ⇒ Boolean
Special methods which are called and used by the AI system.
- #master_ai_script ⇒ Object
-
#setup_ai ⇒ Object
Use these two methods to setup and tick any class with an AI system.
- #tick_ai ⇒ Object
Instance Method Details
#add_ai_page(method_symbol, index) ⇒ Object
34 35 36 |
# File 'lib/include/AIBackend.rb', line 34 def add_ai_page(method_symbol, index) @ai_pages[index] = SDC::AI::Script.new {self.send(method_symbol)} end |
#ai_running? ⇒ Boolean
26 27 28 |
# File 'lib/include/AIBackend.rb', line 26 def ai_running? return current_ai&.running? end |
#ai_script ⇒ Object
42 43 44 |
# File 'lib/include/AIBackend.rb', line 42 def ai_script SDC::AI::done end |
#current_ai ⇒ Object
30 31 32 |
# File 'lib/include/AIBackend.rb', line 30 def current_ai return @ai_pages[@ai_page] end |
#master_ai_running? ⇒ Boolean
Special methods which are called and used by the AI system
22 23 24 |
# File 'lib/include/AIBackend.rb', line 22 def master_ai_running? return @master_ai.running? end |
#master_ai_script ⇒ Object
38 39 40 |
# File 'lib/include/AIBackend.rb', line 38 def master_ai_script SDC::AI::done end |
#setup_ai ⇒ Object
Use these two methods to setup and tick any class with an AI system
9 10 11 12 13 |
# File 'lib/include/AIBackend.rb', line 9 def setup_ai @master_ai = SDC::AI::Script.new {master_ai_script} @ai_pages = [SDC::AI::Script.new {ai_script}] @ai_page = 0 end |
#tick_ai ⇒ Object
15 16 17 18 |
# File 'lib/include/AIBackend.rb', line 15 def tick_ai @master_ai.tick if master_ai_running? current_ai.tick if ai_running? end |