class Entity

Public Class Methods

new() click to toggle source
# File lib/delve/entity.rb, line 2
def initialize
  @components = Hash.new
end

Public Instance Methods

act() click to toggle source
# File lib/delve/entity.rb, line 20
def act
  get(:actor).act if has?(:actor)
end
add(component) click to toggle source
# File lib/delve/entity.rb, line 10
def add(component)
  raise 'Cannot add the same component more than once' if has?(component.id)
  @components[component.id] = component
end
get(component_id) click to toggle source
# File lib/delve/entity.rb, line 15
def get(component_id)
  return nil unless has?(component_id)
  @components[component_id]
end
has?(component_id) click to toggle source
# File lib/delve/entity.rb, line 6
def has?(component_id)
  @components.keys.include? component_id
end