class SK::GameObject

Attributes

children[R]
components[R]
id[R]
manager[R]
name[R]
parent[RW]
transform[RW]

Public Class Methods

new(name, id) click to toggle source
# File lib/shirokuro/ecs/game_object.rb, line 7
def initialize name, id
        @name = name
        @id = id
        @components = []
        @children = []
        @parent = nil
        @transform = Transform.new
        @manager = nil
end

Public Instance Methods

add_child(game_object) click to toggle source
# File lib/shirokuro/ecs/game_object.rb, line 22
def add_child game_object
        if game_object.parent != nil
                game_object.parent.remove_child game_object
        end
        game_object.parent = self
        @children << game_object
end
add_component(component) click to toggle source
# File lib/shirokuro/ecs/game_object.rb, line 17
def add_component component
        component.game_object = self
        @components << component
end
get_component(type) click to toggle source
# File lib/shirokuro/ecs/game_object.rb, line 34
def get_component type
        @components.find{|x| x.is_a?(type)}
end
get_components(type) click to toggle source
# File lib/shirokuro/ecs/game_object.rb, line 38
def get_components type
        @components.collect{|x| x if x.is_a?(type)}
end
physics() click to toggle source
# File lib/shirokuro/ecs/game_object.rb, line 46
def physics
        @manager.physics
end
remove_child(game_object) click to toggle source
# File lib/shirokuro/ecs/game_object.rb, line 30
def remove_child game_object
        @children.delete game_object
end
remove_component(component) click to toggle source
# File lib/shirokuro/ecs/game_object.rb, line 42
def remove_component component
        @components.delete component
end
start() click to toggle source
# File lib/shirokuro/ecs/game_object.rb, line 50
def start
        @components.each{|x| x.start }
end
update(dt) click to toggle source
# File lib/shirokuro/ecs/game_object.rb, line 54
def update dt
        @components.each{|x| x.update dt }
end