93 lines
6.1 KiB
Lua
93 lines
6.1 KiB
Lua
|
TraceManager = TraceManager or {}
|
||
|
|
||
|
TraceManager.EColorType = {
|
||
|
Red = 1;
|
||
|
Green = 2;
|
||
|
Blue = 3;
|
||
|
Yellow = 4;
|
||
|
}
|
||
|
|
||
|
TraceManager.LineColors = {
|
||
|
[TraceManager.EColorType.Red] = {R = 1, G = 0, B = 0, A = 1};
|
||
|
[TraceManager.EColorType.Green] = {R = 0, G = 1, B = 0, A = 1};
|
||
|
[TraceManager.EColorType.Blue] = {R = 0, G = 0, B = 1, A = 1};
|
||
|
[TraceManager.EColorType.Yellow] = {R = 0, G = 1, B = 1, A = 1};
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
---@field LineTraceSingleForObjects fun(WorldContextObject:UObject,Start:FVector,End:FVector,ObjectTypes:ULuaArrayHelper,ActorsToIgnore:ULuaArrayHelper,bEnableClientDebug:bool,TraceHitColorType:TraceManager.EColorType):bool,FHitResult
|
||
|
function TraceManager.LineTraceSingleForObjects(WorldContextObject, Start, End, ObjectTypes, ActorsToIgnore, bEnableClientDebug, TraceHitColorType)
|
||
|
UGCLogSystem.Log("[TraceManager_LineTraceSingleForObjects]")
|
||
|
---@field LineTraceSingleForObjects fun(WorldContextObject:UObject,Start:FVector,End:FVector,ObjectTypes:ULuaArrayHelper,bTraceComplex:bool,ActorsToIgnore:ULuaArrayHelper,DrawDebugType:EDrawDebugTrace,OutHit:FHitResult,bIgnoreSelf:bool,TraceColor:FLinearColor,TraceHitColor:FLinearColor,DrawTime:float):bool,FHitResult
|
||
|
local bHit, HitResult = KismetSystemLibrary.LineTraceSingleForObjects(WorldContextObject, Start, End, ObjectTypes, false, ActorsToIgnore, EDrawDebugTrace.None, nil, true, nil, nil, nil)
|
||
|
if bEnableClientDebug then
|
||
|
if TraceHitColorType == nil then
|
||
|
TraceHitColorType = TraceManager.EColorType.Red
|
||
|
end
|
||
|
if UGCGameSystem.IsServer() then
|
||
|
Start, End = VectorHelper.ToLuaTable(Start), VectorHelper.ToLuaTable(End)
|
||
|
UGCSendRPCSystem.ExeStaticLogic(nil, LogicConfig.ELogicType.TraceManager, "DrawDebugLine", Start, End, TraceHitColorType)
|
||
|
if bHit then
|
||
|
UGCSendRPCSystem.ExeStaticLogic(nil, LogicConfig.ELogicType.TraceManager, "DrawDebugSphere", VectorHelper.ToLuaTable(HitResult.ImpactPoint), 5, TraceManager.EColorType.Green)
|
||
|
end
|
||
|
else
|
||
|
TraceManager.DrawDebugLine(Start, End, TraceHitColorType)
|
||
|
if bHit then
|
||
|
TraceManager.DrawDebugSphere(HitResult.ImpactPoint, 5, TraceManager.EColorType.Green)
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
return bHit, HitResult
|
||
|
end
|
||
|
|
||
|
---@field SphereTraceSingleForObjects fun(WorldContextObject:UObject,Start:FVector,End:FVector,Radius:float,ObjectTypes:ULuaArrayHelper,ActorsToIgnore:ULuaArrayHelper,bEnableClientDebug:bool,TraceHitColorType:TraceManager.EColorType):bool,FHitResult
|
||
|
function TraceManager.SphereTraceSingleForObjects(WorldContextObject, Start, End, Radius, ObjectTypes, ActorsToIgnore, bEnableClientDebug, TraceHitColorType)
|
||
|
UGCLogSystem.Log("[TraceManager_SphereTraceSingleForObjects]")
|
||
|
---@field SphereTraceSingleForObjects fun(WorldContextObject:UObject,Start:FVector,End:FVector,Radius:float,ObjectTypes:ULuaArrayHelper,bTraceComplex:bool,ActorsToIgnore:ULuaArrayHelper,DrawDebugType:EDrawDebugTrace,OutHit:FHitResult,bIgnoreSelf:bool,TraceColor:FLinearColor,TraceHitColor:FLinearColor,DrawTime:float):bool,FHitResult
|
||
|
---@field SphereTraceSingleByProfile fun(WorldContextObject:UObject,Start:FVector,End:FVector,Radius:float,ProfileName:FName,bTraceComplex:bool,ActorsToIgnore:ULuaArrayHelper,DrawDebugType:EDrawDebugTrace,OutHit:FHitResult,bIgnoreSelf:bool,TraceColor:FLinearColor,TraceHitColor:FLinearColor,DrawTime:float):bool,FHitResult
|
||
|
---@field SphereTraceSingle fun(WorldContextObject:UObject,Start:FVector,End:FVector,Radius:float,TraceChannel:ETraceTypeQuery,bTraceComplex:bool,ActorsToIgnore:ULuaArrayHelper,DrawDebugType:EDrawDebugTrace,OutHit:FHitResult,bIgnoreSelf:bool,TraceColor:FLinearColor,TraceHitColor:FLinearColor,DrawTime:float):bool,FHitResult
|
||
|
-- {ETraceTypeQuery.TraceTypeQuery1}
|
||
|
-- local TarceTypes = {ETraceTypeQuery.TraceTypeQuery1, }
|
||
|
-- local bHit, HitResult = KismetSystemLibrary.SphereTraceSingle(WorldContextObject, Start, End, Radius, ETraceTypeQuery.TraceTypeQuery1, false, ActorsToIgnore, EDrawDebugTrace.None, nil, true, nil, nil, nil)
|
||
|
local bHit, HitResult = KismetSystemLibrary.SphereTraceSingleForObjects(WorldContextObject, Start, End, Radius, ObjectTypes, false, ActorsToIgnore, EDrawDebugTrace.None, nil, true, nil, nil, nil)
|
||
|
if bEnableClientDebug then
|
||
|
if TraceHitColorType == nil then
|
||
|
TraceHitColorType = TraceManager.EColorType.Yellow
|
||
|
end
|
||
|
if UGCGameSystem.IsServer() then
|
||
|
Start, End = VectorHelper.ToLuaTable(Start), VectorHelper.ToLuaTable(End)
|
||
|
UGCSendRPCSystem.ExeStaticLogic(nil, LogicConfig.ELogicType.TraceManager, "DrawDebugSphere", Start, Radius, TraceHitColorType)
|
||
|
UGCSendRPCSystem.ExeStaticLogic(nil, LogicConfig.ELogicType.TraceManager, "DrawDebugSphere", End, Radius, TraceHitColorType)
|
||
|
if bHit then
|
||
|
UGCSendRPCSystem.ExeStaticLogic(nil, LogicConfig.ELogicType.TraceManager, "DrawDebugSphere", VectorHelper.ToLuaTable(HitResult.Location), Radius, TraceManager.EColorType.Green)
|
||
|
end
|
||
|
else
|
||
|
TraceManager.DrawDebugSphere(Start, Radius, TraceHitColorType)
|
||
|
TraceManager.DrawDebugSphere(End, Radius, TraceHitColorType)
|
||
|
if bHit then
|
||
|
TraceManager.DrawDebugSphere(HitResult.Location, Radius, TraceManager.EColorType.Green)
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
return bHit, HitResult
|
||
|
end
|
||
|
|
||
|
--------------------------------------------------------- Draw ---------------------------------------------------------
|
||
|
|
||
|
function TraceManager.DrawDebugSphere(Center, Radius, ColorType)
|
||
|
STExtraGameplayStatics.ClientDrawDebugSphere(Center, Radius, 10, TraceManager.LineColors[ColorType], 10, 1)
|
||
|
end
|
||
|
|
||
|
|
||
|
function TraceManager.DrawDebugLine(Start, End, ColorType)
|
||
|
STExtraGameplayStatics.ClientDrawDebugLine(Start, End, TraceManager.LineColors[ColorType], 10, 1)
|
||
|
end
|
||
|
|
||
|
function TraceManager.DrawDebugBox(Center, Extent, Color, Rotation)
|
||
|
STExtraGameplayStatics.ClientDrawDebugBox(Center, Extent, Color, Rotation, 1, 2)
|
||
|
end
|
||
|
|
||
|
------------------------------------------------------- Draw End -------------------------------------------------------
|
||
|
|
||
|
return TraceManager
|