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

priority[RW]

How early this Scene should be executed in a list of Scenes

systems[W]

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

new(name, priority: 0) click to toggle source

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

add(*systems_to_add) click to toggle source

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
call() click to toggle source

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
clear() click to toggle source

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
priority=(priority) click to toggle source
# File lib/felecs/scene_manager.rb, line 14
def priority=(priority)
  @priority = priority
  FelECS::Stage.scenes = FelECS::Stage.scenes.sort_by(&:priority)
  priority
end
remove(*systems_to_remove) click to toggle source

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
systems() click to toggle source

The list of Systems this Scene contains @return [Array<System>]

# File lib/felecs/scene_manager.rb, line 29
def systems
  @systems ||= []
end