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
276 277 278 279 |
# File 'lib/demiurge/agent.rb', line 276 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.
282 283 284 285 286 287 288 289 290 291 |
# File 'lib/demiurge/agent.rb', line 282 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
294 295 296 |
# File 'lib/demiurge/agent.rb', line 294 def intentions_for_next_step super + [@wander_intention] end |