Class: Demiurge::AgentInternal::AgentMaintenanceIntention Private

Inherits:
Intention
  • Object
show all
Defined in:
lib/demiurge/agent.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

TODO:

Merge this with the AgentActionIntention used for taking queued actions

The AgentMaintenanceIntention reduces the level of "busy"-ness of the agent on each tick.

Instance Method Summary collapse

Methods inherited from Intention

#apply_notification, #cancel, #cancel_notification, #cancelled?, #try_apply

Constructor Details

#initialize(engine, name) ⇒ AgentMaintenanceIntention

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Constructor. Takes an engine and agent name.



120
121
122
123
# File 'lib/demiurge/agent.rb', line 120

def initialize(engine, name)
  @name = name
  super(engine)
end

Instance Method Details

#allowed?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

An AgentMaintenanceIntention is always considered to be allowed.

Returns:

  • (Boolean)


131
132
133
# File 'lib/demiurge/agent.rb', line 131

def allowed?
  true
end

#applyObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Reduce the amount of busy-ness.



136
137
138
139
# File 'lib/demiurge/agent.rb', line 136

def apply
  agent = @engine.item_by_name(@name)
  agent.state["busy"] -= 1 if agent.state["busy"] > 0
end

#offerObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Normally, the agent's maintenance intention can't be blocked, cancelled or modified.



127
128
# File 'lib/demiurge/agent.rb', line 127

def offer
end