add entity 'on_render' event
This commit is contained in:
@@ -88,7 +88,7 @@ function on_trigger_exit(index, oid)
|
||||
end
|
||||
end
|
||||
|
||||
function on_update()
|
||||
function on_render()
|
||||
if inair then
|
||||
local dt = time.delta();
|
||||
|
||||
@@ -100,6 +100,9 @@ function on_update()
|
||||
mat4.scale(matrix, scale, matrix)
|
||||
rig:set_matrix(0, matrix)
|
||||
end
|
||||
end
|
||||
|
||||
function on_update()
|
||||
if target ~= -1 then
|
||||
local dir = vec3.sub({player.get_pos(target)}, tsf:get_pos())
|
||||
vec3.normalize(dir, dir)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user