Files
UnrealLuaDemo/Script/lua/Tests/Harness/MockUnLuaRuntime.lua
T

1058 lines
34 KiB
Lua
Raw Normal View History

local ____exports = {}
local state
function ____exports.GetMockState()
return state
end
function ____exports.ResetMockState()
state = {
printedStrings = {},
logs = {},
timers = {},
nextTimerId = 1,
latentDelays = {},
inputBindings = {},
manualRefs = {},
spawnedActors = {},
createdObjects = {},
overriddenCalls = {}
}
end
--- 模拟推进定时器与 Latent Delay 协程
function ____exports.AdvanceMockTime(deltaSeconds)
local timerSnapshot = {}
do
local i = 0
while i < #state.timers do
timerSnapshot[i + 1] = state.timers[i + 1]
i = i + 1
end
end
do
local i = 0
while i < #timerSnapshot do
do
local t = timerSnapshot[i + 1]
if not t.active or t.paused then
goto __continue8
end
t.remaining = t.remaining - deltaSeconds
while t.active and not t.paused and t.remaining <= 0 do
t.callback(t.target)
if t.looping and t.active then
t.remaining = t.remaining + t.interval
else
t.active = false
break
end
end
end
::__continue8::
i = i + 1
end
end
local ready = {}
do
local i = #state.latentDelays - 1
while i >= 0 do
local entry = state.latentDelays[i + 1]
entry.remaining = entry.remaining - deltaSeconds
if entry.remaining <= 0 then
table.remove(state.latentDelays, i + 1)
ready[#ready + 1] = entry
end
i = i - 1
end
end
do
local i = 0
while i < #ready do
local entry = ready[i + 1]
if coroutine.status(entry.co) == "suspended" then
local ok, err = coroutine.resume(entry.co)
if not ok then
error("Latent coroutine resume error: " .. tostring(err))
end
end
i = i + 1
end
end
end
--- 构造模拟的 MulticastDelegate
function ____exports.CreateMockMulticastDelegate()
local entries = {}
local delegate = {
Add = function(self, target, cb)
do
local i = 0
while i < #entries do
if entries[i + 1].target == target and entries[i + 1].cb == cb then
return
end
i = i + 1
end
end
entries[#entries + 1] = {target = target, cb = cb}
end,
Remove = function(self, target, cb)
do
local i = #entries - 1
while i >= 0 do
if entries[i + 1].target == target and entries[i + 1].cb == cb then
table.remove(entries, i + 1)
end
i = i - 1
end
end
end,
Clear = function(self)
do
local i = #entries - 1
while i >= 0 do
table.remove(entries, i + 1)
i = i - 1
end
end
end,
Broadcast = function(self, ...)
local snap = {}
do
local i = 0
while i < #entries do
snap[i + 1] = entries[i + 1]
i = i + 1
end
end
do
local i = 0
while i < #snap do
snap[i + 1].cb(snap[i + 1].target, ...)
i = i + 1
end
end
end,
IsBound = function(self)
return #entries > 0
end
}
return delegate
end
--- 构造模拟的 FScriptDelegate
function ____exports.CreateMockScriptDelegate()
local boundTarget = nil
local boundCb = nil
local delegate = {
Bind = function(self, target, cb)
boundTarget = target
boundCb = cb
end,
Unbind = function(self)
boundTarget = nil
boundCb = nil
end,
Execute = function(self, ...)
if boundCb ~= nil then
return boundCb(boundTarget, ...)
end
return nil
end
}
return delegate
end
--- 构造模拟的 UObject/AActor/UUserWidget 实例并绑定 UnLua Lua 类表
function ____exports.CreateBoundInstance(luaClass, nativeClassName, extraProps)
local uobj = {
__isMockUObject = true,
__valid = true,
__className = nativeClassName,
__name = nativeClassName .. "_Instance",
__location = UE.FVector(0, 0, 0),
__rotation = UE.FRotator(0, 0, 0),
__inViewport = false,
__released = false,
OnTakeAnyDamage = ____exports.CreateMockMulticastDelegate(),
OnActorBeginOverlap = ____exports.CreateMockMulticastDelegate(),
OnClicked = ____exports.CreateMockMulticastDelegate(),
Overridden = setmetatable(
{},
{__index = function(_t, methodName)
return function(selfObj, ...)
state.overriddenCalls[#state.overriddenCalls + 1] = (tostring(selfObj.__className) .. ".") .. methodName
end
end}
)
}
uobj.GetName = function(self)
return self.__name
end
uobj.IsValid = function(self)
return self.__valid == true
end
uobj.IsA = function(self, cls)
if not cls then
return false
end
local target = cls.__className
if self.__className == target then
return true
end
if target == "UObject" then
return true
end
if target == "AActor" and (self.__className == "AActor" or self.__className == "ALuaDemoActor" or self.__className == "APlayerController" or self.__className == "ACharacter") then
return true
end
if target == "UUserWidget" and self.__className == "UUserWidget" then
return true
end
return false
end
uobj.GetWorld = function()
return _G.__MockWorld
end
uobj.K2_GetActorLocation = function(self)
return UE.FVector(self.__location.X, self.__location.Y, self.__location.Z)
end
uobj.K2_SetActorLocation = function(self, loc, _bSweep, outHit, _bTeleport)
self.__location = UE.FVector(loc.X, loc.Y, loc.Z)
local hit = outHit or ({bBlockingHit = false, Distance = 0, Location = loc})
return true, hit
end
uobj.K2_GetActorRotation = function(self)
return UE.FRotator(self.__rotation.Pitch, self.__rotation.Yaw, self.__rotation.Roll)
end
uobj.K2_SetActorRotation = function(self, rot)
self.__rotation = UE.FRotator(rot.Pitch, rot.Yaw, rot.Roll)
return true
end
uobj.K2_DestroyActor = function(self)
self.__valid = false
end
uobj.AddToViewport = function(self)
self.__inViewport = true
end
uobj.RemoveFromViewport = function(self)
self.__inViewport = false
end
uobj.RemoveFromParent = function(self)
self.__inViewport = false
end
uobj.Release = function(self)
self.__released = true
end
uobj.Destroy = function(self)
self.__valid = false
end
if extraProps ~= nil then
for k, v in pairs(extraProps) do
uobj[k] = v
end
end
setmetatable(
uobj,
{__index = function(t, k)
local cur = luaClass
while cur ~= nil do
local v = rawget(cur, k)
if v ~= nil then
return v
end
cur = rawget(cur, "Super")
end
return rawget(t, k)
end}
)
return uobj
end
local function CreateMockTArray()
local data = {}
local arr = {
Length = function(self)
return #data
end,
Num = function(self)
return #data
end,
Add = function(self, item)
data[#data + 1] = item
return #data
end,
AddUnique = function(self, item)
do
local i = 0
while i < #data do
if data[i + 1] == item then
return 0
end
i = i + 1
end
end
data[#data + 1] = item
return #data
end,
Find = function(self, item)
do
local i = 0
while i < #data do
if data[i + 1] == item then
return i + 1
end
i = i + 1
end
end
return 0
end,
Insert = function(self, item, index)
table.insert(data, index, item)
end,
Remove = function(self, index)
table.remove(data, index)
end,
RemoveItem = function(self, item)
local removed = 0
do
local i = #data - 1
while i >= 0 do
if data[i + 1] == item then
table.remove(data, i + 1)
removed = removed + 1
end
i = i - 1
end
end
return removed
end,
Clear = function(self)
do
local i = #data - 1
while i >= 0 do
table.remove(data, i + 1)
i = i - 1
end
end
end,
Reserve = function(self, _size)
return #data == 0
end,
Resize = function(self, size)
while #data > size do
table.remove(data)
end
while #data < size do
data[#data + 1] = 0
end
end,
GetData = function(self)
return data
end,
Get = function(self, index)
return data[index]
end,
GetRef = function(self, index)
return data[index]
end,
Set = function(self, index, item)
data[index] = item
end,
Swap = function(self, firstIndex, secondIndex)
local tmp = data[firstIndex]
data[firstIndex] = data[secondIndex]
data[secondIndex] = tmp
end,
Shuffle = function(self)
do
local i = #data - 1
while i > 0 do
local j = math.random(0, i)
local tmp = data[i + 1]
data[i + 1] = data[j + 1]
data[j + 1] = tmp
i = i - 1
end
end
end,
LastIndex = function(self)
return #data
end,
IsValidIndex = function(self, index)
return index >= 1 and index <= #data
end,
Contains = function(self, item)
do
local i = 0
while i < #data do
if data[i + 1] == item then
return true
end
i = i + 1
end
end
return false
end,
Append = function(self, other)
do
local i = 1
while i <= other:Length() do
data[#data + 1] = other:Get(i)
i = i + 1
end
end
end,
ToTable = function(self)
local copy = {}
do
local i = 0
while i < #data do
copy[i + 1] = data[i + 1]
i = i + 1
end
end
return copy
end
}
setmetatable(
arr,
{__pairs = function()
local idx = 0
return function()
idx = idx + 1
if idx <= #data then
return idx, data[idx]
end
return nil
end
end}
)
return arr
end
local function CreateMockTMap()
local entries = {}
local m = {
Length = function(self)
local n = 0
for _ in pairs(entries) do
n = n + 1
end
return n
end,
Num = function(self)
return self:Length()
end,
Add = function(self, k, v)
entries[k] = v
end,
Remove = function(self, k)
if entries[k] ~= nil then
entries[k] = nil
return true
end
return false
end,
Find = function(self, k)
return entries[k]
end,
FindRef = function(self, k)
return entries[k]
end,
Clear = function(self)
for k in pairs(entries) do
entries[k] = nil
end
end,
Keys = function(self)
local arr = CreateMockTArray()
for k in pairs(entries) do
arr:Add(k)
end
return arr
end,
Values = function(self)
local arr = CreateMockTArray()
for _, v in pairs(entries) do
arr:Add(v)
end
return arr
end,
ToTable = function(self)
local copy = {}
for k, v in pairs(entries) do
copy[k] = v
end
return copy
end
}
setmetatable(
m,
{__pairs = function()
return next, entries, nil
end}
)
return m
end
local function CreateMockTSet()
local entries = {}
local s = {
Length = function(self)
local n = 0
for _ in pairs(entries) do
n = n + 1
end
return n
end,
Num = function(self)
return self:Length()
end,
Add = function(self, item)
entries[item] = true
end,
Remove = function(self, item)
if entries[item] then
entries[item] = nil
return true
end
return false
end,
Contains = function(self, item)
return entries[item] == true
end,
Clear = function(self)
for k in pairs(entries) do
entries[k] = nil
end
end,
ToArray = function(self)
local arr = CreateMockTArray()
for k in pairs(entries) do
arr:Add(k)
end
return arr
end,
ToTable = function(self)
local arr = {}
for k in pairs(entries) do
arr[#arr + 1] = k
end
return arr
end
}
return s
end
local function CreateMockFVector(x, y, z)
local vx = 0
local vy = 0
local vz = 0
if x ~= nil and y == nil and z == nil then
vx = x
vy = x
vz = x
else
vx = x or 0
vy = y or 0
vz = z or 0
end
local vec = {
X = vx,
Y = vy,
Z = vz,
Set = function(self, nx, ny, nz)
if nx ~= nil then
self.X = nx
end
if ny ~= nil then
self.Y = ny
end
if nz ~= nil then
self.Z = nz
end
end,
Add = function(self, other)
if type(other) == "number" then
return CreateMockFVector(self.X + other, self.Y + other, self.Z + other)
end
return CreateMockFVector(self.X + other.X, self.Y + other.Y, self.Z + other.Z)
end,
Sub = function(self, other)
if type(other) == "number" then
return CreateMockFVector(self.X - other, self.Y - other, self.Z - other)
end
return CreateMockFVector(self.X - other.X, self.Y - other.Y, self.Z - other.Z)
end,
Mul = function(self, other)
if type(other) == "number" then
return CreateMockFVector(self.X * other, self.Y * other, self.Z * other)
end
return CreateMockFVector(self.X * other.X, self.Y * other.Y, self.Z * other.Z)
end,
Div = function(self, other)
if type(other) == "number" then
return CreateMockFVector(self.X / other, self.Y / other, self.Z / other)
end
return CreateMockFVector(self.X / other.X, self.Y / other.Y, self.Z / other.Z)
end,
Dot = function(self, other)
return self.X * other.X + self.Y * other.Y + self.Z * other.Z
end,
Cross = function(self, other)
return CreateMockFVector(self.Y * other.Z - self.Z * other.Y, self.Z * other.X - self.X * other.Z, self.X * other.Y - self.Y * other.X)
end,
Size = function(self)
return math.sqrt(self.X * self.X + self.Y * self.Y + self.Z * self.Z)
end,
Size2D = function(self)
return math.sqrt(self.X * self.X + self.Y * self.Y)
end,
SizeSquared = function(self)
return self.X * self.X + self.Y * self.Y + self.Z * self.Z
end,
SizeSquared2D = function(self)
return self.X * self.X + self.Y * self.Y
end,
Normalize = function(self, tol)
if tol == nil then
tol = 1e-8
end
local sq = self:SizeSquared()
if sq > tol then
local inv = 1 / math.sqrt(sq)
self.X = self.X * inv
self.Y = self.Y * inv
self.Z = self.Z * inv
return true
end
return false
end,
IsNormalized = function(self)
return math.abs(1 - self:SizeSquared()) < 0.01
end
}
return vec
end
local function CreateMockFRotator(pitch, yaw, roll)
if pitch == nil then
pitch = 0
end
if yaw == nil then
yaw = 0
end
if roll == nil then
roll = 0
end
return {
Pitch = pitch,
Yaw = yaw,
Roll = roll,
ToQuat = function(self)
return {X = self.Pitch, Y = self.Yaw, Z = self.Roll, W = 1}
end
}
end
local function CreateMockFTransform(rot, trans, scale)
return {
Rotation = rot or ({X = 0, Y = 0, Z = 0, W = 1}),
Translation = trans or CreateMockFVector(),
Scale3D = scale or CreateMockFVector(1, 1, 1)
}
end
local function CreateMockFLinearColor(r, g, b, a)
if r == nil then
r = 0
end
if g == nil then
g = 0
end
if b == nil then
b = 0
end
if a == nil then
a = 1
end
return {R = r, G = g, B = b, A = a}
end
local function MakeMockClassObject(name)
return {
__className = name,
__valid = true,
GetName = function(self)
return name
end,
IsChildOf = function(self, other)
return other ~= nil and (self.__className == other.__className or other.__className == "UObject")
end
}
end
function ____exports.InstallIfNeeded()
____exports.ResetMockState()
local g = _G
if g.UnLua ~= nil and g.UE ~= nil then
return
end
g.UnLua = {
PackagePath = "Script/lua/?.lua",
FTextEnabled = false,
Class = function(superName)
local ____temp_0
if superName ~= nil then
____temp_0 = require(superName)
else
____temp_0 = nil
end
local superClass = ____temp_0
local cls = {}
cls.Super = superClass
return cls
end,
Ref = function(obj)
local cur = state.manualRefs[obj] or 0
state.manualRefs[obj] = cur + 1
return {__refTarget = obj}
end,
Unref = function(obj)
state.manualRefs[obj] = nil
end,
HotReload = function()
state.logs[#state.logs + 1] = "UnLua.HotReload()"
end,
Log = function(...)
local args = {...}
local parts = {}
do
local i = 0
while i < #args do
parts[i + 1] = tostring(args[i + 1])
i = i + 1
end
end
state.logs[#state.logs + 1] = table.concat(parts, "\t")
end,
LogWarn = function(...)
local args = {...}
local parts = {}
do
local i = 0
while i < #args do
parts[i + 1] = tostring(args[i + 1])
i = i + 1
end
end
state.logs[#state.logs + 1] = "[WARN] " .. table.concat(parts, "\t")
end,
LogError = function(...)
local args = {...}
local parts = {}
do
local i = 0
while i < #args do
parts[i + 1] = tostring(args[i + 1])
i = i + 1
end
end
state.logs[#state.logs + 1] = "[ERROR] " .. table.concat(parts, "\t")
end,
Input = {
BindKey = function(mod, keyName, keyEvent, handler, args)
state.inputBindings[#state.inputBindings + 1] = {
kind = "Key",
module = mod,
name = keyName,
event = keyEvent,
handler = handler,
args = args
}
end,
BindAction = function(mod, actionName, keyEvent, handler, args)
state.inputBindings[#state.inputBindings + 1] = {
kind = "Action",
module = mod,
name = actionName,
event = keyEvent,
handler = handler,
args = args
}
end,
BindAxis = function(mod, axisName, handler, args)
state.inputBindings[#state.inputBindings + 1] = {
kind = "Axis",
module = mod,
name = axisName,
event = "Axis",
handler = handler,
args = args
}
end
},
EnhancedInput = {BindAction = function(mod, actionPath, triggerEvent, handler, args)
state.inputBindings[#state.inputBindings + 1] = {
kind = "EnhancedAction",
module = mod,
name = actionPath,
event = triggerEvent,
handler = handler,
args = args
}
end}
}
local FVectorTable = {
Dist = function(a, b)
local dx = a.X - b.X
local dy = a.Y - b.Y
local dz = a.Z - b.Z
return math.sqrt(dx * dx + dy * dy + dz * dz)
end,
Dist2D = function(a, b)
local dx = a.X - b.X
local dy = a.Y - b.Y
return math.sqrt(dx * dx + dy * dy)
end,
DistSquared = function(a, b)
local dx = a.X - b.X
local dy = a.Y - b.Y
local dz = a.Z - b.Z
return dx * dx + dy * dy + dz * dz
end
}
setmetatable(
FVectorTable,
{__call = function(self, x, y, z)
return CreateMockFVector(x, y, z)
end}
)
local mockWorld = {
SpawnActor = function(self, actorClass, transform, _collision, owner, _instigator, moduleName, initializer)
local luaCls = moduleName ~= nil and require(moduleName) or ({})
local ____exports_CreateBoundInstance_5 = ____exports.CreateBoundInstance
local ____tostring_4 = tostring
local ____temp_3 = actorClass and actorClass.__className
if ____temp_3 == nil then
____temp_3 = "AActor"
end
local inst = ____exports_CreateBoundInstance_5(
luaCls,
____tostring_4(____temp_3),
{Owner = owner}
)
if transform ~= nil then
inst.__location = transform.Translation
end
if type(inst.Initialize) == "function" then
inst:Initialize(initializer)
end
if type(inst.ReceiveBeginPlay) == "function" then
inst:ReceiveBeginPlay()
end
state.spawnedActors[#state.spawnedActors + 1] = inst
return inst
end,
SpawnActorEx = function(self, actorClass, transform, initializer, moduleName, spawnParams)
return self:SpawnActor(
actorClass,
transform,
spawnParams and spawnParams.SpawnCollisionHandlingOverride,
spawnParams and spawnParams.Owner,
spawnParams and spawnParams.Instigator,
moduleName,
initializer
)
end
}
g.__MockWorld = mockWorld
g.UE = {
int8 = "int8",
int16 = "int16",
int32 = "int32",
int64 = "int64",
uint8 = "uint8",
uint16 = "uint16",
uint32 = "uint32",
uint64 = "uint64",
float = "float",
double = "double",
bool = "bool",
FName = "FName",
FString = "FString",
FVector = FVectorTable,
FRotator = CreateMockFRotator,
FTransform = CreateMockFTransform,
FLinearColor = CreateMockFLinearColor,
FHitResult = function() return {
bBlockingHit = false,
Distance = 0,
Location = CreateMockFVector(),
ImpactPoint = CreateMockFVector(),
Normal = CreateMockFVector(0, 0, 1)
} end,
FActorSpawnParameters = function() return {Name = "", bNoFail = false, SpawnCollisionHandlingOverride = 0} end,
FWeakObjectPtr = function()
local refObj = nil
return {
Set = function(self, o)
refObj = o
end,
Get = function(self)
return refObj ~= nil and refObj.__valid == true and refObj or nil
end,
IsValid = function(self)
return refObj ~= nil and refObj.__valid == true
end,
Reset = function(self)
refObj = nil
end
}
end,
TArray = function(_elemType) return CreateMockTArray() end,
TMap = function(_keyType, _valType) return CreateMockTMap() end,
TSet = function(_elemType) return CreateMockTSet() end,
ESpawnActorCollisionHandlingMethod = {
Undefined = 0,
AlwaysSpawn = 1,
AdjustIfPossibleButAlwaysSpawn = 2,
AdjustIfPossibleButDontSpawnIfColliding = 3,
DontSpawnIfColliding = 4
},
EDrawDebugTrace = {None = 0, ForOneFrame = 1, ForDuration = 2, Persistent = 3},
ETraceTypeQuery = {TraceTypeQuery1 = 0, TraceTypeQuery2 = 1},
EEndPlayReason = {
Destroyed = 0,
LevelTransition = 1,
EndPlayInEditor = 2,
RemovedFromWorld = 3,
Quit = 4
},
UObject = {
StaticClass = function() return MakeMockClassObject("UObject") end,
Load = function(assetPath) return {
__isMockUObject = true,
__valid = true,
__className = "UObject",
__assetPath = assetPath,
GetName = function(self)
return assetPath
end,
IsValid = function(self)
return true
end
} end
},
UClass = {
StaticClass = function() return MakeMockClassObject("UClass") end,
Load = function(classPath) return MakeMockClassObject(classPath) end
},
AActor = {StaticClass = function() return MakeMockClassObject("AActor") end},
ALuaDemoActor = {StaticClass = function() return MakeMockClassObject("ALuaDemoActor") end},
APlayerController = {StaticClass = function() return MakeMockClassObject("APlayerController") end},
UUserWidget = {StaticClass = function() return MakeMockClassObject("UUserWidget") end},
LoadClass = function(classPath) return MakeMockClassObject(classPath) end,
LoadObject = function(assetPath) return {
__isMockUObject = true,
__valid = true,
__className = "UObject",
__assetPath = assetPath,
GetName = function(self)
return assetPath
end,
IsValid = function(self)
return true
end
} end,
NewObject = function(cls, outer, name, moduleName, initializer)
local luaCls = moduleName ~= nil and require(moduleName) or ({})
local ____exports_CreateBoundInstance_16 = ____exports.CreateBoundInstance
local ____tostring_15 = tostring
local ____temp_14 = cls and cls.__className
if ____temp_14 == nil then
____temp_14 = "UObject"
end
local inst = ____exports_CreateBoundInstance_16(
luaCls,
____tostring_15(____temp_14),
{__name = name or "NewObject", __outer = outer}
)
if type(inst.Initialize) == "function" then
inst:Initialize(initializer)
end
state.createdObjects[#state.createdObjects + 1] = inst
return inst
end,
UKismetSystemLibrary = {
PrintString = function(_worldCtx, inString)
state.printedStrings[#state.printedStrings + 1] = inString or ""
end,
IsValid = function(obj)
return obj ~= nil and obj.__valid == true
end,
K2_SetTimerDelegate = function(delegatePair, time, bLooping)
local ____state_17, ____nextTimerId_18 = state, "nextTimerId"
local ____state_nextTimerId_19 = ____state_17[____nextTimerId_18]
____state_17[____nextTimerId_18] = ____state_nextTimerId_19 + 1
local handleId = ____state_nextTimerId_19
state.timers[#state.timers + 1] = {
handleId = handleId,
target = delegatePair[1],
callback = delegatePair[2],
interval = time,
remaining = time,
looping = bLooping,
paused = false,
active = true
}
return {__handleId = handleId}
end,
K2_ClearAndInvalidateTimerHandle = function(_worldCtx, handle)
if handle and handle.__handleId ~= nil then
do
local i = 0
while i < #state.timers do
if state.timers[i + 1].handleId == handle.__handleId then
state.timers[i + 1].active = false
end
i = i + 1
end
end
handle.__handleId = nil
end
return handle or ({})
end,
K2_IsTimerActiveHandle = function(_worldCtx, handle)
if not handle or handle.__handleId == nil then
return false
end
do
local i = 0
while i < #state.timers do
if state.timers[i + 1].handleId == handle.__handleId then
return state.timers[i + 1].active and not state.timers[i + 1].paused
end
i = i + 1
end
end
return false
end,
Delay = function(worldCtx, duration)
local co, isMain = coroutine.running()
assert(not isMain, "UKismetSystemLibrary.Delay must be called inside a coroutine!")
state.latentDelays[#state.latentDelays + 1] = {co = co, owner = worldCtx, remaining = duration}
coroutine.yield()
end,
RetriggerableDelay = function(worldCtx, duration)
local co, isMain = coroutine.running()
assert(not isMain, "RetriggerableDelay must be called inside a coroutine!")
state.latentDelays[#state.latentDelays + 1] = {co = co, owner = worldCtx, remaining = duration}
coroutine.yield()
end,
LineTraceSingle = function(_worldCtx, startVec, endVec, _channel, _bTraceComplex, _actorsToIgnore, _drawDebugType, outHit, _bIgnoreSelf)
local dist = UE.FVector.Dist(startVec, endVec)
local hit = outHit or ({
bBlockingHit = false,
Distance = 0,
Location = CreateMockFVector(),
ImpactPoint = CreateMockFVector()
})
local bHit = dist > 0
hit.bBlockingHit = bHit
hit.Distance = dist * 0.5
hit.Location = CreateMockFVector((startVec.X + endVec.X) * 0.5, (startVec.Y + endVec.Y) * 0.5, (startVec.Z + endVec.Z) * 0.5)
hit.ImpactPoint = hit.Location
return bHit, hit
end
}
}
end
return ____exports