class Gamefic::Entity

A physical object that can exist in a plot. Most objects with which players interact are entities. Player characters themselves typically derive from entities, e.g., the Gamefic::Actor class.

Public Instance Methods

[](key) click to toggle source

Get a custom property.

@param key [Symbol] The property's name @return The value of the property

# File lib/gamefic/entity.rb, line 38
def [](key)
  session[key]
end
[]=(key, value) click to toggle source

Set a custom property.

@param key [Symbol] The property's name @param value The value to set

# File lib/gamefic/entity.rb, line 46
def []=(key, value)
  session[key] = value
end
parent=(node) click to toggle source

Set the Entity's parent.

@param node [Gamefic::Entity, nil] The new parent.

Calls superclass method Gamefic::Node#parent=
# File lib/gamefic/entity.rb, line 17
def parent=(node)
  if node && node.is_a?(Entity) == false
    raise ArgumentError, "Entity's parent must be an Entity"
  end
  super
end
session() click to toggle source

A freeform property dictionary. Authors can use the session hash to assign custom properties to the entity. It can also be referenced directly using [] without the method name, e.g., entity.session or entity.

@return [Hash]

# File lib/gamefic/entity.rb, line 30
def session
  @session ||= {}
end