Skip to content

Commit 45d16a5

Browse files
committed
feat(dotnet): Managed Interface
1 parent 1b54da7 commit 45d16a5

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

managed/PlayerUtils.cs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using SwiftlyS2.Internal_API;
2+
3+
namespace SwiftlyS2.API.Extensions
4+
{
5+
public class PlayerUtils
6+
{
7+
private static IntPtr _ctx = IntPtr.Zero;
8+
9+
private static void InitializeContext()
10+
{
11+
if (_ctx != IntPtr.Zero) return;
12+
_ctx = Invoker.CallNative<IntPtr>("PlayerUtils", "PlayerUtils", CallKind.ClassFunction);
13+
}
14+
15+
public static void SetBunnyhop(int playerid, bool state)
16+
{
17+
InitializeContext();
18+
Invoker.CallNative("PlayerUtils", "SetBunnyhop", CallKind.ClassFunction, _ctx, playerid, state);
19+
}
20+
21+
public static bool IsListeningToGameEvent(int playerid, string game_event)
22+
{
23+
InitializeContext();
24+
return Invoker.CallNative<bool>("PlayerUtils", "IsListeningToGameEvent", CallKind.ClassFunction, _ctx, playerid, game_event);
25+
}
26+
27+
public static bool GetBunnyhop(int playerid)
28+
{
29+
InitializeContext();
30+
return Invoker.CallNative<bool>("PlayerUtils", "GetBunnyhop", CallKind.ClassFunction, _ctx, playerid);
31+
}
32+
}
33+
}

src/entrypoint.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ bool UtilsExtension::OnPluginLoad(std::string pluginName, void* pluginState, Plu
129129

130130
ADD_CLASS("PlayerUtils");
131131

132+
ADD_CLASS_FUNCTION("PlayerUtils", "PlayerUtils", [](FunctionContext* context, ClassData* data) -> void {});
133+
132134
#ifndef _WIN32
133135
ADD_CLASS_FUNCTION("PlayerUtils", "SetBunnyhop", [](FunctionContext* context, ClassData* data) -> void {
134136
int playerid = context->GetArgumentOr<int>(0, -1);

0 commit comments

Comments
 (0)