From daea6c2d2aa595abff590e73d7b34e338df705cf Mon Sep 17 00:00:00 2001 From: _Tradam Date: Thu, 30 Dec 2021 07:36:01 -0500 Subject: Major 4.0 Update (#14) Check the changelog --- docs/FelFlame/ComponentManager.html | 569 +++++++++--------------------------- 1 file changed, 137 insertions(+), 432 deletions(-) (limited to 'docs/FelFlame/ComponentManager.html') diff --git a/docs/FelFlame/ComponentManager.html b/docs/FelFlame/ComponentManager.html index 95c9fe4..599b547 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
-
-
- -

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

-
-

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

@@ -1260,18 +965,18 @@
 
 
-203
-204
-205
-206
-207
-208
-209
-210
-211
+213 +214 +215 +216 +217 +218 +219 +220 +221 -
# File 'lib/felflame/component_manager.rb', line 203
+      
# File 'lib/felflame/component_manager.rb', line 213
 
 def attr_changed_trigger_systems(attr)
   systems_to_execute = self.class.attr_triggers[attr]
@@ -1279,7 +984,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
@@ -1288,9 +993,9 @@
-

+

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

-

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

+

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

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

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

    +

    true.

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

    +

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

    -

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

    +

    Entities that have this component

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

    true.

    -
    -
  • @@ -1398,45 +1110,15 @@
     
     
    -215
    -216
    -217
    -218
    -219
    -220
    -221
    -222
    -223
    -224
    -225
    -226
    -227
    -228
    -229
    -230
    -231
    -232
    +188 +189 +190 -
    # File 'lib/felflame/component_manager.rb', line 215
    +      
    # File 'lib/felflame/component_manager.rb', line 188
     
    -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
    +def entities
    +  @entities ||= []
     end
    @@ -1444,9 +1126,9 @@
    -

    +

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

    -

    A list of entity ids that are linked to the component

    +

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

    @@ -1468,7 +1150,7 @@
  • - (Array<Integer>) + (Component) @@ -1482,15 +1164,25 @@
     
     
    -189
    -190
    -191
    +194 +195 +196 +197 +198 +199 +200 +201 -
    # File 'lib/felflame/component_manager.rb', line 189
    +      
    # File 'lib/felflame/component_manager.rb', line 194
     
    -def entities
    -  @entities ||= []
    +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
     end
    @@ -1498,9 +1190,9 @@
  • -

    +

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

    -

    An alias for the ID Reader

    +

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

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

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

    +
  • @@ -1536,15 +1233,23 @@
     
     
    -183
    -184
    -185
    +239 +240 +241 +242 +243 +244 +245 -
    # File 'lib/felflame/component_manager.rb', line 183
    +      
    # File 'lib/felflame/component_manager.rb', line 239
     
    -def to_i
    -  id
    +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
     end
    @@ -1595,14 +1300,14 @@
     
     
    -195
    -196
    -197
    -198
    -199
    +205 +206 +207 +208 +209
    -
    # File 'lib/felflame/component_manager.rb', line 195
    +      
    # File 'lib/felflame/component_manager.rb', line 205
     
     def update_attrs(**opts)
       opts.each do |key, value|
    @@ -1619,7 +1324,7 @@
     
    -- cgit v1.2.3