summaryrefslogtreecommitdiffhomepage
path: root/lib/felflame/order.rb
diff options
context:
space:
mode:
author_Tradam <[email protected]>2022-01-03 08:26:24 -0500
committerGitHub <[email protected]>2022-01-03 08:26:24 -0500
commita0f792d8feadf919290b8349dbc0eac143545927 (patch)
treeee70c5357d5969caaed08446c32746e656b223e6 /lib/felflame/order.rb
parentb535a6b1bd8019dbeba17f3853b338383208c9b3 (diff)
downloadFelECS-a0f792d8feadf919290b8349dbc0eac143545927.tar.gz
FelECS-a0f792d8feadf919290b8349dbc0eac143545927.zip
Major 4.0 Update (#16)v4.0.04.0.0
See Changelog
Diffstat (limited to 'lib/felflame/order.rb')
-rw-r--r--lib/felflame/order.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/felflame/order.rb b/lib/felflame/order.rb
new file mode 100644
index 0000000..c11438d
--- /dev/null
+++ b/lib/felflame/order.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+module FelFlame
+ module Order
+ # Sets the priority of all items passed into this method
+ # according to the order they were passed.
+ # If an array is one of the elements then it will give all
+ # of those elements in the array the same priority.
+ # @param sortables [(Systems and Array<Systems>) or (Scenes and Array<Scenes>)]
+ # @return [Boolean] +true+.
+ def self.sort(*sortables)
+ sortables.each_with_index do |sorted, index|
+ if sorted.respond_to? :priority
+ sorted.priority = index
+ else
+ sorted.each do |item|
+ item.priority = index
+ end
+ end
+ end
+ true
+ end
+ end
+end