mirror of
https://github.com/NuclearPowered/Reactor.git
synced 2026-10-19 15:51:54 +00:00
Add an Example
This commit is contained in:
1 parent
eb7fce3350
commit
63fdde22c6
5 files changed
+23
-8
No files matched your search
@@ -2,6 +2,7 @@ namespace Reactor.Example
|
||||
{
|
||||
public enum CustomRpcCalls : uint
|
||||
{
|
||||
Example
|
||||
Example,
|
||||
MethodRpcExample
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ using BepInEx;
|
||||
using BepInEx.IL2CPP;
|
||||
using Reactor.Extensions;
|
||||
using Reactor.Networking;
|
||||
using Reactor.Networking.MethodRpc;
|
||||
using UnhollowerBaseLib.Attributes;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -43,7 +44,18 @@ namespace Reactor.Example
|
||||
Rpc<ExampleRpc>.Instance.SendTo(AmongUsClient.Instance.HostId, new ExampleRpc.Data($"SendTo: from {name} to host"));
|
||||
}
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.F4) && AmongUsClient.Instance && PlayerControl.LocalPlayer)
|
||||
{
|
||||
RpcSay(PlayerControl.LocalPlayer, "Hello from method rpc");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[MethodRpc((uint) CustomRpcCalls.MethodRpcExample)]
|
||||
public static void RpcSay(PlayerControl sender, string text)
|
||||
{
|
||||
Logger<ExamplePlugin>.Info($"{sender.Data.PlayerName} said: {text}");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user