Class: Engine::Component
Direct Known Subclasses
Engine::Components::AudioSource, Engine::Components::DirectionLight, Engine::Components::FontRendererBase, Engine::Components::MeshRenderer, Engine::Components::OrthographicCamera, Engine::Components::PerspectiveCamera, Engine::Components::PointLight, Engine::Components::SpotLight, Engine::Components::SpriteAnimator, Engine::Components::SpriteRenderer, Engine::Components::UI::Flex, Engine::Components::UI::Rect, Engine::Components::UI::SpriteClickbox, Engine::Components::UI::SpriteRenderer, Physics::Components::CubeCollider, Physics::Components::Rigidbody, Physics::Components::SphereCollider
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
allowed_class?, #awake, get_class, included, register_class, #uuid
Instance Attribute Details
#game_object ⇒ Object
Returns the value of attribute game_object.
11
12
13
|
# File 'lib/engine/component.rb', line 11
def game_object
@game_object
end
|
Class Method Details
.destroyed_components ⇒ Object
61
62
63
|
# File 'lib/engine/component.rb', line 61
def self.destroyed_components
@destroyed_components ||= []
end
|
.erase_destroyed_components ⇒ Object
51
52
53
54
55
56
|
# File 'lib/engine/component.rb', line 51
def self.erase_destroyed_components
destroyed_components.each do |object|
object._erase!
end
@destroyed_components = []
end
|
.method_added(name) ⇒ Object
5
6
7
8
9
|
# File 'lib/engine/component.rb', line 5
def self.method_added(name)
@methods ||= Set.new
return if name == :initialize || name == :destroyed?
@methods.add(name)
end
|
Instance Method Details
#_erase! ⇒ Object
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/engine/component.rb', line 40
def _erase!
game_object.components.delete(self)
class_name = self.class.name.split('::').last
self.class.instance_variable_get(:@methods).each do |method|
singleton_class.send(:undef_method, method)
singleton_class.send(:define_method, method) do |*args, **kwargs|
raise "This #{class_name} has been destroyed but you are still trying to access #{method}"
end
end
end
|
#destroy ⇒ Object
58
59
|
# File 'lib/engine/component.rb', line 58
def destroy
end
|
#destroy! ⇒ Object
34
35
36
37
38
|
# File 'lib/engine/component.rb', line 34
def destroy!
Component.destroyed_components << self unless @destroyed
destroy unless @destroyed
@destroyed = true
end
|
#destroyed? ⇒ Boolean
30
31
32
|
# File 'lib/engine/component.rb', line 30
def destroyed?
@destroyed || false
end
|
#renderer? ⇒ Boolean
13
14
15
|
# File 'lib/engine/component.rb', line 13
def renderer?
false
end
|
#set_game_object(game_object) ⇒ Object
21
22
23
|
# File 'lib/engine/component.rb', line 21
def set_game_object(game_object)
@game_object = game_object
end
|
#start ⇒ Object
25
26
|
# File 'lib/engine/component.rb', line 25
def start
end
|
#ui_renderer? ⇒ Boolean
17
18
19
|
# File 'lib/engine/component.rb', line 17
def ui_renderer?
false
end
|
#update(delta_time) ⇒ Object
28
|
# File 'lib/engine/component.rb', line 28
def update(delta_time) end
|