diff options
Diffstat (limited to 'lib/felecs/order.rb')
| -rw-r--r-- | lib/felecs/order.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/felecs/order.rb b/lib/felecs/order.rb new file mode 100644 index 0000000..3e9b656 --- /dev/null +++ b/lib/felecs/order.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +module FelECS + 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 |
