Roflmuffin dont know how to code fix?
This commit is contained in:
parent
56c492ff9b
commit
8c3d3b1183
2 changed files with 59 additions and 53 deletions
|
|
@ -170,7 +170,15 @@ namespace RayTraceAPI
|
||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
public struct QAngle
|
public struct VectorNative
|
||||||
|
{
|
||||||
|
public float X;
|
||||||
|
public float Y;
|
||||||
|
public float Z;
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
public struct QAngleNative
|
||||||
{
|
{
|
||||||
public float X;
|
public float X;
|
||||||
public float Y;
|
public float Y;
|
||||||
|
|
@ -180,30 +188,9 @@ namespace RayTraceAPI
|
||||||
|
|
||||||
public interface CRayTraceInterface
|
public interface CRayTraceInterface
|
||||||
{
|
{
|
||||||
TraceResult TraceShape(
|
public TraceResult TraceShape(Vector start, QAngle angles, CEntityInstance ignore, TraceOptions options);
|
||||||
in Vector3 start,
|
public TraceResult TraceEndShape(Vector start, Vector end, CEntityInstance ignore, TraceOptions options);
|
||||||
in QAngle angles,
|
public TraceResult TraceHullShape(Vector start, Vector end, Vector mins, Vector maxs, CEntityInstance ignore, TraceOptions options);
|
||||||
CEntityInstance ignoreEntity,
|
public TraceResult TraceShapeEx(Vector start, Vector end, nint filter, nint ray);
|
||||||
in TraceOptions options);
|
|
||||||
|
|
||||||
TraceResult TraceEndShape(
|
|
||||||
in Vector3 start,
|
|
||||||
in Vector3 end,
|
|
||||||
CEntityInstance ignoreEntity,
|
|
||||||
in TraceOptions options);
|
|
||||||
|
|
||||||
TraceResult TraceHullShape(
|
|
||||||
in Vector3 start,
|
|
||||||
in Vector3 end,
|
|
||||||
in Vector3 mins,
|
|
||||||
in Vector3 maxs,
|
|
||||||
CEntityInstance ignoreEntity,
|
|
||||||
in TraceOptions options);
|
|
||||||
|
|
||||||
TraceResult TraceShapeEx(
|
|
||||||
in Vector3 start,
|
|
||||||
in Vector3 end,
|
|
||||||
nint traceFilter,
|
|
||||||
nint ray);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
// Created by Michal Přikryl on 10.10.2025.
|
// Created by Michal Přikryl on 10.10.2025.
|
||||||
// Copyright (c) 2025 slynxcz. All rights reserved.
|
// Copyright (c) 2025 slynxcz. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
using System.Buffers;
|
using System.Buffers;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
@ -19,7 +20,6 @@ using CounterStrikeSharp.API.Modules.Commands;
|
||||||
using CounterStrikeSharp.API.Modules.Memory;
|
using CounterStrikeSharp.API.Modules.Memory;
|
||||||
using CounterStrikeSharp.API.Modules.Utils;
|
using CounterStrikeSharp.API.Modules.Utils;
|
||||||
using RayTraceAPI;
|
using RayTraceAPI;
|
||||||
using QAngle = RayTraceAPI.QAngle;
|
|
||||||
using Vector = CounterStrikeSharp.API.Modules.Utils.Vector;
|
using Vector = CounterStrikeSharp.API.Modules.Utils.Vector;
|
||||||
|
|
||||||
namespace RayTraceImpl;
|
namespace RayTraceImpl;
|
||||||
|
|
@ -32,7 +32,8 @@ public class RayTraceImpl : BasePlugin
|
||||||
public override string ModuleVersion => "v1.0.0";
|
public override string ModuleVersion => "v1.0.0";
|
||||||
public override string ModuleAuthor => "Slynx";
|
public override string ModuleAuthor => "Slynx";
|
||||||
|
|
||||||
internal static PluginCapability<CRayTraceInterface> RayTraceInterface { get; } = new("raytrace:craytraceinterface");
|
internal static PluginCapability<CRayTraceInterface> RayTraceInterface { get; } =
|
||||||
|
new("raytrace:craytraceinterface");
|
||||||
|
|
||||||
public override void Load(bool hotReload)
|
public override void Load(bool hotReload)
|
||||||
{
|
{
|
||||||
|
|
@ -52,76 +53,94 @@ public class RayTraceImpl : BasePlugin
|
||||||
Prints.ServerLog("[RayTraceImpl] Native bridge initialization failed.", ConsoleColor.Red);
|
Prints.ServerLog("[RayTraceImpl] Native bridge initialization failed.", ConsoleColor.Red);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Prints.ServerLog("[RayTraceImpl] Managed side initialized.", ConsoleColor.Green);
|
Prints.ServerLog("[RayTraceImpl] Managed side initialized.", ConsoleColor.Green);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class CRayTrace : CRayTraceInterface
|
public class CRayTrace : CRayTraceInterface
|
||||||
{
|
{
|
||||||
public TraceResult TraceShape(in Vector3 start, in QAngle angles, CEntityInstance ignore, in TraceOptions options)
|
public TraceResult TraceShape(Vector start, QAngle angles, CEntityInstance ignore, TraceOptions options)
|
||||||
{
|
{
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
if (!NativeBridge.Loaded)
|
if (!NativeBridge.Loaded)
|
||||||
return default;
|
return default;
|
||||||
|
|
||||||
|
VectorNative startNative = new() { X = start.X, Y = start.Y, Z = start.Z };
|
||||||
|
QAngleNative angNative = new() { X = angles.X, Y = angles.Y, Z = angles.Z };
|
||||||
|
TraceOptions optCopy = options;
|
||||||
|
|
||||||
return NativeBridge.TraceShape!(
|
return NativeBridge.TraceShape!(
|
||||||
NativeBridge.Handle,
|
NativeBridge.Handle,
|
||||||
start,
|
(nint)(&startNative),
|
||||||
angles,
|
(nint)(&angNative),
|
||||||
ignore.Handle,
|
ignore.Handle,
|
||||||
(nint)Unsafe.AsPointer(ref Unsafe.AsRef(in options))
|
(nint)(&optCopy)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public TraceResult TraceEndShape(in Vector3 start, in Vector3 end, CEntityInstance ignore, in TraceOptions options)
|
public TraceResult TraceEndShape(Vector start, Vector end, CEntityInstance ignore, TraceOptions options)
|
||||||
{
|
{
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
if (!NativeBridge.Loaded)
|
if (!NativeBridge.Loaded)
|
||||||
return default;
|
return default;
|
||||||
|
|
||||||
|
VectorNative s = new() { X = start.X, Y = start.Y, Z = start.Z };
|
||||||
|
VectorNative e = new() { X = end.X, Y = end.Y, Z = end.Z };
|
||||||
|
TraceOptions opt = options;
|
||||||
|
|
||||||
return NativeBridge.TraceEndShape!(
|
return NativeBridge.TraceEndShape!(
|
||||||
NativeBridge.Handle,
|
NativeBridge.Handle,
|
||||||
start,
|
(nint)(&s),
|
||||||
end,
|
(nint)(&e),
|
||||||
ignore.Handle,
|
ignore.Handle,
|
||||||
(nint)Unsafe.AsPointer(ref Unsafe.AsRef(in options))
|
(nint)(&opt)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public TraceResult TraceHullShape(in Vector3 start, in Vector3 end, in Vector3 mins, in Vector3 maxs, CEntityInstance ignore, in TraceOptions options)
|
public TraceResult TraceHullShape(Vector start, Vector end, Vector mins, Vector maxs, CEntityInstance ignore, TraceOptions options)
|
||||||
{
|
{
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
if (!NativeBridge.Loaded)
|
if (!NativeBridge.Loaded)
|
||||||
return default;
|
return default;
|
||||||
|
|
||||||
|
VectorNative s = new() { X = start.X, Y = start.Y, Z = start.Z };
|
||||||
|
VectorNative e = new() { X = end.X, Y = end.Y, Z = end.Z };
|
||||||
|
VectorNative mi = new() { X = mins.X, Y = mins.Y, Z = mins.Z };
|
||||||
|
VectorNative ma = new() { X = maxs.X, Y = maxs.Y, Z = maxs.Z };
|
||||||
|
TraceOptions opt = options;
|
||||||
|
|
||||||
return NativeBridge.TraceHullShape!(
|
return NativeBridge.TraceHullShape!(
|
||||||
NativeBridge.Handle,
|
NativeBridge.Handle,
|
||||||
start,
|
(nint)(&s),
|
||||||
end,
|
(nint)(&e),
|
||||||
mins,
|
(nint)(&mi),
|
||||||
maxs,
|
(nint)(&ma),
|
||||||
ignore.Handle,
|
ignore.Handle,
|
||||||
(nint)Unsafe.AsPointer(ref Unsafe.AsRef(in options))
|
(nint)(&opt)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public TraceResult TraceShapeEx(in Vector3 start, in Vector3 end, nint filter, nint ray)
|
public TraceResult TraceShapeEx(Vector start, Vector end, nint filter, nint ray)
|
||||||
{
|
{
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
if (!NativeBridge.Loaded)
|
if (!NativeBridge.Loaded)
|
||||||
return default;
|
return default;
|
||||||
|
|
||||||
|
VectorNative s = new() { X = start.X, Y = start.Y, Z = start.Z };
|
||||||
|
VectorNative e = new() { X = end.X, Y = end.Y, Z = end.Z };
|
||||||
|
|
||||||
return NativeBridge.TraceShapeEx!(
|
return NativeBridge.TraceShapeEx!(
|
||||||
NativeBridge.Handle,
|
NativeBridge.Handle,
|
||||||
start,
|
(nint)(&s),
|
||||||
end,
|
(nint)(&e),
|
||||||
filter,
|
filter,
|
||||||
ray
|
ray
|
||||||
);
|
);
|
||||||
|
|
@ -134,10 +153,10 @@ public static class NativeBridge
|
||||||
public static nint Handle;
|
public static nint Handle;
|
||||||
public static bool Loaded;
|
public static bool Loaded;
|
||||||
|
|
||||||
public static Func<nint, Vector3, QAngle, nint, nint, TraceResult>? TraceShape;
|
public static unsafe Func<nint, nint, nint, nint, nint, TraceResult>? TraceShape;
|
||||||
public static Func<nint, Vector3, Vector3, nint, nint, TraceResult>? TraceEndShape;
|
public static unsafe Func<nint, nint, nint, nint, nint, TraceResult>? TraceEndShape;
|
||||||
public static Func<nint, Vector3, Vector3, Vector3, Vector3, nint, nint, TraceResult>? TraceHullShape;
|
public static unsafe Func<nint, nint, nint, nint, nint, nint, nint, TraceResult>? TraceHullShape;
|
||||||
public static Func<nint, Vector3, Vector3, nint, nint, TraceResult>? TraceShapeEx;
|
public static unsafe Func<nint, nint, nint, nint, nint, TraceResult>? TraceShapeEx;
|
||||||
|
|
||||||
public static bool Initialize()
|
public static bool Initialize()
|
||||||
{
|
{
|
||||||
|
|
@ -170,10 +189,10 @@ public static class NativeBridge
|
||||||
ex = 5;
|
ex = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
TraceShape = VirtualFunction.Create<nint, Vector3, QAngle, nint, nint, TraceResult>(Handle, shape);
|
TraceShape = VirtualFunction.Create<nint, nint, nint, nint, nint, TraceResult>(Handle, shape);
|
||||||
TraceEndShape = VirtualFunction.Create<nint, Vector3, Vector3, nint, nint, TraceResult>(Handle, end);
|
TraceEndShape = VirtualFunction.Create<nint, nint, nint, nint, nint, TraceResult>(Handle, end);
|
||||||
TraceHullShape = VirtualFunction.Create<nint, Vector3, Vector3, Vector3, Vector3, nint, nint, TraceResult>(Handle, hull);
|
TraceHullShape = VirtualFunction.Create<nint, nint, nint, nint, nint, nint, nint, TraceResult>(Handle, hull);
|
||||||
TraceShapeEx = VirtualFunction.Create<nint, Vector3, Vector3, nint, nint, TraceResult>(Handle, ex);
|
TraceShapeEx = VirtualFunction.Create<nint, nint, nint, nint, nint, TraceResult>(Handle, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue