Sha256: 45b82819249055b29b86f033635a90a6189c3869bccb94bbb3a9843128ba92a0

Contents?: true

Size: 791 Bytes

Versions: 3

Compression:

Stored size: 791 Bytes

Contents

require_relative 'system'

module Baku
  class ComponentSystem < System
    attr_reader :components
    
    def initialize(components, game_loop_step)
      @components = components
      @game_loop_step = game_loop_step
    end

    def register_world(world)
      super(world)

      world.entity_manager.register_component_mask(component_mask)
    end

    def process_entities(entities)
      entities.each do |entity|
        entity_components = @components.map { |c| entity.get_component(c) }
        process_entity(entity, *entity_components)
      end
    end

    def component_mask
      @component_mask ||= ComponentMask.from_components(@components)
    end
    
    protected

    def retrieve_entities
      @world.entity_manager.get_entities(component_mask)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
baku-0.3.1 lib/baku/component_system.rb
baku-1.0.0 lib/baku/component_system.rb
baku-0.3.0 lib/baku/component_system.rb