Method: Baku::World#add_system

Defined in:
lib/baku/world.rb

#add_system(system) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/baku/world.rb', line 23

def add_system(system)
  system_list = 
    if system.game_loop_step == :update
      @update_systems
    elsif system.game_loop_step == :draw
      @draw_systems
    end

  if system_list.map(&:class).include?(system.class)
    raise StandardError.new("Already added #{system.class} system to world.")
  end
  
  system_list << system

  @entity_manager.register_component_mask(system.component_mask)
  
  system.world = self
end