Class: Gamefic::Entity
- Inherits:
-
Object
- Object
- Gamefic::Entity
- Extended by:
- Serialized::ClassMethods
- Includes:
- Describable, Grammar::WordAdapter, Node, Serialized
- Defined in:
- lib/gamefic/entity.rb
Direct Known Subclasses
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
- #stream(message) ⇒ Object
- #tell(message) ⇒ Object
- #uid ⇒ Object
-
#update ⇒ Object
Execute the entity’s on_update blocks.
Methods included from Serialized::ClassMethods
Methods included from Grammar::WordAdapter
Methods included from Grammar::Plural
Methods included from Serialized
included, #serialized_attributes
Methods included from Describable
default_description, default_description=, #definitely, #description, #description=, #has_description?, #indefinitely, #keywords, #proper_named=, #proper_named?, #to_s
Methods included from Node
Constructor Details
#initialize(args = {}) {|_self| ... } ⇒ Entity
Returns a new instance of Entity.
17 18 19 20 21 22 23 24 25 |
# File 'lib/gamefic/entity.rb', line 17 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.
14 15 16 |
# File 'lib/gamefic/entity.rb', line 14 def session @session end |
Instance Method Details
#[](key) ⇒ Object
Get an extended property.
71 72 73 |
# File 'lib/gamefic/entity.rb', line 71 def [](key) session[key] end |
#[]=(key, value) ⇒ Object
Set an extended property.
79 80 81 |
# File 'lib/gamefic/entity.rb', line 79 def []=(key, value) session[key] = value end |
#parent=(node) ⇒ Object
Set the Entity’s parent.
61 62 63 64 65 66 |
# File 'lib/gamefic/entity.rb', line 61 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
38 39 40 |
# File 'lib/gamefic/entity.rb', line 38 def post_initialize # raise NotImplementedError, "#{self.class} must implement post_initialize" end |
#pre_initialize ⇒ Object
34 35 36 |
# File 'lib/gamefic/entity.rb', line 34 def pre_initialize # raise NotImplementedError, "#{self.class} must implement post_initialize" end |
#stream(message) ⇒ Object
47 48 49 |
# File 'lib/gamefic/entity.rb', line 47 def stream() # Unlike tell, this method sends raw data without formatting. end |
#tell(message) ⇒ Object
42 43 44 45 |
# File 'lib/gamefic/entity.rb', line 42 def tell() #TODO: Should this even be here? In all likelihood, only Characters receive tells, right? #TODO: On second thought, it might be interesting to see logs from an npc point of view. end |
#uid ⇒ Object
27 28 29 30 31 32 |
# File 'lib/gamefic/entity.rb', line 27 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.
55 56 |
# File 'lib/gamefic/entity.rb', line 55 def update end |