summaryrefslogtreecommitdiffhomepage
path: root/stage_manager.rb
diff options
context:
space:
mode:
authorrealtradam <[email protected]>2021-07-07 17:49:00 -0400
committerrealtradam <[email protected]>2021-07-07 17:49:00 -0400
commit09fc5ef46b911f9d7e31cdedd240e7afc4c11c92 (patch)
tree65d0ac1ffaf269cded9c5df681dee8d9dc7f0d73 /stage_manager.rb
parent4758c32fbd5cba714341f9735a994fd244664ff7 (diff)
downloadFelECS-09fc5ef46b911f9d7e31cdedd240e7afc4c11c92.tar.gz
FelECS-09fc5ef46b911f9d7e31cdedd240e7afc4c11c92.zip
completed functionality
Diffstat (limited to 'stage_manager.rb')
-rw-r--r--stage_manager.rb66
1 files changed, 66 insertions, 0 deletions
diff --git a/stage_manager.rb b/stage_manager.rb
index c5bd741..87ee955 100644
--- a/stage_manager.rb
+++ b/stage_manager.rb
@@ -1,4 +1,70 @@
class FelFlame
class Stage
+ class <<self
+ # Allows clearing of scenes and systems.
+ # Used internally by FelFlame and shouldn't need to be ever used by developers
+ # @!visibility private
+ attr_writer :scenes, :systems
+
+ # Add any number of Scenes to the Stage
+ # @return [Boolean] +true+
+ def add(*scenes_to_add)
+ self.scenes |= scenes_to_add
+ scenes_to_add.each do |scene|
+ self.systems |= scene.systems
+ end
+ systems.sort_by!(&:priority)
+ true
+ end
+
+ # Remove any number of Scenes from the Stage
+ # @return [Boolean] +true+
+ def remove(*scenes_to_remove)
+ self.scenes -= scenes_to_remove
+ update_systems_list
+ true
+ end
+
+ # Updates the list of systems from the Scenes added to the Stage and make sure they are ordered correctly
+ # This is used internally by FelFlame and shouldn't need to be ever used by developers
+ # @return [Boolean] +true+
+ # @!visibility private
+ def update_systems_list
+ systems.clear
+ scenes.each do |scene|
+ self.systems |= scene.systems
+ end
+ systems.sort_by!(&:priority)
+ true
+ end
+
+ # Clears all Scenes that were added to the Stage
+ # @return [Boolean] +true+
+ def clear
+ systems.clear
+ scenes.clear
+ true
+ end
+
+ # Executes one frame of the game. This executes all the Systems in the Scenes added to the Stage. Systems that exist in two or more different Scenes will still only get executed once.
+ # @return [Boolean] +true+
+ def call
+ systems.each(&:call)
+ true
+ end
+
+ # Contains all the Scenes added to the Stage
+ # @return [Array<Scene>]
+ def scenes
+ @scenes ||= []
+ end
+
+ # Stores systems in the order the stage manager needs to call them
+ # This method should generally only need to be used internally and not by a game developer
+ # @!visibility private
+ def systems
+ @systems ||= []
+ end
+ end
end
end