add entity:get_component(...)

This commit is contained in:
MihailRis 2024-07-04 20:54:45 +03:00
parent 8f379f2ee7
commit 019a88ef84
2 changed files with 6 additions and 5 deletions

View File

@ -18,6 +18,7 @@ function on_hud_open()
id=itemid,
count=1
}})
drop.rigidbody:set_vel(vec3.add(throw_force, vec3.add(pvel, DROP_INIT_VEL)))
local velocity = vec3.add(throw_force, vec3.add(pvel, DROP_INIT_VEL))
drop.get_component("rigidbody"):set_vel(velocity)
end)
end

View File

@ -9,7 +9,7 @@ local Transform = {__index={
set_rot=function(self, m) return __transform.set_rot(self.eid, m) end,
}}
function new_Transform(eid)
local function new_Transform(eid)
return setmetatable({eid=eid}, Transform)
end
@ -22,7 +22,7 @@ local Rigidbody = {__index={
set_size=function(self, v) return __rigidbody.set_size(self.eid, v) end,
}}
function new_Rigidbody(eid)
local function new_Rigidbody(eid)
return setmetatable({eid=eid}, Rigidbody)
end
@ -33,7 +33,7 @@ local Modeltree = {__index={
set_texture=function(self, s, s2) return __modeltree.set_texture(self.eid, s, s2) end,
}}
function new_Modeltree(eid)
local function new_Modeltree(eid)
return setmetatable({eid=eid}, Modeltree)
end
@ -42,6 +42,7 @@ end
local Entity = {__index={
despawn=function(self) return entities.despawn(self.eid) end,
set_rig=function(self, s) return entities.set_rig(self.eid, s) end,
get_component=function(self, name) return self.components[name] end,
}}
local entities = {}
@ -52,7 +53,6 @@ return {
entity.transform = new_Transform(eid)
entity.rigidbody = new_Rigidbody(eid)
entity.modeltree = new_Modeltree(eid)
entity.data = {}
entity.components = {}
entities[eid] = entity;
return entity