feat: upgrade to ts2lua-unreal v0.3.0 and refactor Game classes to pure C++ callback + TS composition hot-reload

This commit is contained in:
szy73711 committed 2026-11-30 02:42:51 +08:00
1 parent 4ad4a8f36f
commit 783dccf53d
64 files changed
+2368 -714

No files matched your search

+9 -10
View File
@@ -1,7 +1,5 @@
local ____lualib = require("lualib_bundle")
local __TS__Class = ____lualib.__TS__Class
local ____exports = {}
____exports.BTCondition = __TS__Class()
local ____exports = __module.env
____exports.BTCondition = __TS__DefineClass("BTCondition", __module)
local BTCondition = ____exports.BTCondition
BTCondition.name = "BTCondition"
function BTCondition.prototype.____constructor(self, check)
@@ -12,7 +10,7 @@ function BTCondition.prototype.Tick(self, ctx)
end
function BTCondition.prototype.Reset(self)
end
____exports.BTAction = __TS__Class()
____exports.BTAction = __TS__DefineClass("BTAction", __module)
local BTAction = ____exports.BTAction
BTAction.name = "BTAction"
function BTAction.prototype.____constructor(self, action)
@@ -23,7 +21,7 @@ function BTAction.prototype.Tick(self, ctx)
end
function BTAction.prototype.Reset(self)
end
____exports.BTSequence = __TS__Class()
____exports.BTSequence = __TS__DefineClass("BTSequence", __module)
local BTSequence = ____exports.BTSequence
BTSequence.name = "BTSequence"
function BTSequence.prototype.____constructor(self, children)
@@ -55,7 +53,7 @@ function BTSequence.prototype.Reset(self)
end
end
end
____exports.BTSelector = __TS__Class()
____exports.BTSelector = __TS__DefineClass("BTSelector", __module)
local BTSelector = ____exports.BTSelector
BTSelector.name = "BTSelector"
function BTSelector.prototype.____constructor(self, children)
@@ -87,7 +85,7 @@ function BTSelector.prototype.Reset(self)
end
end
end
____exports.BTInverter = __TS__Class()
____exports.BTInverter = __TS__DefineClass("BTInverter", __module)
local BTInverter = ____exports.BTInverter
BTInverter.name = "BTInverter"
function BTInverter.prototype.____constructor(self, child)
@@ -106,7 +104,7 @@ end
function BTInverter.prototype.Reset(self)
self.child:Reset()
end
____exports.BTCooldown = __TS__Class()
____exports.BTCooldown = __TS__DefineClass("BTCooldown", __module)
local BTCooldown = ____exports.BTCooldown
BTCooldown.name = "BTCooldown"
function BTCooldown.prototype.____constructor(self, child, cooldownSeconds)
@@ -127,4 +125,5 @@ end
function BTCooldown.prototype.Reset(self)
self.child:Reset()
end
return ____exports
function __module.UpdateImports()
end
@@ -1,7 +1,5 @@
local ____lualib = require("lualib_bundle")
local __TS__Class = ____lualib.__TS__Class
local ____exports = {}
____exports.AttributeAndBuffComponent = __TS__Class()
local ____exports = __module.env
____exports.AttributeAndBuffComponent = __TS__DefineClass("AttributeAndBuffComponent", __module)
local AttributeAndBuffComponent = ____exports.AttributeAndBuffComponent
AttributeAndBuffComponent.name = "AttributeAndBuffComponent"
function AttributeAndBuffComponent.prototype.____constructor(self, initialStats)
@@ -177,4 +175,5 @@ function AttributeAndBuffComponent.prototype.Notify(self, attr, val)
end
end
end
return ____exports
function __module.UpdateImports()
end
@@ -1,7 +1,5 @@
local ____lualib = require("lualib_bundle")
local __TS__Class = ____lualib.__TS__Class
local ____exports = {}
____exports.CoroutineTaskRunner = __TS__Class()
local ____exports = __module.env
____exports.CoroutineTaskRunner = __TS__DefineClass("CoroutineTaskRunner", __module)
local CoroutineTaskRunner = ____exports.CoroutineTaskRunner
CoroutineTaskRunner.name = "CoroutineTaskRunner"
function CoroutineTaskRunner.prototype.____constructor(self)
@@ -125,4 +123,5 @@ function CoroutineTaskRunner.WaitUntil(predicate)
local cmd = {kind = "wait_until", predicate = predicate}
coroutine.yield(cmd)
end
return ____exports
function __module.UpdateImports()
end
+4 -5
View File
@@ -1,7 +1,5 @@
local ____lualib = require("lualib_bundle")
local __TS__Class = ____lualib.__TS__Class
local ____exports = {}
____exports.StateMachine = __TS__Class()
local ____exports = __module.env
____exports.StateMachine = __TS__DefineClass("StateMachine", __module)
local StateMachine = ____exports.StateMachine
StateMachine.name = "StateMachine"
function StateMachine.prototype.____constructor(self, ctx)
@@ -85,4 +83,5 @@ end
function StateMachine.prototype.GetHistory(self)
return self.history
end
return ____exports
function __module.UpdateImports()
end
+56 -33
View File
@@ -1,37 +1,37 @@
local ____lualib = require("lualib_bundle")
local __TS__New = ____lualib.__TS__New
local ____exports = {}
local ____TestRunner = require("Tests.Harness.TestRunner")
local Suite = ____TestRunner.Suite
local Test = ____TestRunner.Test
local AssertEqual = ____TestRunner.AssertEqual
local AssertNear = ____TestRunner.AssertNear
local AssertTrue = ____TestRunner.AssertTrue
local AssertFalse = ____TestRunner.AssertFalse
local AssertNil = ____TestRunner.AssertNil
local AssertArrayEqual = ____TestRunner.AssertArrayEqual
local ____MockUnLuaRuntime = require("Tests.Harness.MockUnLuaRuntime")
local CreateBoundInstance = ____MockUnLuaRuntime.CreateBoundInstance
local ____FSM = require("Tests.Gameplay.FSM")
local StateMachine = ____FSM.StateMachine
local ____ObjectPool = require("Tests.Gameplay.ObjectPool")
local ObjectPool = ____ObjectPool.ObjectPool
local ____TimerScheduler = require("Tests.Gameplay.TimerScheduler")
local TimerScheduler = ____TimerScheduler.TimerScheduler
local CooldownTracker = ____TimerScheduler.CooldownTracker
local ____BuffAndAttributeSystem = require("Tests.Gameplay.BuffAndAttributeSystem")
local AttributeAndBuffComponent = ____BuffAndAttributeSystem.AttributeAndBuffComponent
local ____InventorySystem = require("Tests.Gameplay.InventorySystem")
local InventorySystem = ____InventorySystem.InventorySystem
local ____CoroutineTaskRunner = require("Tests.Gameplay.CoroutineTaskRunner")
local CoroutineTaskRunner = ____CoroutineTaskRunner.CoroutineTaskRunner
local ____BehaviorTree = require("Tests.Gameplay.BehaviorTree")
local BTAction = ____BehaviorTree.BTAction
local BTCondition = ____BehaviorTree.BTCondition
local BTCooldown = ____BehaviorTree.BTCooldown
local BTInverter = ____BehaviorTree.BTInverter
local BTSelector = ____BehaviorTree.BTSelector
local BTSequence = ____BehaviorTree.BTSequence
local ____exports = __module.env
local M__Tests_Harness_TestRunner = __MODULE__.Import("Tests.Harness.TestRunner", __module)
local Suite = M__Tests_Harness_TestRunner.Suite
local Test = M__Tests_Harness_TestRunner.Test
local AssertEqual = M__Tests_Harness_TestRunner.AssertEqual
local AssertNear = M__Tests_Harness_TestRunner.AssertNear
local AssertTrue = M__Tests_Harness_TestRunner.AssertTrue
local AssertFalse = M__Tests_Harness_TestRunner.AssertFalse
local AssertNil = M__Tests_Harness_TestRunner.AssertNil
local AssertArrayEqual = M__Tests_Harness_TestRunner.AssertArrayEqual
local M__Tests_Harness_MockUnLuaRuntime = __MODULE__.Import("Tests.Harness.MockUnLuaRuntime", __module)
local CreateBoundInstance = M__Tests_Harness_MockUnLuaRuntime.CreateBoundInstance
local M__Tests_Gameplay_FSM = __MODULE__.Import("Tests.Gameplay.FSM", __module)
local StateMachine = M__Tests_Gameplay_FSM.StateMachine
local M__Tests_Gameplay_ObjectPool = __MODULE__.Import("Tests.Gameplay.ObjectPool", __module)
local ObjectPool = M__Tests_Gameplay_ObjectPool.ObjectPool
local M__Tests_Gameplay_TimerScheduler = __MODULE__.Import("Tests.Gameplay.TimerScheduler", __module)
local TimerScheduler = M__Tests_Gameplay_TimerScheduler.TimerScheduler
local CooldownTracker = M__Tests_Gameplay_TimerScheduler.CooldownTracker
local M__Tests_Gameplay_BuffAndAttributeSystem = __MODULE__.Import("Tests.Gameplay.BuffAndAttributeSystem", __module)
local AttributeAndBuffComponent = M__Tests_Gameplay_BuffAndAttributeSystem.AttributeAndBuffComponent
local M__Tests_Gameplay_InventorySystem = __MODULE__.Import("Tests.Gameplay.InventorySystem", __module)
local InventorySystem = M__Tests_Gameplay_InventorySystem.InventorySystem
local M__Tests_Gameplay_CoroutineTaskRunner = __MODULE__.Import("Tests.Gameplay.CoroutineTaskRunner", __module)
local CoroutineTaskRunner = M__Tests_Gameplay_CoroutineTaskRunner.CoroutineTaskRunner
local M__Tests_Gameplay_BehaviorTree = __MODULE__.Import("Tests.Gameplay.BehaviorTree", __module)
local BTAction = M__Tests_Gameplay_BehaviorTree.BTAction
local BTCondition = M__Tests_Gameplay_BehaviorTree.BTCondition
local BTCooldown = M__Tests_Gameplay_BehaviorTree.BTCooldown
local BTInverter = M__Tests_Gameplay_BehaviorTree.BTInverter
local BTSelector = M__Tests_Gameplay_BehaviorTree.BTSelector
local BTSequence = M__Tests_Gameplay_BehaviorTree.BTSequence
function ____exports.RunGameplayTests()
Suite(
"Gameplay.Systems",
@@ -489,4 +489,27 @@ function ____exports.RunGameplayTests()
end
)
end
return ____exports
function __module.UpdateImports()
Suite = M__Tests_Harness_TestRunner.Suite
Test = M__Tests_Harness_TestRunner.Test
AssertEqual = M__Tests_Harness_TestRunner.AssertEqual
AssertNear = M__Tests_Harness_TestRunner.AssertNear
AssertTrue = M__Tests_Harness_TestRunner.AssertTrue
AssertFalse = M__Tests_Harness_TestRunner.AssertFalse
AssertNil = M__Tests_Harness_TestRunner.AssertNil
AssertArrayEqual = M__Tests_Harness_TestRunner.AssertArrayEqual
CreateBoundInstance = M__Tests_Harness_MockUnLuaRuntime.CreateBoundInstance
StateMachine = M__Tests_Gameplay_FSM.StateMachine
ObjectPool = M__Tests_Gameplay_ObjectPool.ObjectPool
TimerScheduler = M__Tests_Gameplay_TimerScheduler.TimerScheduler
CooldownTracker = M__Tests_Gameplay_TimerScheduler.CooldownTracker
AttributeAndBuffComponent = M__Tests_Gameplay_BuffAndAttributeSystem.AttributeAndBuffComponent
InventorySystem = M__Tests_Gameplay_InventorySystem.InventorySystem
CoroutineTaskRunner = M__Tests_Gameplay_CoroutineTaskRunner.CoroutineTaskRunner
BTAction = M__Tests_Gameplay_BehaviorTree.BTAction
BTCondition = M__Tests_Gameplay_BehaviorTree.BTCondition
BTCooldown = M__Tests_Gameplay_BehaviorTree.BTCooldown
BTInverter = M__Tests_Gameplay_BehaviorTree.BTInverter
BTSelector = M__Tests_Gameplay_BehaviorTree.BTSelector
BTSequence = M__Tests_Gameplay_BehaviorTree.BTSequence
end
@@ -1,7 +1,5 @@
local ____lualib = require("lualib_bundle")
local __TS__Class = ____lualib.__TS__Class
local ____exports = {}
____exports.InventorySystem = __TS__Class()
local ____exports = __module.env
____exports.InventorySystem = __TS__DefineClass("InventorySystem", __module)
local InventorySystem = ____exports.InventorySystem
InventorySystem.name = "InventorySystem"
function InventorySystem.prototype.____constructor(self, capacity)
@@ -158,4 +156,5 @@ function InventorySystem.prototype.Deserialize(self, data)
self.slots[idx] = {itemId = s.itemId, count = s.count}
end
end
return ____exports
function __module.UpdateImports()
end
+4 -5
View File
@@ -1,7 +1,5 @@
local ____lualib = require("lualib_bundle")
local __TS__Class = ____lualib.__TS__Class
local ____exports = {}
____exports.ObjectPool = __TS__Class()
local ____exports = __module.env
____exports.ObjectPool = __TS__DefineClass("ObjectPool", __module)
local ObjectPool = ____exports.ObjectPool
ObjectPool.name = "ObjectPool"
function ObjectPool.prototype.____constructor(self, options)
@@ -58,4 +56,5 @@ end
function ObjectPool.prototype.GetTotalCreated(self)
return self.totalCreated
end
return ____exports
function __module.UpdateImports()
end
+5 -6
View File
@@ -1,7 +1,5 @@
local ____lualib = require("lualib_bundle")
local __TS__Class = ____lualib.__TS__Class
local ____exports = {}
____exports.TimerScheduler = __TS__Class()
local ____exports = __module.env
____exports.TimerScheduler = __TS__DefineClass("TimerScheduler", __module)
local TimerScheduler = ____exports.TimerScheduler
TimerScheduler.name = "TimerScheduler"
function TimerScheduler.prototype.____constructor(self)
@@ -123,7 +121,7 @@ function TimerScheduler.prototype.GetActiveCount(self)
end
return count
end
____exports.CooldownTracker = __TS__Class()
____exports.CooldownTracker = __TS__DefineClass("CooldownTracker", __module)
local CooldownTracker = ____exports.CooldownTracker
CooldownTracker.name = "CooldownTracker"
function CooldownTracker.prototype.____constructor(self)
@@ -156,4 +154,5 @@ function CooldownTracker.prototype.Tick(self, dt)
end
end
end
return ____exports
function __module.UpdateImports()
end