summaryrefslogtreecommitdiffhomepage
path: root/lib/felflame/entity_manager.rb
diff options
context:
space:
mode:
authorrealtradam <[email protected]>2021-07-10 03:09:36 -0400
committerrealtradam <[email protected]>2021-07-10 03:09:36 -0400
commitaab35c0f098d695b7cf53c14a8b08a9b4a24550d (patch)
tree84dd6b9b5787fce8f1bab84761c80818fea783d7 /lib/felflame/entity_manager.rb
parentfea1879f371d5c6d68439b9ab9c64d9a61d92d1c (diff)
downloadFelECS-2.0.0.tar.gz
FelECS-2.0.0.zip
entities and components now reference each other with objects2.0.0
Diffstat (limited to 'lib/felflame/entity_manager.rb')
-rw-r--r--lib/felflame/entity_manager.rb21
1 files changed, 10 insertions, 11 deletions
diff --git a/lib/felflame/entity_manager.rb b/lib/felflame/entity_manager.rb
index 74fc4c3..a05ef93 100644
--- a/lib/felflame/entity_manager.rb
+++ b/lib/felflame/entity_manager.rb
@@ -41,9 +41,8 @@ class FelFlame
# @return [Boolean] +true+
def delete
components.each do |component_manager, component_array|
- component_array.each do |component_id|
- component_manager[component_id].entities.delete(id)
- #self.remove FelFlame::Components.const_get(component_manager.name)[component_id]
+ component_array.each do |component|
+ component.entities.delete(self)
end
end
FelFlame::Entities.data[id] = nil
@@ -58,12 +57,12 @@ class FelFlame
def add(*components_to_add)
components_to_add.each do |component|
if components[component.class].nil?
- components[component.class] = [component.id]
- component.entities.push id
+ components[component.class] = [component]
+ component.entities.push self
check_systems component, :addition_triggers
- elsif !components[component.class].include? component.id
- components[component.class].push component.id
- component.entities.push id
+ elsif !components[component.class].include? component
+ components[component.class].push component
+ component.entities.push self
check_systems component, :addition_triggers
end
end
@@ -87,9 +86,9 @@ class FelFlame
# @return [Boolean] +true+
def remove(*components_to_remove)
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
+ check_systems component, :removal_triggers if component.entities.include? self
+ component.entities.delete self
+ components[component.class].delete component
end
true
end