Merge branch 'method_rpc' into bepinex-upgrade

# Conflicts:
#	Reactor.Example/ExamplePlugin.cs
This commit is contained in:
js6pak committed 2021-10-24 01:34:12 +02:00
commit 534382a263
11 files changed
+563 -13

No files matched your search

+24 -6
View File
@@ -1,8 +1,12 @@
using System;
using BepInEx;
using BepInEx.IL2CPP;
using Reactor.Extensions;
using Reactor.Networking;
using Reactor.Networking.MethodRpc;
using UnhollowerBaseLib.Attributes;
using UnityEngine;
using Random = UnityEngine.Random;
namespace Reactor.Example
{
@@ -25,17 +29,31 @@ namespace Reactor.Example
private void Update()
{
if (Input.GetKeyDown(KeyCode.F3) && AmongUsClient.Instance && PlayerControl.LocalPlayer)
if (AmongUsClient.Instance && PlayerControl.LocalPlayer)
{
var name = PlayerControl.LocalPlayer.Data.PlayerName;
Rpc<ExampleRpc>.Instance.Send(new ExampleRpc.Data($"Send: from {name}"));
if (!AmongUsClient.Instance.AmHost)
if (Input.GetKeyDown(KeyCode.F3))
{
Rpc<ExampleRpc>.Instance.SendTo(AmongUsClient.Instance.HostId, new ExampleRpc.Data($"SendTo: from {name} to host"));
var name = PlayerControl.LocalPlayer.Data.PlayerName;
Rpc<ExampleRpc>.Instance.Send(new ExampleRpc.Data($"Send: from {name}"));
if (!AmongUsClient.Instance.AmHost)
{
Rpc<ExampleRpc>.Instance.SendTo(AmongUsClient.Instance.HostId, new ExampleRpc.Data($"SendTo: from {name} to host"));
}
}
if (Input.GetKeyDown(KeyCode.F4))
{
RpcSay(PlayerControl.LocalPlayer, "Hello from method rpc", Random.value, PlayerControl.LocalPlayer);
}
}
}
}
[MethodRpc((uint) CustomRpcCalls.MethodRpcExample)]
public static void RpcSay(PlayerControl player, string text, float number, PlayerControl testPlayer)
{
Logger<ExamplePlugin>.Info($"{player.Data.PlayerName} text: {text} number: {number} testPlayer: {testPlayer.NetId}");
}
}
}