Add an Example

This commit is contained in:
Zirno authored and js6pak committed 2021-07-26 17:07:57 +02:00
1 parent eb7fce3350
commit 63fdde22c6
5 files changed
+23 -8

No files matched your search

+2 -1
View File
@@ -2,6 +2,7 @@ namespace Reactor.Example
{
public enum CustomRpcCalls : uint
{
Example
Example,
MethodRpcExample
}
}
+12
View File
@@ -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}");
}
}
}