From 3104eaf4ca0515572aeedc114cb6095a07825d90 Mon Sep 17 00:00:00 2001 From: _Tradam Date: Thu, 30 Dec 2021 07:33:27 -0500 Subject: Revert "Major 4.0 update (#12)" This reverts commit 5ef652300e71b572ca58b061610d606840ce19a9. --- docs/FelFlame/ComponentManager.html | 569 +++++++++++++++++++++++++++--------- 1 file changed, 432 insertions(+), 137 deletions(-) (limited to 'docs/FelFlame/ComponentManager.html') diff --git a/docs/FelFlame/ComponentManager.html b/docs/FelFlame/ComponentManager.html index 599b547..1da6816 100644 --- a/docs/FelFlame/ComponentManager.html +++ b/docs/FelFlame/ComponentManager.html @@ -37,7 +37,7 @@ + +
+

+ + #idInteger + + + + + +

+
+ +

Holds the unique ID of a component. The ID is only unique within the scope of the component manager it was created from.

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Integer) + + + +
  • + +
+ +
+ + + + +
+
+
+
+63
+64
+65
+
+
# File 'lib/felflame/component_manager.rb', line 63
+
+def id
+  @id
+end
+
+
+ +

@@ -899,12 +1051,12 @@
 
 
-94
-95
-96
+89 +90 +91 -
# File 'lib/felflame/component_manager.rb', line 94
+      
# File 'lib/felflame/component_manager.rb', line 89
 
 def removal_triggers
   @removal_triggers ||= []
@@ -917,6 +1069,149 @@
   

+
+

Class Method Details

+ + +
+

+ + .[](component_id) ⇒ Component + + + + + +

+
+ +

Gets a Component from the given unique ID. Usage is simular to how an Array lookup works.

+ + +
+
+
+ +
+

Examples:

+ + +
# this gets the 'Health' Component with ID 7
+FelFlame::Components::Health[7]
+ +
+

Parameters:

+
    + +
  • + + component_id + + + (Integer) + + + +
  • + +
+ +

Returns:

+
    + +
  • + + + (Component) + + + + — +
    +

    Returns the Component that uses the given unique ID, nil if there is no Component associated with the given ID

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+169
+170
+171
+
+
# File 'lib/felflame/component_manager.rb', line 169
+
+def [](component_id)
+  data[component_id]
+end
+
+
+ +
+

+ + .each(&block) ⇒ Enumerator + + + + + +

+
+ +

Iterates over all components within the component manager. Special Enumerable methods like map or each_with_index are not implemented

+ + +
+
+
+ +

Returns:

+
    + +
  • + + + (Enumerator) + + + +
  • + +
+ +
+ + + + +
+
+
+
+176
+177
+178
+
+
# File 'lib/felflame/component_manager.rb', line 176
+
+def each(&block)
+  data.compact.each(&block)
+end
+
+
+ +
+

Instance Method Details

@@ -965,18 +1260,18 @@
 
 
-213
-214
-215
-216
-217
-218
-219
-220
-221
+203 +204 +205 +206 +207 +208 +209 +210 +211 -
# File 'lib/felflame/component_manager.rb', line 213
+      
# File 'lib/felflame/component_manager.rb', line 203
 
 def attr_changed_trigger_systems(attr)
   systems_to_execute = self.class.attr_triggers[attr]
@@ -984,7 +1279,7 @@
 
   systems_to_execute |= attr_triggers[attr] unless attr_triggers[attr].nil?
 
-  systems_to_execute.sort_by(&:priority).reverse_each(&:call)
+  systems_to_execute.sort_by(&:priority).reverse.each(&:call)
   true
 end
@@ -993,9 +1288,9 @@
-

+

- #deleteBoolean + #attrsHash<Symbol, Value> @@ -1004,7 +1299,7 @@

-

Removes this component from the list and purges all references to this Component from other Entities, as well as its data.

+

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

@@ -1017,13 +1312,13 @@
  • - (Boolean) + (Hash<Symbol, Value>)
    -

    true.

    +

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

  • @@ -1036,35 +1331,23 @@
     
     
    -224
    -225
    -226
    -227
    -228
    -229
    -230
    -231
    -232
    -233
    -234
     235
    -236
    +236 +237 +238 +239 +240 +241 -
    # File 'lib/felflame/component_manager.rb', line 224
    +      
    # File 'lib/felflame/component_manager.rb', line 235
     
    -def delete
    -  addition_triggers.each do |system|
    -    system.clear_triggers component_or_manager: self
    -  end
    -  entities.reverse_each do |entity|
    -    entity.remove self
    -  end
    -  self.class._data.delete self
    -  instance_variables.each do |var|
    -    instance_variable_set(var, nil)
    +def attrs
    +  return_hash = instance_variables.each_with_object({}) do |key, final|
    +    final[key.to_s.delete_prefix('@').to_sym] = instance_variable_get(key)
       end
    -  true
    +  return_hash.delete(:attr_triggers)
    +  return_hash
     end
    @@ -1072,9 +1355,9 @@
    -

    +

    - #entitiesArray<Component> + #deleteBoolean @@ -1083,7 +1366,7 @@

    -

    Entities that have this component

    +

    Removes this component from the list and purges all references to this Component from other Entities, as well as its ID and data.

    @@ -1096,10 +1379,15 @@
  • - (Array<Component>) + (Boolean) + — +
    +

    true.

    +
    +
  • @@ -1110,15 +1398,45 @@
     
     
    -188
    -189
    -190
    +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 -
    # File 'lib/felflame/component_manager.rb', line 188
    +      
    # File 'lib/felflame/component_manager.rb', line 215
     
    -def entities
    -  @entities ||= []
    +def delete
    +  addition_triggers.each do |system|
    +    system.clear_triggers component_or_manager: self
    +  end
    +  # This needs to be cloned because indices get deleted as
    +  # the remove command is called, breaking the loop if it
    +  # wasn't referencing a clone(will get Nil errors)
    +  iter = entities.map(&:clone)
    +  iter.each do |entity|
    +    #FelFlame::Entities[entity_id].remove self #unless FelFlame::Entities[entity_id].nil?
    +    entity.remove self
    +  end
    +  self.class.data[id] = nil
    +  instance_variables.each do |var|
    +    instance_variable_set(var, nil)
    +  end
    +  true
     end
    @@ -1126,9 +1444,9 @@
    -

    +

    - #entityComponent + #entitiesArray<Integer> @@ -1137,7 +1455,7 @@

    -

    A single entity. Use this if you expect the component to only belong to one entity and you want to access it.

    +

    A list of entity ids that are linked to the component

    @@ -1150,7 +1468,7 @@
  • - (Component) + (Array<Integer>) @@ -1164,25 +1482,15 @@
     
     
    -194
    -195
    -196
    -197
    -198
    -199
    -200
    -201
    +189 +190 +191 -
    # File 'lib/felflame/component_manager.rb', line 194
    +      
    # File 'lib/felflame/component_manager.rb', line 189
     
    -def entity
    -  if entities.empty?
    -    Warning.warn("This component belongs to NO entities but you called the method that is intended for components belonging to a single entity.\nYou may have a bug in your logic.")
    -  elsif entities.length > 1
    -    Warning.warn("This component belongs to MANY entities but you called the method that is intended for components belonging to a single entity.\nYou may have a bug in your logic.")
    -  end
    -  entities.first
    +def entities
    +  @entities ||= []
     end
    @@ -1190,9 +1498,9 @@
  • -

    +

    - #to_hHash<Symbol, Value> + #to_iInteger @@ -1201,7 +1509,7 @@

    -

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

    +

    An alias for the ID Reader

    @@ -1214,14 +1522,9 @@
  • - (Hash<Symbol, Value>) - + (Integer) - — -
    -

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

    -
  • @@ -1233,23 +1536,15 @@
     
     
    -239
    -240
    -241
    -242
    -243
    -244
    -245
    +183 +184 +185 -
    # File 'lib/felflame/component_manager.rb', line 239
    +      
    # File 'lib/felflame/component_manager.rb', line 183
     
    -def to_h
    -  return_hash = instance_variables.each_with_object({}) do |key, final|
    -    final[key.to_s.delete_prefix('@').to_sym] = instance_variable_get(key)
    -  end
    -  return_hash.delete(:attr_triggers)
    -  return_hash
    +def to_i
    +  id
     end
    @@ -1300,14 +1595,14 @@
     
     
    -205
    -206
    -207
    -208
    -209
    +195 +196 +197 +198 +199
    -
    # File 'lib/felflame/component_manager.rb', line 205
    +      
    # File 'lib/felflame/component_manager.rb', line 195
     
     def update_attrs(**opts)
       opts.each do |key, value|
    @@ -1324,7 +1619,7 @@
     
    -- cgit v1.2.3