diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/felflame.rb | 7 | ||||
| -rw-r--r-- | lib/felflame/component_manager.rb | 22 | ||||
| -rw-r--r-- | lib/felflame/order.rb | 19 |
3 files changed, 25 insertions, 23 deletions
diff --git a/lib/felflame.rb b/lib/felflame.rb index b7a386a..21a6eaf 100644 --- a/lib/felflame.rb +++ b/lib/felflame.rb @@ -5,6 +5,7 @@ require_relative 'felflame/component_manager' require_relative 'felflame/system_manager' require_relative 'felflame/scene_manager' require_relative 'felflame/stage_manager' +require_relative 'felflame/order' require_relative 'felflame/version' @@ -39,6 +40,9 @@ module FelFlame # Stores Scenes you add to it which you want to execute on each frame. When called upon will execute all Systems in the Scenes in the Stage and will execute them according to their priority order. module Stage; end + + # Sets the priority of a list of Systems or Scenes for you in the order you pass them to this class. + module Order; end end # An alias for {FelFlame} @@ -58,3 +62,6 @@ FF::Scn = FelFlame::Scenes # An alias for {FelFlame::Stage} FF::Stg = FelFlame::Stage + +# An alias for {FelFlame:: +FF::Odr = FelFlame::Order diff --git a/lib/felflame/component_manager.rb b/lib/felflame/component_manager.rb index 04faccb..6ac7463 100644 --- a/lib/felflame/component_manager.rb +++ b/lib/felflame/component_manager.rb @@ -48,28 +48,6 @@ module FelFlame FelFlame::Components.const_get(component_name) end - # Makes component module behave like an array of component - # managers with additional methods for managing the array - # @!visibility private - # #def respond_to_missing?(method, *) - # if constants.respond_to? method - # true - # else - # super - # end - # end - - ## Makes component module behave like arrays with additional - ## methods for managing the array - ## @!visibility private - # def method_missing(method, *args, **kwargs, &block) - # if constants.respond_to? method - # constants.send(method, *args, **kwargs, &block) - # else - # super - # end - # end - # Stores the components managers in {FelFlame::Components}. This # is needed because calling `FelFlame::Components.constants` # will not let you iterate over the value of the constants diff --git a/lib/felflame/order.rb b/lib/felflame/order.rb index 0bed66b..3202b25 100644 --- a/lib/felflame/order.rb +++ b/lib/felflame/order.rb @@ -1,6 +1,23 @@ module FelFlame module Order - def sort(*sortables) + + # 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 |
