From ba707eebb995eb46141d3c5e1701cd7252ba81c8 Mon Sep 17 00:00:00 2001 From: realtradam Date: Wed, 16 Jun 2021 07:09:43 -0400 Subject: entities, components, and systems improved --- docs/FelFlame/Entities.html | 82 +++++++++++++++++++++------------------------ 1 file changed, 38 insertions(+), 44 deletions(-) (limited to 'docs/FelFlame/Entities.html') diff --git a/docs/FelFlame/Entities.html b/docs/FelFlame/Entities.html index 7669d53..e91c2c0 100644 --- a/docs/FelFlame/Entities.html +++ b/docs/FelFlame/Entities.html @@ -643,12 +643,12 @@
 
 
-104
-105
-106
+113 +114 +115 -
# File 'entity_manager.rb', line 104
+      
# File 'entity_manager.rb', line 113
 
 def [](entity_id)
   data[entity_id]
@@ -670,7 +670,7 @@
 
-

Iterates over all entities. In general when using ECS the use of this method should never be neccassary unless you are doing something very wrong, however I will not stop you. You also call other enumerable methods instead of each, such as each_with_index or select

+

Iterates over all entities. The data is compacted so that means index does not correlate to ID. You also call other enumerable methods instead of each, such as each_with_index or select

@@ -697,15 +697,15 @@
 
 
-111
-112
-113
+120 +121 +122
-
# File 'entity_manager.rb', line 111
+      
# File 'entity_manager.rb', line 120
 
 def each(&block)
-  data.each(&block)
+  data.compact.each(&block)
 end
@@ -774,10 +774,10 @@
 
 
-119
+128
-
# File 'entity_manager.rb', line 119
+      
# File 'entity_manager.rb', line 128
 
 def from_json(json_string, **opts) end
@@ -814,7 +814,7 @@
  • - component + components_to_add (Component) @@ -855,7 +855,6 @@
     
     
    -54
     55
     56
     57
    @@ -868,26 +867,23 @@
     64
     65
     66
    -67
    -68
    +67
  • -
    # File 'entity_manager.rb', line 54
    +      
    # File 'entity_manager.rb', line 55
     
     def add(*components_to_add)
    -  added = false
       components_to_add.each do |component|
         if components[component.class].nil?
           components[component.class] = [component.id]
           component.entities.push id
    -      added =true
    +      check_systems component, :addition_triggers
         elsif !components[component.class].include? component.id
           components[component.class].push component.id
           component.entities.push id
    -      added = true
    +      check_systems component, :addition_triggers
         end
       end
    -  added
     end
    @@ -1002,7 +998,8 @@ 46 47 48 -49
    +49 +50
    # File 'entity_manager.rb', line 39
    @@ -1011,11 +1008,12 @@
       components.each do |component_manager, component_array|
         component_array.each do |component_id|
           component_manager[component_id].entities.delete(id)
    -    end
    +      #self.remove FelFlame::Components.const_get(component_manager.name)[component_id]
    +    end
       end
       FelFlame::Entities.data[id] = nil
    +  @components = {}
       @id = nil
    -  @components = nil
       true
     end
    @@ -1046,7 +1044,7 @@
  • - component_to_remove + components_to_remove (Component) @@ -1087,29 +1085,25 @@
     
     
    -73
    -74
    -75
    -76
    -77
    -78
    -79
    -80
    -81
    -82
    +84 +85 +86 +87 +88 +89 +90 +91 -
    # File 'entity_manager.rb', line 73
    +      
    # File 'entity_manager.rb', line 84
     
     def remove(*components_to_remove)
    -  removed = false
       components_to_remove.each do |component|
    +    check_systems component, :removal_triggers if component.entities.include? id
    +    component.entities.delete id
         components[component.class].delete component.id
    -    if component.entities.delete id
    -      removed = true
    -    end
       end
    -  removed
    +  true
     end
    @@ -1214,10 +1208,10 @@
     
     
    -87
    +96
    -
    # File 'entity_manager.rb', line 87
    +      
    # File 'entity_manager.rb', line 96
     
     def to_json() end
    @@ -1230,7 +1224,7 @@ -- cgit v1.2.3