Class: Gamefic::Entity
- Inherits:
-
Object
- Object
- Gamefic::Entity
- Includes:
- Describable, Grammar::WordAdapter, Messaging, Node
- Defined in:
- lib/gamefic/entity.rb
Direct Known Subclasses
Constant Summary
Constants included from Matchable
Instance Attribute Summary collapse
-
#session ⇒ Object
readonly
Returns the value of attribute session.
Attributes included from Grammar::Plural
Attributes included from Grammar::Person
Attributes included from Grammar::Gender
Attributes included from Describable
#definite_article, #indefinite_article, #name, #synonyms
Instance Method Summary collapse
-
#[](key) ⇒ Object
Get an extended property.
-
#[]=(key, value) ⇒ Object
Set an extended property.
-
#initialize(args = {}) {|_self| ... } ⇒ Entity
constructor
A new instance of Entity.
-
#parent=(node) ⇒ Object
Set the Entity’s parent.
- #post_initialize ⇒ Object
- #pre_initialize ⇒ Object
- #uid ⇒ Object
-
#update ⇒ Object
Execute the entity’s on_update blocks.
Methods included from Grammar::WordAdapter
Methods included from Grammar::Plural
Methods included from Messaging
#flush, #messages, #output, #stream, #tell
Methods included from Describable
default_description, default_description=, #definitely, #description, #description=, #has_description?, #indefinitely, #keywords, #proper_named=, #proper_named?, #to_s
Methods included from Matchable
Methods included from Node
#accessible?, #children, #flatten, #parent
Constructor Details
#initialize(args = {}) {|_self| ... } ⇒ Entity
Returns a new instance of Entity.
15 16 17 18 19 20 21 22 23 |
# File 'lib/gamefic/entity.rb', line 15 def initialize(args = {}) pre_initialize args.each { |key, value| send "#{key}=", value } @session = Hash.new yield self if block_given? post_initialize end |
Instance Attribute Details
#session ⇒ Object (readonly)
Returns the value of attribute session.
13 14 15 |
# File 'lib/gamefic/entity.rb', line 13 def session @session end |
Instance Method Details
#[](key) ⇒ Object
Get an extended property.
60 61 62 |
# File 'lib/gamefic/entity.rb', line 60 def [](key) session[key] end |
#[]=(key, value) ⇒ Object
Set an extended property.
68 69 70 |
# File 'lib/gamefic/entity.rb', line 68 def []=(key, value) session[key] = value end |
#parent=(node) ⇒ Object
Set the Entity’s parent.
50 51 52 53 54 55 |
# File 'lib/gamefic/entity.rb', line 50 def parent=(node) if node != nil and node.kind_of?(Entity) == false raise "Entity's parent must be an Entity" end super end |
#post_initialize ⇒ Object
36 37 38 |
# File 'lib/gamefic/entity.rb', line 36 def post_initialize # raise NotImplementedError, "#{self.class} must implement post_initialize" end |
#pre_initialize ⇒ Object
32 33 34 |
# File 'lib/gamefic/entity.rb', line 32 def pre_initialize # raise NotImplementedError, "#{self.class} must implement post_initialize" end |
#uid ⇒ Object
25 26 27 28 29 30 |
# File 'lib/gamefic/entity.rb', line 25 def uid if @uid == nil @uid = self.object_id.to_s end @uid end |
#update ⇒ Object
Execute the entity’s on_update blocks. This method is typically called by the Engine that manages game execution. The base method does nothing. Subclasses can override it.
44 45 |
# File 'lib/gamefic/entity.rb', line 44 def update end |