mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
fix components order & add skeleton:get_matrix overload & add skeleton:reset_pose
This commit is contained in:
parent
8a9b4a9e9c
commit
8242d299ed
3 changed files with 29 additions and 8 deletions
|
|
@ -48,8 +48,9 @@ end
|
|||
local Skeleton = {__index={
|
||||
get_model=function(self, i) return __skeleton.get_model(self.eid, i) end,
|
||||
set_model=function(self, i, s) return __skeleton.set_model(self.eid, i, s) end,
|
||||
get_matrix=function(self, i) return __skeleton.get_matrix(self.eid, i) end,
|
||||
get_matrix=function(self, i, ...) return __skeleton.get_matrix(self.eid, i, ...) end,
|
||||
set_matrix=function(self, i, m) return __skeleton.set_matrix(self.eid, i, m) end,
|
||||
reset_pose=function(self) return __skeleton.reset_pose(self.eid) end,
|
||||
get_texture=function(self, s) return __skeleton.get_texture(self.eid, s) end,
|
||||
set_texture=function(self, s, s2) return __skeleton.set_texture(self.eid, s, s2) end,
|
||||
index=function(self, s) return __skeleton.index(self.eid, s) end,
|
||||
|
|
@ -84,7 +85,7 @@ local Entity = {__index={
|
|||
def_name=function(self) return entities.def_name(entities.get_def(self.eid)) end,
|
||||
get_player=function(self) return entities.get_player(self.eid) end,
|
||||
set_enabled=function(self, name, flag)
|
||||
local comp = self.components[name]
|
||||
local comp = self.components[name]
|
||||
if comp then
|
||||
if flag then
|
||||
if comp.__disabled and comp.on_enable then
|
||||
|
|
@ -110,6 +111,7 @@ return {
|
|||
entity.rigidbody = new_Rigidbody(eid)
|
||||
entity.skeleton = new_Skeleton(eid)
|
||||
entity.components = {}
|
||||
entity.ordered_components = {}
|
||||
entities[eid] = entity;
|
||||
return entity
|
||||
end,
|
||||
|
|
@ -120,6 +122,7 @@ return {
|
|||
local entity = entities[eid]
|
||||
if entity then
|
||||
entity.components = nil
|
||||
entity.ordered_components = nil
|
||||
entities[eid] = nil;
|
||||
end
|
||||
end,
|
||||
|
|
@ -128,10 +131,10 @@ return {
|
|||
if uid % parts ~= part then
|
||||
goto continue
|
||||
end
|
||||
for _, component in pairs(entity.components) do
|
||||
for _, component in ipairs(entity.ordered_components) do
|
||||
local callback = component.on_update
|
||||
if not component.__disabled and callback then
|
||||
local result, err = pcall(callback, tps)
|
||||
local _, err = pcall(callback, tps)
|
||||
if err then
|
||||
debug.error(err)
|
||||
end
|
||||
|
|
@ -142,7 +145,7 @@ return {
|
|||
end,
|
||||
physics_update = function(delta)
|
||||
for uid, entity in pairs(entities) do
|
||||
for _, component in pairs(entity.components) do
|
||||
for _, component in ipairs(entity.ordered_components) do
|
||||
local callback = component.on_physics_update
|
||||
if not component.__disabled and callback then
|
||||
local result, err = pcall(callback, delta)
|
||||
|
|
@ -155,10 +158,10 @@ return {
|
|||
end,
|
||||
render = function(delta)
|
||||
for _,entity in pairs(entities) do
|
||||
for _, component in pairs(entity.components) do
|
||||
for _, component in ipairs(entity.ordered_components) do
|
||||
local callback = component.on_render
|
||||
if not component.__disabled and callback then
|
||||
local result, err = pcall(callback, delta)
|
||||
local _, err = pcall(callback, delta)
|
||||
if err then
|
||||
debug.error(err)
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue