Registry
TODO:
Functions
Runtime View Runtime views iterate over all of the entities that have all the given components that are passed into the function.
Function | Description |
---|---|
for_each(sol::function) | This function will iterate over all of the entities that are in the runtime_view. It takes in a sol::function as a callback. The callback takes in the current entity so the user can perform actions on that entity. |
exclude(sol::variadic_args) | The exclude function takes in a variable amount of args from the lua script. The arguments that are to be the desired components that we want to exclude from the runtime view. This should be done upon creation of the runtime view before using the for_each(...) function. |
Registry
Function | Description |
---|---|
get_entities(sol::variadic_args) | The get_entities function takes in a variable amount of arguments. The arguments are to be the components that we want the entities to have. This will return a runtime_view of all the entities that have all of the entered components. |
clear() | Clears the entire registry of the entities and the components. |
Example
-- Get all the entities that have a Transform and Sprite Component
-- Exclude entities with UI Components
local view = Registry.get_entities(Transform, Sprite).exclude(UIComponent)
-- Loop through the view and hide all of the sprites
view:for_each(
-- The for_each function takes in a callback function
function (entity)
local sprite = entity:get_component(Sprite)
sprite.bHidden = true
end
)