Class: Demiurge::WanderingAgent
- Inherits:
-
Agent
- Object
- StateItem
- ActionItem
- Agent
- Demiurge::WanderingAgent
- Defined in:
- lib/demiurge/agent.rb
Overview
This agent will wander around. A simple way to make a decorative mobile. Do we want this longer term, or should it be merged into the normal agent?
Constant Summary
Constants inherited from ActionItem
Instance Attribute Summary
Attributes inherited from StateItem
Instance Method Summary collapse
-
#finished_init ⇒ Object
If we're in a room but don't know where, pick a legal location.
-
#initialize(name, engine, state) ⇒ WanderingAgent
constructor
Constructor.
-
#intentions_for_next_step ⇒ Object
Get intentions for the next upcoming tick.
Methods inherited from Agent
#agent?, #clear_intention_queue, #move_to_position, #queue_action
Methods inherited from ActionItem
#__state_internal, #get_action, #get_actions_with_tags, #location, #location_name, #position, #register_actions, #run_action, #zone, #zone_name
Methods inherited from StateItem
#agent?, from_name_type, #get_structure, #state, #state_type, #zone?
Constructor Details
#initialize(name, engine, state) ⇒ WanderingAgent
Constructor
283 284 285 286 |
# File 'lib/demiurge/agent.rb', line 283 def initialize(name, engine, state) super state["wander_counter"] ||= 0 end |
Instance Method Details
#finished_init ⇒ Object
If we're in a room but don't know where, pick a legal location.
289 290 291 292 293 294 295 296 297 298 |
# File 'lib/demiurge/agent.rb', line 289 def finished_init super @wander_intention = AgentInternal::WanderIntention.new(engine, name) unless state["position"] && state["position"]["#"] # Move to legal position. If this is a TMX location or similar, it will assign a specific position. if self.location.respond_to?(:any_legal_position) state["position"] = self.location.any_legal_position end end end |
#intentions_for_next_step ⇒ Object
Get intentions for the next upcoming tick
301 302 303 |
# File 'lib/demiurge/agent.rb', line 301 def intentions_for_next_step super + [@wander_intention] end |