Class: Darkholme::System
- Inherits:
-
Object
- Object
- Darkholme::System
- Defined in:
- lib/darkholme/system.rb
Overview
Updated every frame by the engine, a System manipulates and uses the data contained within a component
Direct Known Subclasses
Class Attribute Summary collapse
-
.family ⇒ Object
readonly
Returns the value of attribute family.
Instance Attribute Summary collapse
-
#engine ⇒ Object
Returns the value of attribute engine.
Class Method Summary collapse
-
.has_family(*component_classes) ⇒ Family
Set the family for a System.
Instance Method Summary collapse
-
#added_to_engine(engine) ⇒ Object
Callback called after the system has been added to an Engine.
-
#entities ⇒ Array<Entity>
An Array of all the entities this system is interested in.
-
#family ⇒ Family
Get the system’s Family instance.
-
#removed_from_engine(engine) ⇒ Object
Callback called after the system has been removed from an Engine.
-
#update(delta) ⇒ Object
Called once per frame by the engine.
Class Attribute Details
.family ⇒ Object (readonly)
Returns the value of attribute family.
6 7 8 |
# File 'lib/darkholme/system.rb', line 6 def family @family end |
Instance Attribute Details
#engine ⇒ Object
Returns the value of attribute engine.
25 26 27 |
# File 'lib/darkholme/system.rb', line 25 def engine @engine end |
Class Method Details
.has_family(*component_classes) ⇒ Family
Set the family for a System. Call this from the body of the class.
19 20 21 |
# File 'lib/darkholme/system.rb', line 19 def has_family(*component_classes) @family = Family.for(*component_classes) end |
Instance Method Details
#added_to_engine(engine) ⇒ Object
Callback called after the system has been added to an Engine
38 39 40 |
# File 'lib/darkholme/system.rb', line 38 def added_to_engine(engine) self.engine = engine end |
#entities ⇒ Array<Entity>
An Array of all the entities this system is interested in
52 53 54 |
# File 'lib/darkholme/system.rb', line 52 def entities engine.entities_for_family(family) end |
#family ⇒ Family
Get the system’s Family instance
59 60 61 |
# File 'lib/darkholme/system.rb', line 59 def family self.class.family end |
#removed_from_engine(engine) ⇒ Object
Callback called after the system has been removed from an Engine
45 46 47 |
# File 'lib/darkholme/system.rb', line 45 def removed_from_engine(engine) self.engine = nil if self.engine == engine end |
#update(delta) ⇒ Object
Called once per frame by the engine. This must be overriden by the subclass.
31 32 33 |
# File 'lib/darkholme/system.rb', line 31 def update(delta) raise NotImplementedError.new("You must override #update(delta)") end |