summaryrefslogtreecommitdiffhomepage
path: root/lib/felecs/stage_manager.rb
diff options
context:
space:
mode:
authorrealtradam <[email protected]>2022-01-20 22:41:04 -0500
committerrealtradam <[email protected]>2022-01-20 22:41:04 -0500
commit9ae334ecc6aaef009f14c0bb8b57afcb721f709b (patch)
treed1d41747a0a4fcde281919933ce59757a4b5e7ce /lib/felecs/stage_manager.rb
parentf003a1acc5dac70b267685701a3b130773310e0b (diff)
downloadFelECS-9ae334ecc6aaef009f14c0bb8b57afcb721f709b.tar.gz
FelECS-9ae334ecc6aaef009f14c0bb8b57afcb721f709b.zip
rename to FelECS
Diffstat (limited to 'lib/felecs/stage_manager.rb')
-rw-r--r--lib/felecs/stage_manager.rb47
1 files changed, 47 insertions, 0 deletions
diff --git a/lib/felecs/stage_manager.rb b/lib/felecs/stage_manager.rb
new file mode 100644
index 0000000..b2a5b7c
--- /dev/null
+++ b/lib/felecs/stage_manager.rb
@@ -0,0 +1,47 @@
+# frozen_string_literal: true
+
+module FelECS
+ module Stage
+ class << self
+ # Allows clearing of scenes and systems.
+ # Used internally by FelECS and shouldn't need to be ever used by developers
+ # @!visibility private
+ attr_writer :scenes
+
+ # Add any number of Scenes to the Stage
+ # @return [Boolean] +true+
+ def add(*scenes_to_add)
+ self.scenes |= scenes_to_add
+ self.scenes = scenes.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
+ true
+ end
+
+ # Clears all Scenes that were added to the Stage
+ # @return [Boolean] +true+
+ def clear
+ self.scenes.clear
+ true
+ end
+
+ # Executes one frame of the game. This executes all the Scenes added to the Stage in order of their priority.
+ # @return [Boolean] +true+
+ def call
+ self.scenes.each(&:call)
+ true
+ end
+
+ # Contains all the Scenes added to the Stage
+ # @return [Array<Scene>]
+ def scenes
+ @scenes ||= []
+ end
+ end
+ end
+end