From 55f1db30e7a609cebd2fab27c55ece1da45be232 Mon Sep 17 00:00:00 2001 From: realtradam Date: Mon, 3 Jan 2022 07:34:38 -0500 Subject: . --- docs/FelFlame.html | 14 +-- docs/FelFlame/ComponentManager.html | 211 ++++++++++-------------------------- docs/FelFlame/Components.html | 18 +-- docs/FelFlame/Entities.html | 52 +++++---- docs/FelFlame/Order.html | 172 +++++++++++++++++++++++++++++ docs/FelFlame/Scenes.html | 62 +++++------ docs/FelFlame/Stage.html | 44 ++++---- docs/FelFlame/Systems.html | 148 ++++++++++++------------- docs/Felflame_.html | 4 +- docs/_index.html | 17 ++- docs/class_list.html | 2 +- docs/file.README.html | 106 +++++++++--------- docs/index.html | 106 +++++++++--------- docs/method_list.html | 80 +++++++------- docs/top-level-namespace.html | 2 +- 15 files changed, 565 insertions(+), 473 deletions(-) create mode 100644 docs/FelFlame/Order.html (limited to 'docs') diff --git a/docs/FelFlame.html b/docs/FelFlame.html index ef9cb69..1ec7927 100644 --- a/docs/FelFlame.html +++ b/docs/FelFlame.html @@ -79,7 +79,7 @@
Defined in:
lib/felflame.rb,
- lib/felflame/scene_manager.rb,
lib/felflame/stage_manager.rb,
lib/felflame/entity_manager.rb,
lib/felflame/system_manager.rb,
lib/felflame/component_manager.rb
+ lib/felflame/order.rb,
lib/felflame/scene_manager.rb,
lib/felflame/stage_manager.rb,
lib/felflame/entity_manager.rb,
lib/felflame/system_manager.rb,
lib/felflame/component_manager.rb
@@ -100,7 +100,7 @@

- Modules: Components, Stage + Modules: Components, Order, Stage @@ -273,12 +273,12 @@

 
 
-15
-16
-17
+17 +18 +19 -
# File 'lib/felflame.rb', line 15
+      
# File 'lib/felflame.rb', line 17
 
 def call
   FelFlame::Stage.call
@@ -293,7 +293,7 @@
 
 
       
diff --git a/docs/FelFlame/ComponentManager.html b/docs/FelFlame/ComponentManager.html
index 119a7ed..143fd3a 100644
--- a/docs/FelFlame/ComponentManager.html
+++ b/docs/FelFlame/ComponentManager.html
@@ -102,7 +102,7 @@
 

Overview

-

Component Managers are what is used to create individual components which can be attached to entities. When a Component is created from a Component Manager that has accessors given to it, you can set or get the values of those accessors using standard ruby message sending (e.g @component.var = 5), or by using the #attrs and #update_attrs methods instead.

+

Component Managers are what is used to create individual components which can be attached to entities. When a Component is created from a Component Manager that has accessors given to it, you can set or get the values of those accessors using standard ruby message sending (e.g @component.var = 5), or by using the #to_h and #update_attrs methods instead.

@@ -312,30 +312,6 @@
  • - #attr_changed_trigger_systems(attr) ⇒ Boolean - - - - - - - - - - - - - -
    -

    Execute systems that have been added to execute on variable change.

    -
    - -
  • - - -
  • - - #delete ⇒ Boolean @@ -449,7 +425,7 @@
    -

    A hash, where all the keys are attributes linked to their respective values.

    +

    A hash, where all the keys are attributes storing their respective values.

  • @@ -531,6 +507,8 @@
     
     
    +154
    +155
     156
     157
     158
    @@ -542,12 +520,10 @@
     164
     165
     166
    -167
    -168
    -169
    +167
    -
    # File 'lib/felflame/component_manager.rb', line 156
    +      
    # File 'lib/felflame/component_manager.rb', line 154
     
     def initialize(**attrs)
       # Prepare the object
    @@ -614,12 +590,12 @@
           
     
     
    -206
    -207
    -208
    +202 +203 +204
    -
    # File 'lib/felflame/component_manager.rb', line 206
    +      
    # File 'lib/felflame/component_manager.rb', line 202
     
     def addition_triggers
       @addition_triggers ||= []
    @@ -670,12 +646,12 @@
           
     
     
    -222
    -223
    -224
    +218 +219 +220
    -
    # File 'lib/felflame/component_manager.rb', line 222
    +      
    # File 'lib/felflame/component_manager.rb', line 218
     
     def attr_triggers
       @attr_triggers ||= {}
    @@ -726,12 +702,12 @@
           
     
     
    -214
    -215
    -216
    +210 +211 +212
    -
    # File 'lib/felflame/component_manager.rb', line 214
    +      
    # File 'lib/felflame/component_manager.rb', line 210
     
     def removal_triggers
       @removal_triggers ||= []
    @@ -787,12 +763,12 @@
           
     
     
    -133
    -134
    -135
    +131 +132 +133
    -
    # File 'lib/felflame/component_manager.rb', line 133
    +      
    # File 'lib/felflame/component_manager.rb', line 131
     
     def addition_triggers
       @addition_triggers ||= []
    @@ -843,12 +819,12 @@
           
     
     
    -149
    -150
    -151
    +147 +148 +149
    -
    # File 'lib/felflame/component_manager.rb', line 149
    +      
    # File 'lib/felflame/component_manager.rb', line 147
     
     def attr_triggers
       @attr_triggers ||= {}
    @@ -899,12 +875,12 @@
           
     
     
    -141
    -142
    -143
    +139 +140 +141
    -
    # File 'lib/felflame/component_manager.rb', line 141
    +      
    # File 'lib/felflame/component_manager.rb', line 139
     
     def removal_triggers
       @removal_triggers ||= []
    @@ -922,78 +898,7 @@
     
         
           
    -

    - - #attr_changed_trigger_systems(attr) ⇒ Boolean - - - - - -

    -
    - -

    Execute systems that have been added to execute on variable change

    - - -
    -
    -
    - -

    Returns:

    -
      - -
    • - - - (Boolean) - - - - — -
      -

      true

      -
      - -
    • - -
    - -
    - - - - -
    -
    -
    -
    -260
    -261
    -262
    -263
    -264
    -265
    -266
    -267
    -268
    -
    -
    # File 'lib/felflame/component_manager.rb', line 260
    -
    -def attr_changed_trigger_systems(attr)
    -  systems_to_execute = self.class.attr_triggers[attr]
    -  systems_to_execute = [] if systems_to_execute.nil?
    -
    -  systems_to_execute |= attr_triggers[attr] unless attr_triggers[attr].nil?
    -
    -  systems_to_execute.sort_by(&:priority).reverse_each(&:call)
    -  true
    -end
    -
    -
    - -
    -

    +

    #deleteBoolean @@ -1036,6 +941,8 @@
     
     
    +269
    +270
     271
     272
     273
    @@ -1046,12 +953,10 @@
     278
     279
     280
    -281
    -282
    -283
    +281

    -
    # File 'lib/felflame/component_manager.rb', line 271
    +      
    # File 'lib/felflame/component_manager.rb', line 269
     
     def delete
       addition_triggers.each do |system|
    @@ -1110,12 +1015,12 @@
           
     
     
    -235
    -236
    -237
    +231 +232 +233
    -
    # File 'lib/felflame/component_manager.rb', line 235
    +      
    # File 'lib/felflame/component_manager.rb', line 231
     
     def entities
       @entities ||= []
    @@ -1164,17 +1069,17 @@
           
     
     
    +237
    +238
    +239
    +240
     241
     242
     243
    -244
    -245
    -246
    -247
    -248
    +244
    -
    # File 'lib/felflame/component_manager.rb', line 241
    +      
    # File 'lib/felflame/component_manager.rb', line 237
     
     def entity
       if entities.empty?
    @@ -1201,7 +1106,7 @@
     
    -

    Returns A hash, where all the keys are attributes linked to their respective values.

    +

    Returns A hash, where all the keys are attributes storing their respective values.

    @@ -1220,7 +1125,7 @@ —
    -

    A hash, where all the keys are attributes linked to their respective values.

    +

    A hash, where all the keys are attributes storing their respective values.

    @@ -1233,16 +1138,16 @@
     
     
    +284
    +285
     286
     287
     288
     289
    -290
    -291
    -292
    +290
    -
    # File 'lib/felflame/component_manager.rb', line 286
    +      
    # File 'lib/felflame/component_manager.rb', line 284
     
     def to_h
       return_hash = instance_variables.each_with_object({}) do |key, final|
    @@ -1300,14 +1205,14 @@
           
     
     
    -252
    -253
    -254
    -255
    -256
    +248 +249 +250 +251 +252
    -
    # File 'lib/felflame/component_manager.rb', line 252
    +      
    # File 'lib/felflame/component_manager.rb', line 248
     
     def update_attrs(**opts)
       opts.each do |key, value|
    @@ -1324,7 +1229,7 @@
     
     
           
    diff --git a/docs/FelFlame/Components.html b/docs/FelFlame/Components.html
    index 33d82b3..37c11bf 100644
    --- a/docs/FelFlame/Components.html
    +++ b/docs/FelFlame/Components.html
    @@ -88,7 +88,7 @@
     

    Overview

    -

    Creates component managers and allows accessing them them under the Components namespace as Constants.

    +

    Creates component managers and allows accessing them them under the Components namespace as Constants. You can use array methods directly on this class to access Component Managers.

    To see how component managers are used please look at the ComponentManager documentation.

    @@ -249,8 +249,6 @@
     
     
    -18
    -19
     20
     21
     22
    @@ -278,24 +276,26 @@
     44
     45
     46
    -47
    +47 +48 +49
    -
    # File 'lib/felflame/component_manager.rb', line 18
    +      
    # File 'lib/felflame/component_manager.rb', line 20
     
     def new(component_name, *attrs, **attrs_with_defaults)
       if FelFlame::Components.const_defined?(component_name)
         raise(NameError.new, "Component Manager '#{component_name}' is already defined")
       end
     
    -
       const_set(component_name, Class.new(FelFlame::ComponentManager) {})
       update_const_cache
     
       attrs.each do |attr|
    -    if FelFlame::Components.const_get(component_name).method_defined?("#{attr}") || FelFlame::Components.const_get(component_name).method_defined?("#{attr}=")
    -      raise NameError.new "The attribute name \"#{attr}\" is already a method"
    +    if FelFlame::Components.const_get(component_name).method_defined?(attr.to_s) || FelFlame::Components.const_get(component_name).method_defined?("#{attr}=")
    +      raise NameError, "The attribute name \"#{attr}\" is already a method"
         end
    +
         FelFlame::Components.const_get(component_name).attr_accessor attr
       end
       attrs_with_defaults.each do |attr, _default|
    @@ -323,7 +323,7 @@
     
     
           
    diff --git a/docs/FelFlame/Entities.html b/docs/FelFlame/Entities.html
    index 4308d4b..43d61fa 100644
    --- a/docs/FelFlame/Entities.html
    +++ b/docs/FelFlame/Entities.html
    @@ -104,7 +104,7 @@
     

    Overview

    -

    Creates and manages Entities. Allows iterating or accessing Entities using array methods directly on the class. Entities are just collections of Components.

    +

    Creates and manages Entities. Entities are just collections of Components. You can use array methods directly on this class to access Entities.

    @@ -325,14 +325,14 @@
     
     
    -7
     8
     9
     10
    -11
    +11 +12
    -
    # File 'lib/felflame/entity_manager.rb', line 7
    +      
    # File 'lib/felflame/entity_manager.rb', line 8
     
     def initialize(*components)
       # Add each component
    @@ -415,7 +415,6 @@
           
     
     
    -56
     57
     58
     59
    @@ -428,10 +427,11 @@
     66
     67
     68
    -69
    +69 +70
    -
    # File 'lib/felflame/entity_manager.rb', line 56
    +      
    # File 'lib/felflame/entity_manager.rb', line 57
     
     def add(*components_to_add)
       components_to_add.each do |component|
    @@ -464,7 +464,7 @@
     
    -

    A single component from a component manager. Use this if you expect the component to only belong to one entity and you want to access it. Access the component using either parameter notation or array notation.

    +

    A single component from a component manager. Use this if you expect the component to only belong to one entity and you want to access it. Access the component using either parameter notation or array notation. Array notation is conventional for better readablility.

    @@ -475,7 +475,7 @@

    Examples:

    -
    @entity.component[@component_manager] # array notation
    +      
    @entity.component[@component_manager] # array notation(the standard)
     @entity.component(@component_manager) # method notation
    @@ -522,7 +522,6 @@
     
     
    -25
     26
     27
     28
    @@ -534,10 +533,12 @@
     34
     35
     36
    -37
    +37 +38 +39
    -
    # File 'lib/felflame/entity_manager.rb', line 25
    +      
    # File 'lib/felflame/entity_manager.rb', line 26
     
     def component(manager = nil)
       if manager.nil?
    @@ -549,6 +550,7 @@
         elsif components[manager].length > 1
           Warning.warn("This entity has MANY of this component but you called the method that is intended for having a single of this component type.\nYou may have a bug in your logic.")
         end
    +
         components[manager].first
       end
     end
    @@ -596,12 +598,12 @@
     
     
    -15
     16
    -17
    +17 +18
    -
    # File 'lib/felflame/entity_manager.rb', line 15
    +      
    # File 'lib/felflame/entity_manager.rb', line 16
     
     def components
       @components ||= {}
    @@ -655,7 +657,6 @@
           
     
     
    -42
     43
     44
     45
    @@ -664,13 +665,14 @@
     48
     49
     50
    -51
    +51 +52
    -
    # File 'lib/felflame/entity_manager.rb', line 42
    +      
    # File 'lib/felflame/entity_manager.rb', line 43
     
     def delete
    -  components.each do |component_manager, component_array|
    +  components.each do |_component_manager, component_array|
         component_array.reverse_each do |component|
           component.entities.delete(self)
         end
    @@ -748,7 +750,6 @@
           
     
     
    -86
     87
     88
     89
    @@ -757,20 +758,17 @@
     92
     93
     94
    -95
    -96
    +95
    -
    # File 'lib/felflame/entity_manager.rb', line 86
    +      
    # File 'lib/felflame/entity_manager.rb', line 87
     
     def remove(*components_to_remove)
       components_to_remove.each do |component|
         check_systems component, :removal_triggers if component.entities.include? self
         component.entities.delete self
         components[component.class].delete component
    -    if components[component.class].empty?
    -      components.delete component.class
    -    end
    +    components.delete component.class if components[component.class].empty?
       end
       true
     end
    @@ -784,7 +782,7 @@ diff --git a/docs/FelFlame/Order.html b/docs/FelFlame/Order.html new file mode 100644 index 0000000..b17a786 --- /dev/null +++ b/docs/FelFlame/Order.html @@ -0,0 +1,172 @@ + + + + + + + Module: FelFlame::Order + + — Documentation by YARD 0.9.26 + + + + + + + + + + + + + + + + + + + +
    + + +

    Module: FelFlame::Order + + + +

    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/felflame/order.rb
    +
    + +
    + + + + + + + + + +

    + Instance Method Summary + collapse +

    + + + + + + +
    +

    Instance Method Details

    + + +
    +

    + + #sort(*sortables) ⇒ Object + + + + + +

    + + + + +
    +
    +
    +
    +3
    +4
    +
    +
    # File 'lib/felflame/order.rb', line 3
    +
    +def sort(*sortables)
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/docs/FelFlame/Scenes.html b/docs/FelFlame/Scenes.html index 5a73e20..6245fa6 100644 --- a/docs/FelFlame/Scenes.html +++ b/docs/FelFlame/Scenes.html @@ -106,8 +106,6 @@

    Creates and manages Scenes. Scenes are collections of Systems, and execute all the Systems when called upon. Any scenes you create are accessable under the Scenes namespace as Constants.

    -

    TODO: Improve Scenes overview

    - @@ -364,13 +362,13 @@
     
     
    -20
    -21
     22
    -23
    +23 +24 +25
    -
    # File 'lib/felflame/scene_manager.rb', line 20
    +      
    # File 'lib/felflame/scene_manager.rb', line 22
     
     def initialize(name, priority: 0)
       self.priority = priority
    @@ -414,12 +412,12 @@
           
     
     
    -10
    -11
    -12
    +12 +13 +14
    -
    # File 'lib/felflame/scene_manager.rb', line 10
    +      
    # File 'lib/felflame/scene_manager.rb', line 12
     
     def priority
       @priority
    @@ -470,12 +468,12 @@
           
     
     
    -27
    -28
    -29
    +29 +30 +31
    -
    # File 'lib/felflame/scene_manager.rb', line 27
    +      
    # File 'lib/felflame/scene_manager.rb', line 29
     
     def systems
       @systems ||= []
    @@ -536,17 +534,17 @@
           
     
     
    -40
    -41
     42
     43
     44
     45
     46
    -47
    +47 +48 +49
    -
    # File 'lib/felflame/scene_manager.rb', line 40
    +      
    # File 'lib/felflame/scene_manager.rb', line 42
     
     def add(*systems_to_add)
       self.systems |= systems_to_add
    @@ -605,13 +603,13 @@
           
     
     
    -33
    -34
     35
    -36
    +36 +37 +38
    -
    # File 'lib/felflame/scene_manager.rb', line 33
    +      
    # File 'lib/felflame/scene_manager.rb', line 35
     
     def call
       systems.each(&:call)
    @@ -666,24 +664,24 @@
           
     
     
    -58
    -59
     60
     61
     62
     63
     64
    -65
    +65 +66 +67
    -
    # File 'lib/felflame/scene_manager.rb', line 58
    +      
    # File 'lib/felflame/scene_manager.rb', line 60
     
     def clear
       systems.each do |system|
         system.scenes.delete self
       end
       systems.clear
    -  #FelFlame::Stage.update_systems_list if FelFlame::Stage.scenes.include? self
    +  # FelFlame::Stage.update_systems_list if FelFlame::Stage.scenes.include? self
       true
     end
    @@ -735,13 +733,13 @@
     
     
    -51
    -52
     53
    -54
    +54 +55 +56
    -
    # File 'lib/felflame/scene_manager.rb', line 51
    +      
    # File 'lib/felflame/scene_manager.rb', line 53
     
     def remove(*systems_to_remove)
       self.systems -= systems_to_remove
    @@ -757,7 +755,7 @@
     
     
           
    diff --git a/docs/FelFlame/Stage.html b/docs/FelFlame/Stage.html
    index 892810b..e944f44 100644
    --- a/docs/FelFlame/Stage.html
    +++ b/docs/FelFlame/Stage.html
    @@ -289,12 +289,12 @@
           
     
     
    -40
    -41
    -42
    +42 +43 +44
    -
    # File 'lib/felflame/stage_manager.rb', line 40
    +      
    # File 'lib/felflame/stage_manager.rb', line 42
     
     def scenes
       @scenes ||= []
    @@ -355,14 +355,14 @@
           
     
     
    -11
    -12
     13
     14
    -15
    +15 +16 +17
    -
    # File 'lib/felflame/stage_manager.rb', line 11
    +      
    # File 'lib/felflame/stage_manager.rb', line 13
     
     def add(*scenes_to_add)
       self.scenes |= scenes_to_add
    @@ -386,7 +386,7 @@
     
    -

    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.

    +

    Executes one frame of the game. This executes all the Scenes added to the Stage in order of their priority.

    @@ -418,13 +418,13 @@
     
     
    -33
    -34
     35
    -36
    +36 +37 +38
    -
    # File 'lib/felflame/stage_manager.rb', line 33
    +      
    # File 'lib/felflame/stage_manager.rb', line 35
     
     def call
       self.scenes.each(&:call)
    @@ -479,13 +479,13 @@
           
     
     
    -26
    -27
     28
    -29
    +29 +30 +31
    -
    # File 'lib/felflame/stage_manager.rb', line 26
    +      
    # File 'lib/felflame/stage_manager.rb', line 28
     
     def clear
       self.scenes.clear
    @@ -540,13 +540,13 @@
           
     
     
    -19
    -20
     21
    -22
    +22 +23 +24
    -
    # File 'lib/felflame/stage_manager.rb', line 19
    +      
    # File 'lib/felflame/stage_manager.rb', line 21
     
     def remove(*scenes_to_remove)
       self.scenes -= scenes_to_remove
    @@ -562,7 +562,7 @@
     
     
           
    diff --git a/docs/FelFlame/Systems.html b/docs/FelFlame/Systems.html
    index 7f5d18c..be6a374 100644
    --- a/docs/FelFlame/Systems.html
    +++ b/docs/FelFlame/Systems.html
    @@ -104,9 +104,7 @@
     

    Overview

    -

    Creates an manages Systems. Systems are the logic of the game and do not contain any data within them. Any systems you create are accessable under the Systems namespace as Constants.

    - -

    TODO: Improve Systems overview

    +

    Creates and manages Systems. Systems are the logic of the game and do not contain any data within them. Any systems you create are accessable under the Systems namespace as Constants. You can use array methods directly on this class to access Systems.

    @@ -576,16 +574,16 @@
     
     
    +115
     116
     117
     118
     119
     120
    -121
    -122
    +121
    -
    # File 'lib/felflame/system_manager.rb', line 116
    +      
    # File 'lib/felflame/system_manager.rb', line 115
     
     def initialize(name, priority: 0, &block)
       FelFlame::Systems.const_set(name, self)
    @@ -645,12 +643,12 @@
           
     
     
    -33
    -34
    -35
    +35 +36 +37
    -
    # File 'lib/felflame/system_manager.rb', line 33
    +      
    # File 'lib/felflame/system_manager.rb', line 35
     
     def addition_triggers
       @addition_triggers ||= []
    @@ -701,12 +699,12 @@
           
     
     
    -51
     52
    -53
    +53 +54
    -
    # File 'lib/felflame/system_manager.rb', line 51
    +      
    # File 'lib/felflame/system_manager.rb', line 52
     
     def attr_triggers
       @attr_triggers ||= {}
    @@ -744,12 +742,12 @@
           
     
     
    -4
    -5
    -6
    +6 +7 +8
    -
    # File 'lib/felflame/system_manager.rb', line 4
    +      
    # File 'lib/felflame/system_manager.rb', line 6
     
     def priority
       @priority
    @@ -800,12 +798,12 @@
           
     
     
    -42
    -43
    -44
    +44 +45 +46
    -
    # File 'lib/felflame/system_manager.rb', line 42
    +      
    # File 'lib/felflame/system_manager.rb', line 44
     
     def removal_triggers
       @removal_triggers ||= []
    @@ -832,12 +830,12 @@
           
     
     
    -17
    -18
    -19
    +19 +20 +21
    -
    # File 'lib/felflame/system_manager.rb', line 17
    +      
    # File 'lib/felflame/system_manager.rb', line 19
     
     def scenes
       @scenes ||= []
    @@ -927,12 +925,12 @@
           
     
     
    +124
     125
    -126
    -127
    +126
    -
    # File 'lib/felflame/system_manager.rb', line 125
    +      
    # File 'lib/felflame/system_manager.rb', line 124
     
     def call
       @block.call
    @@ -1110,23 +1108,22 @@
     219
     220
     221
    -222
    -223
    +222
    # File 'lib/felflame/system_manager.rb', line 157
     
     def clear_triggers(*trigger_types, component_or_manager: nil)
    -  trigger_types = [:addition_triggers, :removal_triggers, :attr_triggers] if trigger_types.empty?
    +  trigger_types = %i[addition_triggers removal_triggers attr_triggers] if trigger_types.empty?
     
       if trigger_types.include? :attr_triggers
    -    if (trigger_types - [:addition_triggers,
    -        :removal_triggers,
    -        :attr_triggers]).empty?
    +    if (trigger_types - %i[addition_triggers
    +                           removal_triggers
    +                           attr_triggers]).empty?
     
           if component_or_manager.nil?
    -        #remove all attrs
    -        self.attr_triggers.each do |cmp_or_mgr, attrs|
    +        # remove all attrs
    +        attr_triggers.each do |cmp_or_mgr, attrs|
               attrs.each do |attr|
                 next if cmp_or_mgr.attr_triggers[attr].nil?
     
    @@ -1135,49 +1132,48 @@
               self.attr_triggers = {}
             end
           else
    -        #remove attrs relevant to comp_or_man
    -        unless self.attr_triggers[component_or_manager].nil?
    -          self.attr_triggers[component_or_manager].each do |attr|
    +        # remove attrs relevant to comp_or_man
    +        unless attr_triggers[component_or_manager].nil?
    +          attr_triggers[component_or_manager].each do |attr|
                 component_or_manager.attr_triggers[attr].delete self
               end
    -          self.attr_triggers[component_or_manager] = []
    +          attr_triggers[component_or_manager] = []
             end
           end
     
    -    else
    +    elsif component_or_manager.nil?
     
    -      if component_or_manager.nil?
    -        (trigger_types - [:addition_triggers, :removal_triggers, :attr_triggers]).each do |attr|
    -          #remove attr
    -          self.attr_triggers.each do |cmp_or_mgr, attrs|
    -            cmp_or_mgr.attr_triggers[attr].delete self
    -          end
    +      (trigger_types - %i[addition_triggers removal_triggers attr_triggers]).each do |attr|
    +        # remove attr
    +        attr_triggers.each do |cmp_or_mgr, _attrs|
    +          cmp_or_mgr.attr_triggers[attr].delete self
             end
    -        self.attr_triggers.delete (trigger_types - [:addition_triggers,
    -                                                    :removal_triggers,
    -                                                    :attr_triggers])
    -      else
    -        #remove attr from component_or_manager
    -        (trigger_types - [:addition_triggers, :removal_triggers, :attr_triggers]).each do |attr|
    -          next if component_or_manager.attr_triggers[attr].nil?
    -          component_or_manager.attr_triggers[attr].delete self
    -        end
    -        self.attr_triggers[component_or_manager] -= trigger_types unless self.attr_triggers[component_or_manager].nil?
           end
    +      attr_triggers.delete(trigger_types - %i[addition_triggers
    +                                              removal_triggers
    +                                              attr_triggers])
    +    else
    +      # remove attr from component_or_manager
    +      (trigger_types - %i[addition_triggers removal_triggers attr_triggers]).each do |attr|
    +        next if component_or_manager.attr_triggers[attr].nil?
    +
    +        component_or_manager.attr_triggers[attr].delete self
    +      end
    +      attr_triggers[component_or_manager] -= trigger_types unless attr_triggers[component_or_manager].nil?
     
         end
       end
     
    -  (trigger_types & [:removal_triggers, :addition_triggers] - [:attr_triggers]).each do |trigger_type|
    +  (trigger_types & %i[removal_triggers addition_triggers] - [:attr_triggers]).each do |trigger_type|
         if component_or_manager.nil?
    -      #remove all removal triggers
    -      self.send(trigger_type).each do |trigger|
    +      # remove all removal triggers
    +      send(trigger_type).each do |trigger|
             trigger.send(trigger_type).delete self
           end
    -      self.send("#{trigger_type.to_s}=", [])
    +      send("#{trigger_type}=", [])
         else
    -      #remove removal trigger relevant to comp/man
    -      self.send(trigger_type).delete component_or_manager
    +      # remove removal trigger relevant to comp/man
    +      send(trigger_type).delete component_or_manager
           component_or_manager.send(trigger_type).delete self
         end
       end
    @@ -1313,14 +1309,14 @@
           
     
     
    +227
     228
     229
     230
    -231
    -232
    +231
    -
    # File 'lib/felflame/system_manager.rb', line 228
    +      
    # File 'lib/felflame/system_manager.rb', line 227
     
     def trigger_when_added(component_or_manager)
       self.addition_triggers |= [component_or_manager]
    @@ -1376,6 +1372,7 @@
           
     
     
    +244
     245
     246
     247
    @@ -1387,11 +1384,10 @@
     253
     254
     255
    -256
    -257
    +256
    -
    # File 'lib/felflame/system_manager.rb', line 245
    +      
    # File 'lib/felflame/system_manager.rb', line 244
     
     def trigger_when_is_changed(component_or_manager, attr)
       if component_or_manager.attr_triggers[attr].nil?
    @@ -1399,10 +1395,10 @@
       else
         component_or_manager.attr_triggers[attr] |= [self]
       end
    -  if self.attr_triggers[component_or_manager].nil?
    -    self.attr_triggers[component_or_manager] = [attr]
    +  if attr_triggers[component_or_manager].nil?
    +    attr_triggers[component_or_manager] = [attr]
       else
    -    self.attr_triggers[component_or_manager] |= [attr]
    +    attr_triggers[component_or_manager] |= [attr]
       end
       true
     end
    @@ -1475,14 +1471,14 @@
     
     
    +236
     237
     238
     239
    -240
    -241
    +240
    -
    # File 'lib/felflame/system_manager.rb', line 237
    +      
    # File 'lib/felflame/system_manager.rb', line 236
     
     def trigger_when_removed(component_or_manager)
       self.removal_triggers |= [component_or_manager]
    @@ -1499,7 +1495,7 @@
     
     
           
    diff --git a/docs/Felflame_.html b/docs/Felflame_.html
    index eda8518..ac59bac 100644
    --- a/docs/Felflame_.html
    +++ b/docs/Felflame_.html
    @@ -117,7 +117,7 @@
     
     
             
    -        
    "3.0.0"
    +
    '3.0.0'
    @@ -133,7 +133,7 @@ diff --git a/docs/_index.html b/docs/_index.html index a183a99..d3becf8 100644 --- a/docs/_index.html +++ b/docs/_index.html @@ -131,6 +131,21 @@ +
      +
    • O
    • +
        + +
      • + Order + + (FelFlame) + +
      • + +
      +
    + +

    Adding and Removing Components

    @@ -234,14 +229,18 @@ entity where a new entity will claim that ID. To get the ID of an Entity:

    Accessing Entities' Attached Components

    +

    This is the most common way of accessing an Entity

    +

    When Components are added to Entities, they can be accessed from the Entity. By using a Component Manager as a key we can access an array of all components created from that Component Manager that are attached to an entity:

    -
    @entity.components[@component_manager] # => [@component1, @component2, component3]
    +
    @entity.components[@component_manager] # => [@component1, @component2, @component3]
     

    Deletion

    -

    To have all Components from an Entity removed and the Entity deleted we do the following:

    +

    To have all Components from an Entity removed and the Entity deleted we do the following:

    + +

    NOTE: The components will not be deleted. They are simply removed from the entity and then the entity is destroyed. You must handle component deletion yourself as for example singleton components need to removed instead of deleted.

    @entity.delete
     
    @@ -270,19 +269,18 @@ When defining attributes symbols should be used.

    @component = FelFlame::Components::Stats.new
     
    -

    Or we can even change the defaults:

    +

    Or we can even override the defaults when creating the component:

    @component = FelFlame::Components::Stats.new(armour: 'steel')
     
    -

    Accessing and Getting ID

    +

    Accessing

    -

    Just like Entities, Components have IDs. -These IDs are only unique within the scope of their respective Component Managers. -Here is how we can get the ID, as well as how to access a Component from its Component Manager.

    +

    You can access components using any array method.

    @component = FelFlame::Components::Stats[2]
    -@component.id # => 2
    +@component = FelFlame::Components::Stats.first
    +@component = FelFlame::Components::Stats.each # you can use iterators this way
     

    Accessing Attributes and Changing Them

    @@ -295,30 +293,26 @@ Here are the ways to edit attrubutes, followed by the ways to read them.

    @component.hp # => 95
    -@component.attrs # => {armour: 'Leather', hp: 95}
    +@component.to_h # => {armour: 'Leather', hp: 95}
     

    Deleting Components

    -

    Deleting a Component is the same format as deleting an Entity. When a Component is deleted referenced to it such as to entities are automatically cleared.

    +

    Deleting a Component is the same convention as deleting an Entity. When a Component is deleted referenced to it such as to entities are automatically cleared.

    @component.delete
     
    -

    Iterating over Components

    - -

    When you make Systems you will want to be able to iterate over all Components of the same Component Manager(for example iterating over all sprites to render them). Here is how we do that:

    - -
    FelFlame::Components::Sprites.each do |component|
    -  #do something with components
    -end
    -
    -

    Accessing Components' attached Entities

    Components also keep track of what Entities are using it. To access this list we do the following:

    @component.entities # => [@entity1, @entity2, @entity3]
    +
    +# get the first entity attached.
    +# this will throw a warning if there is more or less then
    +# exactly one entity
    +@component.entity # => @entity
     

    Systems

    @@ -339,7 +333,9 @@ Here are the ways to edit attrubutes, followed by the ways to read them.

    Priority determines the order Systems should be executed, this is used for Scenes and the Stage. The lower the number, the earlier a given System will be executed. -E.g priority 1 will go first, priority 2 will go second, etcetera.

    +E.g priority 1 will go first, priority 2 will go second, etcetera.

    + +

    Both Scenes and Systems have a priority. System priority will decide the order it will be called inside of a Scene, which the Scene priority will decide the order it will be called inside of the Stage.

    Often we will want to execute some logic on each Component in a given Component Manager so our code might look like this:

    @@ -437,7 +433,7 @@ E.g priority 1 will go first, priority 2 will go second, etcetera.

    Once we have all the core parts of ECS, we will want to organize our Systems. To do this we will use Scenes to group up Systems so they can quickly be enabled or disabled. Note that Alternative Executions will occur even if they are not part of a Scene. Here is how we make a new Scene:

    -
    @scene = FelFlame::Scenes.new('ExampleScene')
    +
    @scene = FelFlame::Scenes.new('ExampleScene', priority: 5)
     

    Accessing

    @@ -451,14 +447,22 @@ E.g priority 1 will go first, priority 2 will go second, etcetera.

    Adding Systems is simple. We can add as many as we want. In this example we add 3 different systems:

    -
    FelFlame::Scenes::ExampleScene.add(FelFlame::Systems::Render, @system2, @system3)
    +
    FelFlame::Scenes::ExampleScene.add(
    +  FelFlame::Systems::Render,
    +  @system2,
    +  @system3
    +)
     

    Removing Systems

    -

    Removing Systems works simularly:

    +

    Removing Systems works similarly:

    -
    FelFlame::Scenes::ExampleScene.remove(FelFlame::Systems::Render, @system2, @system3)
    +
    FelFlame::Scenes::ExampleScene.remove(
    +  FelFlame::Systems::Render,
    +  @system2,
    +  @system3
    +)
     

    Clearing

    @@ -481,7 +485,7 @@ E.g priority 1 will go first, priority 2 will go second, etcetera.

    Adding Scenes

    -

    Finally we have the Stage. There is only a single Stage and we do not have to create it as it exists by default. By adding a Scene to the Stage we are saying that the Scene is active. To add a Scene we do the following:

    +

    Finally we have the Stage. There is only a single Stage and we do not have to create it as it exists by default. By adding a Scene to the Stage we are saying that the Scene is 'active'. To add a Scene we do the following:

    FelFlame::Stage.add FelFlame::Scene::ExampleScene
     
    @@ -495,7 +499,7 @@ E.g priority 1 will go first, priority 2 will go second, etcetera.

    Executing

    -

    On each frame of the game we want to execute the Stage once. When the Stage is executed it is progressing your game 1 frame forward. The Stage will make sure for you that all the Systems from all Scenes added will be executed in the correct order according to their priority. Here is how we do it:

    +

    On each frame of the game generally we will want to execute the Stage once. When the Stage is executed it is progressing your game 1 frame forward. The Stage will call all Scenes you added to it in the order of their priority. Here is how we do it:

    FelFlame::Stage.call
     
    @@ -514,7 +518,7 @@ E.g priority 1 will go first, priority 2 will go second, etcetera.

    diff --git a/docs/index.html b/docs/index.html index 5333a27..916cce2 100644 --- a/docs/index.html +++ b/docs/index.html @@ -76,11 +76,11 @@

    Adding and Removing Components

    @@ -234,14 +229,18 @@ entity where a new entity will claim that ID. To get the ID of an Entity:

    Accessing Entities' Attached Components

    +

    This is the most common way of accessing an Entity

    +

    When Components are added to Entities, they can be accessed from the Entity. By using a Component Manager as a key we can access an array of all components created from that Component Manager that are attached to an entity:

    -
    @entity.components[@component_manager] # => [@component1, @component2, component3]
    +
    @entity.components[@component_manager] # => [@component1, @component2, @component3]
     

    Deletion

    -

    To have all Components from an Entity removed and the Entity deleted we do the following:

    +

    To have all Components from an Entity removed and the Entity deleted we do the following:

    + +

    NOTE: The components will not be deleted. They are simply removed from the entity and then the entity is destroyed. You must handle component deletion yourself as for example singleton components need to removed instead of deleted.

    @entity.delete
     
    @@ -270,19 +269,18 @@ When defining attributes symbols should be used.

    @component = FelFlame::Components::Stats.new
     
    -

    Or we can even change the defaults:

    +

    Or we can even override the defaults when creating the component:

    @component = FelFlame::Components::Stats.new(armour: 'steel')
     
    -

    Accessing and Getting ID

    +

    Accessing

    -

    Just like Entities, Components have IDs. -These IDs are only unique within the scope of their respective Component Managers. -Here is how we can get the ID, as well as how to access a Component from its Component Manager.

    +

    You can access components using any array method.

    @component = FelFlame::Components::Stats[2]
    -@component.id # => 2
    +@component = FelFlame::Components::Stats.first
    +@component = FelFlame::Components::Stats.each # you can use iterators this way
     

    Accessing Attributes and Changing Them

    @@ -295,30 +293,26 @@ Here are the ways to edit attrubutes, followed by the ways to read them.

    @component.hp # => 95
    -@component.attrs # => {armour: 'Leather', hp: 95}
    +@component.to_h # => {armour: 'Leather', hp: 95}
     

    Deleting Components

    -

    Deleting a Component is the same format as deleting an Entity. When a Component is deleted referenced to it such as to entities are automatically cleared.

    +

    Deleting a Component is the same convention as deleting an Entity. When a Component is deleted referenced to it such as to entities are automatically cleared.

    @component.delete
     
    -

    Iterating over Components

    - -

    When you make Systems you will want to be able to iterate over all Components of the same Component Manager(for example iterating over all sprites to render them). Here is how we do that:

    - -
    FelFlame::Components::Sprites.each do |component|
    -  #do something with components
    -end
    -
    -

    Accessing Components' attached Entities

    Components also keep track of what Entities are using it. To access this list we do the following:

    @component.entities # => [@entity1, @entity2, @entity3]
    +
    +# get the first entity attached.
    +# this will throw a warning if there is more or less then
    +# exactly one entity
    +@component.entity # => @entity
     

    Systems

    @@ -339,7 +333,9 @@ Here are the ways to edit attrubutes, followed by the ways to read them.

    Priority determines the order Systems should be executed, this is used for Scenes and the Stage. The lower the number, the earlier a given System will be executed. -E.g priority 1 will go first, priority 2 will go second, etcetera.

    +E.g priority 1 will go first, priority 2 will go second, etcetera.

    + +

    Both Scenes and Systems have a priority. System priority will decide the order it will be called inside of a Scene, which the Scene priority will decide the order it will be called inside of the Stage.

    Often we will want to execute some logic on each Component in a given Component Manager so our code might look like this:

    @@ -437,7 +433,7 @@ E.g priority 1 will go first, priority 2 will go second, etcetera.

    Once we have all the core parts of ECS, we will want to organize our Systems. To do this we will use Scenes to group up Systems so they can quickly be enabled or disabled. Note that Alternative Executions will occur even if they are not part of a Scene. Here is how we make a new Scene:

    -
    @scene = FelFlame::Scenes.new('ExampleScene')
    +
    @scene = FelFlame::Scenes.new('ExampleScene', priority: 5)
     

    Accessing

    @@ -451,14 +447,22 @@ E.g priority 1 will go first, priority 2 will go second, etcetera.

    Adding Systems is simple. We can add as many as we want. In this example we add 3 different systems:

    -
    FelFlame::Scenes::ExampleScene.add(FelFlame::Systems::Render, @system2, @system3)
    +
    FelFlame::Scenes::ExampleScene.add(
    +  FelFlame::Systems::Render,
    +  @system2,
    +  @system3
    +)
     

    Removing Systems

    -

    Removing Systems works simularly:

    +

    Removing Systems works similarly:

    -
    FelFlame::Scenes::ExampleScene.remove(FelFlame::Systems::Render, @system2, @system3)
    +
    FelFlame::Scenes::ExampleScene.remove(
    +  FelFlame::Systems::Render,
    +  @system2,
    +  @system3
    +)
     

    Clearing

    @@ -481,7 +485,7 @@ E.g priority 1 will go first, priority 2 will go second, etcetera.

    Adding Scenes

    -

    Finally we have the Stage. There is only a single Stage and we do not have to create it as it exists by default. By adding a Scene to the Stage we are saying that the Scene is active. To add a Scene we do the following:

    +

    Finally we have the Stage. There is only a single Stage and we do not have to create it as it exists by default. By adding a Scene to the Stage we are saying that the Scene is 'active'. To add a Scene we do the following:

    FelFlame::Stage.add FelFlame::Scene::ExampleScene
     
    @@ -495,7 +499,7 @@ E.g priority 1 will go first, priority 2 will go second, etcetera.

    Executing

    -

    On each frame of the game we want to execute the Stage once. When the Stage is executed it is progressing your game 1 frame forward. The Stage will make sure for you that all the Systems from all Scenes added will be executed in the correct order according to their priority. Here is how we do it:

    +

    On each frame of the game generally we will want to execute the Stage once. When the Stage is executed it is progressing your game 1 frame forward. The Stage will call all Scenes you added to it in the order of their priority. Here is how we do it:

    FelFlame::Stage.call
     
    @@ -514,7 +518,7 @@ E.g priority 1 will go first, priority 2 will go second, etcetera.

    diff --git a/docs/method_list.html b/docs/method_list.html index d8253e9..e0c8da1 100644 --- a/docs/method_list.html +++ b/docs/method_list.html @@ -93,14 +93,6 @@
  • -
    - #attr_changed_trigger_systems - FelFlame::ComponentManager -
    -
  • - - -
  • #attr_triggers FelFlame::Systems @@ -108,7 +100,7 @@
  • -
  • +
  • #attr_triggers FelFlame::ComponentManager @@ -116,7 +108,7 @@
  • -
  • +
  • attr_triggers FelFlame::ComponentManager @@ -124,7 +116,7 @@
  • -
  • +
  • call FelFlame @@ -132,7 +124,7 @@
  • -
  • +
  • #call FelFlame::Scenes @@ -140,7 +132,7 @@
  • -
  • +
  • call FelFlame::Stage @@ -148,7 +140,7 @@
  • -
  • +
  • #call FelFlame::Systems @@ -156,7 +148,7 @@
  • -
  • +
  • #clear FelFlame::Scenes @@ -164,7 +156,7 @@
  • -
  • +
  • clear FelFlame::Stage @@ -172,7 +164,7 @@
  • -
  • +
  • #clear_triggers FelFlame::Systems @@ -180,7 +172,7 @@
  • -
  • +
  • #component FelFlame::Entities @@ -188,7 +180,7 @@
  • -
  • +
  • #components FelFlame::Entities @@ -196,7 +188,7 @@
  • -
  • +
  • const_cache FelFlame::Systems @@ -204,7 +196,7 @@
  • -
  • +
  • #delete FelFlame::Entities @@ -212,7 +204,7 @@
  • -
  • +
  • #delete FelFlame::ComponentManager @@ -220,7 +212,7 @@
  • -
  • +
  • #entities FelFlame::ComponentManager @@ -228,7 +220,7 @@
  • -
  • +
  • #entity FelFlame::ComponentManager @@ -236,7 +228,7 @@
  • -
  • +
  • #initialize FelFlame::Scenes @@ -244,7 +236,7 @@
  • -
  • +
  • #initialize FelFlame::Entities @@ -252,7 +244,7 @@
  • -
  • +
  • #initialize FelFlame::Systems @@ -260,7 +252,7 @@
  • -
  • +
  • #initialize FelFlame::ComponentManager @@ -268,7 +260,7 @@
  • -
  • +
  • new FelFlame::Components @@ -276,7 +268,7 @@
  • -
  • +
  • #priority FelFlame::Scenes @@ -284,7 +276,7 @@
  • -
  • +
  • #priority FelFlame::Systems @@ -292,7 +284,7 @@
  • -
  • +
  • #redefine FelFlame::Systems @@ -300,7 +292,7 @@
  • -
  • +
  • #removal_triggers FelFlame::Systems @@ -308,7 +300,7 @@
  • -
  • +
  • #removal_triggers FelFlame::ComponentManager @@ -316,7 +308,7 @@
  • -
  • +
  • removal_triggers FelFlame::ComponentManager @@ -324,7 +316,7 @@
  • -
  • +
  • #remove FelFlame::Scenes @@ -332,7 +324,7 @@
  • -
  • +
  • remove FelFlame::Stage @@ -340,7 +332,7 @@
  • -
  • +
  • #remove FelFlame::Entities @@ -348,7 +340,7 @@
  • -
  • +
  • scenes FelFlame::Stage @@ -356,7 +348,7 @@
  • -
  • +
  • #scenes FelFlame::Systems @@ -364,6 +356,14 @@
  • +
  • +
    + #sort + FelFlame::Order +
    +
  • + +
  • #systems diff --git a/docs/top-level-namespace.html b/docs/top-level-namespace.html index 9462bb1..78ec112 100644 --- a/docs/top-level-namespace.html +++ b/docs/top-level-namespace.html @@ -127,7 +127,7 @@
    -- cgit v1.2.3