Method: FelFlame::Entities#component
- Defined in:
- lib/felflame/entity_manager.rb
#component(manager = nil) ⇒ Component
A single component from a component manager. Use this if you expect the component to only belong to one entity and you want to access it. Access the component using either parameter notation or array notation. Array notation is conventional for better readablility.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/felflame/entity_manager.rb', line 26 def component(manager = nil) if manager.nil? FelFlame::Entities.component_redirect.entity = self FelFlame::Entities.component_redirect else if components[manager].nil? raise "This entity(#{self}) doesnt have any components of this type: #{manager}" elsif components[manager].length > 1 Warning.warn("This entity has MANY of this component but you called the method that is intended for having a single of this component type.\nYou may have a bug in your logic.") end components[manager].first end end |