Class: Entity

Inherits:
Object
  • Object
show all
Defined in:
lib/delve/entity.rb

Instance Method Summary collapse

Constructor Details

#initializeEntity

Returns a new instance of Entity.



2
3
4
# File 'lib/delve/entity.rb', line 2

def initialize
  @components = Hash.new
end

Instance Method Details

#actObject



20
21
22
# File 'lib/delve/entity.rb', line 20

def act
  get(:actor).act if has?(:actor)
end

#add(component) ⇒ Object



10
11
12
13
# 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) ⇒ Object



15
16
17
18
# File 'lib/delve/entity.rb', line 15

def get(component_id)
  return nil unless has?(component_id)
  @components[component_id]
end

#has?(component_id) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/delve/entity.rb', line 6

def has?(component_id)
  @components.keys.include? component_id
end