class Demiurge::WanderingAgent

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?

Public Class Methods

new(name, engine, state) click to toggle source

Constructor

Calls superclass method Demiurge::Agent::new
# File lib/demiurge/agent.rb, line 277
def initialize(name, engine, state)
  super
  state["wander_counter"] ||= 0
end

Public Instance Methods

finished_init() click to toggle source

If we're in a room but don't know where, pick a legal location.

Calls superclass method Demiurge::Agent#finished_init
# File lib/demiurge/agent.rb, line 283
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() click to toggle source

Get intentions for the next upcoming tick

# File lib/demiurge/agent.rb, line 295
def intentions_for_next_step
  super + [@wander_intention]
end