This function trigger an event using the EnTT dispatcher.
All those functions are automatically generated based on shiva::event.
-- Global signatureshiva.dispatcher:trigger_[event_name]_event(evt_arg);-- Example of generated oneshiva.dispatcher:trigger_quit_game_event(evt_arg);
Parameters
Example
functionon_key_pressed(evt)if (evt.keycode == Keyboard.Escape) then-- quit_game.hpp take a integer as argument for his construction shiva.dispatcher:trigger_quit_game_event(1)endend
Entity Registry API Documentation
shiva.entity_registry:create
This function create an entity through the EnTT registry and return an unique identifier.
This function checks whether the requested component is associated with the given entity through the EnTT registry
All those functions are automatically generated based on the common components.
-- Global signatureshiva.entity_registry:has_[component_name]_component(entity_id);-- Example of generated oneshiva.entity_registry:has_layer_1_component(entity_id);
Parameters
Return value
Example
functionfoo()local entity_id = shiva.entity_registry:create()local component = shiva.entity_registry:add_layer_1_component(entity_id)local same_component = shiva.entity_registry:get_layer_1_component(entity_id)assert(shiva.entity_registry:has_layer_1_component(entity_id) ==true, "should be true") shiva.entity_registry:remove_layer_1_component(entity_id)assert(shiva.entity_registry:has_layer_1_component(entity_id) ==false, "should be false")end
This function takes an entity as a parameter and retrieves the component associated with it through the EnTT registry.
All those functions are automatically generated based on the common components.
-- Global signatureshiva.entity_registry:get_[component_name]_component(entity_id);-- Example of generated oneshiva.entity_registry:get_layer_1_component(entity_id);
Parameters
Return value
Example
functionfoo()local entity_id = shiva.entity_registry:create()local component = shiva.entity_registry:add_layer_1_component(entity_id)local same_component = shiva.entity_registry:get_layer_1_component(entity_id)assert(shiva.entity_registry:has_layer_1_component(entity_id) ==true, "should be true") shiva.entity_registry:remove_layer_1_component(entity_id)assert(shiva.entity_registry:has_layer_1_component(entity_id) ==false, "should be false")end
This function takes an entity as a parameter and remove the component associated with it through the EnTT registry.
All those functions are automatically generated based on the common components.
-- Global signatureshiva.entity_registry:remove_[component_name]_component(entity_id);-- Example of generated oneshiva.entity_registry:remove_layer_1_component(entity_id);
Parameters
Example
functionfoo()local entity_id = shiva.entity_registry:create()local component = shiva.entity_registry:add_layer_1_component(entity_id)local same_component = shiva.entity_registry:get_layer_1_component(entity_id)assert(shiva.entity_registry:has_layer_1_component(entity_id) ==true, "should be true") shiva.entity_registry:remove_layer_1_component(entity_id)assert(shiva.entity_registry:has_layer_1_component(entity_id) ==false, "should be false")end
This function takes an entity as a parameter and add the component through the EnTT registry, and return a reference to the component.
All those functions are automatically generated based on the common components.
-- Global signatureshiva.entity_registry:add_[component_name]_component(entity_id);-- Example of generated oneshiva.entity_registry:add_layer_1_component(entity_id);
Parameters
Return value
Example
functionfoo()local entity_id = shiva.entity_registry:create()local component = shiva.entity_registry:add_layer_1_component(entity_id)local same_component = shiva.entity_registry:get_layer_1_component(entity_id)assert(shiva.entity_registry:has_layer_1_component(entity_id) ==true, "should be true") shiva.entity_registry:remove_layer_1_component(entity_id)assert(shiva.entity_registry:has_layer_1_component(entity_id) ==false, "should be false")end