Class: FelFlame::Scenes

Inherits:
Object
  • Object
show all
Defined in:
felflame.rb,
scene_manager.rb

Overview

Creates and manages Scenes. Scenes are collections of Systems, and execute all the Systems when called upon.

TODO: Improve Scenes overview

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Scenes

Create a new Scene using the name given

Parameters:

  • name (String)

    String format must follow requirements of a constant



10
11
12
13
# File 'scene_manager.rb', line 10

def initialize(name)
  FelFlame::Scenes.const_set(name, self)
  @const_name = name
end

Instance Attribute Details

#const_nameObject (readonly)

The Constant name assigned to this Scene



4
5
6
# File 'scene_manager.rb', line 4

def const_name
  @const_name
end

#systemsArray<System>

The list of Systems this Scene contains

Returns:

  • (Array<System>)


17
18
19
# File 'scene_manager.rb', line 17

def systems
  @systems ||= []
end

Instance Method Details

#add(*systems_to_add) ⇒ Boolean

Adds any number of Systems to this Scene

Returns:

  • (Boolean)

    true



30
31
32
33
34
35
# File 'scene_manager.rb', line 30

def add(*systems_to_add)
  self.systems |= systems_to_add
  systems.sort_by!(&:priority)
  FelFlame::Stage.update_systems_list if FelFlame::Stage.scenes.include? self
  true
end

#callBoolean

Execute all systems in this Scene, in the order of their priority

Returns:

  • (Boolean)

    true



23
24
25
26
# File 'scene_manager.rb', line 23

def call
  systems.each(&:call)
  true
end

#clearBoolean

Removes all Systems from this Scene

Returns:

  • (Boolean)

    true



48
49
50
51
52
# File 'scene_manager.rb', line 48

def clear
  systems.clear
  FelFlame::Stage.update_systems_list if FelFlame::Stage.scenes.include? self
  true
end

#remove(*systems_to_remove) ⇒ Boolean

Removes any number of SystemS from this Scene

Returns:

  • (Boolean)

    true



39
40
41
42
43
44
# File 'scene_manager.rb', line 39

def remove(*systems_to_remove)
  self.systems -= systems_to_remove
  systems.sort_by!(&:priority)
  FelFlame::Stage.update_systems_list if FelFlame::Stage.scenes.include? self
  true
end