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.



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

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)


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

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.



142
143
144
145
# File 'lib/demiurge/agent.rb', line 142

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.



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

def offer
end