summaryrefslogtreecommitdiff
path: root/Source/Asura.Framework
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2019-01-27 01:26:36 +0800
committerchai <chaifix@163.com>2019-01-27 01:26:36 +0800
commit6c8788ed76e1ead173fdeb51caaa43d538fcfe21 (patch)
tree4ec71c3aca07d58d96574671f83f9750f901cb11 /Source/Asura.Framework
parent409262a6a26972770ba64728a60d45dd2d9fb752 (diff)
*misc
Diffstat (limited to 'Source/Asura.Framework')
-rw-r--r--Source/Asura.Framework/AI/StateMachine.lua3
-rw-r--r--Source/Asura.Framework/Audio/SoundPlayer.lua4
-rw-r--r--Source/Asura.Framework/Class.lua3
-rw-r--r--Source/Asura.Framework/Component.lua12
-rw-r--r--Source/Asura.Framework/Filesystem/Loader.lua19
-rw-r--r--Source/Asura.Framework/Filesystem/animation_loader.lua13
-rw-r--r--Source/Asura.Framework/Filesystem/material_loader.lua11
-rw-r--r--Source/Asura.Framework/Filesystem/path_loader.lua11
-rw-r--r--Source/Asura.Framework/Filesystem/scene_loader.lua5
-rw-r--r--Source/Asura.Framework/Framework.lua2
-rw-r--r--Source/Asura.Framework/Game.lua1
-rw-r--r--Source/Asura.Framework/Scene.lua11
-rw-r--r--Source/Asura.Framework/Transform.lua8
-rw-r--r--Source/Asura.Framework/ai/behavior_tree.lua (renamed from Source/Asura.Framework/Object.lua)0
-rw-r--r--Source/Asura.Framework/ai/state_machine.lua6
-rw-r--r--Source/Asura.Framework/ai/state_map.lua12
-rw-r--r--Source/Asura.Framework/ai/statemachine.lua3
-rw-r--r--Source/Asura.Framework/audio/soundplayer.lua4
-rw-r--r--Source/Asura.Framework/class.lua3
-rw-r--r--Source/Asura.Framework/component.lua12
-rw-r--r--Source/Asura.Framework/entity.lua64
-rw-r--r--Source/Asura.Framework/filesystem/animation_loader.lua13
-rw-r--r--Source/Asura.Framework/filesystem/entity_loader.lua5
-rw-r--r--Source/Asura.Framework/filesystem/loader.lua19
-rw-r--r--Source/Asura.Framework/filesystem/material_loader.lua11
-rw-r--r--Source/Asura.Framework/filesystem/path_loader.lua11
-rw-r--r--Source/Asura.Framework/filesystem/scene_loader.lua5
-rw-r--r--Source/Asura.Framework/filesystem/statemap_loader.lua7
-rw-r--r--Source/Asura.Framework/framework.lua2
-rw-r--r--Source/Asura.Framework/game.lua1
-rw-r--r--Source/Asura.Framework/object.lua0
-rw-r--r--Source/Asura.Framework/scene.lua11
-rw-r--r--Source/Asura.Framework/transform.lua8
33 files changed, 216 insertions, 84 deletions
diff --git a/Source/Asura.Framework/AI/StateMachine.lua b/Source/Asura.Framework/AI/StateMachine.lua
deleted file mode 100644
index 58012ca..0000000
--- a/Source/Asura.Framework/AI/StateMachine.lua
+++ /dev/null
@@ -1,3 +0,0 @@
-local StateMachine = Class()
-
-return StateMachine \ No newline at end of file
diff --git a/Source/Asura.Framework/Audio/SoundPlayer.lua b/Source/Asura.Framework/Audio/SoundPlayer.lua
index 8bbeddb..c3921af 100644
--- a/Source/Asura.Framework/Audio/SoundPlayer.lua
+++ b/Source/Asura.Framework/Audio/SoundPlayer.lua
@@ -1,3 +1,5 @@
-local SoundPlayer = AsuraEngine.Component.New("SoundPlayer")
+local SoundPlayer = AsuraEngine.Component.Sub("SoundPlayer")
+
+
return SoundPlayer \ No newline at end of file
diff --git a/Source/Asura.Framework/Class.lua b/Source/Asura.Framework/Class.lua
index bec3e9a..164cb4a 100644
--- a/Source/Asura.Framework/Class.lua
+++ b/Source/Asura.Framework/Class.lua
@@ -1,5 +1,4 @@
local Class = {}
+AsuraEngine.Class = Class
-
-AsuraEngine.Class = Class \ No newline at end of file
diff --git a/Source/Asura.Framework/Component.lua b/Source/Asura.Framework/Component.lua
index dd843eb..b498a36 100644
--- a/Source/Asura.Framework/Component.lua
+++ b/Source/Asura.Framework/Component.lua
@@ -1,6 +1,14 @@
-local Component = Class()
+local Component = AsuraEngine.Class("Component")
-Component.gameobject = AsuraEngine.Type.GameObject
+AsuraEngine.Component = Component
+
+--Component.gameobject = AsuraEngine.Type.GameObject
+
+--派生新的组件
+function Component.Sub(cname)
+ assert(Component.components[cname] == nil)
+
+end
function Component:Ctor(go)
self.gameobject = go
diff --git a/Source/Asura.Framework/Filesystem/Loader.lua b/Source/Asura.Framework/Filesystem/Loader.lua
index 9ac058b..2d1e8cf 100644
--- a/Source/Asura.Framework/Filesystem/Loader.lua
+++ b/Source/Asura.Framework/Filesystem/Loader.lua
@@ -1,9 +1,14 @@
-local Loader = Class()
-
-function Loader:InnerResource( data )
-
-
-
+-- Assets loaders
+AsuraEngine.Loader = {}
+local Loader = AsuraEngine.Loader
+Loader.Loaders = {}
+
+function Loader.New(type)
+ if Loader.Loaders[type] ~= nil then
+ return Loader.Loaders[type]
+ end
+ local loader = {}
+ Loader[type] = loader
+ return loader
end
-return Loader \ No newline at end of file
diff --git a/Source/Asura.Framework/Filesystem/animation_loader.lua b/Source/Asura.Framework/Filesystem/animation_loader.lua
index f1dee29..4f989bd 100644
--- a/Source/Asura.Framework/Filesystem/animation_loader.lua
+++ b/Source/Asura.Framework/Filesystem/animation_loader.lua
@@ -1,11 +1,12 @@
-local AnimationLoader = AsuraEngine.Loader.New("animation")
-local AnimationManager = require "AnimationManager"
-local Animation = require "Animation"
+require "AnimationManager"
+require "Animation"
+
+local loader = AsuraEngine.Loader.New("animation")
+local manager = AsuraEngine.AnimationManager
+local Animation = AsuraEngine.Animation
function AnimationLoader.Load(asset)
local animation = AsuraEngine.Class()
-end
-
-return AnimationLoader \ No newline at end of file
+end \ No newline at end of file
diff --git a/Source/Asura.Framework/Filesystem/material_loader.lua b/Source/Asura.Framework/Filesystem/material_loader.lua
index 2ea47f4..2c2058e 100644
--- a/Source/Asura.Framework/Filesystem/material_loader.lua
+++ b/Source/Asura.Framework/Filesystem/material_loader.lua
@@ -1,8 +1,7 @@
-local MaterialLoader = AsuraEngine.Loader.New("material")
-local MaterialManager = require "MaterialManager"
+require "MaterialManager"
-function MaterialLoader.Load(mat)
-
-end
+local loader = AsuraEngine.Loader.New("material")
-return MaterialLoader \ No newline at end of file
+function loader.Load(asset)
+
+end \ No newline at end of file
diff --git a/Source/Asura.Framework/Filesystem/path_loader.lua b/Source/Asura.Framework/Filesystem/path_loader.lua
index c62be96..8618c03 100644
--- a/Source/Asura.Framework/Filesystem/path_loader.lua
+++ b/Source/Asura.Framework/Filesystem/path_loader.lua
@@ -1,10 +1,9 @@
-local PathLoader = AsuraEngine.Loader.New("path")
-local PathManager = require "Path/PathManager"
+require "Path/PathManager"
-function PathLoader.Load(asset)
+local loader = AsuraEngine.Loader.New("path")
+
+function loader.Load(asset)
if asset.type ~= "path" then
return nil
end
-end
-
-return Path \ No newline at end of file
+end \ No newline at end of file
diff --git a/Source/Asura.Framework/Filesystem/scene_loader.lua b/Source/Asura.Framework/Filesystem/scene_loader.lua
index e69de29..3284c57 100644
--- a/Source/Asura.Framework/Filesystem/scene_loader.lua
+++ b/Source/Asura.Framework/Filesystem/scene_loader.lua
@@ -0,0 +1,5 @@
+local loader = AsuraEngine.Loader.New("scene")
+
+function loader.Load(asset)
+
+end \ No newline at end of file
diff --git a/Source/Asura.Framework/Framework.lua b/Source/Asura.Framework/Framework.lua
index b465f78..449cc4a 100644
--- a/Source/Asura.Framework/Framework.lua
+++ b/Source/Asura.Framework/Framework.lua
@@ -1 +1 @@
-require "" \ No newline at end of file
+require ""
diff --git a/Source/Asura.Framework/Game.lua b/Source/Asura.Framework/Game.lua
index 3e44b53..e69de29 100644
--- a/Source/Asura.Framework/Game.lua
+++ b/Source/Asura.Framework/Game.lua
@@ -1 +0,0 @@
---űѭ
diff --git a/Source/Asura.Framework/Scene.lua b/Source/Asura.Framework/Scene.lua
index afe6344..0ef41c7 100644
--- a/Source/Asura.Framework/Scene.lua
+++ b/Source/Asura.Framework/Scene.lua
@@ -1,8 +1,13 @@
---[[
-ԭ½
-]]
local Scene = Class()
+AsuraEngine.Scene = Scene
+function Scene.Ctor(self)
+ self.entities = {} --当前场景的所有entity
+end
+--获取当前的场景
+function Scene.GetCurrent()
+
+end
return Scene \ No newline at end of file
diff --git a/Source/Asura.Framework/Transform.lua b/Source/Asura.Framework/Transform.lua
index e69de29..e45a027 100644
--- a/Source/Asura.Framework/Transform.lua
+++ b/Source/Asura.Framework/Transform.lua
@@ -0,0 +1,8 @@
+local Transform = AsuraEngine.Class("Transform")
+AsuraEngine.Transform = Transform
+
+function Transform.Ctor(self)
+ self.position = {}
+ self.rotation = {}
+ self.size = {}
+end
diff --git a/Source/Asura.Framework/Object.lua b/Source/Asura.Framework/ai/behavior_tree.lua
index e69de29..e69de29 100644
--- a/Source/Asura.Framework/Object.lua
+++ b/Source/Asura.Framework/ai/behavior_tree.lua
diff --git a/Source/Asura.Framework/ai/state_machine.lua b/Source/Asura.Framework/ai/state_machine.lua
new file mode 100644
index 0000000..b1ff849
--- /dev/null
+++ b/Source/Asura.Framework/ai/state_machine.lua
@@ -0,0 +1,6 @@
+local StateMachine = Class()
+AsuraEngine.StateMachine = StateMachine
+
+function StateMachine.Ctor(self, statemap)
+ self.statemap = statemap
+end \ No newline at end of file
diff --git a/Source/Asura.Framework/ai/state_map.lua b/Source/Asura.Framework/ai/state_map.lua
new file mode 100644
index 0000000..7e986de
--- /dev/null
+++ b/Source/Asura.Framework/ai/state_map.lua
@@ -0,0 +1,12 @@
+local StateMap = AsuraEngine.Asset.Sub("StateMap")
+
+AsuraEngine.StateMap = StateMap
+
+function StateMap.Ctor(self)
+
+end
+
+function StateMap.ToAsset()
+
+end
+
diff --git a/Source/Asura.Framework/ai/statemachine.lua b/Source/Asura.Framework/ai/statemachine.lua
deleted file mode 100644
index 58012ca..0000000
--- a/Source/Asura.Framework/ai/statemachine.lua
+++ /dev/null
@@ -1,3 +0,0 @@
-local StateMachine = Class()
-
-return StateMachine \ No newline at end of file
diff --git a/Source/Asura.Framework/audio/soundplayer.lua b/Source/Asura.Framework/audio/soundplayer.lua
index 8bbeddb..c3921af 100644
--- a/Source/Asura.Framework/audio/soundplayer.lua
+++ b/Source/Asura.Framework/audio/soundplayer.lua
@@ -1,3 +1,5 @@
-local SoundPlayer = AsuraEngine.Component.New("SoundPlayer")
+local SoundPlayer = AsuraEngine.Component.Sub("SoundPlayer")
+
+
return SoundPlayer \ No newline at end of file
diff --git a/Source/Asura.Framework/class.lua b/Source/Asura.Framework/class.lua
index bec3e9a..164cb4a 100644
--- a/Source/Asura.Framework/class.lua
+++ b/Source/Asura.Framework/class.lua
@@ -1,5 +1,4 @@
local Class = {}
+AsuraEngine.Class = Class
-
-AsuraEngine.Class = Class \ No newline at end of file
diff --git a/Source/Asura.Framework/component.lua b/Source/Asura.Framework/component.lua
index dd843eb..b498a36 100644
--- a/Source/Asura.Framework/component.lua
+++ b/Source/Asura.Framework/component.lua
@@ -1,6 +1,14 @@
-local Component = Class()
+local Component = AsuraEngine.Class("Component")
-Component.gameobject = AsuraEngine.Type.GameObject
+AsuraEngine.Component = Component
+
+--Component.gameobject = AsuraEngine.Type.GameObject
+
+--派生新的组件
+function Component.Sub(cname)
+ assert(Component.components[cname] == nil)
+
+end
function Component:Ctor(go)
self.gameobject = go
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
diff --git a/Source/Asura.Framework/filesystem/animation_loader.lua b/Source/Asura.Framework/filesystem/animation_loader.lua
index f1dee29..4f989bd 100644
--- a/Source/Asura.Framework/filesystem/animation_loader.lua
+++ b/Source/Asura.Framework/filesystem/animation_loader.lua
@@ -1,11 +1,12 @@
-local AnimationLoader = AsuraEngine.Loader.New("animation")
-local AnimationManager = require "AnimationManager"
-local Animation = require "Animation"
+require "AnimationManager"
+require "Animation"
+
+local loader = AsuraEngine.Loader.New("animation")
+local manager = AsuraEngine.AnimationManager
+local Animation = AsuraEngine.Animation
function AnimationLoader.Load(asset)
local animation = AsuraEngine.Class()
-end
-
-return AnimationLoader \ No newline at end of file
+end \ No newline at end of file
diff --git a/Source/Asura.Framework/filesystem/entity_loader.lua b/Source/Asura.Framework/filesystem/entity_loader.lua
index ad2351c..67a849d 100644
--- a/Source/Asura.Framework/filesystem/entity_loader.lua
+++ b/Source/Asura.Framework/filesystem/entity_loader.lua
@@ -1,2 +1,5 @@
-local EntityLoader = AsuraEngine.Loader.New("entity")
+local loader = AsuraEngine.Loader.New("entity")
+function loader.Load(asset)
+
+end \ No newline at end of file
diff --git a/Source/Asura.Framework/filesystem/loader.lua b/Source/Asura.Framework/filesystem/loader.lua
index 9ac058b..2d1e8cf 100644
--- a/Source/Asura.Framework/filesystem/loader.lua
+++ b/Source/Asura.Framework/filesystem/loader.lua
@@ -1,9 +1,14 @@
-local Loader = Class()
-
-function Loader:InnerResource( data )
-
-
-
+-- Assets loaders
+AsuraEngine.Loader = {}
+local Loader = AsuraEngine.Loader
+Loader.Loaders = {}
+
+function Loader.New(type)
+ if Loader.Loaders[type] ~= nil then
+ return Loader.Loaders[type]
+ end
+ local loader = {}
+ Loader[type] = loader
+ return loader
end
-return Loader \ No newline at end of file
diff --git a/Source/Asura.Framework/filesystem/material_loader.lua b/Source/Asura.Framework/filesystem/material_loader.lua
index 2ea47f4..2c2058e 100644
--- a/Source/Asura.Framework/filesystem/material_loader.lua
+++ b/Source/Asura.Framework/filesystem/material_loader.lua
@@ -1,8 +1,7 @@
-local MaterialLoader = AsuraEngine.Loader.New("material")
-local MaterialManager = require "MaterialManager"
+require "MaterialManager"
-function MaterialLoader.Load(mat)
-
-end
+local loader = AsuraEngine.Loader.New("material")
-return MaterialLoader \ No newline at end of file
+function loader.Load(asset)
+
+end \ No newline at end of file
diff --git a/Source/Asura.Framework/filesystem/path_loader.lua b/Source/Asura.Framework/filesystem/path_loader.lua
index c62be96..8618c03 100644
--- a/Source/Asura.Framework/filesystem/path_loader.lua
+++ b/Source/Asura.Framework/filesystem/path_loader.lua
@@ -1,10 +1,9 @@
-local PathLoader = AsuraEngine.Loader.New("path")
-local PathManager = require "Path/PathManager"
+require "Path/PathManager"
-function PathLoader.Load(asset)
+local loader = AsuraEngine.Loader.New("path")
+
+function loader.Load(asset)
if asset.type ~= "path" then
return nil
end
-end
-
-return Path \ No newline at end of file
+end \ No newline at end of file
diff --git a/Source/Asura.Framework/filesystem/scene_loader.lua b/Source/Asura.Framework/filesystem/scene_loader.lua
index e69de29..3284c57 100644
--- a/Source/Asura.Framework/filesystem/scene_loader.lua
+++ b/Source/Asura.Framework/filesystem/scene_loader.lua
@@ -0,0 +1,5 @@
+local loader = AsuraEngine.Loader.New("scene")
+
+function loader.Load(asset)
+
+end \ No newline at end of file
diff --git a/Source/Asura.Framework/filesystem/statemap_loader.lua b/Source/Asura.Framework/filesystem/statemap_loader.lua
new file mode 100644
index 0000000..ededcfc
--- /dev/null
+++ b/Source/Asura.Framework/filesystem/statemap_loader.lua
@@ -0,0 +1,7 @@
+require "ai/statemap_manager"
+local loader = AsuraEngine.Loader.New("statemap")
+
+--载入statemap
+function loader.Load(asset)
+
+end \ No newline at end of file
diff --git a/Source/Asura.Framework/framework.lua b/Source/Asura.Framework/framework.lua
index b465f78..449cc4a 100644
--- a/Source/Asura.Framework/framework.lua
+++ b/Source/Asura.Framework/framework.lua
@@ -1 +1 @@
-require "" \ No newline at end of file
+require ""
diff --git a/Source/Asura.Framework/game.lua b/Source/Asura.Framework/game.lua
index 3e44b53..e69de29 100644
--- a/Source/Asura.Framework/game.lua
+++ b/Source/Asura.Framework/game.lua
@@ -1 +0,0 @@
---űѭ
diff --git a/Source/Asura.Framework/object.lua b/Source/Asura.Framework/object.lua
deleted file mode 100644
index e69de29..0000000
--- a/Source/Asura.Framework/object.lua
+++ /dev/null
diff --git a/Source/Asura.Framework/scene.lua b/Source/Asura.Framework/scene.lua
index afe6344..0ef41c7 100644
--- a/Source/Asura.Framework/scene.lua
+++ b/Source/Asura.Framework/scene.lua
@@ -1,8 +1,13 @@
---[[
-ԭ½
-]]
local Scene = Class()
+AsuraEngine.Scene = Scene
+function Scene.Ctor(self)
+ self.entities = {} --当前场景的所有entity
+end
+--获取当前的场景
+function Scene.GetCurrent()
+
+end
return Scene \ No newline at end of file
diff --git a/Source/Asura.Framework/transform.lua b/Source/Asura.Framework/transform.lua
index e69de29..e45a027 100644
--- a/Source/Asura.Framework/transform.lua
+++ b/Source/Asura.Framework/transform.lua
@@ -0,0 +1,8 @@
+local Transform = AsuraEngine.Class("Transform")
+AsuraEngine.Transform = Transform
+
+function Transform.Ctor(self)
+ self.position = {}
+ self.rotation = {}
+ self.size = {}
+end