-
Notifications
You must be signed in to change notification settings - Fork 0
/
PlayerObjectInterceptPatch.cs
59 lines (52 loc) · 1.97 KB
/
PlayerObjectInterceptPatch.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using HarmonyLib;
using QSB.Player.TransformSync;
using QSB.PlayerBodySetup.Remote;
using System;
using System.Reflection;
using UnityEngine;
namespace QSBFPS;
[HarmonyPatch]
public class PlayerObjectInterceptPatch : MonoBehaviour
{
[HarmonyPrefix]
[HarmonyPatch(typeof(PlayerTransformSync), "InitRemoteTransform")]
public static bool PlayerTransformSync_InitRemoteTransform_Prefix(PlayerTransformSync __instance, ref Transform __result)
{
FieldInfo[] field;
Type classType = typeof(PlayerTransformSync);
field = classType.GetFields(BindingFlags.NonPublic | BindingFlags.Instance);
Transform _visibleCameraRoot;
Transform _visibleRoastingSystem; ;
Transform _visibleStickPivot;
Transform _visibleStickTip;
Transform playerTransform = RemotePlayerCreation.CreatePlayer(
__instance.Player,
out _visibleCameraRoot,
out _visibleRoastingSystem,
out _visibleStickPivot,
out _visibleStickTip);
for (int i = 0; i < field.Length; i++)
{
if (field[i].Name == "_visibleCameraRoot")
{
field[i].SetValue(__instance, _visibleCameraRoot);
}
else if (field[i].Name == "_visibleRoastingSystem")
{
field[i].SetValue(__instance, _visibleRoastingSystem);
}
else if (field[i].Name == "_visibleStickPivot")
{
field[i].SetValue(__instance, _visibleStickPivot);
}
else if (field[i].Name == "_visibleStickTip")
{
field[i].SetValue(__instance, _visibleStickTip);
}
}
qsbFPS.Instance.idToGameObjects.Add(__instance.Player.PlayerId, playerTransform.gameObject);
qsbFPS.Instance.ModHelper.Console.WriteLine($"ID-Object pair: {__instance.Player.PlayerId}, {playerTransform.gameObject}");
__result = playerTransform;
return false;
}
}