Decompiled source of CrashoutCrewSkysTheLimit v1.0.1
CrashoutCrew_SkysTheLimit.dll
Decompiled a day ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using Aggro.Core; using Aggro.Core.Networking; using BepInEx; using CrashoutCrew_LobbyEnforcer; using CrashoutCrew_SkysTheLimit.Patches; using FMODUnity; using HarmonyLib; using Microsoft.CodeAnalysis; using Mirror; using Unity.Mathematics; using UnityEngine; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("aggro.core")] [assembly: IgnoresAccessChecksTo("febjam")] [assembly: AssemblyCompany("CrashoutCrew_SkysTheLimit")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+141c9618b809295e3f91c216c892cfee5b4a9724")] [assembly: AssemblyProduct("CrashoutCrew_SkysTheLimit")] [assembly: AssemblyTitle("CrashoutCrew_SkysTheLimit")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace TemplatePlugin { internal static class TemplatePluginInfo { public const string PLUGIN_GUID = "crashout_crew_skys_the_limit"; public const string PLUGIN_NAME = "CrashoutCrew_SkysTheLimit"; public const string GAME_NAME = "CrashoutCrew"; } } namespace CrashoutCrew_SkysTheLimit { public class ExtendedPredictedRigidbodyGroup : MonoBehaviour { public ExtendedRigidbodyGroupState lastRecorded = new ExtendedRigidbodyGroupState(); public List<Entity> serverGroup = new List<Entity>(); public readonly SortedList<double, ExtendedRigidbodyGroupState> stateHistory = new SortedList<double, ExtendedRigidbodyGroupState>(); } public struct ExtendedRigidbodyGroupPayload { public const byte MovingBit = 1; public const byte UprightBit = 2; public byte count; public float dt; public List<byte> flags; public List<Entity> entities; public List<Vector3> positions; public List<Quaternion> rotations; public List<Vector3> velocities; public List<Vector3> angularVelocities; public static ExtendedRigidbodyGroupPayload Create() { return new ExtendedRigidbodyGroupPayload { flags = new List<byte>(), entities = new List<Entity>(), positions = new List<Vector3>(), rotations = new List<Quaternion>(), velocities = new List<Vector3>(), angularVelocities = new List<Vector3>() }; } } public struct ExtendedRigidbodyGroupState { public double timestamp; public List<RigidbodyGroupEntryState> group; public ExtendedRigidbodyGroupState() { timestamp = 0.0; group = new List<RigidbodyGroupEntryState>(); } public static ExtendedRigidbodyGroupState Interpolate(in ExtendedRigidbodyGroupState a, in ExtendedRigidbodyGroupState b, float t) { //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) //IL_003d: Unknown result type (might be due to invalid IL or missing references) ExtendedRigidbodyGroupState result = new ExtendedRigidbodyGroupState(); int count = a.group.Count; for (int i = 0; i < count; i++) { RigidbodyGroupEntryState val = a.group[i]; RigidbodyGroupEntryState val2 = b.group[i]; result.group.Add(RigidbodyGroupEntryState.Interpolate(ref val, ref val2, t)); } return result; } } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("crashout_crew_skys_the_limit", "CrashoutCrew_SkysTheLimit", "1.0.1")] public class PluginMain : BaseUnityPlugin { public const string GameName = "CrashoutCrew"; private const string Version = "1.0.1"; private readonly Harmony _harmony = new Harmony("crashout_crew_skys_the_limit"); private void Awake() { Enforcer.Enforce("crashout_crew_skys_the_limit", "1.0.1", (EnforcementDirection)2); _harmony.PatchAll(); Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); SceneManager.sceneLoaded += delegate { StackNetworkHandler.Init(); }; } } public static class SkysTheLimitAPI { internal static int StackLimit = 32; public static void SetStackLimit(int limit) { StackLimit = limit; } } public static class StackNetworkHandler { private static bool _init; public static void Init() { if (NetworkClient.active) { if (!_init) { _init = true; RegisterSerializers(); NetworkClient.RegisterHandler<ServerTeleportMsg1>((Action<ServerTeleportMsg1>)OnClientReceiveTeleport1, true); NetworkClient.RegisterHandler<ServerTeleportMsg2>((Action<ServerTeleportMsg2>)OnClientReceiveTeleport2, true); NetworkClient.RegisterHandler<ServerTeleportMsg3>((Action<ServerTeleportMsg3>)OnClientReceiveTeleport3, true); NetworkClient.RegisterHandler<ExtendedRigidbodyGroupSyncMsg>((Action<ExtendedRigidbodyGroupSyncMsg>)PredictedRigidbodyGroup_Patches.OnSyncMsg, true); NetworkClient.RegisterHandler<StackContextMsg>((Action<StackContextMsg>)Grabbable_Patches.OnStackContext, true); } else { NetworkClient.ReplaceHandler<ServerTeleportMsg1>((Action<ServerTeleportMsg1>)OnClientReceiveTeleport1, true); NetworkClient.ReplaceHandler<ServerTeleportMsg2>((Action<ServerTeleportMsg2>)OnClientReceiveTeleport2, true); NetworkClient.ReplaceHandler<ServerTeleportMsg3>((Action<ServerTeleportMsg3>)OnClientReceiveTeleport3, true); NetworkClient.ReplaceHandler<ExtendedRigidbodyGroupSyncMsg>((Action<ExtendedRigidbodyGroupSyncMsg>)PredictedRigidbodyGroup_Patches.OnSyncMsg, true); NetworkClient.ReplaceHandler<StackContextMsg>((Action<StackContextMsg>)Grabbable_Patches.OnStackContext, true); } } } private static void RegisterSerializers() { Writer<ServerTeleportMsg1>.write = WriteServerTeleportMsg1; Reader<ServerTeleportMsg1>.read = ReadServerTeleportMsg1; Writer<ServerTeleportMsg2>.write = WriteServerTeleportMsg2; Reader<ServerTeleportMsg2>.read = ReadServerTeleportMsg2; Writer<ServerTeleportMsg3>.write = WriteServerTeleportMsg3; Reader<ServerTeleportMsg3>.read = ReadServerTeleportMsg3; Writer<ExtendedRigidbodyGroupSyncMsg>.write = delegate(NetworkWriter w, ExtendedRigidbodyGroupSyncMsg m) { NetworkWriterExtensions.WriteUInt(w, m.netId); NetworkWriterExtensions.WriteVarUInt(w, m.tick); w.WriteExtendedRigidbodyGroupPayload(m.payload); }; Reader<ExtendedRigidbodyGroupSyncMsg>.read = (NetworkReader r) => new ExtendedRigidbodyGroupSyncMsg { netId = NetworkReaderExtensions.ReadUInt(r), tick = NetworkReaderExtensions.ReadVarUInt(r), payload = r.ReadExtendedRigidbodyGroupPayload() }; Writer<StackContextMsg>.write = delegate(NetworkWriter w, StackContextMsg m) { NetworkWriterExtensions.WriteUInt(w, m.netId); w.WriteEntityArray(m.stack); }; Reader<StackContextMsg>.read = (NetworkReader r) => new StackContextMsg { netId = NetworkReaderExtensions.ReadUInt(r), stack = r.ReadEntityArray() }; } public static void WriteExtendedRigidbodyGroupPayload(this NetworkWriter writer, ExtendedRigidbodyGroupPayload payload) { //IL_0068: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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_00dd: 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) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: 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_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_020b: 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_0221: 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_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0154: 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_0181: Unknown result type (might be due to invalid IL or missing references) writer.WriteByte(payload.count); if (payload.count == 0) { return; } NetworkWriterExtensions.WriteFloat(writer, payload.dt); for (int i = 0; i < payload.count; i++) { byte b = payload.flags[i]; bool flag = (b & 1) != 0; bool num = (b & 2) != 0; writer.WriteByte(b); if (i > 0) { NetworkSerialization.WriteEntity(writer, payload.entities[i - 1]); } Vector3 val = payload.positions[i]; NetworkWriterExtensions.WriteUShort(writer, Compression.ScaleFloatToUShort(val.x, -200f, 500f, (ushort)0, ushort.MaxValue)); NetworkWriterExtensions.WriteUShort(writer, Compression.ScaleFloatToUShort(val.y, -200f, 500f, (ushort)0, ushort.MaxValue)); NetworkWriterExtensions.WriteUShort(writer, Compression.ScaleFloatToUShort(val.z, -200f, 500f, (ushort)0, ushort.MaxValue)); if (num) { Quaternion val2 = payload.rotations[i]; ((Quaternion)(ref val2)).Normalize(); NetworkWriterExtensions.WriteUShort(writer, Compression.ScaleFloatToUShort((float)((double)Mathf.Sign(val2.y) * (double)Mathf.Acos(val2.w) * 2.0), MathF.PI * -2f, MathF.PI * 2f, (ushort)0, ushort.MaxValue)); if (flag) { Vector3 val3 = payload.velocities[i]; NetworkWriterExtensions.WriteUShort(writer, (ushort)math.f32tof16(val3.x)); NetworkWriterExtensions.WriteUShort(writer, (ushort)math.f32tof16(val3.y)); NetworkWriterExtensions.WriteUShort(writer, (ushort)math.f32tof16(val3.z)); NetworkWriterExtensions.WriteUShort(writer, (ushort)math.f32tof16(payload.angularVelocities[i].y)); } continue; } NetworkWriterExtensions.WriteUInt(writer, Compression.CompressQuaternion(payload.rotations[i])); if (flag) { Vector3 val4 = payload.velocities[i]; NetworkWriterExtensions.WriteUShort(writer, (ushort)math.f32tof16(val4.x)); NetworkWriterExtensions.WriteUShort(writer, (ushort)math.f32tof16(val4.y)); NetworkWriterExtensions.WriteUShort(writer, (ushort)math.f32tof16(val4.z)); Vector3 val5 = payload.angularVelocities[i]; NetworkWriterExtensions.WriteUShort(writer, (ushort)math.f32tof16(val5.x)); NetworkWriterExtensions.WriteUShort(writer, (ushort)math.f32tof16(val5.y)); NetworkWriterExtensions.WriteUShort(writer, (ushort)math.f32tof16(val5.z)); } } } public static ExtendedRigidbodyGroupPayload ReadExtendedRigidbodyGroupPayload(this NetworkReader reader) { //IL_00c7: 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_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0198: 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_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) byte b = reader.ReadByte(); ExtendedRigidbodyGroupPayload result = ExtendedRigidbodyGroupPayload.Create(); result.count = b; if (b == 0) { return result; } result.dt = NetworkReaderExtensions.ReadFloat(reader); for (int i = 0; i < b; i++) { byte b2 = reader.ReadByte(); bool flag = (b2 & 1) != 0; bool num = (b2 & 2) != 0; result.flags.Add(b2); if (i > 0) { result.entities.Add(NetworkSerialization.ReadEntity(reader)); } float num2 = Compression.ScaleUShortToFloat(NetworkReaderExtensions.ReadUShort(reader), (ushort)0, ushort.MaxValue, -200f, 500f); float num3 = Compression.ScaleUShortToFloat(NetworkReaderExtensions.ReadUShort(reader), (ushort)0, ushort.MaxValue, -200f, 500f); float num4 = Compression.ScaleUShortToFloat(NetworkReaderExtensions.ReadUShort(reader), (ushort)0, ushort.MaxValue, -200f, 500f); result.positions.Add(new Vector3(num2, num3, num4)); if (num) { float num5 = Compression.ScaleUShortToFloat(NetworkReaderExtensions.ReadUShort(reader), (ushort)0, ushort.MaxValue, MathF.PI * -2f, MathF.PI * 2f); result.rotations.Add(new Quaternion(0f, Mathf.Sin(num5 / 2f), 0f, Mathf.Cos(num5 / 2f))); if (flag) { float num6 = math.f16tof32((uint)NetworkReaderExtensions.ReadUShort(reader)); float num7 = math.f16tof32((uint)NetworkReaderExtensions.ReadUShort(reader)); float num8 = math.f16tof32((uint)NetworkReaderExtensions.ReadUShort(reader)); result.velocities.Add(new Vector3(num6, num7, num8)); result.angularVelocities.Add(new Vector3(0f, math.f16tof32((uint)NetworkReaderExtensions.ReadUShort(reader)), 0f)); } else { result.velocities.Add(Vector3.zero); result.angularVelocities.Add(Vector3.zero); } continue; } result.rotations.Add(Compression.DecompressQuaternion(NetworkReaderExtensions.ReadUInt(reader))); if (flag) { float num9 = math.f16tof32((uint)NetworkReaderExtensions.ReadUShort(reader)); float num10 = math.f16tof32((uint)NetworkReaderExtensions.ReadUShort(reader)); float num11 = math.f16tof32((uint)NetworkReaderExtensions.ReadUShort(reader)); result.velocities.Add(new Vector3(num9, num10, num11)); float num12 = math.f16tof32((uint)NetworkReaderExtensions.ReadUShort(reader)); float num13 = math.f16tof32((uint)NetworkReaderExtensions.ReadUShort(reader)); float num14 = math.f16tof32((uint)NetworkReaderExtensions.ReadUShort(reader)); result.angularVelocities.Add(new Vector3(num12, num13, num14)); } else { result.velocities.Add(Vector3.zero); result.angularVelocities.Add(Vector3.zero); } } return result; } private static void WriteEntityArray(this NetworkWriter writer, Entity[] entities) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) NetworkWriterExtensions.WriteInt(writer, entities.Length); foreach (Entity val in entities) { NetworkSerialization.WriteEntity(writer, val); } } private static Entity[] ReadEntityArray(this NetworkReader reader) { //IL_0015: 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) int num = NetworkReaderExtensions.ReadInt(reader); Entity[] array = (Entity[])(object)new Entity[num]; for (int i = 0; i < num; i++) { array[i] = NetworkSerialization.ReadEntity(reader); } return array; } private static void WriteServerTeleportMsg1(this NetworkWriter writer, ServerTeleportMsg1 msg) { writer.WriteEntityArray(msg.entities); NetworkWriterExtensions.WriteArray<Vector3>(writer, msg.positions); NetworkWriterExtensions.WriteArray<Quaternion>(writer, msg.rotations); } private static ServerTeleportMsg1 ReadServerTeleportMsg1(this NetworkReader reader) { return new ServerTeleportMsg1 { entities = reader.ReadEntityArray(), positions = NetworkReaderExtensions.ReadArray<Vector3>(reader), rotations = NetworkReaderExtensions.ReadArray<Quaternion>(reader) }; } private static void WriteServerTeleportMsg2(this NetworkWriter writer, ServerTeleportMsg2 msg) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) writer.WriteEntityArray(msg.entities); NetworkWriterExtensions.WriteArray<Vector3>(writer, msg.positions); NetworkWriterExtensions.WriteQuaternion(writer, msg.rotation); } private static ServerTeleportMsg2 ReadServerTeleportMsg2(this NetworkReader reader) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) return new ServerTeleportMsg2 { entities = reader.ReadEntityArray(), positions = NetworkReaderExtensions.ReadArray<Vector3>(reader), rotation = NetworkReaderExtensions.ReadQuaternion(reader) }; } private static void WriteServerTeleportMsg3(this NetworkWriter writer, ServerTeleportMsg3 msg) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) writer.WriteEntityArray(msg.entities); NetworkWriterExtensions.WriteArray<Vector3>(writer, msg.positions); NetworkWriterExtensions.WriteVector3(writer, msg.velocity); NetworkWriterExtensions.WriteQuaternion(writer, msg.rotation); } private static ServerTeleportMsg3 ReadServerTeleportMsg3(this NetworkReader reader) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) return new ServerTeleportMsg3 { entities = reader.ReadEntityArray(), positions = NetworkReaderExtensions.ReadArray<Vector3>(reader), velocity = NetworkReaderExtensions.ReadVector3(reader), rotation = NetworkReaderExtensions.ReadQuaternion(reader) }; } public static void TeleportInternal(in Entity[] entities, in Vector3[] positions, in Quaternion[] rotations, in Vector3[] velocities) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: 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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < entities.Length; i++) { Entity val = entities[i]; Vector3 val2 = positions[i]; Quaternion val3 = rotations[i]; if (((Entity)(ref val)).Exists(false)) { Rigidbody rigidbody = ((Entity)(ref val)).rigidbody; rigidbody.position = val2; rigidbody.rotation = PhysicsUtil.Constrain(val3, rigidbody.constraints); if (!rigidbody.isKinematic) { rigidbody.velocity = velocities[i]; rigidbody.angularVelocity = Vector3.zero; rigidbody.WakeUp(); } ((Entity)(ref val)).transform.SetPositionAndRotation(val2, val3); } } } private static void OnClientReceiveTeleport1(ServerTeleportMsg1 msg) { if (!NetworkServer.active) { TeleportInternal(in msg.entities, in msg.positions, in msg.rotations, (Vector3[])(object)new Vector3[msg.entities.Length]); PredictedRigidbodyGroup_Patches.ClientClearState(msg.entities); } } private static void OnClientReceiveTeleport2(ServerTeleportMsg2 msg) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) if (!NetworkServer.active) { Quaternion[] rotations = Enumerable.Repeat<Quaternion>(msg.rotation, msg.entities.Length).ToArray(); TeleportInternal(in msg.entities, in msg.positions, in rotations, (Vector3[])(object)new Vector3[msg.entities.Length]); PredictedRigidbodyGroup_Patches.ClientClearState(msg.entities); } } private static void OnClientReceiveTeleport3(ServerTeleportMsg3 msg) { //IL_0009: 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) if (!NetworkServer.active) { Quaternion[] rotations = Enumerable.Repeat<Quaternion>(msg.rotation, msg.entities.Length).ToArray(); Vector3[] velocities = Enumerable.Repeat<Vector3>(msg.velocity, msg.entities.Length).ToArray(); TeleportInternal(in msg.entities, in msg.positions, in rotations, in velocities); PredictedRigidbodyGroup_Patches.ClientClearState(msg.entities); } } } public struct ServerTeleportMsg1 : NetworkMessage { public Entity[] entities; public Vector3[] positions; public Quaternion[] rotations; } public struct ServerTeleportMsg2 : NetworkMessage { public Entity[] entities; public Vector3[] positions; public Quaternion rotation; } public struct ServerTeleportMsg3 : NetworkMessage { public Entity[] entities; public Vector3[] positions; public Vector3 velocity; public Quaternion rotation; } public struct StackContextMsg : NetworkMessage { public uint netId; public Entity[] stack; } public struct ExtendedRigidbodyGroupSyncMsg : NetworkMessage { public uint netId; public uint tick; public ExtendedRigidbodyGroupPayload payload; } } namespace CrashoutCrew_SkysTheLimit.Patches { [HarmonyPatch(typeof(GrabbableHolder))] public class GrabbableHolder_Patches { [HarmonyPatch("OnEntityCreated")] [HarmonyPrefix] public static void OnEntityCreated(GrabbableHolder __instance) { __instance.maximumStackHeight = SkysTheLimitAPI.StackLimit; } } [HarmonyPatch(typeof(Grabbable))] public class Grabbable_Patches { private static readonly Dictionary<uint, Entity[]> PendingStacks = new Dictionary<uint, Entity[]>(); private static float SpringInterpolation(float[] samples, int x) { if (x >= samples.Length) { return samples[^1]; } return samples[x]; } private static void SendStackContext(Grabbable grabbable, List<Entity> stack) { if (NetworkServer.active) { NetworkServer.SendToReadyObservers<StackContextMsg>(((NetworkBehaviour)grabbable).netIdentity, new StackContextMsg { netId = ((NetworkBehaviour)grabbable).netId, stack = stack.ToArray() }, true, 0); } } public static void OnStackContext(StackContextMsg msg) { if (!NetworkServer.active) { PendingStacks[msg.netId] = msg.stack; } } private static void GetRpcStack(Grabbable grabbable, List<Entity> into) { if (PendingStacks.Remove(((NetworkBehaviour)grabbable).netId, out Entity[] value)) { into.AddRange(value); } else { grabbable.GetStack(into); } } [HarmonyPatch("OnInitializeBehaviour")] [HarmonyPrefix] public static void OnInitializeBehaviour_Prefix(Grabbable __instance) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown __instance.springs = (SpringData[])(object)new SpringData[SkysTheLimitAPI.StackLimit]; for (int i = 0; i < __instance.springs.Length; i++) { SpringData val = new SpringData(); val.angularFrequency = SpringInterpolation(new float[4] { 12f, 14f, 16f, 20f }, i); val.dampingRatio = SpringInterpolation(new float[4] { 1.125f, 1.5f, 2f, 3f }, i); val.distanceMultiplier = 1.4f + 1.6f / (float)(i + 1); val.lerpMultiplier = 1f / (0.5f * (float)i + 1f); __instance.springs[i] = val; } } [HarmonyPatch("OnInitializeBehaviour")] [HarmonyPostfix] public static void OnInitializeBehaviour_Postfix(Grabbable __instance) { if (((NetworkBehaviour)__instance).isServer) { __instance.Network_stackSlotsRemaining = SkysTheLimitAPI.StackLimit - 1; } } [HarmonyPatch("OnUpdateSimulation")] public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(instructions); for (int i = 0; i < list.Count; i++) { if (!(list[i].opcode != OpCodes.Ldc_I4_4) && !(list[i + 1].opcode != OpCodes.Stloc_S)) { list[i] = new CodeInstruction(OpCodes.Ldsfld, (object)AccessTools.Field(typeof(SkysTheLimitAPI), "StackLimit")); break; } } return list; } [HarmonyPatch("ServerBackFromOutbound")] [HarmonyPrefix] public static bool ServerBackFromOutbound(Grabbable __instance) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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_0061: 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_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: 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_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: 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_00fa: 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_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: 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) Entity val; if (!NetworkServer.active) { Debug.LogWarning((object)"[Server] function 'System.Void Grabbable::ServerBackFromOutbound()' called when server was not active"); } else if ((Object)(object)__instance.Network_baseGrabbable != (Object)null) { val = EntityExtensions.GetEntity<NetworkIdentity>(__instance.Network_baseGrabbable); ((Entity)(ref val)).GetObject<Grabbable>().ServerBackFromOutbound(); } else { __instance._isInteractable = true; __instance._serverIsOutbounding = false; for (int i = 0; i < __instance._stack.Count; i++) { val = __instance._stack[i]; ((Entity)(ref val)).GetObject<Grabbable>()._serverIsOutbounding = false; } List<Entity> list = new List<Entity>(); __instance.GetStack(list); RoomType currentRoomType = GameUtil.GetCurrentRoomType(); foreach (Entity item in list.Skip(1)) { __instance.SetPhysics(item, currentRoomType); } val = ((IEntityBehaviourBase)__instance).entity; Vector3 position = ((Entity)(ref val)).transform.position; val = ((IEntityBehaviourBase)__instance).entity; Quaternion rotation = ((Entity)(ref val)).transform.rotation; __instance.ServerFixStack(position, rotation); SendStackContext(__instance, list); __instance.RpcReadyFromInbound(Entity.invalid, Entity.invalid, Entity.invalid, currentRoomType); } return false; } [HarmonyPatch("UserCode_RpcReadyFromInbound__Entity__Entity__Entity__RoomType")] [HarmonyPrefix] public static bool UserCode_RpcReadyFromInbound__Entity__Entity__Entity__RoomType(Grabbable __instance, Entity e2, Entity e3, Entity e4, RoomType room) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) if (((NetworkBehaviour)__instance).isServer) { return false; } __instance._isInteractable = true; List<Entity> list = new List<Entity>(); GetRpcStack(__instance, list); foreach (Entity item in list.Skip(1)) { __instance.SetPhysics(item, room); } return false; } [HarmonyPatch("ServerBreakEntireStack")] [HarmonyPrefix] public static bool ServerBreakEntireStack(Grabbable __instance) { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0109: 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_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0154: 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_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016e: 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_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: 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_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0205: 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_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0223: 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_0231: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) Entity val; if (!NetworkServer.active) { Debug.LogWarning((object)"[Server] function 'System.Void Grabbable::ServerBreakEntireStack()' called when server was not active"); } else if ((Object)(object)__instance.Network_baseGrabbable != (Object)null) { val = EntityExtensions.GetEntity<NetworkIdentity>(__instance.Network_baseGrabbable); ((Entity)(ref val)).GetObject<Grabbable>().ServerBreakEntireStack(); } else { if (__instance.serverHolderEntity != Entity.invalid) { Grabbable._holders.Clear(); val = __instance.serverHolderEntity; ((Entity)(ref val)).GetObjects<GrabbableHolder>(Grabbable._holders, (ObjectQueryFlags)3); using (IEnumerator<GrabbableHolder> enumerator = Grabbable._holders.Where((GrabbableHolder holder) => holder.id == __instance.serverHolderId).GetEnumerator()) { if (enumerator.MoveNext()) { enumerator.Current.ServerRemoveItem(); } } __instance.serverHolderEntity = Entity.invalid; } if (__instance.serverPlayerEntity != Entity.invalid) { val = __instance.serverPlayerEntity; ((Entity)(ref val)).GetObject<PlayerGrabber>().ServerDropBoxesSimple(); __instance.serverPlayerEntity = Entity.invalid; } List<Entity> list = new List<Entity>(); __instance.GetStack(list); RoomType currentRoomType = GameUtil.GetCurrentRoomType(); foreach (Entity item in list) { __instance.SetPhysics(item, currentRoomType); } SendStackContext(__instance, list); __instance.RpcBreakStack(Entity.invalid, Entity.invalid, Entity.invalid, Entity.invalid, currentRoomType); val = ((IEntityBehaviourBase)__instance).entity; ((Entity)(ref val)).predictedRigidbodyGroup.ServerResetGroup(); Enumerator<Entity> enumerator3 = __instance._stack.GetEnumerator(); try { while (enumerator3.MoveNext()) { Entity current2 = enumerator3.Current; Grabbable val2 = ((Entity)(ref current2)).GetObject<Grabbable>(); val2.RpcQueueEvBrokeEntireStack(); Vector3 onUnitSphere = Random.onUnitSphere; onUnitSphere.y = math.abs(onUnitSphere.y); Vector3 val3 = ((Entity)(ref current2)).transform.TransformDirection(onUnitSphere); ((Entity)(ref current2)).rigidbody.AddForce(val3 * val2.breakStackForceAmount, (ForceMode)1); val2.Network_baseGrabbable = null; ((Entity)(ref current2)).predictedRigidbodyGroup.ServerResetGroup(); } } finally { ((IDisposable)enumerator3/*cast due to .constrained prefix*/).Dispose(); } __instance._stack.Clear(); __instance.tutorialStackBroken = true; } return false; } [HarmonyPatch("UserCode_RpcBreakStack__Entity__Entity__Entity__Entity__RoomType")] [HarmonyPrefix] public static bool UserCode_RpcBreakStack__Entity__Entity__Entity__Entity__RoomType(Grabbable __instance, Entity e1, Entity e2, Entity e3, Entity e4, RoomType room) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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_002a: Unknown result type (might be due to invalid IL or missing references) if (((NetworkBehaviour)__instance).isServer) { return false; } List<Entity> list = new List<Entity>(); GetRpcStack(__instance, list); foreach (Entity item in list) { __instance.SetPhysics(item, room); } return false; } [HarmonyPatch("ServerPlaceInHolder")] [HarmonyPrefix] public static bool ServerPlaceInHolder(Grabbable __instance, GrabbableHolder holder) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: 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) if (!NetworkServer.active) { Debug.LogWarning((object)"[Server] function 'System.Void Grabbable::ServerPlaceInHolder()' called when server was not active"); } else if ((Object)(object)__instance.Network_baseGrabbable != (Object)null) { Entity entity = EntityExtensions.GetEntity<NetworkIdentity>(__instance.Network_baseGrabbable); ((Entity)(ref entity)).GetObject<Grabbable>().ServerPlaceInHolder(holder); } else { Transform container = holder.container; __instance.serverPlayerEntity = Entity.invalid; __instance.serverHolderEntity = ((IEntityBehaviourBase)holder).entity; __instance.serverHolderId = holder.id; List<Entity> list = new List<Entity>(); __instance.GetStack(list); RoomType currentRoomType = GameUtil.GetCurrentRoomType(); for (int i = 0; i < list.Count; i++) { __instance.SetKinematic(list[i], container, i, true, true); } __instance.ServerFixStack(container.position, container.rotation); SendStackContext(__instance, list); __instance.RpcPlaceInHolder(((IEntityBehaviourBase)holder).entity, holder.id, Entity.invalid, Entity.invalid, Entity.invalid, currentRoomType); } return false; } [HarmonyPatch("UserCode_RpcPlaceInHolder__Entity__Int32__Entity__Entity__Entity__RoomType")] [HarmonyPrefix] public static bool UserCode_RpcPlaceInHolder__Entity__Int32__Entity__Entity__Entity__RoomType(Grabbable __instance, Entity holderEntity, int holderId, Entity e2, Entity e3, Entity e4, RoomType room) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) if (((NetworkBehaviour)__instance).isServer) { return false; } GrabbableHolder val = default(GrabbableHolder); if (!__instance.TryGetHolder(holderEntity, holderId, ref val)) { Debug.LogError((object)"Could not find holder!"); } else { Transform container = val.container; List<Entity> list = new List<Entity>(); GetRpcStack(__instance, list); for (int i = 0; i < list.Count; i++) { __instance.SetKinematic(list[i], container, i, true, true); } } return false; } [HarmonyPatch("ServerPlayerDropped")] [HarmonyPrefix] public static bool ServerPlayerDropped(Grabbable __instance, Vector3 position, Vector3 velocity, Quaternion rotation) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0075: 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_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: 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_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: 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_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) if (!NetworkServer.active) { Debug.LogWarning((object)"[Server] function 'System.Void Grabbable::ServerPlayerDropped(UnityEngine.Vector3,UnityEngine.Vector3,UnityEngine.Quaternion)' called when server was not active"); } else if ((Object)(object)__instance.Network_baseGrabbable != (Object)null) { Entity entity = EntityExtensions.GetEntity<NetworkIdentity>(__instance.Network_baseGrabbable); ((Entity)(ref entity)).GetObject<Grabbable>().ServerPlayerDropped(position, velocity, rotation); } else { List<Entity> list = new List<Entity>(); __instance.GetStack(list); RoomType currentRoomType = GameUtil.GetCurrentRoomType(); __instance.serverPlayerEntity = Entity.invalid; foreach (Entity item in list) { __instance.SetPhysics(item, currentRoomType); } SendStackContext(__instance, list); __instance.RpcPlayerDropped(Entity.invalid, Entity.invalid, Entity.invalid, currentRoomType); Grabbable._entities.Clear(); __instance.GetStack(Grabbable._entities); using (IEnumerator<RigidbodyConstraints> enumerator2 = Grabbable._entities.Select((Entity e) => ((Entity)(ref e)).rigidbody.constraints).Where((Func<RigidbodyConstraints, bool>)PhysicsUtil.IsConstrainingRotation).GetEnumerator()) { if (enumerator2.MoveNext()) { RigidbodyConstraints current2 = enumerator2.Current; rotation = PhysicsUtil.Constrain(rotation, current2); } } __instance.ServerFixStack(position, velocity, rotation); } return false; } [HarmonyPatch("UserCode_RpcPlayerDropped__Entity__Entity__Entity__RoomType")] [HarmonyPrefix] public static bool UserCode_RpcPlayerDropped__Entity__Entity__Entity__RoomType(Grabbable __instance, Entity e2, Entity e3, Entity e4, RoomType room) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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_002a: Unknown result type (might be due to invalid IL or missing references) if (((NetworkBehaviour)__instance).isServer) { return false; } List<Entity> list = new List<Entity>(); GetRpcStack(__instance, list); foreach (Entity item in list) { __instance.SetPhysics(item, room); } return false; } [HarmonyPatch("ServerPlayerGrabbed")] [HarmonyPrefix] public static bool ServerPlayerGrabbed(Grabbable __instance, PlayerGrabber grabber) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: 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) if (!NetworkServer.active) { Debug.LogWarning((object)"[Server] function 'System.Void Grabbable::ServerPlayerGrabbed(PlayerGrabber)' called when server was not active"); } else if ((Object)(object)__instance.Network_baseGrabbable != (Object)null) { Entity entity = EntityExtensions.GetEntity<NetworkIdentity>(__instance.Network_baseGrabbable); ((Entity)(ref entity)).GetObject<Grabbable>().ServerPlayerGrabbed(grabber); } else { Transform grabbedContainer = grabber.grabbedContainer; __instance.serverPlayerEntity = ((IEntityBehaviourBase)grabber).entity; __instance.serverHolderEntity = Entity.invalid; List<Entity> list = new List<Entity>(); __instance.GetStack(list); for (int i = 0; i < list.Count; i++) { __instance.SetKinematic(list[i], grabbedContainer, i, false, false); } SendStackContext(__instance, list); __instance.RpcSetPlaceInPlayerGrabber(((IEntityBehaviourBase)grabber).entity, Entity.invalid, Entity.invalid, Entity.invalid); } return false; } [HarmonyPatch("UserCode_RpcSetPlaceInPlayerGrabber__Entity__Entity__Entity__Entity")] [HarmonyPrefix] public static bool UserCode_RpcSetPlaceInPlayerGrabber__Entity__Entity__Entity__Entity(Grabbable __instance, Entity player, Entity e2, Entity e3, Entity e4) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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) PlayerGrabber val = default(PlayerGrabber); if (((NetworkBehaviour)__instance).isServer || !((Entity)(ref player)).TryGetObject<PlayerGrabber>(ref val)) { return false; } Transform grabbedContainer = val.grabbedContainer; List<Entity> list = new List<Entity>(); GetRpcStack(__instance, list); for (int i = 0; i < list.Count; i++) { __instance.SetKinematic(list[i], grabbedContainer, i, false, false); } EventReference pickUpSfx = __instance.pickUpSfx; Entity entity = ((IEntityBehaviourBase)__instance).entity; AudioManager.PlaySfx(pickUpSfx, ((Entity)(ref entity)).transform.position); return false; } [HarmonyPatch("ServerPlayerPrepareForStacked")] [HarmonyPrefix] public static bool ServerPlayerPrepareForStacked(Grabbable __instance) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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_006f: 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_0098: 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_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) if (!NetworkServer.active) { Debug.LogWarning((object)"[Server] function 'System.Void Grabbable::ServerPlayerPrepareForStacked()' called when server was not active"); } else if ((Object)(object)__instance.Network_baseGrabbable != (Object)null) { Entity entity = EntityExtensions.GetEntity<NetworkIdentity>(__instance.Network_baseGrabbable); ((Entity)(ref entity)).GetObject<Grabbable>().ServerPlayerPrepareForStacked(); } else { List<Entity> list = new List<Entity>(); __instance.GetStack(list); RoomType currentRoomType = GameUtil.GetCurrentRoomType(); __instance.serverPlayerEntity = Entity.invalid; foreach (Entity item in list) { __instance.SetPhysics(item, currentRoomType); } SendStackContext(__instance, list); __instance.RpcPlayerPrepareForStacked(Entity.invalid, Entity.invalid, Entity.invalid, currentRoomType); } return false; } [HarmonyPatch("UserCode_RpcPlayerPrepareForStacked__Entity__Entity__Entity__RoomType")] [HarmonyPrefix] public static bool UserCode_RpcPlayerPrepareForStacked__Entity__Entity__Entity__RoomType(Grabbable __instance, Entity e2, Entity e3, Entity e4, RoomType room) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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_002a: Unknown result type (might be due to invalid IL or missing references) if (((NetworkBehaviour)__instance).isServer) { return false; } List<Entity> list = new List<Entity>(); GetRpcStack(__instance, list); foreach (Entity item in list) { __instance.SetPhysics(item, room); } return false; } [HarmonyPatch("ServerReadyForOutboundTransition")] [HarmonyPrefix] public static bool ServerReadyForOutboundTransition(Grabbable __instance, GrabbableHolder holder) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //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_009d: 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_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) Entity val; if (!NetworkServer.active) { Debug.LogWarning((object)"[Server] function 'System.Void Grabbable::ServerReadyForOutboundTransition(GrabbableHolder)' called when server was not active"); } else if ((Object)(object)__instance.Network_baseGrabbable != (Object)null) { val = EntityExtensions.GetEntity<NetworkIdentity>(__instance.Network_baseGrabbable); ((Entity)(ref val)).GetObject<Grabbable>().ServerReadyForOutboundTransition(holder); } else { __instance._isInteractable = false; __instance._serverIsOutbounding = true; for (int i = 0; i < __instance._stack.Count; i++) { val = __instance._stack[i]; ((Entity)(ref val)).GetObject<Grabbable>()._serverIsOutbounding = true; } Transform container = holder.container; List<Entity> list = new List<Entity>(); __instance.GetStack(list); for (int j = 1; j < list.Count; j++) { __instance.SetKinematic(list[j], container, j, false, true); } SendStackContext(__instance, list); __instance.RpcReadyForOutboundTransition(((IEntityBehaviourBase)holder).entity, holder.id, Entity.invalid, Entity.invalid, Entity.invalid); } return false; } [HarmonyPatch("UserCode_RpcReadyForOutboundTransition__Entity__Int32__Entity__Entity__Entity")] [HarmonyPrefix] public static bool UserCode_RpcReadyForOutboundTransition__Entity__Int32__Entity__Entity__Entity(Grabbable __instance, Entity holderEntity, int holderId, Entity e2, Entity e3, Entity e4) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) if (((NetworkBehaviour)__instance).isServer) { return false; } __instance._isInteractable = false; GrabbableHolder val = default(GrabbableHolder); if (!__instance.TryGetHolder(holderEntity, holderId, ref val)) { Debug.LogError((object)"Could not find holder!"); return false; } Transform container = val.container; List<Entity> list = new List<Entity>(); GetRpcStack(__instance, list); for (int i = 1; i < list.Count; i++) { __instance.SetKinematic(list[i], container, i, false, true); } return false; } [HarmonyPatch("ServerRemoveFromHolder")] [HarmonyPrefix] public static bool ServerRemoveFromHolder(Grabbable __instance) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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_006f: 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_0098: 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_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) if (!NetworkServer.active) { Debug.LogWarning((object)"[Server] function 'System.Void Grabbable::ServerRemoveFromHolder()' called when server was not active"); } else if ((Object)(object)__instance.Network_baseGrabbable != (Object)null) { Entity entity = EntityExtensions.GetEntity<NetworkIdentity>(__instance.Network_baseGrabbable); ((Entity)(ref entity)).GetObject<Grabbable>().ServerRemoveFromHolder(); } else { __instance.serverHolderEntity = Entity.invalid; List<Entity> list = new List<Entity>(); __instance.GetStack(list); RoomType currentRoomType = GameUtil.GetCurrentRoomType(); foreach (Entity item in list) { __instance.SetPhysics(item, currentRoomType); } SendStackContext(__instance, list); __instance.RpcRemoveFromHolder(Entity.invalid, Entity.invalid, Entity.invalid, currentRoomType); } return false; } [HarmonyPatch("UserCode_RpcRemoveFromHolder__Entity__Entity__Entity__RoomType")] [HarmonyPrefix] public static bool UserCode_RpcRemoveFromHolder__Entity__Entity__Entity__RoomType(Grabbable __instance, Entity e2, Entity e3, Entity e4, RoomType room) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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_002a: Unknown result type (might be due to invalid IL or missing references) if (((NetworkBehaviour)__instance).isServer) { return false; } List<Entity> list = new List<Entity>(); GetRpcStack(__instance, list); foreach (Entity item in list) { __instance.SetPhysics(item, room); } return false; } } [HarmonyPatch(typeof(PredictedRigidbodyGroup))] public static class PredictedRigidbodyGroup_Patches { [HarmonyPatch("OnEntityCreated")] [HarmonyPrefix] public static bool OnEntityCreated(PredictedRigidbodyGroup __instance) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) ExtendedPredictedRigidbodyGroup extendedData = GetExtendedData(__instance); __instance.motionSmoothingVelocityThresholdSqr = __instance.motionSmoothingVelocityThreshold * __instance.motionSmoothingVelocityThreshold; __instance.motionSmoothingAngularVelocityThresholdSqr = __instance.motionSmoothingAngularVelocityThreshold * __instance.motionSmoothingAngularVelocityThreshold; __instance.positionCorrectionThresholdSqr = __instance.positionCorrectionThreshold * __instance.positionCorrectionThreshold; Entity entity = ((IEntityBehaviourBase)__instance).entity; __instance.predictedRigidbody = ((Entity)(ref entity)).rigidbody; entity = ((IEntityBehaviourBase)__instance).entity; __instance.predictedRigidbodyTransform = ((Entity)(ref entity)).transform; __instance.tf = __instance.predictedRigidbodyTransform; if (!((NetworkBehaviour)__instance).isServer) { return false; } extendedData.serverGroup.Clear(); extendedData.serverGroup.Add(((IEntityBehaviourBase)__instance).entity); return false; } private static ExtendedPredictedRigidbodyGroup GetExtendedData(PredictedRigidbodyGroup basePrg) { ExtendedPredictedRigidbodyGroup result = default(ExtendedPredictedRigidbodyGroup); if (!((Component)basePrg).TryGetComponent<ExtendedPredictedRigidbodyGroup>(ref result)) { return ((Component)basePrg).gameObject.AddComponent<ExtendedPredictedRigidbodyGroup>(); } return result; } private static List<Entity> GetExtendedGroup(PredictedRigidbodyGroup group) { return GetExtendedData(group).serverGroup; } [HarmonyPatch("ServerAddToGroup")] [HarmonyPrefix] public static bool OnServerAddToGroup(PredictedRigidbodyGroup __instance, Entity e) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) if (!NetworkServer.active) { return true; } if (e == ((IEntityBehaviourBase)__instance).entity) { return false; } List<Entity> extendedGroup = GetExtendedGroup(__instance); if (!extendedGroup.Contains(((IEntityBehaviourBase)__instance).entity)) { extendedGroup.Insert(0, ((IEntityBehaviourBase)__instance).entity); } if (!extendedGroup.Contains(e)) { extendedGroup.Add(e); } ((NetworkBehaviour)__instance).SetDirty(); return false; } [HarmonyPatch("ServerRemoveFromGroup")] [HarmonyPrefix] public static bool OnServerRemoveFromGroup(PredictedRigidbodyGroup __instance, Entity e) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) if (!NetworkServer.active) { return true; } GetExtendedGroup(__instance).Remove(e); ((NetworkBehaviour)__instance).SetDirty(); return false; } [HarmonyPatch("ServerResetGroup")] [HarmonyPrefix] public static bool OnServerResetGroup(PredictedRigidbodyGroup __instance) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) if (!NetworkServer.active) { return true; } List<Entity> extendedGroup = GetExtendedGroup(__instance); extendedGroup.Clear(); extendedGroup.Add(((IEntityBehaviourBase)__instance).entity); ((NetworkBehaviour)__instance).SetDirty(); return false; } [HarmonyPatch("ServerClearGroup")] [HarmonyPrefix] public static bool OnServerClearGroup(PredictedRigidbodyGroup __instance) { if (!NetworkServer.active) { return true; } GetExtendedGroup(__instance).Clear(); ((NetworkBehaviour)__instance).SetDirty(); return false; } [HarmonyPatch("ServerTeleport", new Type[] { typeof(List<Vector3>), typeof(List<Quaternion>) })] [HarmonyPrefix] public static bool OnServerTeleport1(PredictedRigidbodyGroup __instance, List<Vector3> positions, List<Quaternion> rotations) { if (!NetworkServer.active) { return true; } Entity[] entities = GetExtendedGroup(__instance).ToArray(); if (entities.Length == 0) { return true; } Vector3[] positions2 = positions.ToArray(); Quaternion[] rotations2 = rotations.ToArray(); StackNetworkHandler.TeleportInternal(in entities, in positions2, in rotations2, (Vector3[])(object)new Vector3[entities.Length]); NetworkServer.SendToAll<ServerTeleportMsg1>(new ServerTeleportMsg1 { entities = entities, positions = positions2, rotations = rotations2 }, 0, false); ClientClearState(entities); return false; } [HarmonyPatch("ServerTeleport", new Type[] { typeof(List<Vector3>), typeof(Quaternion) })] [HarmonyPrefix] public static bool OnServerTeleport2(PredictedRigidbodyGroup __instance, List<Vector3> positions, Quaternion rotation) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) if (!NetworkServer.active) { return true; } Entity[] entities = GetExtendedGroup(__instance).ToArray(); if (entities.Length == 0) { return true; } Vector3[] positions2 = positions.ToArray(); StackNetworkHandler.TeleportInternal(in entities, in positions2, Enumerable.Repeat<Quaternion>(rotation, entities.Length).ToArray(), (Vector3[])(object)new Vector3[entities.Length]); NetworkServer.SendToAll<ServerTeleportMsg2>(new ServerTeleportMsg2 { entities = entities, positions = positions2, rotation = rotation }, 0, false); ClientClearState(entities); return false; } [HarmonyPatch("ServerTeleport", new Type[] { typeof(List<Vector3>), typeof(Vector3), typeof(Quaternion) })] [HarmonyPrefix] public static bool OnServerTeleport3(PredictedRigidbodyGroup __instance, List<Vector3> positions, Vector3 velocity, Quaternion rotation) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) if (!NetworkServer.active) { return true; } Entity[] entities = GetExtendedGroup(__instance).ToArray(); if (entities.Length == 0) { return true; } Vector3[] positions2 = positions.ToArray(); StackNetworkHandler.TeleportInternal(in entities, in positions2, Enumerable.Repeat<Quaternion>(rotation, entities.Length).ToArray(), Enumerable.Repeat<Vector3>(velocity, entities.Length).ToArray()); NetworkServer.SendToAll<ServerTeleportMsg3>(new ServerTeleportMsg3 { entities = entities, positions = positions2, velocity = velocity, rotation = rotation }, 0, false); ClientClearState(entities); return false; } [HarmonyPatch("OnUpdateSimulationLate")] [HarmonyPrefix] public static bool OnUpdateSimulationLate(PredictedRigidbodyGroup __instance) { //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) ExtendedPredictedRigidbodyGroup extendedData = GetExtendedData(__instance); if (((NetworkBehaviour)__instance).isServer) { if (__instance.IsMoving()) { if (!__instance._wasMovingLastFrame) { __instance._serverSendRpc = true; ((NetworkBehaviour)__instance).ClearAllDirtyBits(); } __instance._wasMovingLastFrame = true; } else { __instance._wasMovingLastFrame = false; } } if (!((NetworkBehaviour)__instance).isClientOnly || extendedData.lastRecorded.group.Count == 0) { return false; } if (__instance.onlyRecordChanges) { bool flag = false; Vector3 val = default(Vector3); Quaternion val2 = default(Quaternion); foreach (RigidbodyGroupEntryState item in extendedData.lastRecorded.group) { RigidbodyGroupEntryState current = item; if (((Entity)(ref current.entity)).Exists(false)) { ((Entity)(ref current.entity)).predictedRigidbodyGroup.tf.GetPositionAndRotation(ref val, ref val2); Vector3 val3 = current.position - val; if ((double)((Vector3)(ref val3)).sqrMagnitude >= __instance.positionCorrectionThresholdSqr || (double)Quaternion.Angle(current.rotation, val2) >= __instance.rotationCorrectionThreshold) { flag = true; break; } } } if (!flag) { return false; } } __instance.RecordState(); return false; } [HarmonyPatch("RecordState")] [HarmonyPrefix] public static bool RecordState(PredictedRigidbodyGroup __instance) { //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: 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) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: 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_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0151: 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_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: 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_0135: 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_0141: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0202: 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_020b: 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_0214: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0172: 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_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0194: 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_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: 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_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) ExtendedPredictedRigidbodyGroup extendedData = GetExtendedData(__instance); double time = NetworkTime.time; if (time < __instance.lastRecordTime + (double)__instance.recordInterval) { return false; } __instance.lastRecordTime = time; double predictedTime = NetworkTime.predictedTime; if (predictedTime == extendedData.lastRecorded.timestamp) { return false; } if (extendedData.stateHistory.Count >= __instance.stateHistoryLimit) { extendedData.stateHistory.RemoveAt(0); } List<Entity> list = new List<Entity>(); for (int i = 0; i < extendedData.lastRecorded.group.Count; i++) { list.Add(extendedData.lastRecorded.group[i].entity); } int count = extendedData.stateHistory.Count; ExtendedRigidbodyGroupState extendedRigidbodyGroupState = new ExtendedRigidbodyGroupState(); if (count > 0) { extendedRigidbodyGroupState = extendedData.stateHistory.Values[count - 1]; } ExtendedRigidbodyGroupState extendedRigidbodyGroupState2 = new ExtendedRigidbodyGroupState(); extendedRigidbodyGroupState2.timestamp = predictedTime; for (int j = 0; j < list.Count; j++) { Entity entity = list[j]; Vector3 zero = Vector3.zero; Quaternion identity = Quaternion.identity; Vector3 val = Vector3.zero; Vector3 val2 = Vector3.zero; if (((Entity)(ref entity)).Exists(false)) { PredictedRigidbodyGroup predictedRigidbodyGroup = ((Entity)(ref entity)).predictedRigidbodyGroup; predictedRigidbodyGroup.tf.GetPositionAndRotation(ref zero, ref identity); val = predictedRigidbodyGroup.predictedRigidbody.velocity; val2 = predictedRigidbodyGroup.predictedRigidbody.angularVelocity; } Vector3 positionDelta = Vector3.zero; Vector3 velocityDelta = Vector3.zero; Vector3 angularVelocityDelta = Vector3.zero; Quaternion rotationDelta = Quaternion.identity; if (count > 0) { RigidbodyGroupEntryState val3 = extendedRigidbodyGroupState.group[j]; positionDelta = zero - val3.position; velocityDelta = val - val3.velocity; Quaternion val4 = identity * Quaternion.Inverse(val3.rotation); rotationDelta = ((Quaternion)(ref val4)).normalized; angularVelocityDelta = val2 - val3.angularVelocity; } extendedRigidbodyGroupState2.group.Add(new RigidbodyGroupEntryState { entity = entity, positionDelta = positionDelta, position = zero, rotationDelta = rotationDelta, rotation = identity, velocityDelta = velocityDelta, velocity = val, angularVelocityDelta = angularVelocityDelta, angularVelocity = val2 }); } extendedData.stateHistory.Add(predictedTime, extendedRigidbodyGroupState2); extendedData.lastRecorded = extendedRigidbodyGroupState2; return false; } [HarmonyPatch("UpdateServer")] [HarmonyPrefix] public static bool UpdateServer(PredictedRigidbodyGroup __instance) { ExtendedPredictedRigidbodyGroup extendedData = GetExtendedData(__instance); if (__instance.reduceSendsWhileIdle) { bool flag = extendedData.serverGroup.Any((Entity t) => ((Entity)(ref t)).Exists(false) && ((Entity)(ref t)).predictedRigidbodyGroup.IsMoving()); ((NetworkBehaviour)__instance).syncInterval = ((!flag || extendedData.serverGroup.Count <= 0) ? 1f : __instance.dynamicMinSyncInterval); } if (extendedData.serverGroup.Count <= 0) { return false; } ((NetworkBehaviour)__instance).SetDirty(); return false; } private static ExtendedRigidbodyGroupState GetRigidbodyGroupState(PredictedRigidbodyGroup __instance, ExtendedRigidbodyGroupPayload payload, double timestamp) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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_0065: 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_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) ExtendedRigidbodyGroupState result = new ExtendedRigidbodyGroupState(); result.timestamp = timestamp; for (int i = 0; i < payload.count; i++) { result.group.Add(new RigidbodyGroupEntryState { entity = ((i != 0) ? payload.entities[i - 1] : ((IEntityBehaviourBase)__instance).entity), position = payload.positions[i], rotation = payload.rotations[i], velocity = payload.velocities[i], angularVelocity = payload.angularVelocities[i] }); } return result; } private static void OnReceivedState(PredictedRigidbodyGroup __instance, in ExtendedRigidbodyGroupState groupState) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0084: 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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: 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_0303: Unknown result type (might be due to invalid IL or missing references) //IL_0308: Unknown result type (might be due to invalid IL or missing references) //IL_0313: Unknown result type (might be due to invalid IL or missing references) //IL_0318: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_031c: 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_0323: Unknown result type (might be due to invalid IL or missing references) //IL_0328: 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_0342: Unknown result type (might be due to invalid IL or missing references) //IL_0347: Unknown result type (might be due to invalid IL or missing references) //IL_0349: Unknown result type (might be due to invalid IL or missing references) List<Vector3> list = new List<Vector3>(); List<float> list2 = new List<float>(); List<Quaternion> list3 = new List<Quaternion>(); int num = 0; while (true) { int num2 = num; int count = groupState.group.Count; if (num2 >= count) { break; } RigidbodyGroupEntryState val = groupState.group[num]; Vector3 zero = Vector3.zero; Quaternion identity = Quaternion.identity; if (((Entity)(ref val.entity)).Exists(false)) { ((Entity)(ref val.entity)).predictedRigidbodyGroup.predictedRigidbodyTransform.GetPositionAndRotation(ref zero, ref identity); } list.Add(zero); list3.Add(identity); list2.Add(Vector3.SqrMagnitude(val.position - zero)); num++; } if (__instance.compareLastFirst) { bool flag = true; int num3 = 0; while (true) { int num4 = num3; int count2 = groupState.group.Count; if (num4 >= count2) { break; } if ((double)list2[num3] < __instance.positionCorrectionThresholdSqr) { if ((double)Quaternion.Angle(groupState.group[num3].rotation, list3[num3]) < __instance.rotationCorrectionThreshold) { num3++; continue; } flag = false; break; } flag = false; break; } if (flag) { return; } } __instance.RecordState(); ExtendedPredictedRigidbodyGroup extendedData = GetExtendedData(__instance); if (extendedData.stateHistory.Count < 2) { return; } ExtendedRigidbodyGroupState extendedRigidbodyGroupState = extendedData.stateHistory.Values[0]; ExtendedRigidbodyGroupState extendedRigidbodyGroupState2 = extendedData.stateHistory.Values[extendedData.stateHistory.Count - 1]; if (groupState.timestamp < extendedRigidbodyGroupState.timestamp) { if (extendedData.stateHistory.Count >= __instance.stateHistoryLimit) { Debug.LogWarning((object)$"Hard correcting client object {((Object)__instance).name} because the client is too far behind the server. History of size={extendedData.stateHistory.Count} @ t={groupState.timestamp:F3} oldest={extendedRigidbodyGroupState.timestamp:F3} newest={extendedRigidbodyGroupState2.timestamp:F3}. This would cause the client to be out of sync as long as it's behind."); } ApplyState(__instance, in groupState); return; } if (extendedRigidbodyGroupState2.timestamp < groupState.timestamp) { if (list2.Any((float t) => (double)t >= __instance.positionCorrectionThresholdSqr)) { ApplyState(__instance, in groupState); } return; } ExtendedRigidbodyGroupState a = default(ExtendedRigidbodyGroupState); ExtendedRigidbodyGroupState b = default(ExtendedRigidbodyGroupState); int afterIndex = default(int); double num5 = default(double); if (!Prediction.Sample<ExtendedRigidbodyGroupState>(extendedData.stateHistory, groupState.timestamp, ref a, ref b, ref afterIndex, ref num5)) { Debug.LogError((object)$"Failed to sample history of size={extendedData.stateHistory.Count} @ t={groupState.timestamp:F3} oldest={extendedRigidbodyGroupState.timestamp:F3} newest={extendedRigidbodyGroupState2.timestamp:F3}. This should never happen because the timestamp is within history."); ApplyState(__instance, in groupState); return; } ExtendedRigidbodyGroupState extendedRigidbodyGroupState3 = ExtendedRigidbodyGroupState.Interpolate(in a, in b, (float)num5); bool flag2 = false; int num6 = 0; while (true) { int num7 = num6; int count3 = groupState.group.Count; if (num7 >= count3) { break; } RigidbodyGroupEntryState val2 = groupState.group[num6]; RigidbodyGroupEntryState val3 = extendedRigidbodyGroupState3.group[num6]; if ((double)Vector3.SqrMagnitude(val2.position - val3.position) < __instance.positionCorrectionThresholdSqr && (double)Quaternion.Angle(val2.rotation, val3.rotation) < __instance.rotationCorrectionThreshold) { num6++; continue; } flag2 = true; break; } if (flag2) { ApplyState(__instance, CorrectHistory(extendedData.stateHistory, __instance.stateHistoryLimit, groupState, a, b, afterIndex)); } } private static void ApplyState(PredictedRigidbodyGroup __instance, in ExtendedRigidbodyGroupState groupState) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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_0151: 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_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: 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_017e: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: 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_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) bool flag = false; float num = __instance.snapThreshold * __instance.snapThreshold; for (int i = 0; i < groupState.group.Count; i++) { Entity entity = groupState.group[i].entity; if (!((Entity)(ref entity)).Exists(false)) { continue; } Rigidbody predictedRigidbody = ((Entity)(ref entity)).predictedRigidbodyGroup.predictedRigidbody; Vector3 val = predictedRigidbody.velocity; if ((double)((Vector3)(ref val)).sqrMagnitude <= (double)num) { val = predictedRigidbody.angularVelocity; if ((double)((Vector3)(ref val)).sqrMagnitude <= (double)num) { flag = true; break; } } } if (flag) { foreach (RigidbodyGroupEntryState item in groupState.group) { RigidbodyGroupEntryState current = item; if (((Entity)(ref current.entity)).Exists(false)) { Rigidbody predictedRigidbody2 = ((Entity)(ref current.entity)).predictedRigidbodyGroup.predictedRigidbody; predictedRigidbody2.position = current.position; predictedRigidbody2.rotation = current.rotation; if (!predictedRigidbody2.isKinematic) { predictedRigidbody2.velocity = current.velocity; predictedRigidbody2.angularVelocity = current.angularVelocity; } } } ExtendedPredictedRigidbodyGroup extendedData = GetExtendedData(__instance); extendedData.stateHistory.Clear(); extendedData.stateHistory.Add(groupState.timestamp, groupState); return; } foreach (RigidbodyGroupEntryState item2 in groupState.group) { RigidbodyGroupEntryState current2 = item2; if (((Entity)(ref current2.entity)).Exists(false)) { Rigidbody predictedRigidbody3 = ((Entity)(ref current2.entity)).predictedRigidbodyGroup.predictedRigidbody; predictedRigidbody3.MovePosition(current2.position); predictedRigidbody3.MoveRotation(current2.rotation); if (!predictedRigidbody3.isKinematic) { predictedRigidbody3.velocity = current2.velocity; predictedRigidbody3.angularVelocity = current2.angularVelocity; } } } } private static ExtendedRigidbodyGroupState CorrectHistory(SortedList<double, ExtendedRigidbodyGroupState> history, int stateHistoryLimit, ExtendedRigidbodyGroupState corrected, ExtendedRigidbodyGroupState before, ExtendedRigidbodyGroupState after, int afterIndex) { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: 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_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_009d: 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_00ab: 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_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00be: 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_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016b: 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_0175: 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_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_018f: 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_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: 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_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: 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) //IL_01da: Unknown result type (might be due to invalid IL or missing references) if (history.Count >= stateHistoryLimit) { history.RemoveAt(0); afterIndex--; } double num = after.timestamp - before.timestamp; double num2 = after.timestamp - corrected.timestamp; double num3 = ((num != 0.0) ? (num2 / num) : 0.0); Quaternion val2; for (int i = 0; i < after.group.Count; i++) { RigidbodyGroupEntryState val = after.group[i]; val.positionDelta = Vector3.Lerp(Vector3.zero, val.positionDelta, (float)num3); val.velocityDelta = Vector3.Lerp(Vector3.zero, val.velocityDelta, (float)num3); val.angularVelocityDelta = Vector3.Lerp(Vector3.zero, val.angularVelocityDelta, (float)num3); val2 = Quaternion.Slerp(Quaternion.identity, val.rotationDelta, (float)num3); val.rotationDelta = ((Quaternion)(ref val2)).normalized; after.group[i] = val; } history[after.timestamp] = after; ExtendedRigidbodyGroupState result = corrected; for (int j = afterIndex; j < history.Count; j++) { double key = history.Keys[j]; ExtendedRigidbodyGroupState extendedRigidbodyGroupState = history.Values[j]; for (int k = 0; k < extendedRigidbodyGroupState.group.Count; k++) { RigidbodyGroupEntryState val3 = extendedRigidbodyGroupState.group[k]; RigidbodyGroupEntryState val4 = result.group[k]; val3.position = val4.position + val3.positionDelta; val3.velocity = val4.velocity + val3.velocityDelta; val3.angularVelocity = val4.angularVelocity + val3.angularVelocityDelta; val2 = val3.rotationDelta * val4.rotation; val3.rotation = ((Quaternion)(ref val2)).normalized; extendedRigidbodyGroupState.group[k] = val3; } history[key] = extendedRigidbodyGroupState; result = extendedRigidbodyGroupState; } return result; } public static void OnSyncMsg(ExtendedRigidbodyGroupSyncMsg msg) { PredictedRigidbodyGroup val = default(PredictedRigidbodyGroup); if (NetworkClient.spawned.TryGetValue(msg.netId, out var value) && !((Object)(object)value == (Object)null) && ((Component)value).TryGetComponent<PredictedRigidbodyGroup>(ref val) && !((NetworkBehaviour)val).isServer && msg.tick > val._lastTick) { val._lastTick = msg.tick; ProcessPayload(val, msg.payload); } } private static void ProcessPayload(PredictedRigidbodyGroup prg, ExtendedRigidbodyGroupPayload payload) { //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) ExtendedPredictedRigidbodyGroup extendedData = GetExtendedData(prg); double remoteTimeStamp = ((NetworkConnection)NetworkClient.connection).remoteTimeStamp; int count = payload.count; if (count != extendedData.lastRecorded.group.Count) { extendedData.stateHistory.Clear(); prg.lastRecordTime = 0.0; extendedData.lastRecorded = new ExtendedRigidbodyGroupState(); } if (count <= 0) { return; } double num = payload.dt; double num2 = remoteTimeStamp + num; if (prg.oneFrameAhead) { num2 += num; } ExtendedRigidbodyGroupState groupState = GetRigidbodyGroupState(prg, payload, num2); bool flag = false;