class FelECS::Scenes
Creates and manages Scenes
. Scenes
are collections of Systems
, and execute all the Systems
when called upon. Any scenes you create are accessable under the {FelECS::Scenes} namespace as Constants.
Attributes
How early this Scene should be executed in a list of Scenes
Allows overwriting the storage of systems, such as for clearing. This method should generally only need to be used internally and not by a game developer/ @!visibility private
Public Class Methods
Create a new Scene using the name given @param name [String] String format must follow requirements of a constant
# File lib/felecs/scene_manager.rb, line 22 def initialize(name, priority: 0) self.priority = priority FelECS::Scenes.const_set(name, self) end
Public Instance Methods
Adds any number of Systems
to this Scene @return [Boolean] true
# File lib/felecs/scene_manager.rb, line 42 def add(*systems_to_add) self.systems |= systems_to_add self.systems = systems.sort_by(&:priority) systems_to_add.each do |system| system.scenes |= [self] end true end
Execute all systems in this Scene, in the order of their priority @return [Boolean] true
# File lib/felecs/scene_manager.rb, line 35 def call systems.each(&:call) true end
Removes all Systems
from this Scene @return [Boolean] true
# File lib/felecs/scene_manager.rb, line 60 def clear systems.each do |system| system.scenes.delete self end systems.clear # FelECS::Stage.update_systems_list if FelECS::Stage.scenes.include? self true end
# File lib/felecs/scene_manager.rb, line 14 def priority=(priority) @priority = priority FelECS::Stage.scenes = FelECS::Stage.scenes.sort_by(&:priority) priority end
Removes any number of Systems
from this Scene @return [Boolean] true
# File lib/felecs/scene_manager.rb, line 53 def remove(*systems_to_remove) self.systems -= systems_to_remove true end
The list of Systems
this Scene contains @return [Array<System>]
# File lib/felecs/scene_manager.rb, line 29 def systems @systems ||= [] end