NAK_CVR_Mods/AvatarScale/Networking/ModNetworkDebugger.cs
NotAKidoS c7eb5715ba [AvatarScaleMod] Test 2: Height Request
Now requests initial height on instance join instead of syncing every 10s.
Reworked inbould & outbound message queue.
Fixed potential race condition where scalefactor could become 0.

A lot of this is still incredibly jank. Just trying to get things working before cleanup.
2023-09-20 20:26:38 -05:00

49 lines
No EOL
1.9 KiB
C#

using NAK.AvatarScaleMod.AvatarScaling;
using UnityEngine;
namespace NAK.AvatarScaleMod.Networking;
public static class ModNetworkDebugger
{
public static void DoDebugInput()
{
// if (NetworkManager.Instance == null || NetworkManager.Instance.GameNetwork.ConnectionState != ConnectionState.Connected)
// {
// MelonLogger.Warning("Attempted to send a game network message without being connected to an online instance...");
// return;
// }
if (AvatarScaleManager.Instance == null)
return;
float currentHeight;
const float step = 0.1f;
if (Input.GetKeyDown(KeyCode.Equals) || Input.GetKeyDown(KeyCode.KeypadPlus))
{
currentHeight = AvatarScaleManager.Instance.GetHeight();
AvatarScaleManager.Instance.SetHeight(currentHeight + step);
currentHeight = AvatarScaleManager.Instance.GetHeight();
ModNetwork.SendNetworkHeight(currentHeight);
AvatarScaleMod.Logger.Msg($"Networking height: {currentHeight}");
}
else if (Input.GetKeyDown(KeyCode.Minus) || Input.GetKeyDown(KeyCode.KeypadMinus))
{
currentHeight = AvatarScaleManager.Instance.GetHeight();
AvatarScaleManager.Instance.SetHeight(currentHeight - step);
currentHeight = AvatarScaleManager.Instance.GetHeight();
ModNetwork.SendNetworkHeight(currentHeight);
AvatarScaleMod.Logger.Msg($"Networking height: {currentHeight}");
}
else if (Input.GetKeyDown(KeyCode.Backspace))
{
AvatarScaleManager.Instance.ResetHeight();
currentHeight = AvatarScaleManager.Instance.GetHeight();
AvatarScaleMod.Logger.Msg($"Networking height: {currentHeight}");
ModNetwork.SendNetworkHeight(currentHeight);
}
}
}