Class: BeltsEngine::Ecs::SystemManager

Inherits:
Object
  • Object
show all
Defined in:
lib/belts_engine/ecs/system_manager.rb

Instance Method Summary collapse

Constructor Details

#initialize(game) ⇒ SystemManager

Returns a new instance of SystemManager.



3
4
5
6
7
8
# File 'lib/belts_engine/ecs/system_manager.rb', line 3

def initialize(game)
  @game = game
  @systems = []

  register_app_systems
end

Instance Method Details

#register_system(klass) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/belts_engine/ecs/system_manager.rb', line 14

def register_system(klass)
  @systems << klass.new(@game) # TODO: Avoid duplicates

  klass.collection_keys.each do |key|
    @game.collections.register(**key)
  end
end

#updateObject



10
11
12
# File 'lib/belts_engine/ecs/system_manager.rb', line 10

def update
  @systems.each(&:update)
end