mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-06 11:31:49 +00:00
add entity 'on_render' event
This commit is contained in:
parent
d099b294a2
commit
0d230f2449
5 changed files with 32 additions and 8 deletions
|
|
@ -68,7 +68,7 @@ return {
|
|||
end
|
||||
end,
|
||||
update = function()
|
||||
for id,entity in pairs(entities) do
|
||||
for _,entity in pairs(entities) do
|
||||
for _, component in pairs(entity.components) do
|
||||
local callback = component.on_update
|
||||
if callback then
|
||||
|
|
@ -80,5 +80,19 @@ return {
|
|||
end
|
||||
end
|
||||
end
|
||||
end,
|
||||
render = function()
|
||||
for _,entity in pairs(entities) do
|
||||
for _, component in pairs(entity.components) do
|
||||
local callback = component.on_render
|
||||
if callback then
|
||||
local result, err = pcall(callback)
|
||||
if err then
|
||||
--// TODO: replace with error logging
|
||||
print(err)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue