summaryrefslogtreecommitdiffhomepage
path: root/app/ECS/component_manager.rb
blob: 7c05bd5d12c45024a53da4ab80fa2d3bb84f8b66 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#require 'app/ECS/base_component.rb'

#require 'app/ECS/components/00_test_component.rb'
#require 'app/ECS/components/01_based.rb'

class ECS
  class Components
    class <<self
      def entity_destroyed(entity_id)
        constants.each do |component|
          component.delete(entity_id) unless (component.id & ECS::Entity.signatures[entity_id]).zero?
        end
      end

      def entity_created(entity_id)
        constants.each do |component|
          const_get(component.to_s).add(entity_id) unless (const_get(component.to_s).id & ECS::Entity.signatures[entity_id]).zero?
        end
      end
    end
  end
end