--[[ 实体,作为scene中的实体存在。 ]] require "transform" local Entity = AsuraEngine.Asset.Sub("Entity") AsuraEngine.Entity = Entity function Entity:Ctor() self.transform = AsuraEngine.Transform.New() end function Entity:AddComponent(type, name) local cname = type if name == nil then cname = name end local component = AsuraEngine.Component.GetComponent(type) self.components[cname] = compoennt end --根据组件名拿到组件 function Entity:GetComponent(name) return self.components[name] end --根据组件类型拿到组件 function Entity:GetComponentByType(tname) end function Entity:OnEnable() end function Entity:OnEvent(e) if self.components == nil or type(self.components) ~= "table" then AsuraEditor.LogError("") return end for name, component in self.components do if component.OnEvent ~= nil then component:OnEvent(e) end end end function Entity:OnUpdate(dt) for name, component in self.components do if component.OnUpdate ~= nil then component:OnUpdate(dt) end end end function Entity:OnRender() for name, component in self.components do if component.OnRender ~= nil then component.OnRender() end end end function Entity:OnDisable() for name, component in self.components do if component.OnDisable ~= nil then component.OnDisable() end end end function Entity:GetTrasform() return self.transform end function Entity:GetPosition() end function Entity:GetScale() end function Entity:GetRotation() end function Entity:SetTrasform(transform) end function Entity:SetPosition() end function Entity:SetScale() end function Entity:SetRotation() end --写asset function Entity:ToAsset() end return Entity