Class: Demiurge::DSL::TmxLocationBuilder

Inherits:
LocationBuilder show all
Defined in:
lib/demiurge/tmx.rb

Overview

Special builder for tmx_location blocks

Since:

  • 0.0.1

Constant Summary

Constants inherited from ActionItemBuilder

ActionItemBuilder::LEGAL_OPTIONS

Instance Method Summary collapse

Methods inherited from LocationBuilder

#agent, #description

Methods inherited from ActionItemBuilder

#__state_internal, #define_action, #display, #every_X_ticks, #on_intention, #on_notification, #position, #state

Constructor Details

#initialize(name, engine, options = {}) ⇒ TmxLocationBuilder

Constructor

Since:

  • 0.0.1



52
53
54
55
# File 'lib/demiurge/tmx.rb', line 52

def initialize(name, engine, options = {})
  options["type"] ||= "TmxLocation"
  super
end

Instance Method Details

#built_itemObject

Validate built_item before returning it

Since:

  • 0.0.1



74
75
76
77
# File 'lib/demiurge/tmx.rb', line 74

def built_item
  raise("A TMX location (name: #{@name.inspect}) must have a tile layout!") unless @state["tile_layout"] || @state["manasource_tile_layout"]
  super
end

#manasource_tile_layout(tmx_spec) ⇒ Object

Specify a TMX file as the tile layout, and interpret it according to ManaSource TMX conventions.

Since:

  • 0.0.1



66
67
68
69
70
71
# File 'lib/demiurge/tmx.rb', line 66

def manasource_tile_layout(tmx_spec)
  # Make sure this loads correctly, but use the cache for efficiency.
  TmxLocation.tile_cache_entry(tmx_spec, nil)

  @state["manasource_tile_layout"] = tmx_spec
end

#tile_layout(tmx_spec) ⇒ Object

Specify a TMX file as the tile layout, but assume relatively little about the TMX format.

Since:

  • 0.0.1



58
59
60
61
62
63
# File 'lib/demiurge/tmx.rb', line 58

def tile_layout(tmx_spec)
  # Make sure this loads correctly, but use the cache for efficiency.
  TmxLocation.tile_cache_entry(nil, tmx_spec)

  @state["tile_layout"] = tmx_spec
end