Top Level Namespace
Defined in:
Macro Summary
-
accept_event(name)
Will generate event hook stubs for accepting the provided event.
-
accept_events(*names)
Wrapper for multiple
accept_event
calls - call_post_constructors
- component_event(contexts, comp, target, _type = EventType::Added, priority = 1)
- component_event_system(context, comp, target, _type = EventType::Added, priority = 1)
- create_controller(name, features)
- create_feature(name, systems)
- emit_event(event, *args)
-
emits_event(name)
Will generate event hook stubs for the provided event.
-
emits_events(*names)
Will generate event hook stubs for the provided events
-
generate_event_systems
Process EventSystem annotations :nodoc:
-
prop(var, kype, **kwargs)
Will create getter/setter for the provided
var
, ensuring its type - property_alias(var, kype, **kwargs)
Macro Detail
Will generate event hook stubs for accepting the provided event. Will create {{name.id.underscore.id}}_event_hooks
array and {{name.id.underscore.id}}(&block)
method which will append the block to the event hooks array.
The clear_{{name.id.underscore.id}}_event_hooks
method will clear all the hooks on the object
class Test
accept_event OnEntityCreated
def initialize
on_entity_created_event_hooks.size # => 0
on_entity_created do |event|
# do something with event
end
on_entity_created_event_hooks.size # => 1
clear_on_entity_created_event_hooks
on_entity_created_event_hooks.size # => 0
end
end
obj = Test.new
obj.on_entity_created(event) # => does something with event
Will generate event hook stubs for the provided event. Will create {{name.id.underscore.id}}_event_cache
getter/setter as well as {{name.id.underscore.id}}(event)
method.
class Test
emits_event OnEntityCreated
# override event methods
def on_entity_created(event : Entitas::Events::OnEntityCreated)
# do something with event
end
end
obj = Test.new
obj.on_entity_created(event) # => does something with event
Will generate event hook stubs for the provided events
class Test
emits_events OnEntityCreated, OnEntityDestroyed
# override event methods
def on_entity_created(event : Entitas::Events::OnEntityCreated)
# do something with event
end
end
obj = Test.new
obj.on_entity_created(event) # => does something with event
obj.on_entity_destroyed(event) # => raises Entitas::Error::MethodNotImplemented