mirror of
https://github.com/NuclearPowered/Reactor.git
synced 2026-10-20 01:46:21 +00:00
Merge branch 'method_rpc' into bepinex-upgrade
# Conflicts: # Reactor.Example/ExamplePlugin.cs
This commit is contained in:
11 files changed
+563
-13
No files matched your search
@@ -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}");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user