summaryrefslogtreecommitdiffhomepage
path: root/app/ECS/component_manager.rb
blob: b07cf7928094876f715f5f03e2188e4f87aabc9b (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