Class: Demiurge::DSL::LocationBuilder
- Inherits:
-
ActionItemBuilder
- Object
- ActionItemBuilder
- Demiurge::DSL::LocationBuilder
- Defined in:
- lib/demiurge/dsl.rb
Overview
Declare a "location" block in a World File.
Direct Known Subclasses
Constant Summary
Constants inherited from ActionItemBuilder
ActionItemBuilder::LEGAL_OPTIONS
Instance Attribute Summary
Attributes inherited from ActionItemBuilder
Instance Method Summary collapse
-
#agent(name, options = {}, &block) ⇒ Object
Declare an agent in this location.
-
#description(d) ⇒ Object
Declare a description for this location.
-
#initialize(name, engine, options = {}) ⇒ LocationBuilder
constructor
Constructor for a "location" DSL block.
Methods inherited from ActionItemBuilder
#__state_internal, #define_action, #display, #every_X_ticks, #on_intention, #on_notification, #position, #state
Constructor Details
#initialize(name, engine, options = {}) ⇒ LocationBuilder
Constructor for a "location" DSL block
553 554 555 556 557 |
# File 'lib/demiurge/dsl.rb', line 553 def initialize(name, engine, = {}) ["type"] ||= "Location" super @agents = [] end |
Instance Method Details
#agent(name, options = {}, &block) ⇒ Object
Declare an agent in this location.
565 566 567 568 569 570 571 |
# File 'lib/demiurge/dsl.rb', line 565 def agent(name, = {}, &block) state = { "position" => @name, "zone" => @state["zone"], "home_zone" => @state["zone"] } builder = AgentBuilder.new(name, @engine, .merge("state" => state) ) builder.instance_eval(&block) @built_item.state["contents"] << name nil end |
#description(d) ⇒ Object
Declare a description for this location.
560 561 562 |
# File 'lib/demiurge/dsl.rb', line 560 def description(d) @state["description"] = d end |