Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of NetworkingReworked v0.2.2
NetworkingReworked.dll
Decompiled a year ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using HarmonyLib; using NetworkingRework.Utils; using NetworkingReworked.Physics; using Photon.Pun; using Photon.Realtime; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("NetworkingReworked")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("NetworkingReworked")] [assembly: AssemblyCopyright("Copyright © 2025")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("b7ec27b9-952f-42af-894e-fa3d7b78e44b")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] internal static class FakeOwnershipData { private static readonly HashSet<int> simulatedViewIDs = new HashSet<int>(); private static readonly Dictionary<int, bool> locallyGrabbedViews = new Dictionary<int, bool>(); private static readonly Dictionary<int, bool> networkGrabbedViews = new Dictionary<int, bool>(); private static readonly Dictionary<int, int> grabCounts = new Dictionary<int, int>(); private static readonly Dictionary<int, float> recentlyThrown = new Dictionary<int, float>(); private static readonly HashSet<int> itemsInCart = new HashSet<int>(); private static readonly Dictionary<int, int> itemToCartMap = new Dictionary<int, int>(); private static Dictionary<int, object[]> cachedStreamData = new Dictionary<int, object[]>(); public static void AddItemToCart(PhotonView itemView, PhotonView cartView) { if (!itemToCartMap.ContainsKey(itemView.ViewID)) { itemToCartMap.Add(itemView.ViewID, cartView.ViewID); itemsInCart.Add(itemView.ViewID); } } public static void RemoveItemFromCart(PhotonView photonView) { itemToCartMap.Remove(photonView.ViewID); itemsInCart.Remove(photonView.ViewID); } public static bool IsItemInCart(PhotonView photonView) { return itemsInCart.Contains(photonView.ViewID); } public static int GetCartHoldingItem(PhotonView photonView) { int viewID = photonView.ViewID; if (itemsInCart.Contains(viewID)) { return itemToCartMap[viewID]; } return -1; } public static void ClearItemsInCart() { itemsInCart.Clear(); } public static void SimulateOwnership(PhotonView view) { if (!((Object)(object)view == (Object)null)) { simulatedViewIDs.Add(view.ViewID); } } public static void RemoveSimulatedOwnership(PhotonView view) { if (!((Object)(object)view == (Object)null)) { simulatedViewIDs.Remove(view.ViewID); } } public static bool IsSimulated(PhotonView view) { return (Object)(object)view != (Object)null && simulatedViewIDs.Contains(view.ViewID); } public static void SetLocallyGrabbed(PhotonView view, bool isGrabbed) { if (!((Object)(object)view == (Object)null)) { locallyGrabbedViews[view.ViewID] = isGrabbed; } } public static void SetNetworkGrabbed(PhotonView view) { if (!((Object)(object)view == (Object)null)) { int viewID = view.ViewID; networkGrabbedViews[viewID] = true; } } public static void ReleaseNetworkGrab(int id) { networkGrabbedViews[id] = false; } public static bool IsNetworkGrabbed(int photonViewID) { bool value; return networkGrabbedViews.TryGetValue(photonViewID, out value) && value; } public static bool IsLocallyGrabbed(PhotonView view) { bool value = default(bool); return (Object)(object)view != (Object)null && locallyGrabbedViews.TryGetValue(view.ViewID, out value) && value; } public static void SetRecentlyThrown(PhotonView view) { recentlyThrown.Remove(view.ViewID); recentlyThrown.Add(view.ViewID, Time.time); } public static float HowLongAgoThrown(PhotonView view) { if ((Object)(object)view == (Object)null) { return -1f; } if (recentlyThrown.TryGetValue(view.ViewID, out var value)) { return Time.time - value; } return -1f; } public static void AddGrabber(PhotonView view) { if (!((Object)(object)view == (Object)null)) { int viewID = view.ViewID; if (!grabCounts.ContainsKey(viewID)) { grabCounts[viewID] = 1; } else { grabCounts[viewID]++; } } } public static void RemoveGrabber(PhotonView view) { if ((Object)(object)view == (Object)null) { return; } int viewID = view.ViewID; if (grabCounts.ContainsKey(viewID)) { grabCounts[viewID]--; if (grabCounts[viewID] <= 0) { grabCounts.Remove(viewID); } } } public static bool IsGrabbed(PhotonView view) { int value; return (Object)(object)view != (Object)null && grabCounts.TryGetValue(view.ViewID, out value) && value > 0; } public static void ClearItem(PhotonView view) { simulatedViewIDs.Remove(view.ViewID); grabCounts.Remove(view.ViewID); locallyGrabbedViews.Remove(view.ViewID); recentlyThrown.Remove(view.ViewID); itemsInCart.Remove(view.ViewID); itemToCartMap.Remove(view.ViewID); } public static void ClearAll() { simulatedViewIDs.Clear(); grabCounts.Clear(); locallyGrabbedViews.Clear(); recentlyThrown.Clear(); itemsInCart.Clear(); } public static void ClearGrabStates() { grabCounts.Clear(); locallyGrabbedViews.Clear(); } public static void Store(int viewID, object[] data) { cachedStreamData[viewID] = data; } public static object[] Get(int viewID) { cachedStreamData.TryGetValue(viewID, out var value); return value; } public static PhotonStream ReconstructReadStream(int viewID) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown object[] array = Get(viewID); if (array == null) { return null; } object[] array2 = new object[array.Length - 3]; Array.Copy(array, 3, array2, 0, array2.Length); return new PhotonStream(false, array2); } } public static class PhotonStreamCache { public struct StreamState { public Vector3 position; public Quaternion rotation; public Vector3 velocity; public Vector3 angularVelocity; public float timestamp; } private static readonly Dictionary<int, StreamState> cache = new Dictionary<int, StreamState>(); public static void Update(int viewID, Vector3 pos, Quaternion rot, Vector3 vel, Vector3 angVel) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) cache[viewID] = new StreamState { position = pos, rotation = rot, velocity = vel, angularVelocity = angVel, timestamp = Time.time }; } public static void Update(int viewID, StreamState state) { state.timestamp = Time.time; cache[viewID] = state; } public static bool TryGet(int viewID, out StreamState state) { return cache.TryGetValue(viewID, out state); } public static void Clear() { cache.Clear(); } public static void Store(int viewID, object[] data) { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) if (data.Length >= 8) { if (data[0] is bool && data[1] is bool && data[2] is bool && data[3] is Vector3 && data[4] is Vector3 && data[5] is Vector3 && data[6] is Vector3 && data[7] is Quaternion) { Vector3 vel = (Vector3)data[3]; Vector3 angVel = (Vector3)data[4]; Vector3 pos = (Vector3)data[5]; Vector3 val = (Vector3)data[6]; Quaternion rot = (Quaternion)data[7]; Update(viewID, pos, rot, vel, angVel); } else if (data[0] is Vector3 && data[1] is Vector3 && data[2] is Vector3 && data[3] is Quaternion && data[4] is Vector3 && data[5] is Vector3 && data[6] is bool && data[7] is bool) { Vector3 vel2 = (Vector3)data[0]; Vector3 angVel2 = (Vector3)data[1]; Vector3 pos2 = (Vector3)data[2]; Quaternion rot2 = (Quaternion)data[3]; Update(viewID, pos2, rot2, vel2, angVel2); } } } } [RequireComponent(typeof(PhotonView), typeof(Rigidbody), typeof(PhysGrabObject))] public class FakeOwnershipController : MonoBehaviourPun { private PhotonView view; private Rigidbody rb; private PhysGrabObject physGrabObject; private PhysGrabCart cart; private bool isSoftSyncing = false; private void Awake() { view = ((Component)this).GetComponent<PhotonView>(); rb = ((Component)this).GetComponent<Rigidbody>(); physGrabObject = ((Component)this).GetComponent<PhysGrabObject>(); cart = ((Component)this).GetComponent<PhysGrabCart>(); if ((Object)(object)cart == (Object)null) { cart = ((Component)this).GetComponentInParent<PhysGrabCart>(); } } private void Start() { if (!PhotonNetwork.IsMasterClient && SemiFunc.IsMultiplayer()) { SimulateOwnership(); } } private void FixedUpdate() { if (!PhotonNetwork.IsMasterClient && SemiFunc.IsMultiplayer()) { CheckSteadyState(); if (FakeOwnershipData.IsLocallyGrabbed(view) && Object.op_Implicit((Object)(object)cart)) { UpdateItemsInCart(); } if (!FakeOwnershipData.IsLocallyGrabbed(view)) { ApplyPassiveSync(); } } } public void CheckSteadyState() { if ((Object)(object)view == (Object)null || (Object)(object)physGrabObject == (Object)null || !((Behaviour)physGrabObject).isActiveAndEnabled) { FakeOwnershipData.ClearItem(view); } } public void HardSync() { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) if (PhotonStreamCache.TryGet(view.ViewID, out var state) && !FakeOwnershipData.IsLocallyGrabbed(view)) { rb.position = state.position; rb.rotation = state.rotation; rb.velocity = state.velocity; rb.angularVelocity = state.angularVelocity; } } private void UpdateItemsInCart() { if ((Object)(object)cart == (Object)null) { return; } Traverse val = Traverse.Create((object)cart).Field("itemsInCart"); if (!(val.GetValue() is List<PhysGrabObject> list)) { return; } foreach (PhysGrabObject item in list) { PhotonView component = ((Component)item).GetComponent<PhotonView>(); if (!((Object)(object)component == (Object)null)) { FakeOwnershipData.AddItemToCart(component, ((MonoBehaviourPun)this).photonView); } } } private void ApplyPassiveSync() { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) if (!isSoftSyncing && PhotonStreamCache.TryGet(view.ViewID, out var state) && !FakeOwnershipData.IsLocallyGrabbed(view) && (!IsItemInCart() || !CartIsBeingHeld())) { rb.position = Vector3.Lerp(rb.position, state.position, 0.075f); rb.rotation = Quaternion.Slerp(rb.rotation, state.rotation, 0.075f); rb.velocity = Vector3.Lerp(rb.velocity, state.velocity, 0.075f); rb.angularVelocity = Vector3.Lerp(rb.angularVelocity, state.angularVelocity, 0.075f); } } private bool CartIsBeingHeld() { int cartHoldingItem = FakeOwnershipData.GetCartHoldingItem(((MonoBehaviourPun)this).photonView); if (cartHoldingItem <= 0) { return false; } return FakeOwnershipData.IsNetworkGrabbed(cartHoldingItem); } private bool IsItemInCart() { return FakeOwnershipData.IsItemInCart(view); } public void SimulateOwnership() { if (!((Object)(object)view == (Object)null)) { FakeOwnershipData.SimulateOwnership(view); PhysGrabHinge componentInParent = ((Component)this).GetComponentInParent<PhysGrabHinge>(); if (!((Object)(object)componentInParent != (Object)null)) { } } } public void SyncAfterRelease() { if (!((Object)(object)view == (Object)null)) { OverwriteStoredNetworkData(); if (!Object.op_Implicit((Object)(object)cart)) { HardSync(); } } } public void SlowSyncCartWithItems(float duration = 0.2f, float stagger = 0.02f) { if (!isSoftSyncing) { ((MonoBehaviour)this).StartCoroutine(SlowSyncCartRoutine(duration, stagger)); } } private IEnumerator SlowSyncCartRoutine(float duration, float stagger) { isSoftSyncing = true; if (!PhotonStreamCache.TryGet(view.ViewID, out var hostState)) { isSoftSyncing = false; yield break; } Vector3 startPos = rb.position; Quaternion startRot = rb.rotation; Vector3 startVel = rb.velocity; Vector3 startAngVel = rb.angularVelocity; for (float t = 0f; t < duration; t += Time.fixedDeltaTime) { float progress = t / duration; rb.position = Vector3.Lerp(startPos, hostState.position, progress); rb.rotation = Quaternion.Slerp(startRot, hostState.rotation, progress); rb.velocity = Vector3.Lerp(startVel, hostState.velocity, progress); rb.angularVelocity = Vector3.Lerp(startAngVel, hostState.angularVelocity, progress); yield return (object)new WaitForFixedUpdate(); } rb.position = hostState.position; rb.rotation = hostState.rotation; rb.velocity = hostState.velocity; rb.angularVelocity = hostState.angularVelocity; isSoftSyncing = false; if (!((Object)(object)cart != (Object)null)) { yield break; } Traverse itemsInCartField = Traverse.Create((object)cart).Field("itemsInCart"); if (!(itemsInCartField.GetValue() is List<PhysGrabObject> itemsInCart)) { yield break; } foreach (PhysGrabObject item in itemsInCart) { FakeOwnershipController controller = ((Component)item).GetComponent<FakeOwnershipController>(); if ((Object)(object)controller != (Object)null) { yield return (object)new WaitForSeconds(stagger); controller.SoftSyncOnly(duration * 0.8f); } } } public void SoftSyncOnly(float duration) { if (!isSoftSyncing) { ((MonoBehaviour)this).StartCoroutine(SoftSyncRoutine(duration)); } } private IEnumerator SoftSyncRoutine(float duration) { isSoftSyncing = true; if (!PhotonStreamCache.TryGet(view.ViewID, out var hostState)) { isSoftSyncing = false; yield break; } Vector3 startPos = rb.position; Quaternion startRot = rb.rotation; Vector3 startVel = rb.velocity; Vector3 startAngVel = rb.angularVelocity; for (float t = 0f; t < duration; t += Time.fixedDeltaTime) { float progress = t / duration; rb.position = Vector3.Lerp(startPos, hostState.position, progress); rb.rotation = Quaternion.Slerp(startRot, hostState.rotation, progress); rb.velocity = Vector3.Lerp(startVel, hostState.velocity, progress); rb.angularVelocity = Vector3.Lerp(startAngVel, hostState.angularVelocity, progress); yield return (object)new WaitForFixedUpdate(); } rb.position = hostState.position; rb.rotation = hostState.rotation; rb.velocity = hostState.velocity; rb.angularVelocity = hostState.angularVelocity; isSoftSyncing = false; } private void OverwriteStoredNetworkData() { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) PhotonTransformView ptv = ((Component)physGrabObject).GetComponent<PhotonTransformView>(); BindingFlags flags; Type viewType; if (!((Object)(object)ptv == (Object)null)) { flags = BindingFlags.Instance | BindingFlags.NonPublic; viewType = typeof(PhotonTransformView); Vector3 position = rb.position; Quaternion rotation = rb.rotation; SetField("m_StoredPosition", position); SetField("m_Direction", Vector3.zero); SetField("m_NetworkPosition", position); SetField("receivedPosition", position); SetField("prevPosition", position); SetField("m_NetworkRotation", rotation); SetField("receivedRotation", rotation); SetField("prevRotation", rotation); SetField("smoothedRotation", rotation); SetField("receivedVelocity", rb.velocity); SetField("receivedAngularVelocity", rb.angularVelocity); SetField("m_Distance", 0f); SetField("m_Angle", 0f); SetField("m_firstTake", false); SetField("teleport", false); } void SetField(string name, object value) { viewType.GetField(name, flags)?.SetValue(ptv, value); } } } [HarmonyPatch(typeof(PhysGrabObject), "GrabPlayerAddRPC")] public static class GrabAddHook { private static void Prefix(PhysGrabObject __instance, int photonViewID) { if (PhotonNetwork.IsMasterClient || !SemiFunc.IsMultiplayer()) { return; } PhotonView component = ((Component)__instance).GetComponent<PhotonView>(); if (!((Object)(object)component == (Object)null) && !BlockedItems.IsBlockedType(__instance)) { FakeOwnershipData.AddGrabber(component); FakeOwnershipData.SetNetworkGrabbed(component); if (PhotonNetwork.LocalPlayer.ActorNumber == PhotonNetwork.GetPhotonView(photonViewID).OwnerActorNr) { FakeOwnershipData.SetLocallyGrabbed(component, isGrabbed: true); FakeOwnershipData.SimulateOwnership(component); } } } } [HarmonyPatch(typeof(PhysGrabObject), "GrabPlayerRemoveRPC")] public static class GrabReleaseHook { private static void Prefix(PhysGrabObject __instance, int photonViewID) { if (PhotonNetwork.IsMasterClient || !SemiFunc.IsMultiplayer()) { return; } PhotonView component = ((Component)__instance).GetComponent<PhotonView>(); if ((Object)(object)component == (Object)null || BlockedItems.IsBlockedType(__instance)) { return; } FakeOwnershipData.RemoveGrabber(component); FakeOwnershipData.RemoveItemFromCart(component); if (PhotonNetwork.LocalPlayer.ActorNumber == PhotonNetwork.GetPhotonView(photonViewID).OwnerActorNr) { FakeOwnershipData.SetRecentlyThrown(component); FakeOwnershipData.SetLocallyGrabbed(component, isGrabbed: false); FakeOwnershipController component2 = ((Component)__instance).GetComponent<FakeOwnershipController>(); if (!((Object)(object)component2 != (Object)null)) { } } } } public static class SerializeReading { [HarmonyPatch(typeof(RunManager), "Awake")] public static class PatchTrigger { private static void Prefix() { FakeOwnershipData.ClearAll(); if (!PhotonNetwork.IsMasterClient && SemiFunc.IsMultiplayer() && !loadedOnce) { ApplyPatch(); loadedOnce = true; } } } private static readonly string HarmonyID = "com.ovchinikov.jank"; private static bool loadedOnce = false; public static void ApplyPatch() { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Expected O, but got Unknown MethodInfo methodInfo = AccessTools.Method(typeof(PhotonNetwork), "OnSerializeRead", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(SerializeReading), "OnPhotonSerializeRead_Prefix", (Type[])null, (Type[])null); if (!(methodInfo == null) && !(methodInfo2 == null)) { Harmony val = new Harmony(HarmonyID); val.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } private static void OnPhotonSerializeRead_Prefix(object[] data, Player sender, int networkTime, short correctPrefix) { if (data == null || data.Length != 15) { return; } object obj = data[0]; if (!(obj is int)) { return; } int viewID = (int)obj; if (true) { foreach (object obj2 in data) { } object[] array = new object[8]; if (data.Length >= 15 && data[7] is bool && data[8] is bool && data[9] is bool && data[10] is Vector3 && data[11] is Vector3 && data[12] is Vector3 && data[13] is Vector3 && data[14] is Quaternion) { Array.Copy(data, 7, array, 0, 8); PhotonStreamCache.Store(viewID, array); } } } private static PhysGrabHinge isHinge(int pID) { PhotonView photonView = PhotonNetwork.GetPhotonView(pID); if ((Object)(object)photonView == (Object)null) { return null; } PhysGrabObject componentInParent = ((Component)photonView).gameObject.GetComponentInParent<PhysGrabObject>(); if ((Object)(object)componentInParent == (Object)null) { return null; } PhysGrabHinge component = ((Component)componentInParent).GetComponent<PhysGrabHinge>(); if ((Object)(object)component != (Object)null) { return component; } return null; } } [HarmonyPatch(typeof(ItemMelee), "OnPhotonSerializeView")] public static class ItemMeleeSerializationPatch { private static bool Prefix(ItemMelee __instance, PhotonStream stream, PhotonMessageInfo info) { if (!SemiFunc.IsMultiplayer() || PhotonNetwork.IsMasterClient) { return true; } PhysGrabObject component = ((Component)__instance).GetComponent<PhysGrabObject>(); if ((Object)(object)component != (Object)null) { PhotonView component2 = ((Component)component).GetComponent<PhotonView>(); if (!component2.IsMine) { Traverse val = Traverse.Create((object)__instance).Field("isSwinging"); Traverse val2 = Traverse.Create((object)__instance).Field("newSwing"); bool value = val.GetValue<bool>(); if (stream.ReceiveNext() is bool flag) { val.SetValue((object)flag); } else { val.SetValue((object)false); } bool value2 = val.GetValue<bool>(); if (!value && value2) { val2.SetValue((object)true); __instance.ActivateHitbox(); } } } return false; } } [HarmonyPatch(typeof(PhotonView), "get_IsMine")] public static class PhotonView_IsMine_Postfix { public static void Postfix(PhotonView __instance, ref bool __result) { if (FakeOwnershipData.IsSimulated(__instance)) { __result = true; } } } [HarmonyPatch(typeof(PhysGrabObject), "OnPhotonSerializeView")] public static class PhysGrabObjectSerializationPatch { private static bool Prefix(PhysGrabObject __instance, PhotonStream stream, PhotonMessageInfo info) { //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) if (PhotonNetwork.IsMasterClient || !SemiFunc.IsMultiplayer()) { return true; } PhotonView component = ((Component)__instance).GetComponent<PhotonView>(); Traverse val = Traverse.Create((object)__instance).Field("rbVelocity"); Traverse val2 = Traverse.Create((object)__instance).Field("rbAngularVelocity"); Traverse val3 = Traverse.Create((object)__instance).Field("isKinematic"); Traverse val4 = Traverse.Create((object)__instance).Field("lastUpdateTime"); PhysGrabObjectImpactDetector component2 = ((Component)__instance).GetComponent<PhysGrabObjectImpactDetector>(); if ((Object)(object)component2 == (Object)null) { component2 = ((Component)__instance).GetComponent<PhysGrabObjectImpactDetector>(); Traverse.Create((object)__instance).Field("impactDetector").SetValue((object)component2); } try { if (stream.IsWriting && PhotonNetwork.IsMasterClient) { if ((Object)(object)__instance.rb == (Object)null) { __instance.rb = ((Component)__instance).GetComponent<Rigidbody>(); } stream.SendNext((object)val.GetValue<Vector3>()); stream.SendNext((object)val2.GetValue<Vector3>()); stream.SendNext((object)component2.isSliding); stream.SendNext((object)val3.GetValue<bool>()); } else if (!component.IsMine) { Vector3 val5 = (Vector3)stream.ReceiveNext(); Vector3 val6 = (Vector3)stream.ReceiveNext(); bool isSliding = (bool)stream.ReceiveNext(); bool flag = (bool)stream.ReceiveNext(); val.SetValue((object)val5); val2.SetValue((object)val6); component2.isSliding = isSliding; val3.SetValue((object)flag); val4.SetValue((object)Time.time); } } catch (Exception) { return true; } return false; } } [HarmonyPatch(typeof(PhysGrabObject), "GrabPlayerAddRPC")] public static class GrabPlayerAddRPC_Patch { [HarmonyPostfix] public static void Postfix(PhysGrabObject __instance, int photonViewID) { if (!SemiFunc.IsMultiplayer() || PhotonNetwork.IsMasterClient || BlockedItems.IsBlockedType(__instance)) { return; } FakeOwnershipController fakeOwnershipController = ((Component)__instance).GetComponent<FakeOwnershipController>(); if ((Object)(object)fakeOwnershipController == (Object)null) { fakeOwnershipController = ((Component)__instance).gameObject.AddComponent<FakeOwnershipController>(); } fakeOwnershipController.SimulateOwnership(); PhysGrabCart val = default(PhysGrabCart); CartOwnershipFixer cartOwnershipFixer = default(CartOwnershipFixer); if (!((Component)__instance).TryGetComponent<PhysGrabCart>(ref val) || !((Component)__instance).TryGetComponent<CartOwnershipFixer>(ref cartOwnershipFixer)) { return; } foreach (PhysGrabber item in __instance.playerGrabbing) { if (item.isLocal) { cartOwnershipFixer.FixInitialPressTimerRPC(item.photonView.ViewID); break; } } } } [HarmonyPatch(typeof(PhysGrabObjectGrabArea), "Update")] public static class PhysGrabObjectGrabArea_Update_Transpiler { private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Expected O, but got Unknown //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown Debug.Log((object)"[Transpiler] Patching PhysGrabObjectGrabArea.Update for IsMasterClient"); List<CodeInstruction> list = new List<CodeInstruction>(instructions); MethodInfo methodInfo = AccessTools.PropertyGetter(typeof(PhotonNetwork), "IsMasterClient"); MethodInfo methodInfo2 = AccessTools.Method(typeof(PhysGrabObjectGrabArea_Update_Transpiler), "GetIsMine", (Type[])null, (Type[])null); for (int i = 0; i < list.Count; i++) { if (CodeInstructionExtensions.Calls(list[i], methodInfo)) { Debug.Log((object)"[Transpiler] Found IsMasterClient check, replacing with GetIsMine(__instance)"); list[i] = new CodeInstruction(OpCodes.Ldarg_0, (object)null); list.Insert(i + 1, new CodeInstruction(OpCodes.Call, (object)methodInfo2)); i++; } } return list; } public static bool GetIsMine(PhysGrabObjectGrabArea area) { PhotonView val = default(PhotonView); if (((Component)area).TryGetComponent<PhotonView>(ref val)) { return val.IsMine; } PhotonView componentInParent = ((Component)area).GetComponentInParent<PhotonView>(); if (componentInParent != null) { return componentInParent.IsMine; } return false; } } [HarmonyPatch(typeof(PhysGrabCart), "Start")] public static class CartOwnershipFixer_Attacher { private static void Postfix(PhysGrabCart __instance) { CartOwnershipFixer cartOwnershipFixer = default(CartOwnershipFixer); if (!((Component)__instance).TryGetComponent<CartOwnershipFixer>(ref cartOwnershipFixer)) { CartOwnershipFixer cartOwnershipFixer2 = ((Component)__instance).gameObject.AddComponent<CartOwnershipFixer>(); cartOwnershipFixer2.cart = __instance; Debug.Log((object)("[CartOwnershipFixer] Attached to " + ((Object)__instance).name)); } } } public class CartOwnershipFixer : MonoBehaviourPun { public PhysGrabCart cart; private void Awake() { if ((Object)(object)cart == (Object)null) { cart = ((Component)this).GetComponent<PhysGrabCart>(); } } [PunRPC] public void FixInitialPressTimerRPC(int grabberViewID) { PhysGrabber val = FindGrabberByViewID(grabberViewID); if ((Object)(object)val != (Object)null) { val.initialPressTimer = 1f; Debug.Log((object)("[CartOwnershipFixer] initialPressTimer fixed to 0.1f for " + ((Object)val).name)); } } private PhysGrabber FindGrabberByViewID(int viewID) { foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { PhysGrabber componentInChildren = ((Component)item).GetComponentInChildren<PhysGrabber>(); if ((Object)(object)componentInChildren != (Object)null && componentInChildren.photonView.ViewID == viewID) { return componentInChildren; } } return null; } } [HarmonyPatch(typeof(PhysGrabCart), "FixedUpdate")] public static class PhysGrabCart_FixedUpdate_Transpiler { private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(instructions); MethodInfo methodInfo = AccessTools.PropertyGetter(typeof(PhotonNetwork), "IsMasterClient"); for (int i = 0; i < list.Count; i++) { if (CodeInstructionExtensions.Calls(list[i], methodInfo)) { list[i] = new CodeInstruction(OpCodes.Ldarg_0, (object)null); list.Insert(i + 1, new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(PhysGrabCart_CommonHelpers), "GetIsMineOrSingleplayer", (Type[])null, (Type[])null))); i++; } } return list; } } [HarmonyPatch(typeof(PhysGrabCart), "SmallCartLogic")] public static class PhysGrabCart_SmallCartLogic_Transpiler { private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Expected O, but got Unknown //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(instructions); MethodInfo methodInfo = AccessTools.Method(typeof(SemiFunc), "IsMasterClientOrSingleplayer", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(PhysGrabCart_SmallCartLogic_Transpiler), "GetIsMineOrSingleplayer", (Type[])null, (Type[])null); if (methodInfo == null) { Debug.LogError((object)"[Transpiler] Could not find SemiFunc.IsMasterClientOrSingleplayer"); return list; } for (int i = 0; i < list.Count; i++) { CodeInstruction val = list[i]; if (CodeInstructionExtensions.Calls(val, methodInfo)) { List<Label> labels = ((val.labels.Count > 0) ? new List<Label>(val.labels) : new List<Label>()); list[i] = new CodeInstruction(OpCodes.Ldarg_0, (object)null) { labels = labels }; list.Insert(i + 1, new CodeInstruction(OpCodes.Call, (object)methodInfo2)); i++; } } return list; } public static bool GetIsMineOrSingleplayer(PhysGrabCart cart) { PhotonView component = ((Component)cart).GetComponent<PhotonView>(); bool flag = !SemiFunc.IsMultiplayer(); return ((Object)(object)component != (Object)null && component.IsMine) || flag; } } [HarmonyPatch(typeof(PhysGrabCart), "Update")] public static class PhysGrabCart_Update_Transpiler { private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(instructions); MethodInfo methodInfo = AccessTools.Method(typeof(SemiFunc), "IsMasterClientOrSingleplayer", (Type[])null, (Type[])null); for (int i = 0; i < list.Count; i++) { if (CodeInstructionExtensions.Calls(list[i], methodInfo)) { list[i] = new CodeInstruction(OpCodes.Ldarg_0, (object)null); list.Insert(i + 1, new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(PhysGrabCart_CommonHelpers), "GetIsMineOrSingleplayer", (Type[])null, (Type[])null))); i++; } } return list; } } public static class PhysGrabCart_CommonHelpers { public static bool GetIsMineOrSingleplayer(PhysGrabCart cart) { PhotonView component = ((Component)cart).GetComponent<PhotonView>(); bool flag = !SemiFunc.IsMultiplayer(); return ((Object)(object)component != (Object)null && component.IsMine) || flag; } } [HarmonyPatch(typeof(PhysGrabCart), "CartSteer")] public static class PhysGrabCart_CartSteer_Transpiler { private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(instructions); MethodInfo methodInfo = AccessTools.Method(typeof(SemiFunc), "IsMasterClientOrSingleplayer", (Type[])null, (Type[])null); for (int i = 0; i < list.Count - 1; i++) { if (CodeInstructionExtensions.Calls(list[i], methodInfo)) { list[i] = new CodeInstruction(OpCodes.Ldarg_0, (object)null); list.Insert(i + 1, new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(PhysGrabCart_CartSteer_Transpiler), "GetIsMineOrSingleplayer", (Type[])null, (Type[])null))); i++; } } return list; } public static bool GetIsMineOrSingleplayer(PhysGrabCart cart) { PhotonView component = ((Component)cart).GetComponent<PhotonView>(); bool flag = !SemiFunc.IsMultiplayer(); return ((Object)(object)component != (Object)null && component.IsMine) || flag; } } [HarmonyPatch(typeof(PhysGrabHinge), "FixedUpdate")] public static class PhysGrabHinge_FixedUpdatePatch { [HarmonyPrefix] public static bool Prefix(PhysGrabHinge __instance) { //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_033b: Unknown result type (might be due to invalid IL or missing references) //IL_0340: Unknown result type (might be due to invalid IL or missing references) //IL_034a: Unknown result type (might be due to invalid IL or missing references) //IL_034f: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_02f1: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Unknown result type (might be due to invalid IL or missing references) //IL_02f8: Unknown result type (might be due to invalid IL or missing references) //IL_02fd: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_0310: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_031e: Unknown result type (might be due to invalid IL or missing references) //IL_02ca: Unknown result type (might be due to invalid IL or missing references) //IL_035f: Unknown result type (might be due to invalid IL or missing references) //IL_0364: Unknown result type (might be due to invalid IL or missing references) //IL_0359: Unknown result type (might be due to invalid IL or missing references) //IL_035b: Unknown result type (might be due to invalid IL or missing references) //IL_032d: Unknown result type (might be due to invalid IL or missing references) //IL_03b3: Unknown result type (might be due to invalid IL or missing references) //IL_03b8: Unknown result type (might be due to invalid IL or missing references) //IL_03bc: Unknown result type (might be due to invalid IL or missing references) //IL_03c3: Unknown result type (might be due to invalid IL or missing references) //IL_03c8: Unknown result type (might be due to invalid IL or missing references) //IL_03d4: Unknown result type (might be due to invalid IL or missing references) //IL_03d9: Unknown result type (might be due to invalid IL or missing references) //IL_03dd: Unknown result type (might be due to invalid IL or missing references) //IL_03ef: Unknown result type (might be due to invalid IL or missing references) //IL_03f4: Unknown result type (might be due to invalid IL or missing references) //IL_0373: Unknown result type (might be due to invalid IL or missing references) //IL_049c: Unknown result type (might be due to invalid IL or missing references) //IL_04a7: Unknown result type (might be due to invalid IL or missing references) //IL_04ac: Unknown result type (might be due to invalid IL or missing references) //IL_04b0: Unknown result type (might be due to invalid IL or missing references) //IL_04b5: Unknown result type (might be due to invalid IL or missing references) //IL_04ba: Unknown result type (might be due to invalid IL or missing references) //IL_04bc: Unknown result type (might be due to invalid IL or missing references) //IL_04c0: Unknown result type (might be due to invalid IL or missing references) //IL_04c5: Unknown result type (might be due to invalid IL or missing references) //IL_04cd: Unknown result type (might be due to invalid IL or missing references) //IL_056f: Unknown result type (might be due to invalid IL or missing references) //IL_0574: Unknown result type (might be due to invalid IL or missing references) //IL_044b: Unknown result type (might be due to invalid IL or missing references) //IL_0450: Unknown result type (might be due to invalid IL or missing references) //IL_0420: Unknown result type (might be due to invalid IL or missing references) //IL_0425: Unknown result type (might be due to invalid IL or missing references) //IL_06ec: Unknown result type (might be due to invalid IL or missing references) //IL_06f1: Unknown result type (might be due to invalid IL or missing references) //IL_0644: Unknown result type (might be due to invalid IL or missing references) //IL_0649: Unknown result type (might be due to invalid IL or missing references) //IL_05ad: Unknown result type (might be due to invalid IL or missing references) //IL_05b2: Unknown result type (might be due to invalid IL or missing references) //IL_05c1: Unknown result type (might be due to invalid IL or missing references) //IL_05c6: Unknown result type (might be due to invalid IL or missing references) //IL_05e0: Unknown result type (might be due to invalid IL or missing references) //IL_05ee: Unknown result type (might be due to invalid IL or missing references) //IL_05fc: Unknown result type (might be due to invalid IL or missing references) //IL_060d: Unknown result type (might be due to invalid IL or missing references) //IL_07f3: Unknown result type (might be due to invalid IL or missing references) //IL_06e4: Unknown result type (might be due to invalid IL or missing references) //IL_06e6: Unknown result type (might be due to invalid IL or missing references) //IL_068e: Unknown result type (might be due to invalid IL or missing references) //IL_0693: Unknown result type (might be due to invalid IL or missing references) //IL_0698: Unknown result type (might be due to invalid IL or missing references) //IL_06a4: Unknown result type (might be due to invalid IL or missing references) //IL_06a6: Unknown result type (might be due to invalid IL or missing references) //IL_06a8: Unknown result type (might be due to invalid IL or missing references) //IL_06aa: Unknown result type (might be due to invalid IL or missing references) //IL_06ac: Unknown result type (might be due to invalid IL or missing references) //IL_06bf: Expected I4, but got Unknown if (!SemiFunc.IsMultiplayer()) { return true; } PhysGrabObject componentInParent = ((Component)__instance).GetComponentInParent<PhysGrabObject>(); PhotonView component = ((Component)__instance).GetComponent<PhotonView>(); if ((Object)(object)componentInParent == (Object)null || (Object)(object)component == (Object)null) { return false; } PhotonTransformView componentInParent2 = ((Component)component).GetComponentInParent<PhotonTransformView>(); if (GameManager.Multiplayer() && componentInParent2 != null) { componentInParent2.KinematicClientForce(0.1f); } Traverse val = Traverse.Create((object)__instance); bool flag = ReflectionUtils.TryGetStructField<bool>(val, "dead"); bool flag2 = ReflectionUtils.TryGetStructField<bool>(val, "broken"); bool flag3 = ReflectionUtils.TryGetStructField<bool>(val, "closed"); bool flag4 = ReflectionUtils.TryGetStructField<bool>(val, "closing"); bool flag5 = ReflectionUtils.TryGetStructField<bool>(val, "closeHeavy"); bool flag6 = ReflectionUtils.TryGetStructField<bool>(val, "hingePointHasRb"); float num = ReflectionUtils.TryGetStructField<float>(val, "closeDisableTimer"); float num2 = ReflectionUtils.TryGetStructField<float>(val, "closedForceTimer"); float num3 = ReflectionUtils.TryGetStructField<float>(val, "bounceCooldown"); float num4 = ReflectionUtils.TryGetStructField<float>(val, "moveLoopEndDisableTimer"); float num5 = ReflectionUtils.TryGetStructField<float>(val, "closeSpeed"); float num6 = ReflectionUtils.TryGetStructField<float>(val, "hingeOffsetPositiveThreshold"); float num7 = ReflectionUtils.TryGetStructField<float>(val, "hingeOffsetNegativeThreshold"); float num8 = ReflectionUtils.TryGetStructField<float>(val, "hingeOffsetSpeed"); float num9 = ReflectionUtils.TryGetStructField<float>(val, "closeMaxSpeed"); float num10 = ReflectionUtils.TryGetStructField<float>(val, "closeHeavySpeed"); float num11 = ReflectionUtils.TryGetStructField<float>(val, "closeThreshold"); float num12 = ReflectionUtils.TryGetStructField<float>(val, "openForceNeeded"); float num13 = ReflectionUtils.TryGetStructField<float>(val, "bounceAmount"); Vector3 val2 = ReflectionUtils.TryGetStructField<Vector3>(val, "hingePointPosition"); Vector3 val3 = ReflectionUtils.TryGetStructField<Vector3>(val, "restPosition"); Vector3 val4 = ReflectionUtils.TryGetStructField<Vector3>(val, "bounceVelocity"); Vector3 val5 = ReflectionUtils.TryGetStructField<Vector3>(val, "hingeOffsetPositive"); Vector3 val6 = ReflectionUtils.TryGetStructField<Vector3>(val, "hingeOffsetNegative"); Quaternion val7 = ReflectionUtils.TryGetStructField<Quaternion>(val, "restRotation"); BounceEffect val8 = ReflectionUtils.TryGetStructField<BounceEffect>(val, "bounceEffect"); Rigidbody val9 = ReflectionUtils.TryGetField<Rigidbody>(val, "hingePointRb"); HingeJoint val10 = ReflectionUtils.TryGetField<HingeJoint>(val, "joint"); Transform val11 = ReflectionUtils.TryGetField<Transform>(val, "hingePoint"); if (flag || flag2 || !componentInParent.spawned || (GameManager.instance.gameMode != 0 && !PhotonNetwork.IsMasterClient && !component.IsMine)) { return false; } if (flag2) { float value = val.Field("brokenTimer").GetValue<float>(); value += Time.fixedDeltaTime; val.Field("brokenTimer").SetValue((object)value); } if (flag6) { if (val10.angle >= num6) { Vector3 val12 = val2 + val11.TransformDirection(val5); Vector3 val13 = Vector3.Lerp(val9.position, val12, num8 * Time.fixedDeltaTime); if (val9.position != val13) { val9.MovePosition(val13); } } else if (val10.angle <= num7) { Vector3 val14 = val2 + val11.TransformDirection(val6); Vector3 val15 = Vector3.Lerp(val9.position, val14, num8 * Time.fixedDeltaTime); if (val9.position != val15) { val9.MovePosition(val15); } } else { Vector3 val16 = Vector3.Lerp(val9.position, val2, num8 * Time.fixedDeltaTime); if (flag3) { val16 = val2; } if (val9.position != val16) { val9.MovePosition(val16); } } } Vector3 val17; if (!flag3 && num <= 0f && Object.op_Implicit((Object)(object)val10)) { if (!flag4) { val17 = componentInParent.rb.angularVelocity; Vector3 normalized = ((Vector3)(ref val17)).normalized; val17 = -((Joint)val10).axis * val10.angle; float num14 = Vector3.Dot(normalized, ((Vector3)(ref val17)).normalized); val17 = componentInParent.rb.angularVelocity; if (((Vector3)(ref val17)).magnitude < num9 && Mathf.Abs(val10.angle) < num11) { if (!(num14 > 0f)) { val17 = componentInParent.rb.angularVelocity; if (!(((Vector3)(ref val17)).magnitude < 0.1f)) { goto IL_0506; } } flag5 = false; val17 = componentInParent.rb.angularVelocity; num5 = Mathf.Max(((Vector3)(ref val17)).magnitude, 0.2f); if (num5 > num10) { flag5 = true; } flag4 = true; } } else if (componentInParent.playerGrabbing.Count > 0) { flag4 = false; } else { Vector3 eulerAngles = ((Quaternion)(ref val7)).eulerAngles; Quaternion rotation = componentInParent.rb.rotation; Vector3 val18 = eulerAngles - ((Quaternion)(ref rotation)).eulerAngles; val18 = Vector3.ClampMagnitude(val18, num5); componentInParent.rb.AddRelativeTorque(val18, (ForceMode)5); if (Mathf.Abs(val10.angle) < 2f) { num2 = 0.25f; flag4 = false; HingeRPC.CloseImpulse(__instance, flag5); } } } goto IL_0506; IL_0506: if (componentInParent.playerGrabbing.Count > 0) { num = 0.1f; } else if (num > 0f) { num -= Time.fixedDeltaTime; } if (flag3) { if (num2 > 0f) { num2 -= Time.fixedDeltaTime; } else { val17 = componentInParent.rb.angularVelocity; if (((Vector3)(ref val17)).magnitude > num12) { HingeRPC.OpenImpulse(__instance); num = 2f; flag4 = false; } } if (!componentInParent.rb.isKinematic && (componentInParent.rb.position != val3 || componentInParent.rb.rotation != val7)) { componentInParent.rb.MovePosition(val3); componentInParent.rb.MoveRotation(val7); componentInParent.rb.angularVelocity = Vector3.zero; componentInParent.rb.velocity = Vector3.zero; } } if (componentInParent.playerGrabbing.Count <= 0 && !flag4 && !flag3) { Vector3 angularVelocity = componentInParent.rb.angularVelocity; if (((Vector3)(ref angularVelocity)).magnitude <= 0.1f && ((Vector3)(ref val4)).magnitude > 0.5f && num3 <= 0f) { num3 = 1f; componentInParent.rb.AddTorque(num13 * -((Vector3)(ref val4)).normalized, (ForceMode)1); BounceEffect val19 = val8; BounceEffect val20 = val19; switch ((int)val20) { case 2: componentInParent.heavyImpactImpulse = true; break; case 1: componentInParent.mediumImpactImpulse = true; break; case 0: componentInParent.lightImpactImpulse = true; break; } num4 = 1f; } val4 = angularVelocity; } else { val4 = Vector3.zero; } if (num3 > 0f) { num3 -= Time.fixedDeltaTime; } if (!flag4) { componentInParent.OverrideDrag(__instance.drag, 0.1f); componentInParent.OverrideAngularDrag(__instance.drag, 0.1f); } val.Field("closeDisableTimer").SetValue((object)num); val.Field("closedForceTimer").SetValue((object)num2); val.Field("bounceCooldown").SetValue((object)num3); val.Field("moveLoopEndDisableTimer").SetValue((object)num4); val.Field("closing").SetValue((object)flag4); val.Field("closeSpeed").SetValue((object)num5); val.Field("closeHeavy").SetValue((object)flag5); val.Field("bounceVelocity").SetValue((object)val4); return false; } } public static class PhysGrabHinge_OnJointBreakPatch { private static bool Prefix(PhysGrabHinge __instance, float breakForce) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) if (!SemiFunc.IsMultiplayer()) { return true; } PhotonView component = ((Component)__instance).GetComponent<PhotonView>(); PhysGrabObject component2 = ((Component)__instance).GetComponent<PhysGrabObject>(); if (GameManager.instance.gameMode == 0 || component.IsMine) { component2.rb.AddForce(-component2.rb.velocity * 2f, (ForceMode)1); component2.rb.AddTorque(-component2.rb.angularVelocity * 10f, (ForceMode)1); AccessTools.Field(typeof(PhysGrabHinge), "broken").SetValue(__instance, true); } if (PhotonNetwork.IsMasterClient) { AccessTools.Method(typeof(PhysGrabHinge), "HingeBreakImpulse", (Type[])null, (Type[])null).Invoke(__instance, null); } return false; } } [HarmonyPatch(typeof(PhysGrabObject), "Start")] public static class PhysStartPatch { [HarmonyPostfix] public static void Postfix(PhysGrabObject __instance) { if (!PhotonNetwork.IsMasterClient && SemiFunc.IsMultiplayer() && (Object)(object)((Component)__instance).GetComponent<FakeOwnershipController>() == (Object)null) { WaitForAdd(__instance); } } public static IEnumerator WaitForAdd(PhysGrabObject __instance) { yield return (object)new WaitForSeconds(1f); if ((Object)(object)((Component)__instance).GetComponent<PhysGrabHinge>() == (Object)null) { ((Component)__instance).gameObject.AddComponent<FakeOwnershipController>(); } } } [BepInPlugin("net.ovchinikov.nwrework", "Network Rework", "1.0.0")] public class OwnershipTransferPlugin : BaseUnityPlugin { public static Harmony harmony; private void Awake() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown harmony = new Harmony("net.ovchinikov.nwrework"); harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"[NetworkRework] Loaded and patched."); } } [HarmonyPatch(typeof(PhysGrabObject), "FixedUpdate")] public static class PhysGrabObject_FixedUpdate_Transpiler { [HarmonyTranspiler] public static IEnumerable<CodeInstruction> ReplaceHostChecksWithIsMine(IEnumerable<CodeInstruction> instructions) { //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Expected O, but got Unknown //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Expected O, but got Unknown //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Expected O, but got Unknown //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Expected O, but got Unknown //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Expected O, but got Unknown //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Expected O, but got Unknown //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Expected O, but got Unknown //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Expected O, but got Unknown Debug.Log((object)"[NetworkingReworked] Transpiler activated"); List<CodeInstruction> list = new List<CodeInstruction>(instructions); MethodInfo methodInfo = AccessTools.PropertyGetter(typeof(PhotonNetwork), "IsMasterClient"); MethodInfo methodInfo2 = AccessTools.Method(typeof(SemiFunc), "IsMasterClientOrSingleplayer", (Type[])null, (Type[])null); FieldInfo fieldInfo = AccessTools.Field(typeof(PhysGrabObject), "isMaster"); MethodInfo methodInfo3 = AccessTools.PropertyGetter(typeof(MonoBehaviourPun), "photonView"); MethodInfo methodInfo4 = AccessTools.PropertyGetter(typeof(PhotonView), "IsMine"); int num = 0; for (int i = 0; i < list.Count; i++) { CodeInstruction val = list[i]; if (methodInfo != null && CodeInstructionExtensions.Calls(val, methodInfo)) { list[i] = new CodeInstruction(OpCodes.Ldarg_0, (object)null); list.Insert(++i, new CodeInstruction(OpCodes.Callvirt, (object)methodInfo3)); list.Insert(++i, new CodeInstruction(OpCodes.Callvirt, (object)methodInfo4)); Debug.Log((object)"[NetworkingReworked] Replaced old 'IsMasterClient' call w/ 'this.photonView.IsMine'"); num++; } else if (methodInfo2 != null && CodeInstructionExtensions.Calls(val, methodInfo2)) { list[i] = new CodeInstruction(OpCodes.Ldarg_0, (object)null); list.Insert(++i, new CodeInstruction(OpCodes.Callvirt, (object)methodInfo3)); MethodInfo methodInfo5 = AccessTools.Method(typeof(PhysGrabObject_FixedUpdate_Transpiler), "GetIsMineOrSingleplayer", (Type[])null, (Type[])null); list.Insert(++i, new CodeInstruction(OpCodes.Call, (object)methodInfo5)); Debug.Log((object)"[NetworkingReworked] Replaced old 'SemiFunc.IsMasterClientOrSingleplayer' w/ 'this.photonView.IsMine'"); num++; } else if (fieldInfo != null && CodeInstructionExtensions.LoadsField(val, fieldInfo, false)) { list[i] = new CodeInstruction(OpCodes.Callvirt, (object)methodInfo3); list.Insert(++i, new CodeInstruction(OpCodes.Callvirt, (object)methodInfo4)); Debug.Log((object)"[NetworkingReworked] Replaced 'isMaster' field read w/ 'this.photonView.IsMine'"); num++; } } Debug.Log((object)$"[NetworkingReworked] Done transpiling. Replacements made: {num}"); return list; } public static bool GetIsMineOrSingleplayer(PhysGrabObject grabObject) { PhotonView component = ((Component)grabObject).GetComponent<PhotonView>(); bool flag = !SemiFunc.IsMultiplayer(); return ((Object)(object)component != (Object)null && component.IsMine) || flag; } } public static class HurtColliderPatch { public static bool IsOwnerOrSingleplayer(GameObject obj) { PhotonView componentInParent = obj.GetComponentInParent<PhotonView>(); return !PhotonNetwork.InRoom || ((Object)(object)componentInParent != (Object)null && componentInParent.IsMine); } [HarmonyTranspiler] public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(instructions); MethodInfo method = typeof(SemiFunc).GetMethod("IsMasterClientOrSingleplayer"); MethodInfo method2 = typeof(HurtColliderPatch).GetMethod("IsOwnerOrSingleplayer"); int num = 0; for (int i = 0; i < list.Count; i++) { if (num < 1 && list[i].opcode == OpCodes.Call && list[i].operand as MethodInfo == method) { list[i] = new CodeInstruction(OpCodes.Ldarg_0, (object)null); list.Insert(i + 1, new CodeInstruction(OpCodes.Call, (object)method2)); num++; } } return list; } } [HarmonyPatch(typeof(PhysGrabHinge), "Awake")] public static class PhysGrabHinge_Awake_Transpiler { [HarmonyTranspiler] public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { List<CodeInstruction> list = new List<CodeInstruction>(instructions); List<CodeInstruction> list2 = new List<CodeInstruction>(); bool flag = false; int num = 0; for (int i = 0; i < list.Count; i++) { CodeInstruction val = list[i]; if (!flag && val.opcode == OpCodes.Call && val.operand is MethodInfo methodInfo && methodInfo.Name == "Destroy") { Debug.Log((object)"[NetworkingReworked] Found Object.Destroy — starting skip block"); flag = true; num = 0; } else if (flag) { num++; if (num > 5) { Debug.Log((object)"[NetworkingReworked] Ending skip block after ~5 instructions"); flag = false; } } else { list2.Add(val); } } return list2; } } [HarmonyPatch(typeof(PhotonTransformView), "Update")] public static class PhotonTransformView_Update_PrefixPatch { private static bool Prefix(PhotonTransformView __instance) { if (((MonoBehaviourPun)__instance).photonView.IsMine) { FieldInfo fieldInfo = AccessTools.Field(typeof(PhotonTransformView), "kinematicClientForcedTimer"); FieldInfo fieldInfo2 = AccessTools.Field(typeof(PhotonTransformView), "kinematicClientForced"); if (fieldInfo != null && fieldInfo2 != null) { float num = (float)fieldInfo.GetValue(__instance); bool flag = (bool)fieldInfo2.GetValue(__instance); if (num > 0f) { num -= Time.deltaTime; if (num <= 0f) { flag = false; } fieldInfo.SetValue(__instance, num); fieldInfo2.SetValue(__instance, flag); } } return false; } return true; } } [HarmonyPatch(typeof(PhysGrabObject), "OverrideTimersTick")] public static class PhysGrabObject_OverrideTimersTick_Transpiler { public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Expected O, but got Unknown //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Expected O, but got Unknown //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Expected O, but got Unknown //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Expected O, but got Unknown //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Expected O, but got Unknown //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Expected O, but got Unknown //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Expected O, but got Unknown //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(instructions); MethodInfo methodInfo = AccessTools.Method(typeof(PhysGrabObject_OverrideTimersTick_Transpiler), "GetIsMineOrSingleplayer", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.PropertyGetter(typeof(PhotonNetwork), "IsMasterClient"); MethodInfo methodInfo3 = AccessTools.Method(typeof(SemiFunc), "IsMasterClientOrSingleplayer", (Type[])null, (Type[])null); FieldInfo fieldInfo = AccessTools.Field(typeof(PhysGrabObject), "isMaster"); MethodInfo methodInfo4 = AccessTools.PropertyGetter(typeof(MonoBehaviourPun), "photonView"); MethodInfo methodInfo5 = AccessTools.PropertyGetter(typeof(PhotonView), "IsMine"); for (int i = 0; i < list.Count; i++) { CodeInstruction val = list[i]; if (methodInfo2 != null && CodeInstructionExtensions.Calls(val, methodInfo2)) { List<Label> collection = new List<Label>(val.labels); CodeInstruction val2 = new CodeInstruction(OpCodes.Ldarg_0, (object)null); val2.labels.AddRange(collection); list[i] = val2; list.Insert(++i, new CodeInstruction(OpCodes.Callvirt, (object)methodInfo4)); list.Insert(++i, new CodeInstruction(OpCodes.Callvirt, (object)methodInfo5)); Debug.Log((object)"[NetworkingReworked] Replaced 'PhotonNetwork.IsMasterClient' call with 'this.photonView.IsMine'"); } else if (methodInfo3 != null && CodeInstructionExtensions.Calls(val, methodInfo3)) { List<Label> collection2 = new List<Label>(val.labels); CodeInstruction val3 = new CodeInstruction(OpCodes.Ldarg_0, (object)null); val3.labels.AddRange(collection2); list[i] = val3; list.Insert(++i, new CodeInstruction(OpCodes.Callvirt, (object)methodInfo4)); list.Insert(++i, new CodeInstruction(OpCodes.Call, (object)methodInfo)); Debug.Log((object)"[NetworkingReworked] Replaced 'SemiFunc.IsMasterClientOrSingleplayer' call with 'this.photonView.IsMine'"); } else if (fieldInfo != null && CodeInstructionExtensions.LoadsField(val, fieldInfo, false)) { List<Label> collection3 = new List<Label>(val.labels); CodeInstruction val4 = new CodeInstruction(OpCodes.Callvirt, (object)methodInfo4); val4.labels.AddRange(collection3); list[i] = val4; list.Insert(++i, new CodeInstruction(OpCodes.Callvirt, (object)methodInfo5)); Debug.Log((object)"[NetworkingReworked] Replaced 'isMaster' field read with 'this.photonView.IsMine'"); } } return list; } public static bool GetIsMineOrSingleplayer(PhysGrabObject grabObject) { PhotonView component = ((Component)grabObject).GetComponent<PhotonView>(); bool flag = !SemiFunc.IsMultiplayer(); return ((Object)(object)component != (Object)null && component.IsMine) || flag; } } [HarmonyPatch(typeof(PhysGrabObject), "Update")] public static class PhysGrabObject_Update_Transpiler { public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Expected O, but got Unknown //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(instructions); MethodInfo methodInfo = AccessTools.Method(typeof(PhysGrabObject_Update_Transpiler), "GetIsMineOrSingleplayer", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(SemiFunc), "IsMasterClientOrSingleplayer", (Type[])null, (Type[])null); MethodInfo methodInfo3 = AccessTools.PropertyGetter(typeof(MonoBehaviourPun), "photonView"); MethodInfo methodInfo4 = AccessTools.PropertyGetter(typeof(PhotonView), "IsMine"); for (int i = 0; i < list.Count; i++) { CodeInstruction val = list[i]; if (methodInfo2 != null && CodeInstructionExtensions.Calls(val, methodInfo2)) { List<Label> collection = new List<Label>(val.labels); CodeInstruction val2 = new CodeInstruction(OpCodes.Ldarg_0, (object)null); val2.labels.AddRange(collection); list[i] = val2; list.Insert(++i, new CodeInstruction(OpCodes.Callvirt, (object)methodInfo3)); list.Insert(++i, new CodeInstruction(OpCodes.Call, (object)methodInfo)); Debug.Log((object)"[NetworkingReworked] Replaced SemiFunc.IsMasterClientOrSingleplayer() with this.photonView.IsMine in Update"); } } return list; } public static bool GetIsMineOrSingleplayer(PhysGrabObject grabObject) { PhotonView component = ((Component)grabObject).GetComponent<PhotonView>(); bool flag = !SemiFunc.IsMultiplayer(); return ((Object)(object)component != (Object)null && component.IsMine) || flag; } } [HarmonyPatch(typeof(PhysGrabObjectImpactDetector), "OnTriggerStay")] public static class PhysGrabObjectImpactDetector_OnTriggerStay_Transpiler { [HarmonyTranspiler] public static IEnumerable<CodeInstruction> Transpile(IEnumerable<CodeInstruction> instructions) { //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Expected O, but got Unknown //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Expected O, but got Unknown //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(instructions); MethodInfo methodInfo = AccessTools.PropertyGetter(typeof(PhotonNetwork), "IsMasterClient"); MethodInfo methodInfo2 = typeof(Component).GetMethods().First((MethodInfo m) => m.Name == "GetComponent" && m.IsGenericMethod && m.GetParameters().Length == 0).MakeGenericMethod(typeof(PhotonView)); MethodInfo methodInfo3 = AccessTools.PropertyGetter(typeof(PhotonView), "IsMine"); for (int i = 0; i < list.Count; i++) { if (CodeInstructionExtensions.Calls(list[i], methodInfo)) { list[i] = new CodeInstruction(OpCodes.Ldarg_0, (object)null); list.Insert(++i, new CodeInstruction(OpCodes.Callvirt, (object)methodInfo2)); list.Insert(++i, new CodeInstruction(OpCodes.Callvirt, (object)methodInfo3)); } } return list; } } [HarmonyPatch(typeof(PhysGrabObjectImpactDetector), "OnCollisionStay")] public static class PhysGrabObjectImpactDetector_OnCollisionStay_Transpiler { [HarmonyTranspiler] public static IEnumerable<CodeInstruction> Transpile(IEnumerable<CodeInstruction> instructions) { //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Expected O, but got Unknown //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Expected O, but got Unknown //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(instructions); MethodInfo methodInfo = AccessTools.PropertyGetter(typeof(PhotonNetwork), "IsMasterClient"); MethodInfo methodInfo2 = typeof(Component).GetMethods().First((MethodInfo m) => m.Name == "GetComponent" && m.IsGenericMethod && m.GetParameters().Length == 0).MakeGenericMethod(typeof(PhotonView)); MethodInfo methodInfo3 = AccessTools.PropertyGetter(typeof(PhotonView), "IsMine"); FieldInfo fieldInfo = AccessTools.Field(typeof(PhysGrabObjectImpactDetector), "photonView"); for (int i = 0; i < list.Count; i++) { if (CodeInstructionExtensions.Calls(list[i], methodInfo)) { list[i] = new CodeInstruction(OpCodes.Ldarg_0, (object)null); list.Insert(++i, new CodeInstruction(OpCodes.Ldfld, (object)fieldInfo)); list.Insert(++i, new CodeInstruction(OpCodes.Callvirt, (object)methodInfo3)); } } return list; } } [HarmonyPatch(typeof(PhysGrabObjectImpactDetector), "Update")] public static class PhysGrabObjectImpactDetector_Update_Transpiler { [HarmonyTranspiler] public static IEnumerable<CodeInstruction> Transpile(IEnumerable<CodeInstruction> instructions) { //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Expected O, but got Unknown //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Expected O, but got Unknown //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(instructions); MethodInfo methodInfo = AccessTools.PropertyGetter(typeof(PhotonNetwork), "IsMasterClient"); MethodInfo methodInfo2 = AccessTools.PropertyGetter(typeof(PhotonView), "IsMine"); FieldInfo fieldInfo = AccessTools.Field(typeof(PhysGrabObjectImpactDetector), "photonView"); for (int i = 0; i < list.Count; i++) { if (CodeInstructionExtensions.Calls(list[i], methodInfo)) { list[i] = new CodeInstruction(OpCodes.Ldarg_0, (object)null); list.Insert(++i, new CodeInstruction(OpCodes.Ldfld, (object)fieldInfo)); list.Insert(++i, new CodeInstruction(OpCodes.Callvirt, (object)methodInfo2)); } } return list; } } [HarmonyPatch(typeof(PhysGrabObjectImpactDetector), "FixedUpdate")] public static class PhysGrabObjectImpactDetector_FixedUpdate_Transpiler { [HarmonyTranspiler] public static IEnumerable<CodeInstruction> Transpile(IEnumerable<CodeInstruction> instructions) { //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Expected O, but got Unknown //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Expected O, but got Unknown //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(instructions); MethodInfo methodInfo = AccessTools.PropertyGetter(typeof(PhotonNetwork), "IsMasterClient"); MethodInfo methodInfo2 = AccessTools.PropertyGetter(typeof(PhotonView), "IsMine"); FieldInfo fieldInfo = AccessTools.Field(typeof(PhysGrabObjectImpactDetector), "photonView"); for (int i = 0; i < list.Count; i++) { if (CodeInstructionExtensions.Calls(list[i], methodInfo)) { list[i] = new CodeInstruction(OpCodes.Ldarg_0, (object)null); list.Insert(++i, new CodeInstruction(OpCodes.Ldfld, (object)fieldInfo)); list.Insert(++i, new CodeInstruction(OpCodes.Callvirt, (object)methodInfo2)); } } return list; } } [HarmonyPatch(typeof(PhysGrabObject), "GrabEnded")] public static class DelayedReleasePatch { public static float lastSyncTS; [HarmonyPrefix] public static bool Prefix(PhysGrabObject __instance) { PhotonView component = ((Component)__instance).GetComponent<PhotonView>(); if ((Object)(object)component == (Object)null) { return true; } PhysGrabber val = null; foreach (PhysGrabber item in __instance.playerGrabbing) { if ((Object)(object)item == (Object)null || !item.isLocal) { continue; } val = item; break; } DelayedReleaseHandler.Schedule(val, __instance); if ((Object)(object)val == (Object)null) { Debug.Log((object)"Couldn't find you grabbing."); return true; } DelayedReleaseHandler.physGrab = __instance; DelayedReleaseHandler.recentlyDropped = true; StoreSnapshot(val); PerformGrabEndedLocally(__instance, val); return false; } public static void PerformGrabEndedLocally(PhysGrabObject __instance, PhysGrabber player) { if (__instance.grabbedLocal) { __instance.grabbedLocal = false; MethodInfo method = typeof(PhysGrabObject).GetMethod("Throw", BindingFlags.Instance | BindingFlags.NonPublic); if (method != null) { method.Invoke(__instance, new object[1] { player }); } if (__instance.playerGrabbing.Contains(player)) { __instance.playerGrabbing.Remove(player); } } } public static void StoreSnapshot(PhysGrabber grabber) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) DelayedReleaseHandler.StreamData value = default(DelayedReleaseHandler.StreamData); value.pullerPos = grabber.physGrabPointPullerPosition; value.planePos = grabber.physGrabPointPlane.position; value.mouseVel = grabber.mouseTurningVelocity; value.isRotating = grabber.isRotating; value.colorState = grabber.colorState; DelayedReleaseHandler.readyForDispatch = value; } } [HarmonyPatch(typeof(PhysGrabber), "PhysGrabBeamDeactivateRPC")] public static class PreventPrematureRPC { [HarmonyPrefix] public static bool Prefix(PhysGrabber __instance) { if (__instance.photonView.IsMine && DelayedReleaseHandler.ignoreNextGrabBeamDeactive) { DelayedReleaseHandler.ignoreNextGrabBeamDeactive = false; if (Object.op_Implicit((Object)(object)DelayedReleaseHandler.physGrab)) { FakeOwnershipController component = ((Component)DelayedReleaseHandler.physGrab).GetComponent<FakeOwnershipController>(); if ((Object)(object)component != (Object)null) { component.SyncAfterRelease(); } DelayedReleaseHandler.physGrab = null; } return false; } return true; } } [HarmonyPatch(typeof(PhysGrabber), "PhysGrabBeamDeactivate")] public static class PreventPhysGrabBeamDeactivatePre { [HarmonyPrefix] public static bool Prefix(PhysGrabber __instance) { if (DelayedReleaseHandler.recentlyDropped) { MethodInfo method = typeof(PhysGrabber).GetMethod("PhysGrabBeamDeactivateRPC", BindingFlags.Instance | BindingFlags.NonPublic); if (method != null) { method.Invoke(__instance, new object[0]); } return false; } return true; } } [HarmonyPatch(typeof(PhysGrabber), "OnPhotonSerializeView")] public static class StreamInjectPatch { [HarmonyPrefix] public static bool Prefix(PhysGrabber __instance, PhotonStream stream) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) if (!stream.IsWriting) { return true; } PhotonView val = (PhotonView)Access(__instance, "photonView"); if ((Object)(object)val == (Object)null) { return true; } int viewID = val.ViewID; DelayedReleaseHandler.StreamData? readyForDispatch = DelayedReleaseHandler.readyForDispatch; if (!readyForDispatch.HasValue) { stream.SendNext((object)__instance.physGrabPointPullerPosition); stream.SendNext((object)__instance.physGrabPointPlane.position); stream.SendNext((object)__instance.mouseTurningVelocity); stream.SendNext((object)__instance.isRotating); stream.SendNext((object)__instance.colorState); return true; } DelayedReleaseHandler.StreamData value = DelayedReleaseHandler.readyForDispatch.Value; stream.SendNext((object)value.pullerPos); stream.SendNext((object)value.planePos); stream.SendNext((object)value.mouseVel); stream.SendNext((object)value.isRotating); stream.SendNext((object)value.colorState); DelayedReleaseHandler.ignoreNextGrabBeamDeactive = true; DelayedReleaseHandler.readyForDispatch = null; DelayedReleaseHandler.recentlyDropped = false; ((MonoBehaviour)DelayedReleaseHandler.handlerInstance).StartCoroutine(DelayedRPCDispatch(__instance, DelayedReleaseHandler.physGrab, viewID)); return false; } private static object Access(object target, string name) { return target.GetType().GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(target); } private static IEnumerator DelayedRPCDispatch(PhysGrabber grabber, PhysGrabObject physGrab, int id) { yield return (object)new WaitForSeconds(0.01f); ((Component)physGrab).GetComponent<PhotonView>().RPC("GrabEndedRPC", (RpcTarget)2, new object[1] { id }); grabber.photonView.RPC("PhysGrabBeamDeactivateRPC", (RpcTarget)0, Array.Empty<object>()); } } public class DelayedReleaseHandler : MonoBehaviour { public struct StreamData { public Vector3 pullerPos; public Vector3 planePos; public Vector3 mouseVel; public bool isRotating; public int colorState; } public static StreamData? readyForDispatch; public static bool recentlyDropped; public static bool ignoreNextGrabBeamDeactive; public static PhysGrabObject physGrab; public static DelayedReleaseHandler handlerInstance; private static GameObject handlerObject; public static void Schedule(PhysGrabber grabber, PhysGrabObject grabbedObject) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown PhotonNetwork.LogLevel = (PunLogLevel)2; if ((Object)(object)handlerObject == (Object)null) { handlerObject = new GameObject("DelayedReleaseHandler"); DelayedReleaseHandler delayedReleaseHandler = handlerObject.AddComponent<DelayedReleaseHandler>(); handlerInstance = delayedReleaseHandler; Object.DontDestroyOnLoad((Object)(object)handlerObject); } } } public static class ReflectionUtils { public static string DumpObject(object obj, int depth = 0, int maxDepth = 1) { if (obj == null) { return "null"; } Type type = obj.GetType(); if (depth > maxDepth || type.IsPrimitive || type == typeof(string) || type.IsEnum) { return obj.ToString(); } StringBuilder stringBuilder = new StringBuilder(); string text = new string(' ', depth * 2); stringBuilder.AppendLine(text + type.Name + " {"); FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); FieldInfo[] array = fields; foreach (FieldInfo fieldInfo in array) { object obj2; try { obj2 = fieldInfo.GetValue(obj); } catch (Exception ex) { obj2 = "Exception: " + ex.Message; } stringBuilder.Append(text + " " + fieldInfo.Name + ": "); if (obj2 == null) { stringBuilder.AppendLine("null"); } else if (fieldInfo.FieldType.IsPrimitive || fieldInfo.FieldType == typeof(string) || fieldInfo.FieldType.IsEnum) { stringBuilder.AppendLine(obj2.ToString()); } else { stringBuilder.AppendLine(DumpObject(obj2, depth + 1, maxDepth)); } } stringBuilder.AppendLine(text + "}"); return stringBuilder.ToString(); } public static T TryGetField<T>(Traverse t, string name) where T : class { Traverse val = t.Field(name); if (val != null && val.FieldExists()) { return val.GetValue<T>(); } return null; } public static T TryGetStructField<T>(Traverse t, string name) where T : struct { Traverse val = t.Field(name); if (val != null && val.FieldExists()) { return val.GetValue<T>(); } return default(T); } } namespace NetworkingRework.Utils { internal class BlockedItems { public static bool IsBlockedType(PhysGrabObject grabObject) { if ((Object)(object)grabObject == (Object)null) { return true; } if (Object.op_Implicit((Object)(object)((Component)grabObject).GetComponent<PhysGrabCart>())) { return false; } if ((Object)(object)((Component)grabObject).GetComponent<Enemy>() != (Object)null || (Object)(object)((Component)grabObject).GetComponent<EnemyRigidbody>() != (Object)null || (Object)(object)((Component)grabObject).GetComponent<PhysGrabHinge>() != (Object)null || (Object)(object)((Component)grabObject).GetComponentInParent<Enemy>() != (Object)null || (Object)(object)((Component)grabObject).GetComponentInParent<EnemyRigidbody>() != (Object)null || (Object)(object)((Component)grabObject).GetComponent<ItemBattery>() != (Object)null || (Object)(object)((Component)grabObject).GetComponent<ItemGun>() != (Object)null || (Object)(object)((Component)grabObject).GetComponent<ItemRubberDuck>() != (Object)null || (Object)(object)((Component)grabObject).GetComponentInParent<ItemBattery>() != (Object)null || (Object)(object)((Component)grabObject).GetComponentInParent<ItemGun>() != (Object)null || (Object)(object)((Component)grabObject).GetComponentInParent<ItemRubberDuck>() != (Object)null) { return true; } Component[] componentsInParent = ((Component)grabObject).GetComponentsInParent<Component>(true); foreach (Component val in componentsInParent) { if (!((Object)(object)val == (Object)null)) { string name = ((object)val).GetType().Name; if (name.StartsWith("ItemGrenade") || name.StartsWith("ItemDrone") || name.StartsWith("ItemUpgrade")) { return true; } } } return false; } } } namespace NetworkingReworked { [HarmonyPatch(typeof(PhotonTransformView))] public static class PhotonTransformViewPatch { private static FieldInfo rbField = typeof(PhotonTransformView).GetField("rb", BindingFlags.Instance | BindingFlags.NonPublic); private static FieldInfo m_NetworkPosition = typeof(PhotonTransformView).GetField("m_NetworkPosition", BindingFlags.Instance | BindingFlags.NonPublic); private static FieldInfo m_NetworkRotation = typeof(PhotonTransformView).GetField("m_NetworkRotation", BindingFlags.Instance | BindingFlags.NonPublic); private static FieldInfo m_Distance = typeof(PhotonTransformView).GetField("m_Distance", BindingFlags.Instance | BindingFlags.NonPublic); private static FieldInfo m_Angle = typeof(PhotonTransformView).GetField("m_Angle", BindingFlags.Instance | BindingFlags.NonPublic); private static FieldInfo teleportField = typeof(PhotonTransformView).GetField("teleport", BindingFlags.Instance | BindingFlags.NonPublic); private static FieldInfo smoothedPositionField = typeof(PhotonTransformView).GetField("smoothedPosition", BindingFlags.Instance | BindingFlags.NonPublic); private static FieldInfo smoothedRotationField = typeof(PhotonTransformView).GetField("smoothedRotation", BindingFlags.Instance | BindingFlags.NonPublic); private static FieldInfo isSleepingField = typeof(PhotonTransformView).GetField("isSleeping", BindingFlags.Instance | BindingFlags.NonPublic); private static FieldInfo receivedVelocityField = typeof(PhotonTransformView).GetField("receivedVelocity", BindingFlags.Instance | BindingFlags.NonPublic); private static FieldInfo receivedAngularVelocityField = typeof(PhotonTransformView).GetField("receivedAngularVelocity", BindingFlags.Instance | BindingFlags.NonPublic); private static FieldInfo kinematicClientForcedTimerField = typeof(PhotonTransformView).GetField("kinematicClientForcedTimer", BindingFlags.Instance | BindingFlags.NonPublic); private static FieldInfo kinematicClientForcedField = typeof(PhotonTransformView).GetField("kinematicClientForced", BindingFlags.Instance | BindingFlags.NonPublic); [HarmonyPrefix] [HarmonyPatch("Update")] public static bool Prefix_Update(PhotonTransformView __instance) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_02fa: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_0321: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) if (!SemiFunc.IsMultiplayer()) { return true; } PhotonView component = ((Component)__instance).GetComponent<PhotonView>(); Rigidbody val = (Rigidbody)rbField.GetValue(__instance); if ((Object)(object)val == (Object)null || (Object)(object)component == (Object)null) { return false; } Vector3 val2 = (Vector3)m_NetworkPosition.GetValue(__instance); Quaternion val3 = (Quaternion)m_NetworkRotation.GetValue(__instance); float num = (float)m_Distance.GetValue(__instance); float num2 = (float)m_Angle.GetValue(__instance); bool flag = (bool)teleportField.GetValue(__instance); bool flag2 = (bool)isSleepingField.GetValue(__instance); Vector3 val4 = (Vector3)smoothedPositionField.GetValue(__instance); Quaternion val5 = (Quaternion)smoothedRotationField.GetValue(__instance); Vector3 velocity = (Vector3)receivedVelocityField.GetValue(__instance); Vector3 angularVelocity = (Vector3)receivedAngularVelocityField.GetValue(__instance); float num3 = (float)kinematicClientForcedTimerField.GetValue(__instance); bool flag3 = (bool)kinematicClientForcedField.GetValue(__instance); if (!val.IsSleeping()) { Debug.DrawLine(((Component)__instance).transform.position, ((Component)__instance).transform.position + Vector3.up * 5f, Color.red); } if (!component.IsMine) { if (flag2) { if (!val.isKinematic) { val.isKinematic = true; } if (val.position != val2 || val.rotation != val3) { val.position = val2; val.rotation = val3; } return false; } val.interpolation = (RigidbodyInterpolation)1; if (val.isKinematic) { val4 = Vector3.MoveTowards(val4, val2, num * Time.deltaTime * (float)PhotonNetwork.SerializationRate * 0.9f); val5 = Quaternion.RotateTowards(val5, val3, num2 * Time.deltaTime * (float)PhotonNetwork.SerializationRate * 0.9f); } else { float num4 = Vector3.Distance(val.position, val2); val4 = Vector3.MoveTowards(val.position, val2, num4 * Time.deltaTime * (float)PhotonNetwork.SerializationRate); val5 = Quaternion.RotateTowards(val.rotation, val3, Quaternion.Angle(val.rotation, val3) * Time.deltaTime * (float)PhotonNetwork.SerializationRate); } val.MovePosition(val4); val.MoveRotation(val5); smoothedPositionField.SetValue(__instance, val4); smoothedRotationField.SetValue(__instance, val5); if (!flag) { val.interpolation = (RigidbodyInterpolation)1; if (!val.isKinematic) { val.velocity = velocity; val.angularVelocity = angularVelocity; } } else { val.position = val2; val.rotation = val3; smoothedPositionField.SetValue(__instance, val2); smoothedRotationField.SetValue(__instance, val3); teleportField.SetValue(__instance, false); } } if (num3 > 0f) { num3 -= Time.deltaTime; if (num3 <= 0f) { flag3 = false; } kinematicClientForcedTimerField.SetValue(__instance, num3); kinematicClientForcedField.SetValue(__instance, flag3); } return false; } } [HarmonyPatch(typeof(PhotonTransformView))] public static class PhotonTransformViewSerializationPatch { private static readonly BindingFlags instanceFlags = BindingFlags.Instance | BindingFlags.NonPublic; private static readonly FieldInfo rbField = typeof(PhotonTransformView).GetField("rb", instanceFlags); private static readonly FieldInfo m_DirectionField = typeof(PhotonTransformView).GetField("m_Direction", instanceFlags); private static readonly FieldInfo m_StoredPositionField = typeof(PhotonTransformView).GetField("m_StoredPosition", instanceFlags); private static readonly FieldInfo isKinematicField = typeof(PhotonTransformView).GetField("isKinematic", instanceFlags); private static readonly FieldInfo teleportField = typeof(PhotonTransformView).GetField("teleport", instanceFlags); private static readonly FieldInfo kinematicClientForcedField = typeof(PhotonTransformView).GetField("kinematicClientForced", instanceFlags); private static readonly FieldInfo prevRotationField = typeof(PhotonTransformView).GetField("prevRotation", instanceFlags); private static readonly FieldInfo prevPositionField = typeof(PhotonTransformView).GetField("prevPosition", instanceFlags); private static readonly FieldInfo receivedPositionField = typeof(PhotonTransformView).GetField("receivedPosition", instanceFlags); private static readonly FieldInfo receivedRotationField = typeof(PhotonTransformView).GetField("receivedRotation", instanceFlags); private static readonly FieldInfo extrapolateTimerField = typeof(PhotonTransformView).GetField("extrapolateTimer", instanceFlags); private static readonly FieldInfo isSleepingField = typeof(PhotonTransformView).GetField("isSleeping", instanceFlags); private static readonly FieldInfo m_NetworkPositionField = typeof(PhotonTransformView).GetField("m_NetworkPosition", instanceFlags); private static readonly FieldInfo m_NetworkRotationField = typeof(PhotonTransformView).GetField("m_NetworkRotation", instanceFlags); private static readonly FieldInfo m_firstTakeField = typeof(PhotonTransformView).GetField("m_firstTake", instanceFlags); private static readonly FieldInfo m_DistanceField = typeof(PhotonTransformView).GetField("m_Distance", instanceFlags); private static readonly FieldInfo m_AngleField = typeof(PhotonTransformView).GetField("m_Angle", instanceFlags); private static readonly FieldInfo smoothedRotationField = typeof(PhotonTransformView).GetField("smoothedRotation", instanceFlags); private static readonly FieldInfo receivedVelocityField = typeof(PhotonTransformView).GetField("receivedVelocity", instanceFlags); private static readonly FieldInfo receivedAngularVelocityField = typeof(PhotonTransformView).GetField("receivedAngularVelocity", instanceFlags); [HarmonyPrefix] [HarmonyPatch("OnPhotonSerializeView")] public static bool Prefix_OnPhotonSerializeView(PhotonTransformView __instance, PhotonStream stream, PhotonMessageInfo info) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_02f0: Unknown result type (might be due to invalid IL or missing references) //IL_02f8: Unknown result type (might be due to invalid IL or missing references) //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_031e: Unknown result type (might be due to invalid IL or missing references) //IL_0331: Unknown result type (might be due to invalid IL or missing references) //IL