diff options
author | chai <chaifix@163.com> | 2019-01-27 01:26:36 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2019-01-27 01:26:36 +0800 |
commit | 6c8788ed76e1ead173fdeb51caaa43d538fcfe21 (patch) | |
tree | 4ec71c3aca07d58d96574671f83f9750f901cb11 /Source/Asura.Framework/entity.lua | |
parent | 409262a6a26972770ba64728a60d45dd2d9fb752 (diff) |
*misc
Diffstat (limited to 'Source/Asura.Framework/entity.lua')
-rw-r--r-- | Source/Asura.Framework/entity.lua | 64 |
1 files changed, 57 insertions, 7 deletions
diff --git a/Source/Asura.Framework/entity.lua b/Source/Asura.Framework/entity.lua index ffd9b65..0edded4 100644 --- a/Source/Asura.Framework/entity.lua +++ b/Source/Asura.Framework/entity.lua @@ -1,27 +1,76 @@ -local Entity = AsuraEngine.Asset.SubClass("Entity") +--[[ +实体,作为scene中的实体存在。 +]] +require "transform" -function Entity:OnEnable() +local Entity = AsuraEngine.Asset.Sub("Entity") +AsuraEngine.Entity = Entity +function Entity:Ctor() + self.transform = AsuraEngine.Transform.New() end -function Entity:OnEvent(e) +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:OnUpdate(dt) +--根据组件类型拿到组件 +function Entity:GetComponentByType(tname) end -function Entity:OnRender() +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:OnDisable() +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() @@ -52,6 +101,7 @@ function Entity:SetRotation() end +--写asset function Entity:ToAsset() end |