test: add comprehensive ts2lua-unreal TS/Lua 5.4 test suites and upgrade to v0.2.2
This commit is contained in:
1 parent
ee2e62bb34
commit
3dd61c32a9
75 files changed
+9929
-10
No files matched your search
@@ -0,0 +1,130 @@
|
||||
local ____lualib = require("lualib_bundle")
|
||||
local __TS__Class = ____lualib.__TS__Class
|
||||
local ____exports = {}
|
||||
____exports.BTCondition = __TS__Class()
|
||||
local BTCondition = ____exports.BTCondition
|
||||
BTCondition.name = "BTCondition"
|
||||
function BTCondition.prototype.____constructor(self, check)
|
||||
self.check = check
|
||||
end
|
||||
function BTCondition.prototype.Tick(self, ctx)
|
||||
return self.check(ctx) and 0 or 1
|
||||
end
|
||||
function BTCondition.prototype.Reset(self)
|
||||
end
|
||||
____exports.BTAction = __TS__Class()
|
||||
local BTAction = ____exports.BTAction
|
||||
BTAction.name = "BTAction"
|
||||
function BTAction.prototype.____constructor(self, action)
|
||||
self.action = action
|
||||
end
|
||||
function BTAction.prototype.Tick(self, ctx)
|
||||
return self.action(ctx)
|
||||
end
|
||||
function BTAction.prototype.Reset(self)
|
||||
end
|
||||
____exports.BTSequence = __TS__Class()
|
||||
local BTSequence = ____exports.BTSequence
|
||||
BTSequence.name = "BTSequence"
|
||||
function BTSequence.prototype.____constructor(self, children)
|
||||
self.runningIndex = 0
|
||||
self.children = children
|
||||
end
|
||||
function BTSequence.prototype.Tick(self, ctx)
|
||||
while self.runningIndex < #self.children do
|
||||
local status = self.children[self.runningIndex + 1]:Tick(ctx)
|
||||
if status == 2 then
|
||||
return 2
|
||||
end
|
||||
if status == 1 then
|
||||
self:Reset()
|
||||
return 1
|
||||
end
|
||||
self.runningIndex = self.runningIndex + 1
|
||||
end
|
||||
self:Reset()
|
||||
return 0
|
||||
end
|
||||
function BTSequence.prototype.Reset(self)
|
||||
self.runningIndex = 0
|
||||
do
|
||||
local i = 0
|
||||
while i < #self.children do
|
||||
self.children[i + 1]:Reset()
|
||||
i = i + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
____exports.BTSelector = __TS__Class()
|
||||
local BTSelector = ____exports.BTSelector
|
||||
BTSelector.name = "BTSelector"
|
||||
function BTSelector.prototype.____constructor(self, children)
|
||||
self.runningIndex = 0
|
||||
self.children = children
|
||||
end
|
||||
function BTSelector.prototype.Tick(self, ctx)
|
||||
while self.runningIndex < #self.children do
|
||||
local status = self.children[self.runningIndex + 1]:Tick(ctx)
|
||||
if status == 2 then
|
||||
return 2
|
||||
end
|
||||
if status == 0 then
|
||||
self:Reset()
|
||||
return 0
|
||||
end
|
||||
self.runningIndex = self.runningIndex + 1
|
||||
end
|
||||
self:Reset()
|
||||
return 1
|
||||
end
|
||||
function BTSelector.prototype.Reset(self)
|
||||
self.runningIndex = 0
|
||||
do
|
||||
local i = 0
|
||||
while i < #self.children do
|
||||
self.children[i + 1]:Reset()
|
||||
i = i + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
____exports.BTInverter = __TS__Class()
|
||||
local BTInverter = ____exports.BTInverter
|
||||
BTInverter.name = "BTInverter"
|
||||
function BTInverter.prototype.____constructor(self, child)
|
||||
self.child = child
|
||||
end
|
||||
function BTInverter.prototype.Tick(self, ctx)
|
||||
local st = self.child:Tick(ctx)
|
||||
if st == 0 then
|
||||
return 1
|
||||
end
|
||||
if st == 1 then
|
||||
return 0
|
||||
end
|
||||
return 2
|
||||
end
|
||||
function BTInverter.prototype.Reset(self)
|
||||
self.child:Reset()
|
||||
end
|
||||
____exports.BTCooldown = __TS__Class()
|
||||
local BTCooldown = ____exports.BTCooldown
|
||||
BTCooldown.name = "BTCooldown"
|
||||
function BTCooldown.prototype.____constructor(self, child, cooldownSeconds)
|
||||
self.lastSuccessTime = -9999
|
||||
self.child = child
|
||||
self.cooldownSeconds = cooldownSeconds
|
||||
end
|
||||
function BTCooldown.prototype.Tick(self, ctx)
|
||||
if ctx.time - self.lastSuccessTime < self.cooldownSeconds then
|
||||
return 1
|
||||
end
|
||||
local st = self.child:Tick(ctx)
|
||||
if st == 0 then
|
||||
self.lastSuccessTime = ctx.time
|
||||
end
|
||||
return st
|
||||
end
|
||||
function BTCooldown.prototype.Reset(self)
|
||||
self.child:Reset()
|
||||
end
|
||||
return ____exports
|
||||
Reference in new issue
Block a user