From bc30ceeb3347dc1f823a30da6204f673674d0ef8 Mon Sep 17 00:00:00 2001 From: Galster-dev <46283010+Galster-dev@users.noreply.github.com> Date: Tue, 13 Apr 2021 22:36:08 +0300 Subject: [PATCH] fix invisible dummies (#21) --- Reactor.Debugger/DebuggerPlugin.cs | 5 ++++- Reactor/Patches/PlayerIdPatch.cs | 26 ++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 Reactor/Patches/PlayerIdPatch.cs diff --git a/Reactor.Debugger/DebuggerPlugin.cs b/Reactor.Debugger/DebuggerPlugin.cs index 36dc0df..f81a9d2 100644 --- a/Reactor.Debugger/DebuggerPlugin.cs +++ b/Reactor.Debugger/DebuggerPlugin.cs @@ -66,8 +66,11 @@ namespace Reactor.Debugger playerControl.transform.position = PlayerControl.LocalPlayer.transform.position; playerControl.GetComponent().enabled = true; playerControl.NetTransform.enabled = false; - playerControl.SetName("Dummy " + (i + 1)); + playerControl.SetName($"{TranslationController.Instance.GetString(StringNames.Dummy, Array.Empty())} {i}"); playerControl.SetColor((byte) (i % Palette.PlayerColors.Length)); + playerControl.SetHat(i % (uint)HatManager.Instance.AllHats.Count, playerControl.Data.ColorId); + playerControl.SetPet(i % (uint)HatManager.Instance.AllPets.Count); + playerControl.SetSkin(i % (uint)HatManager.Instance.AllSkins.Count); GameData.Instance.RpcSetTasks(playerControl.PlayerId, new byte[0]); } diff --git a/Reactor/Patches/PlayerIdPatch.cs b/Reactor/Patches/PlayerIdPatch.cs new file mode 100644 index 0000000..c56f1f4 --- /dev/null +++ b/Reactor/Patches/PlayerIdPatch.cs @@ -0,0 +1,26 @@ +using System.Linq; +using HarmonyLib; + +namespace Reactor.Patches +{ + internal static class PlayerIdPatch + { + [HarmonyPatch(typeof(GameData), nameof(GameData.GetAvailableId))] + public static class GetAvailableIdPatch + { + public static bool Prefix(GameData __instance, out sbyte __result) + { + sbyte i = 0; + + while (__instance.AllPlayers.ToArray().Any(p => p.PlayerId == i)) + { + i++; + } + + __result = i; + + return false; + } + } + } +}