using System; using System.Buffers.Binary; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Core.Logging.Interpolation; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using Fusion; using Fusion.Sockets; using HarmonyLib; using Il2CppInterop.Runtime; using Il2CppInterop.Runtime.Attributes; using Il2CppInterop.Runtime.Injection; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSystem; using Il2CppSystem.Collections.Generic; using Microsoft.CodeAnalysis; using SSSGame; using UnityEngine; using UnityEngine.Events; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.InputSystem.Utilities; using UnityEngine.Rendering; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("CartPort")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+f125dc1c5a1088217f0d0b2164bf26ae55376f12")] [assembly: AssemblyProduct("CartPort")] [assembly: AssemblyTitle("CartPort")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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 CartPort { internal static class CartPortFusionSession { private static int _dedupeFrame = -1; private static readonly HashSet _dedupePayloadHashes = new HashSet(); private static readonly HashSet _inboundFusionCallbacksRegistered = new HashSet(); private static bool _loggedInboundFusionCallbacksOnce; private static NetworkRunner _cachedRunningRunner; private static bool _loggedSummonDroppedNonAuthorityOnce; internal static bool IsAuthoritativeServerPeer(NetworkRunner runner) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Invalid comparison between Unknown and I4 //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Invalid comparison between Unknown and I4 //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Invalid comparison between Unknown and I4 if ((Object)(object)runner == (Object)null || !runner.IsRunning) { return false; } try { if (runner.IsServer) { return true; } } catch { } GameMode gameMode; try { gameMode = runner.GameMode; } catch { return false; } if ((int)gameMode == 3 || (int)gameMode == 4) { return true; } if ((int)gameMode != 2) { return false; } try { if (runner.IsSharedModeMasterClient) { return true; } } catch { } try { return LikelyDedicatedSharedRelayPeer(runner); } catch { return false; } } private static bool LikelyDedicatedSharedRelayPeer(NetworkRunner runner) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 try { if ((int)SystemInfo.graphicsDeviceType == 4) { return true; } } catch { } try { if (Application.isBatchMode) { return true; } } catch { } try { if (runner.IsClient) { return false; } } catch { return false; } return false; } internal static void TryLogSummonDroppedNonAuthority(NetworkRunner runner, string inboundLabel) { //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Expected O, but got Unknown //IL_00a6: 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_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) if (_loggedSummonDroppedNonAuthorityOnce) { return; } _loggedSummonDroppedNonAuthorityOnce = true; bool flag = default(bool); try { string value = "?"; try { GameMode gameMode = runner.GameMode; value = ((object)(GameMode)(ref gameMode)).ToString(); } catch { } string value2 = "?"; string value3 = "?"; string value4 = "?"; try { flag = runner.IsServer; value2 = flag.ToString(); } catch { } try { flag = runner.IsClient; value3 = flag.ToString(); } catch { } try { flag = runner.IsSharedModeMasterClient; value4 = flag.ToString(); } catch { } string value5 = "?"; string value6 = "?"; try { flag = Application.isBatchMode; value5 = flag.ToString(); } catch { } try { GraphicsDeviceType graphicsDeviceType = SystemInfo.graphicsDeviceType; value6 = ((object)(GraphicsDeviceType)(ref graphicsDeviceType)).ToString(); } catch { } CartPortPlugin.Log.LogWarning((object)($"CartPort: CPRT summon ReliableData ignored — this peer is not treated as summon authority ({inboundLabel}). GameMode={value} IsServer={value2} IsClient={value3} IsSharedModeMasterClient={value4} BatchMode={value5} GraphicsDeviceType={value6}. " + "If this is the dedicated server, widen IsAuthoritativeServerPeer or enable Simulation socket + diagnostics.")); } catch (Exception ex) { ManualLogSource log = CartPortPlugin.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(46, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("CartPort: summon non-authority diag failed ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")."); } log.LogWarning(val); } } internal static bool TrySummonAuthoritative(Structure structure, Vector3 position, Quaternion rotation, out bool clientSentReliableAwaitingHost) { //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Expected O, but got Unknown //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Expected O, but got Unknown //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Expected O, but got Unknown //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011f: 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_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0133: 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_00e9: 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_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: 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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0171: 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_017f: 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_019b: Expected O, but got Unknown //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) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown clientSentReliableAwaitingHost = false; if (!CartPortPlugin.ServerAuthoritativeSummon.Value) { return false; } NetworkRunner val = TryGetRunningRunner(); if ((Object)(object)val == (Object)null || !val.IsRunning) { return false; } NetworkObject val2 = ((Component)structure).GetComponent() ?? ((Component)structure).GetComponentInParent(); if (!((Object)(object)val2 == (Object)null)) { NetworkId id = val2.Id; if (((NetworkId)(ref id)).IsValid) { bool flag2 = default(bool); try { if (val2.HasStateAuthority) { CartSummon.ApplySummonOnAuthorityImmediate(structure, position, rotation); ManualLogSource log = CartPortPlugin.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(83, 0, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("CartPort: Local peer has state authority — applied direct summon (no server relay)."); } log.LogInfo(val3); return true; } } catch (Exception ex) { ManualLogSource log2 = CartPortPlugin.Log; BepInExWarningLogInterpolatedStringHandler val4 = new BepInExWarningLogInterpolatedStringHandler(74, 1, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("CartPort: HasStateAuthority check failed ("); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(ex.Message); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("); continuing normal relay path."); } log2.LogWarning(val4); } if (IsAuthoritativeServerPeer(val)) { CartSummon.ApplySummonOnAuthority(structure, position, rotation); return true; } PlayerRef val5 = default(PlayerRef); bool flag3 = false; try { val5 = val2.StateAuthority; flag3 = ((PlayerRef)(ref val5)).PlayerId >= 0; } catch { } PlayerRef val6 = default(PlayerRef); try { val6 = val.LocalPlayer; } catch { } try { byte[] array = CartPortSummonPayload.Serialize(val2.Id, position, rotation); Il2CppStructArray val7 = new Il2CppStructArray((long)array.Length); for (int i = 0; i < array.Length; i++) { ((Il2CppArrayBase)(object)val7)[i] = array[i]; } bool flag4 = false; if (flag3 && val5 != val6) { try { val.SendReliableDataToPlayer(val5, val7); flag4 = true; ManualLogSource log3 = CartPortPlugin.Log; BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(88, 1, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("CartPort: Sent summon request directly to state-authority player "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(((PlayerRef)(ref val5)).PlayerId); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" (Fusion ReliableData)."); } log3.LogInfo(val3); } catch (Exception ex2) { ManualLogSource log4 = CartPortPlugin.Log; BepInExWarningLogInterpolatedStringHandler val4 = new BepInExWarningLogInterpolatedStringHandler(89, 2, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("CartPort: SendReliableDataToPlayer("); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(((PlayerRef)(ref val5)).PlayerId); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(") failed ("); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(ex2.Message); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("); falling back to SendReliableDataToServer."); } log4.LogWarning(val4); } } if (!flag4) { val.SendReliableDataToServer(val7); CartPortPlugin.Log.LogInfo((object)"CartPort: Sent summon request to server/master (Fusion ReliableData). Local prediction will run next."); } clientSentReliableAwaitingHost = true; return true; } catch (Exception ex3) { ManualLogSource log5 = CartPortPlugin.Log; BepInExWarningLogInterpolatedStringHandler val4 = new BepInExWarningLogInterpolatedStringHandler(74, 1, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("CartPort: Fusion ReliableData send failed ("); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(ex3.Message); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("); using local summon fallback."); } log5.LogWarning(val4); return false; } } } return false; } internal static void HandleReliableSummonFromSimulation(NetworkRunner runner, PlayerRef player, Il2CppStructArray dataArray) { if (!CartPortPlugin.ServerAuthoritativeSummon.Value) { return; } if ((Object)(object)runner == (Object)null || !IsAuthoritativeServerPeer(runner)) { if ((Object)(object)runner != (Object)null && dataArray != null && ((Il2CppArrayBase)(object)dataArray).Length >= CartPortSummonPayload.TotalByteCount && CartPortSummonPayload.HasCartPortMagicPrefix(dataArray)) { TryLogSummonDroppedNonAuthority(runner, "simulation Il2CppStructArray"); } } else if (dataArray != null && ((Il2CppArrayBase)(object)dataArray).Length >= CartPortSummonPayload.TotalByteCount) { int length = ((Il2CppArrayBase)(object)dataArray).Length; byte[] array = new byte[length]; for (int i = 0; i < length; i++) { array[i] = ((Il2CppArrayBase)(object)dataArray)[i]; } ApplySummonPayloadFromManagedBytes(runner, array, length, "simulation Il2CppStructArray"); } } internal static void HandleReliableSummonFromSimulation(NetworkRunner runner, PlayerRef player, ArraySegment segment) { if (!CartPortPlugin.ServerAuthoritativeSummon.Value) { return; } if ((Object)(object)runner == (Object)null || !IsAuthoritativeServerPeer(runner)) { if ((Object)(object)runner != (Object)null && segment.Count >= CartPortSummonPayload.TotalByteCount && CartPortSummonPayload.HasCartPortMagicPrefix(segment)) { TryLogSummonDroppedNonAuthority(runner, "RunnerCallbacks Il2Cpp ArraySegment"); } } else { if (segment.Count < CartPortSummonPayload.TotalByteCount) { return; } Il2CppArrayBase array = segment.Array; if (array != null) { byte[] array2 = new byte[segment.Count]; int offset = segment.Offset; for (int i = 0; i < segment.Count; i++) { array2[i] = array[offset + i]; } ApplySummonPayloadFromManagedBytes(runner, array2, segment.Count, "RunnerCallbacks Il2Cpp ArraySegment"); } } } internal static void HandleReliableSummonFromSimulation(NetworkRunner runner, PlayerRef player, ArraySegment segment) { if (!CartPortPlugin.ServerAuthoritativeSummon.Value) { return; } if ((Object)(object)runner == (Object)null || !IsAuthoritativeServerPeer(runner)) { if ((Object)(object)runner != (Object)null && segment.Count >= CartPortSummonPayload.TotalByteCount && CartPortSummonPayload.HasCartPortMagicPrefix(segment)) { TryLogSummonDroppedNonAuthority(runner, "RunnerCallbacks System.ArraySegment"); } } else if (segment.Count >= CartPortSummonPayload.TotalByteCount) { byte[] array = new byte[segment.Count]; segment.AsSpan().CopyTo(array); ApplySummonPayloadFromManagedBytes(runner, array, segment.Count, "RunnerCallbacks System.ArraySegment"); } } internal static void NotifyRunnerSeen(NetworkRunner runner) { try { if ((Object)(object)runner != (Object)null && runner.IsRunning) { _cachedRunningRunner = runner; } } catch { } TryRegisterInboundFusionCallbacks(runner); } internal static void TryRegisterInboundFusionCallbacks(NetworkRunner runner) { //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Expected O, but got Unknown if (!CartPortPlugin.RegisterFusionInboundRunnerCallbacks.Value || !CartPortPlugin.ServerAuthoritativeSummon.Value) { return; } CartPortPlugin.EnsureFusionInboundClassInjectorRegistered(); if (!CartPortPlugin.FusionInboundCallbacksClassInjectorOk || (Object)(object)runner == (Object)null || !runner.IsRunning) { return; } IntPtr pointer; try { pointer = ((Il2CppObjectBase)runner).Pointer; } catch { return; } if (!_inboundFusionCallbacksRegistered.Add(pointer)) { return; } try { if (CartPortPlugin.FusionInboundCallbacksUseInjectPath) { INetworkRunnerCallbacks val = ((Il2CppObjectBase)new CartPortInboundFusionCallbacksInjected()).TryCast(); if (val == null) { _inboundFusionCallbacksRegistered.Remove(pointer); CartPortPlugin.Log.LogWarning((object)"CartPort: TryCast to INetworkRunnerCallbacks failed — AddCallbacks skipped (inject path)."); return; } runner.AddCallbacks((INetworkRunnerCallbacks[])(object)new INetworkRunnerCallbacks[1] { val }); } else { runner.AddCallbacks((INetworkRunnerCallbacks[])(object)new INetworkRunnerCallbacks[1] { new CartPortInboundFusionCallbacksSubclass() }); } if (!_loggedInboundFusionCallbacksOnce) { _loggedInboundFusionCallbacksOnce = true; CartPortPlugin.Log.LogInfo((object)"CartPort: Registered Fusion INetworkRunnerCallbacks (NetworkRunner.AddCallbacks) for summon ReliableData."); } } catch (Exception ex) { _inboundFusionCallbacksRegistered.Remove(pointer); ManualLogSource log = CartPortPlugin.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(47, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("CartPort: NetworkRunner.AddCallbacks failed ("); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex.Message); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(")."); } log.LogWarning(val2); } } private static void ApplySummonPayloadFromManagedBytes(NetworkRunner runner, byte[] tmp, int count, string sourceLabel) { //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Expected O, but got Unknown //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Expected O, but got Unknown //IL_00d6: 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_00c7: 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_00fe: Expected O, but got Unknown //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Expected O, but got Unknown //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)runner == (Object)null) { return; } int frameCount = Time.frameCount; if (frameCount != _dedupeFrame) { _dedupeFrame = frameCount; _dedupePayloadHashes.Clear(); } HashCode hashCode = default(HashCode); for (int i = 0; i < count; i++) { hashCode.Add(tmp[i]); } int item = hashCode.ToHashCode(); if (!_dedupePayloadHashes.Add(item) || !CartPortSummonPayload.TryDeserialize(new ArraySegment(tmp, 0, count), out var networkId, out var position, out var rotation)) { return; } ManualLogSource log = CartPortPlugin.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(70, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("CartPort: Server received summon ReliableData ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(sourceLabel); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") for NetworkId "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(networkId.Raw); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" → pos "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(position); } log.LogInfo(val); if (!TryResolveNetworkObjectForSummon(runner, networkId, out var netObj) || (Object)(object)netObj == (Object)null) { ManualLogSource log2 = CartPortPlugin.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(154, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("CartPort: Server could not resolve NetworkId "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(networkId.Raw); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" for summon (TryFindObject + AOI fallback exhausted). Object may be outside simulation interest on this peer."); } log2.LogWarning(val2); return; } Structure componentInChildren = ((Component)netObj).GetComponentInChildren(true); if ((Object)(object)componentInChildren == (Object)null) { ManualLogSource log3 = CartPortPlugin.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(55, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("CartPort: NetworkObject '"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(((Object)netObj).name); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' has no Structure for summon."); } log3.LogWarning(val2); return; } try { CartSummon.ApplySummonOnAuthority(componentInChildren, position, rotation); } catch (Exception ex) { ManualLogSource log4 = CartPortPlugin.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(34, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("CartPort: Server summon failed ("); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex.Message); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(")."); } log4.LogWarning(val2); } } internal static bool TryResolveNetworkObjectForSummon(NetworkRunner runner, NetworkId netId, out NetworkObject netObj) { //IL_0004: 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_004a: 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) netObj = null; try { if (runner.TryFindObject(netId, ref netObj) && (Object)(object)netObj != (Object)null) { return true; } } catch { netObj = null; } try { foreach (NetworkObject item in Resources.FindObjectsOfTypeAll()) { if ((Object)(object)item == (Object)null) { continue; } NetworkId id = item.Id; if (!((NetworkId)(ref id)).IsValid || item.Id != netId) { continue; } try { if ((Object)(object)item.Runner == (Object)(object)runner) { netObj = item; return true; } } catch { netObj = item; return true; } } } catch { } netObj = null; return false; } internal static NetworkRunner TryGetRunningRunner() { //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) try { if ((Object)(object)_cachedRunningRunner != (Object)null && _cachedRunningRunner.IsRunning && IsAuthoritativeServerPeer(_cachedRunningRunner)) { return _cachedRunningRunner; } } catch { _cachedRunningRunner = null; } NetworkRunner val = null; NetworkRunner val2 = null; NetworkRunner val3 = null; foreach (NetworkRunner item in Resources.FindObjectsOfTypeAll()) { if ((Object)(object)item == (Object)null || !item.IsRunning || (Object)(object)((Component)item).gameObject == (Object)null) { continue; } if (val3 == null) { val3 = item; } try { if (IsAuthoritativeServerPeer(item) && val == null) { val = item; } Scene scene = ((Component)item).gameObject.scene; if (((Scene)(ref scene)).IsValid() && val2 == null) { val2 = item; } } catch { } } NetworkRunner val4 = val ?? val2 ?? val3; try { if ((Object)(object)_cachedRunningRunner != (Object)null && _cachedRunningRunner.IsRunning && val4 == null) { val4 = _cachedRunningRunner; } } catch { _cachedRunningRunner = null; } if ((Object)(object)val4 != (Object)null) { NotifyRunnerSeen(val4); } return val4; } internal static NetworkRunner TryGetRunnerForSimulation(Simulation simulation) { if (simulation == null) { return null; } try { ICallbacks callbacks = simulation.Callbacks; if (callbacks != null) { NetworkRunner val = ((Il2CppObjectBase)callbacks).TryCast(); if ((Object)(object)val != (Object)null) { return val; } } } catch { } foreach (NetworkRunner item in Resources.FindObjectsOfTypeAll()) { if ((Object)(object)item == (Object)null || !item.IsRunning) { continue; } try { if (item.Simulation == simulation) { return item; } } catch { } } return null; } } internal static class CartPortGameplayInputSuspend { private static Dictionary _snapshot; internal static bool IsActive => _snapshot != null; internal static void Push() { //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) Pop(); _snapshot = new Dictionary(); foreach (PlayerInput item in Resources.FindObjectsOfTypeAll()) { if ((Object)(object)((item != null) ? item.actions : null) == (Object)null) { continue; } Scene scene = ((Component)item).gameObject.scene; if (!((Scene)(ref scene)).IsValid()) { continue; } scene = ((Component)item).gameObject.scene; if (!((Scene)(ref scene)).isLoaded) { continue; } ReadOnlyArray actionMaps = item.actions.actionMaps; for (int i = 0; i < actionMaps.Count; i++) { InputActionMap val = actionMaps[i]; if (val != null && !_snapshot.ContainsKey(val)) { _snapshot[val] = val.enabled; } } } foreach (InputActionAsset item2 in Resources.FindObjectsOfTypeAll()) { if (((item2 != null) ? item2.actionMaps : null) == null) { continue; } ReadOnlyArray actionMaps2 = item2.actionMaps; for (int j = 0; j < actionMaps2.Count; j++) { InputActionMap val2 = actionMaps2[j]; if (val2 != null && !_snapshot.ContainsKey(val2)) { _snapshot[val2] = val2.enabled; } } } ApplySuspend(); if (CartPortPlugin.VerboseLogging.Value && _snapshot.Count == 0) { CartPortPlugin.Log.LogInfo((object)"CartPort: No InputActionMaps found to suspend (camera may still move)."); } } internal static void Pop() { if (_snapshot == null) { return; } foreach (KeyValuePair item in _snapshot) { InputActionMap key = item.Key; if (key == null) { continue; } try { if (item.Value) { key.Enable(); } else { key.Disable(); } } catch { } } _snapshot = null; } internal static void ReassertGameplayDisabled() { if (_snapshot == null) { return; } foreach (InputActionMap key in _snapshot.Keys) { if (key != null && IsGameplayMap(key.name) && key.enabled) { key.Disable(); } } } private static void ApplySuspend() { foreach (InputActionMap key in _snapshot.Keys) { if (key != null) { string n = key.name ?? string.Empty; if (IsGameplayMap(n)) { key.Disable(); } else if (IsUiLikeMap(n)) { key.Enable(); } } } } private static bool IsGameplayMap(string n) { if (string.IsNullOrEmpty(n)) { return false; } if (!n.Contains("Player", StringComparison.OrdinalIgnoreCase) && !n.Contains("Gameplay", StringComparison.OrdinalIgnoreCase) && !n.Contains("Character", StringComparison.OrdinalIgnoreCase) && !n.Contains("Ground", StringComparison.OrdinalIgnoreCase) && !n.Contains("Look", StringComparison.OrdinalIgnoreCase) && !n.Contains("Camera", StringComparison.OrdinalIgnoreCase) && !n.Contains("Aim", StringComparison.OrdinalIgnoreCase)) { return n.Contains("Move", StringComparison.OrdinalIgnoreCase); } return true; } private static bool IsUiLikeMap(string n) { if (string.IsNullOrEmpty(n)) { return false; } if (!n.Contains("UI", StringComparison.OrdinalIgnoreCase) && !n.Contains("Menu", StringComparison.OrdinalIgnoreCase) && !n.Contains("Interface", StringComparison.OrdinalIgnoreCase) && !n.Contains("Build", StringComparison.OrdinalIgnoreCase)) { return n.Contains("Construct", StringComparison.OrdinalIgnoreCase); } return true; } } internal static class CartPortGameReliablePatches { private static bool _attemptedLateDiscover; internal static bool DiscoveryComplete { get; private set; } internal static int PatchedCallbackMethodCount { get; private set; } internal static void TryDiscoverExtended(Harmony harmony) { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown if (harmony == null || PatchedCallbackMethodCount > 0) { return; } bool flag = default(bool); try { DiscoveryComplete = false; DiscoverInner(harmony); ManualLogSource log = CartPortPlugin.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(83, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("CartPort: Extended reliable callback discovery finished (total patched "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(PatchedCallbackMethodCount); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" method(s))."); } log.LogInfo(val); if (PatchedCallbackMethodCount == 0) { CartPortPlugin.Log.LogWarning((object)"CartPort: Extended discovery still found no OnReliableDataReceived patch targets — inbound summon may rely on Fusion simulation hooks only."); } } catch (Exception ex) { ManualLogSource log2 = CartPortPlugin.Log; BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(58, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("CartPort: Extended reliable callback discovery aborted ("); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(")."); } log2.LogError(val2); } } internal static void TryDiscoverLate(Harmony harmony) { //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Expected O, but got Unknown //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown if (harmony == null || _attemptedLateDiscover || PatchedCallbackMethodCount > 0) { return; } _attemptedLateDiscover = true; DiscoveryComplete = false; bool flag = default(bool); try { DiscoverInner(harmony); ManualLogSource log = CartPortPlugin.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(73, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("CartPort: Late reliable callback discovery complete (patched "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(PatchedCallbackMethodCount); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" method(s))."); } log.LogInfo(val); } catch (Exception ex) { DiscoveryComplete = true; ManualLogSource log2 = CartPortPlugin.Log; BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(54, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("CartPort: Late reliable callback discovery aborted ("); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(")."); } log2.LogError(val2); } } internal static void TryDiscover(Harmony harmony) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown if (DiscoveryComplete || harmony == null) { return; } try { DiscoverInner(harmony); } catch (Exception ex) { DiscoveryComplete = true; ManualLogSource log = CartPortPlugin.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(49, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("CartPort: Reliable callback discovery aborted ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")."); } log.LogError(val); } } private static void DiscoverInner(Harmony harmony) { //IL_0338: Unknown result type (might be due to invalid IL or missing references) //IL_033f: Expected O, but got Unknown //IL_03f0: Unknown result type (might be due to invalid IL or missing references) //IL_03f7: Expected O, but got Unknown //IL_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Expected O, but got Unknown //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Expected O, but got Unknown MethodInfo methodInfo = AccessTools.Method(typeof(CartPortGameReliablePatches), "PostfixIl2CppArraySegment", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(CartPortGameReliablePatches), "PostfixSystemArraySegment", (Type[])null, (Type[])null); Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); bool flag2 = default(bool); BepInExInfoLogInterpolatedStringHandler val; foreach (Assembly assembly in assemblies) { if (ShouldSkipAssemblyForReliableDiscovery(assembly.GetName().Name)) { continue; } Type[] types; try { types = assembly.GetTypes(); } catch (ReflectionTypeLoadException ex) { types = ex.Types; } Type[] array = types; foreach (Type type in array) { if (type == null || type.IsInterface || type.IsAbstract) { continue; } string text = type.Namespace ?? string.Empty; if (text.StartsWith("Fusion.", StringComparison.Ordinal) || text.StartsWith("Il2Cpp", StringComparison.Ordinal) || text.StartsWith("CartPort", StringComparison.Ordinal)) { continue; } MethodInfo[] methods = type.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (MethodInfo methodInfo3 in methods) { if (methodInfo3.Name.IndexOf("OnReliableDataReceived", StringComparison.Ordinal) < 0) { continue; } ParameterInfo[] parameters = methodInfo3.GetParameters(); if (parameters.Length != 3 || parameters[0].ParameterType.IsByRef || parameters[1].ParameterType.IsByRef || parameters[2].ParameterType.IsByRef || !typeof(NetworkRunner).IsAssignableFrom(parameters[0].ParameterType) || !typeof(PlayerRef).IsAssignableFrom(parameters[1].ParameterType)) { continue; } Type parameterType = parameters[2].ParameterType; string? fullName = parameterType.FullName; MethodInfo methodInfo4; if (fullName != null && fullName.Contains("Il2CppSystem.ArraySegment", StringComparison.Ordinal)) { methodInfo4 = methodInfo; } else { string? fullName2 = parameterType.FullName; if (fullName2 == null || !fullName2.Contains("System.ArraySegment", StringComparison.Ordinal)) { continue; } string? fullName3 = parameterType.FullName; if (fullName3 != null && fullName3.Contains("Il2CppSystem", StringComparison.Ordinal)) { continue; } methodInfo4 = methodInfo2; } bool flag = false; try { Patches patchInfo = Harmony.GetPatchInfo((MethodBase)methodInfo3); if (patchInfo?.Postfixes != null) { foreach (Patch postfix in patchInfo.Postfixes) { MethodInfo patchMethod = postfix.PatchMethod; if (patchMethod != null && postfix.owner == "com.cartport.aska" && patchMethod.Name == methodInfo4.Name) { flag = true; break; } } } } catch { } if (flag) { continue; } try { harmony.Patch((MethodBase)methodInfo3, (HarmonyMethod)null, new HarmonyMethod(methodInfo4), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); PatchedCallbackMethodCount++; ManualLogSource log = CartPortPlugin.Log; val = new BepInExInfoLogInterpolatedStringHandler(63, 2, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("CartPort: Harmony postfix on "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(type.FullName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(methodInfo3.Name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" (ReliableData → summon handler)."); } log.LogInfo(val); } catch (Exception ex2) { ManualLogSource log2 = CartPortPlugin.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(29, 3, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("CartPort: Failed to patch "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(type.FullName); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("."); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(methodInfo3.Name); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex2.Message); } log2.LogWarning(val2); } } } } DiscoveryComplete = true; if (PatchedCallbackMethodCount == 0) { CartPortPlugin.Log.LogWarning((object)"CartPort: No Assembly-CSharp OnReliableDataReceived methods were patched — dedicated server may still miss summon ReliableData unless Fusion simulation hook fires."); return; } ManualLogSource log3 = CartPortPlugin.Log; val = new BepInExInfoLogInterpolatedStringHandler(74, 1, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("CartPort: Patched "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(PatchedCallbackMethodCount); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" game OnReliableDataReceived method(s) for summon relay."); } log3.LogInfo(val); } private static bool ShouldSkipAssemblyForReliableDiscovery(string an) { if (string.IsNullOrEmpty(an)) { return true; } if (an.Equals("Assembly-CSharp", StringComparison.Ordinal) || an.IndexOf("Assembly-CSharp", StringComparison.Ordinal) >= 0) { return false; } string[] array = new string[17] { "System", "mscorlib", "netstandard", "UnityEngine", "Unity.", "Fusion.", "Mono.", "Il2CppInterop", "Il2Cppmscorlib", "Il2CppSystem", "Il2Cpp", "BepInEx", "HarmonyLib", "CartPort", "Newtonsoft", "Microsoft.", "NuGet" }; foreach (string value in array) { if (an.StartsWith(value, StringComparison.Ordinal)) { return true; } } return false; } private static void PostfixIl2CppArraySegment(object __instance, NetworkRunner runner, PlayerRef player, ArraySegment data) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) CartPortFusionSession.HandleReliableSummonFromSimulation(runner, player, data); } private static void PostfixSystemArraySegment(object __instance, NetworkRunner runner, PlayerRef player, ArraySegment data) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) CartPortFusionSession.HandleReliableSummonFromSimulation(runner, player, data); } } [Il2CppImplements(new Type[] { typeof(INetworkRunnerCallbacks) })] internal sealed class CartPortInboundFusionCallbacksInjected : Il2CppObjectBase { internal CartPortInboundFusionCallbacksInjected() : base(IL2CPP.il2cpp_object_new(Il2CppClassPointerStore.NativeClassPtr)) { } internal CartPortInboundFusionCallbacksInjected(IntPtr ptr) : base(ptr) { } public void OnReliableDataReceived(NetworkRunner runner, PlayerRef player, ArraySegment data) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) CartPortFusionSession.HandleReliableSummonFromSimulation(runner, player, data); } public void OnPlayerJoined(NetworkRunner runner, PlayerRef player) { } public void OnPlayerLeft(NetworkRunner runner, PlayerRef player) { } public void OnInput(NetworkRunner runner, NetworkInput input) { } public void OnInputMissing(NetworkRunner runner, PlayerRef player, NetworkInput input) { } public void OnShutdown(NetworkRunner runner, ShutdownReason shutdownReason) { } public void OnConnectedToServer(NetworkRunner runner) { } public void OnDisconnectedFromServer(NetworkRunner runner) { } public void OnConnectRequest(NetworkRunner runner, ConnectRequest request, Il2CppStructArray token) { } public void OnConnectFailed(NetworkRunner runner, NetAddress remoteAddress, NetConnectFailedReason reason) { } public void OnUserSimulationMessage(NetworkRunner runner, SimulationMessagePtr message) { } public void OnSessionListUpdated(NetworkRunner runner, List sessionList) { } public void OnCustomAuthenticationResponse(NetworkRunner runner, Dictionary data) { } public void OnHostMigration(NetworkRunner runner, HostMigrationToken hostMigrationToken) { } public void OnSceneLoadDone(NetworkRunner runner) { } public void OnSceneLoadStart(NetworkRunner runner) { } } internal sealed class CartPortInboundFusionCallbacksSubclass : INetworkRunnerCallbacks { internal CartPortInboundFusionCallbacksSubclass() : base(IL2CPP.il2cpp_object_new(Il2CppClassPointerStore.NativeClassPtr)) { } internal CartPortInboundFusionCallbacksSubclass(IntPtr ptr) : base(ptr) { } public override void OnReliableDataReceived(NetworkRunner runner, PlayerRef player, ArraySegment data) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) CartPortFusionSession.HandleReliableSummonFromSimulation(runner, player, data); } public override void OnPlayerJoined(NetworkRunner runner, PlayerRef player) { } public override void OnPlayerLeft(NetworkRunner runner, PlayerRef player) { } public override void OnInput(NetworkRunner runner, NetworkInput input) { } public override void OnInputMissing(NetworkRunner runner, PlayerRef player, NetworkInput input) { } public override void OnShutdown(NetworkRunner runner, ShutdownReason shutdownReason) { } public override void OnConnectedToServer(NetworkRunner runner) { } public override void OnDisconnectedFromServer(NetworkRunner runner) { } public override void OnConnectRequest(NetworkRunner runner, ConnectRequest request, Il2CppStructArray token) { } public override void OnConnectFailed(NetworkRunner runner, NetAddress remoteAddress, NetConnectFailedReason reason) { } public override void OnUserSimulationMessage(NetworkRunner runner, SimulationMessagePtr message) { } public override void OnSessionListUpdated(NetworkRunner runner, List sessionList) { } public override void OnCustomAuthenticationResponse(NetworkRunner runner, Dictionary data) { } public override void OnHostMigration(NetworkRunner runner, HostMigrationToken hostMigrationToken) { } public override void OnSceneLoadDone(NetworkRunner runner) { } public override void OnSceneLoadStart(NetworkRunner runner) { } } internal static class CartPortInput { internal static Vector2 MouseGuiPosition() { //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_0034: 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_0047: 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_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: 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_0028: Unknown result type (might be due to invalid IL or missing references) Mouse current = Mouse.current; if (current != null) { Vector2 val = ((InputControl)(object)((Pointer)current).position).ReadValue(); return new Vector2(val.x, (float)Screen.height - val.y); } Vector3 mousePosition = Input.mousePosition; return new Vector2(mousePosition.x, (float)Screen.height - mousePosition.y); } internal static bool WasLeftClickPressed() { Mouse current = Mouse.current; if (current != null && current.leftButton.wasPressedThisFrame) { return true; } return Input.GetMouseButtonDown(0); } internal static bool GetKeyDown(KeyCode code) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) Keyboard current = Keyboard.current; if (current != null && TryGetKeyControl(current, code, out var ctrl) && ((ButtonControl)ctrl).wasPressedThisFrame) { return true; } return Input.GetKeyDown(code); } internal static bool WasDigitRowPressed(int digit1To9) { //IL_00cd: Unknown result type (might be due to invalid IL or missing references) if ((digit1To9 < 1 || digit1To9 > 9) ? true : false) { return false; } Keyboard current = Keyboard.current; if (current != null) { KeyControl val = (KeyControl)(digit1To9 switch { 1 => current.digit1Key, 2 => current.digit2Key, 3 => current.digit3Key, 4 => current.digit4Key, 5 => current.digit5Key, 6 => current.digit6Key, 7 => current.digit7Key, 8 => current.digit8Key, 9 => current.digit9Key, _ => null, }); if (val != null && ((ButtonControl)val).wasPressedThisFrame) { return true; } } KeyCode? val2 = DigitToAlphaKeyCode(digit1To9); if (val2.HasValue) { return Input.GetKeyDown(val2.Value); } return false; } private static KeyCode? DigitToAlphaKeyCode(int d) { return d switch { 1 => (KeyCode)49, 2 => (KeyCode)50, 3 => (KeyCode)51, 4 => (KeyCode)52, 5 => (KeyCode)53, 6 => (KeyCode)54, 7 => (KeyCode)55, 8 => (KeyCode)56, 9 => (KeyCode)57, _ => null, }; } private static bool TryGetKeyControl(Keyboard kb, KeyCode code, out KeyControl ctrl) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Invalid comparison between Unknown and I4 //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 //IL_0065: 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_00da: Expected I4, but got Unknown //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Invalid comparison between Unknown and I4 //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Expected I4, but got Unknown //IL_002f: 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_0060: Expected I4, but got Unknown //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Invalid comparison between Unknown and I4 KeyControl val; if ((int)code <= 27) { if ((int)code != 9) { if ((int)code != 13) { if ((int)code != 27) { goto IL_03d1; } val = kb.escapeKey; } else { val = kb.enterKey; } } else { val = kb.tabKey; } } else if ((int)code <= 57) { if ((int)code != 32) { switch (code - 48) { case 0: break; case 1: goto IL_029f; case 2: goto IL_02ab; case 3: goto IL_02b7; case 4: goto IL_02c3; case 5: goto IL_02cf; case 6: goto IL_02db; case 7: goto IL_02e7; case 8: goto IL_02f3; case 9: goto IL_02ff; default: goto IL_03d1; } val = kb.digit0Key; } else { val = kb.spaceKey; } } else { switch (code - 96) { case 0: goto IL_014f; case 1: goto IL_015b; case 2: goto IL_0167; case 3: goto IL_0173; case 4: goto IL_017f; case 5: goto IL_018b; case 6: goto IL_0197; case 7: goto IL_01a3; case 8: goto IL_01af; case 9: goto IL_01bb; case 10: goto IL_01c7; case 11: goto IL_01d3; case 12: goto IL_01df; case 13: goto IL_01eb; case 14: goto IL_01f7; case 15: goto IL_0203; case 16: goto IL_020f; case 17: goto IL_021b; case 18: goto IL_0227; case 19: goto IL_0233; case 20: goto IL_023f; case 21: goto IL_024b; case 22: goto IL_0257; case 23: goto IL_0263; case 24: goto IL_026f; case 25: goto IL_027b; case 26: goto IL_0287; } switch (code - 282) { case 0: break; case 1: goto IL_0323; case 2: goto IL_032f; case 3: goto IL_033b; case 4: goto IL_0347; case 5: goto IL_0353; case 6: goto IL_035c; case 7: goto IL_0365; case 8: goto IL_036e; case 9: goto IL_0377; case 10: goto IL_0380; case 11: goto IL_0389; case 22: goto IL_03a4; case 21: goto IL_03ad; case 24: goto IL_03b6; case 23: goto IL_03bf; default: goto IL_03d1; } val = kb.f1Key; } goto IL_03d3; IL_01df: val = kb.lKey; goto IL_03d3; IL_01c7: val = kb.jKey; goto IL_03d3; IL_01af: val = kb.hKey; goto IL_03d3; IL_0197: val = kb.fKey; goto IL_03d3; IL_01a3: val = kb.gKey; goto IL_03d3; IL_01bb: val = kb.iKey; goto IL_03d3; IL_01d3: val = kb.kKey; goto IL_03d3; IL_018b: val = kb.eKey; goto IL_03d3; IL_0173: val = kb.cKey; goto IL_03d3; IL_02ff: val = kb.digit9Key; goto IL_03d3; IL_02f3: val = kb.digit8Key; goto IL_03d3; IL_02e7: val = kb.digit7Key; goto IL_03d3; IL_02db: val = kb.digit6Key; goto IL_03d3; IL_02cf: val = kb.digit5Key; goto IL_03d3; IL_02c3: val = kb.digit4Key; goto IL_03d3; IL_02b7: val = kb.digit3Key; goto IL_03d3; IL_02ab: val = kb.digit2Key; goto IL_03d3; IL_029f: val = kb.digit1Key; goto IL_03d3; IL_015b: val = kb.aKey; goto IL_03d3; IL_0167: val = kb.bKey; goto IL_03d3; IL_017f: val = kb.dKey; goto IL_03d3; IL_014f: val = kb.backquoteKey; goto IL_03d3; IL_03b6: val = kb.leftCtrlKey; goto IL_03d3; IL_03bf: val = kb.rightCtrlKey; goto IL_03d3; IL_03a4: val = kb.leftShiftKey; goto IL_03d3; IL_03ad: val = kb.rightShiftKey; goto IL_03d3; IL_03d1: val = null; goto IL_03d3; IL_0389: val = kb.f12Key; goto IL_03d3; IL_0380: val = kb.f11Key; goto IL_03d3; IL_0377: val = kb.f10Key; goto IL_03d3; IL_036e: val = kb.f9Key; goto IL_03d3; IL_0365: val = kb.f8Key; goto IL_03d3; IL_035c: val = kb.f7Key; goto IL_03d3; IL_0353: val = kb.f6Key; goto IL_03d3; IL_0347: val = kb.f5Key; goto IL_03d3; IL_033b: val = kb.f4Key; goto IL_03d3; IL_032f: val = kb.f3Key; goto IL_03d3; IL_0323: val = kb.f2Key; goto IL_03d3; IL_03d3: ctrl = val; return ctrl != null; IL_0287: val = kb.zKey; goto IL_03d3; IL_027b: val = kb.yKey; goto IL_03d3; IL_026f: val = kb.xKey; goto IL_03d3; IL_0263: val = kb.wKey; goto IL_03d3; IL_0257: val = kb.vKey; goto IL_03d3; IL_024b: val = kb.uKey; goto IL_03d3; IL_023f: val = kb.tKey; goto IL_03d3; IL_0233: val = kb.sKey; goto IL_03d3; IL_0227: val = kb.rKey; goto IL_03d3; IL_021b: val = kb.qKey; goto IL_03d3; IL_020f: val = kb.pKey; goto IL_03d3; IL_0203: val = kb.oKey; goto IL_03d3; IL_01f7: val = kb.nKey; goto IL_03d3; IL_01eb: val = kb.mKey; goto IL_03d3; } } [HarmonyPatch(typeof(NetworkRunner), "Fusion_Simulation_ICallbacks_OnReliableData")] internal static class NetworkRunner_OnReliableData_Patch { [HarmonyPrepare] private static bool Prepare() { try { return CartPortPlugin.EnableHarmonyFusionReliablePatches.Value; } catch { return false; } } private static bool Prefix(NetworkRunner __instance, PlayerRef player, Il2CppStructArray dataArray) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) CartPortFusionSession.NotifyRunnerSeen(__instance); if (dataArray != null && ((Il2CppArrayBase)(object)dataArray).Length >= CartPortSummonPayload.TotalByteCount && CartPortSummonPayload.HasCartPortMagicPrefix(dataArray)) { CartPortFusionSession.HandleReliableSummonFromSimulation(__instance, player, dataArray); return false; } return true; } } internal static class CartPortPersistentSummonOverride { private sealed class OverrideEntry { internal Structure Structure; internal Vector3 TargetPos; internal Quaternion TargetRot; internal int ExpiryFrame; internal int ApplyCount; } private static readonly List _active = new List(); private const float ArrivalThreshold = 3f; internal static bool IsActive(Structure structure) { foreach (OverrideEntry item in _active) { if ((Object)(object)item.Structure == (Object)(object)structure) { return true; } } return false; } internal static void AddOrRefresh(Structure structure, Vector3 pos, Quaternion rot, int durationFrames) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: 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_00ce: Unknown result type (might be due to invalid IL or missing references) bool flag = default(bool); foreach (OverrideEntry item in _active) { if (!((Object)(object)item.Structure != (Object)(object)structure)) { item.TargetPos = pos; item.TargetRot = rot; item.ExpiryFrame = Time.frameCount + durationFrames; ManualLogSource log = CartPortPlugin.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(57, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("CartPort: Persistent override refreshed for '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(((Object)((Component)structure).gameObject).name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(durationFrames); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" frames)."); } log.LogInfo(val); return; } } _active.Add(new OverrideEntry { Structure = structure, TargetPos = pos, TargetRot = rot, ExpiryFrame = Time.frameCount + durationFrames }); CartPortPlugin.Log.LogInfo((object)($"CartPort: Persistent override started for '{((Object)((Component)structure).gameObject).name}' ({durationFrames} frames). " + "Will re-apply transform every frame to fight Fusion sync.")); } internal static void Cancel(Structure structure) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown bool flag = default(bool); for (int num = _active.Count - 1; num >= 0; num--) { if (!((Object)(object)_active[num].Structure != (Object)(object)structure)) { ManualLogSource log = CartPortPlugin.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(47, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("CartPort: Persistent override cancelled for '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(((Object)((Component)structure).gameObject).name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'."); } log.LogInfo(val); _active.RemoveAt(num); } } } internal static void CancelAll() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown if (_active.Count > 0) { ManualLogSource log = CartPortPlugin.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(48, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("CartPort: All "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(_active.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" persistent override(s) cancelled."); } log.LogInfo(val); _active.Clear(); } } internal static void Tick() { //IL_00d8: 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_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Expected O, but got Unknown //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Expected O, but got Unknown if (_active.Count == 0) { return; } bool flag = default(bool); for (int num = _active.Count - 1; num >= 0; num--) { OverrideEntry overrideEntry = _active[num]; if ((Object)(object)overrideEntry.Structure == (Object)null) { _active.RemoveAt(num); } else if (Time.frameCount > overrideEntry.ExpiryFrame) { ManualLogSource log = CartPortPlugin.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(120, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("CartPort: Persistent override expired for '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(((Object)((Component)overrideEntry.Structure).gameObject).name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' "); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("after "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(overrideEntry.ApplyCount); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" re-applications — cart may be held by an unreachable authority peer."); } log.LogInfo(val); _active.RemoveAt(num); } else if (Vector3.Distance(((Component)overrideEntry.Structure).transform.position, overrideEntry.TargetPos) < 3f) { ManualLogSource log2 = CartPortPlugin.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(89, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("CartPort: Persistent override succeeded for '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(((Object)((Component)overrideEntry.Structure).gameObject).name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' "); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("(arrived within "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(3f); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("m after "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(overrideEntry.ApplyCount); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" re-applications)."); } log2.LogInfo(val); _active.RemoveAt(num); } else { CartSummon.BruteForceApplyTransform(overrideEntry.Structure, overrideEntry.TargetPos, overrideEntry.TargetRot); overrideEntry.ApplyCount++; } } } } internal static class CartPortServerSummonQueue { private sealed class Entry { internal NetworkId NetId; internal Vector3 Pos; internal Quaternion Rot; internal int DeadlineFrame; internal int LastAuthorityRequestFrame = -99999; } private static readonly List Pending = new List(); internal static void Enqueue(NetworkId netId, Vector3 pos, Quaternion rot) { //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_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: 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_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: 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_0043: 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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown //IL_0089: Unknown result type (might be due to invalid IL or missing references) int deadlineFrame = Time.frameCount + Mathf.Max(30, CartPortPlugin.ServerSummonAuthorityWaitFrames.Value); bool flag = default(bool); for (int i = 0; i < Pending.Count; i++) { if (Pending[i].NetId == netId) { Pending[i].Pos = pos; Pending[i].Rot = rot; Pending[i].DeadlineFrame = deadlineFrame; ManualLogSource log = CartPortPlugin.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(84, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("CartPort: Updated queued server summon for NetworkId "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(netId.Raw); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" (waiting for state authority)."); } log.LogInfo(val); return; } } Pending.Add(new Entry { NetId = netId, Pos = pos, Rot = rot, DeadlineFrame = deadlineFrame }); } internal static void Tick() { //IL_034a: Unknown result type (might be due to invalid IL or missing references) //IL_0351: Expected O, but got Unknown //IL_0399: Unknown result type (might be due to invalid IL or missing references) //IL_03a0: Expected O, but got Unknown //IL_0057: 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_007f: Expected O, but got Unknown //IL_013b: 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_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Expected O, but got Unknown //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Expected O, but got Unknown //IL_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Expected O, but got Unknown //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Expected O, but got Unknown //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Expected O, but got Unknown //IL_0222: 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_0244: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) if (Pending.Count == 0) { return; } NetworkRunner val = CartPortFusionSession.TryGetRunningRunner(); if ((Object)(object)val == (Object)null || !val.IsRunning || !CartPortFusionSession.IsAuthoritativeServerPeer(val)) { Pending.Clear(); return; } bool flag = default(bool); for (int num = Pending.Count - 1; num >= 0; num--) { Entry entry = Pending[num]; if (!CartPortFusionSession.TryResolveNetworkObjectForSummon(val, entry.NetId, out var netObj) || (Object)(object)netObj == (Object)null) { ManualLogSource log = CartPortPlugin.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(62, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("CartPort: Queued summon dropped — NetworkId "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(entry.NetId.Raw); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" no longer exists."); } log.LogWarning(val2); Pending.RemoveAt(num); } else if (netObj.HasStateAuthority) { Structure componentInChildren = ((Component)netObj).GetComponentInChildren(true); if ((Object)(object)componentInChildren == (Object)null) { ManualLogSource log2 = CartPortPlugin.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(61, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("CartPort: Queued summon dropped — no Structure on NetworkId "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(entry.NetId.Raw); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("."); } log2.LogWarning(val2); Pending.RemoveAt(num); } else { CartSummon.ApplySummonOnAuthorityImmediate(componentInChildren, entry.Pos, entry.Rot); ManualLogSource log3 = CartPortPlugin.Log; BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(84, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("CartPort: Applied queued server summon for NetworkId "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(entry.NetId.Raw); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" after state authority arrived."); } log3.LogInfo(val3); Pending.RemoveAt(num); } } else if (Time.frameCount > entry.DeadlineFrame) { if (CartPortPlugin.ServerSummonUnityPhysicsFallbackAfterQueueTimeout.Value) { Structure componentInChildren2 = ((Component)netObj).GetComponentInChildren(true); if ((Object)(object)componentInChildren2 != (Object)null) { ManualLogSource log4 = CartPortPlugin.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(141, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("CartPort: Queued summon timed out for NetworkId "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(entry.NetId.Raw); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" — applying Unity physics fallback (ocean / carts Fusion never hands authority to this peer)."); } log4.LogWarning(val2); CartSummon.ApplySummonOnAuthorityImmediate(componentInChildren2, entry.Pos, entry.Rot); if (CartPortPlugin.ForceSummonServerQueueFallbackPersist.Value) { CartPortPersistentSummonOverride.AddOrRefresh(componentInChildren2, entry.Pos, entry.Rot, CartPortPlugin.ForceSummonPersistDurationFrames.Value); } } else { ManualLogSource log5 = CartPortPlugin.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(107, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("CartPort: Queued summon timed out — never gained state authority for NetworkId "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(entry.NetId.Raw); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(". No Structure for fallback."); } log5.LogWarning(val2); } } else { ManualLogSource log6 = CartPortPlugin.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(143, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("CartPort: Queued summon timed out — never gained state authority for NetworkId "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(entry.NetId.Raw); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(". Cart may stay stuck until Fusion releases authority elsewhere."); } log6.LogWarning(val2); } Pending.RemoveAt(num); } else { int num2 = Mathf.Max(5, CartPortPlugin.ServerSummonAuthorityRetryIntervalFrames.Value); if (Time.frameCount - entry.LastAuthorityRequestFrame >= num2) { if (CartPortPlugin.ServerAllowAuthorityOverrideOnSummon.Value) { try { netObj.AllowStateAuthorityOverride = true; } catch (Exception ex) { ManualLogSource log7 = CartPortPlugin.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(41, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("CartPort: AllowStateAuthorityOverride ("); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex.Message); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(")."); } log7.LogWarning(val2); } } try { netObj.RequestStateAuthority(); } catch (Exception ex2) { ManualLogSource log8 = CartPortPlugin.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(42, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("CartPort: RequestStateAuthority failed ("); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex2.Message); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(")."); } log8.LogWarning(val2); } entry.LastAuthorityRequestFrame = Time.frameCount; } } } } } internal static class CartPortSummonPayload { private static readonly byte[] MagicBytes = new byte[4] { 67, 80, 82, 84 }; private const byte Version = 1; private const int InnerByteCount = 33; internal static int TotalByteCount => MagicBytes.Length + 33; internal static bool HasCartPortMagicPrefix(byte[] buf, int count) { return HasCartPortMagicPrefix(buf, 0, count); } internal static bool HasCartPortMagicPrefix(byte[] buf, int offset, int count) { if (buf == null || count < MagicBytes.Length || offset < 0 || offset + MagicBytes.Length > buf.Length) { return false; } for (int i = 0; i < MagicBytes.Length; i++) { if (buf[offset + i] != MagicBytes[i]) { return false; } } return true; } internal static bool HasCartPortMagicPrefix(ArraySegment segment) { if (segment.Count < MagicBytes.Length) { return false; } Il2CppArrayBase array = segment.Array; if (array == null) { return false; } int offset = segment.Offset; for (int i = 0; i < MagicBytes.Length; i++) { if (array[offset + i] != MagicBytes[i]) { return false; } } return true; } internal static bool HasCartPortMagicPrefix(ArraySegment segment) { if (segment.Count < MagicBytes.Length || segment.Array == null) { return false; } byte[] array = segment.Array; int offset = segment.Offset; for (int i = 0; i < MagicBytes.Length; i++) { if (array[offset + i] != MagicBytes[i]) { return false; } } return true; } internal static bool HasCartPortMagicPrefix(Il2CppStructArray data) { if (data == null || ((Il2CppArrayBase)(object)data).Length < MagicBytes.Length) { return false; } for (int i = 0; i < MagicBytes.Length; i++) { if (((Il2CppArrayBase)(object)data)[i] != MagicBytes[i]) { return false; } } return true; } internal static byte[] Serialize(NetworkId networkId, Vector3 position, Quaternion rotation) { //IL_0030: 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_005a: 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_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0099: 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_00c2: Unknown result type (might be due to invalid IL or missing references) byte[] array = new byte[TotalByteCount]; MagicBytes.CopyTo(array.AsSpan()); int num = MagicBytes.Length; array[num] = 1; BinaryPrimitives.WriteUInt32LittleEndian(array.AsSpan(num + 1), networkId.Raw); int num2 = num + 5; BinaryPrimitives.WriteSingleLittleEndian(array.AsSpan(num2), position.x); BinaryPrimitives.WriteSingleLittleEndian(array.AsSpan(num2 + 4), position.y); BinaryPrimitives.WriteSingleLittleEndian(array.AsSpan(num2 + 8), position.z); num2 += 12; BinaryPrimitives.WriteSingleLittleEndian(array.AsSpan(num2), rotation.x); BinaryPrimitives.WriteSingleLittleEndian(array.AsSpan(num2 + 4), rotation.y); BinaryPrimitives.WriteSingleLittleEndian(array.AsSpan(num2 + 8), rotation.z); BinaryPrimitives.WriteSingleLittleEndian(array.AsSpan(num2 + 12), rotation.w); return array; } internal static bool TryDeserialize(ArraySegment data, out NetworkId networkId, out Vector3 position, out Quaternion rotation) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0008: 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_008f: 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_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: 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_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) networkId = default(NetworkId); position = default(Vector3); rotation = default(Quaternion); if (data.Count < TotalByteCount || data.Array == null) { return false; } byte[] array = data.Array; int offset = data.Offset; for (int i = 0; i < MagicBytes.Length; i++) { if (array[offset + i] != MagicBytes[i]) { return false; } } offset += MagicBytes.Length; if (array[offset] != 1) { return false; } uint raw = BinaryPrimitives.ReadUInt32LittleEndian(array.AsSpan(offset + 1)); networkId = new NetworkId { Raw = raw }; int num = offset + 5; position = new Vector3(BinaryPrimitives.ReadSingleLittleEndian(array.AsSpan(num)), BinaryPrimitives.ReadSingleLittleEndian(array.AsSpan(num + 4)), BinaryPrimitives.ReadSingleLittleEndian(array.AsSpan(num + 8))); num += 12; rotation = new Quaternion(BinaryPrimitives.ReadSingleLittleEndian(array.AsSpan(num)), BinaryPrimitives.ReadSingleLittleEndian(array.AsSpan(num + 4)), BinaryPrimitives.ReadSingleLittleEndian(array.AsSpan(num + 8)), BinaryPrimitives.ReadSingleLittleEndian(array.AsSpan(num + 12))); return true; } } public class CartPortUiBehaviour : MonoBehaviour { private bool _menuVisible; private readonly List _structures = new List(); private GUIStyle _wrappedLabelStyle; private CursorLockMode _savedCursorLockMode; private bool _savedCursorVisible; private bool _haveSavedCursor; private Rect _panelRect; private readonly List<(Rect rect, Structure structure)> _summonRects = new List<(Rect, Structure)>(); private Rect _refreshRect; private Rect _forceModeRect; private Rect _closeRect; private bool _forceMode; private int _deferSummonDueFrame = -1; private Structure _deferSummonStructure; private Vector3 _deferSummonPos; private Quaternion _deferSummonRot; private bool _deferSummonClientPredictionAfterServerRelay; internal static CartPortUiBehaviour Instance { get; private set; } private GUIStyle WrappedLabelStyle { get { //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) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_0028: Expected O, but got Unknown GUIStyle obj = _wrappedLabelStyle; if (obj == null) { GUIStyle val = new GUIStyle(GUI.skin.label) { wordWrap = true }; GUIStyle val2 = val; _wrappedLabelStyle = val; obj = val2; } return obj; } } private void Awake() { Instance = this; ((Behaviour)this).enabled = true; } private void Start() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown CartPortPlugin.EnsureFusionInboundClassInjectorRegistered(); try { if (CartPortPlugin.EnableHarmonyFusionReliablePatches.Value && CartPortPlugin.PatchAssemblyCSharpReliableCallbacks.Value) { CartPortGameReliablePatches.TryDiscover(CartPortPlugin.HarmonyInstance); } } catch (Exception ex) { ManualLogSource log = CartPortPlugin.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(48, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("CartPort: Reliable callback discovery failed ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")."); } log.LogError(val); } ((MonoBehaviour)this).Invoke("LateDiscoverGameReliableCallbacks", 5f); ((MonoBehaviour)this).Invoke("ExtendedDiscoverGameReliableCallbacks", 25f); } private void LateDiscoverGameReliableCallbacks() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown try { if (CartPortPlugin.EnableHarmonyFusionReliablePatches.Value && CartPortPlugin.PatchAssemblyCSharpReliableCallbacks.Value) { CartPortGameReliablePatches.TryDiscoverLate(CartPortPlugin.HarmonyInstance); } } catch (Exception ex) { ManualLogSource log = CartPortPlugin.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(53, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("CartPort: Late reliable callback discovery failed ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")."); } log.LogError(val); } } private void ExtendedDiscoverGameReliableCallbacks() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown try { if (CartPortPlugin.EnableHarmonyFusionReliablePatches.Value && CartPortPlugin.PatchAssemblyCSharpReliableCallbacks.Value) { CartPortGameReliablePatches.TryDiscoverExtended(CartPortPlugin.HarmonyInstance); } } catch (Exception ex) { ManualLogSource log = CartPortPlugin.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(57, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("CartPort: Extended reliable callback discovery failed ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")."); } log.LogError(val); } } private void OnDestroy() { if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } private void Update() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) CartPortServerSummonQueue.Tick(); CartPortPersistentSummonOverride.Tick(); if (CartPortInput.GetKeyDown(CartPortPlugin.ToggleMenuKey.Value)) { SetMenuVisible(!_menuVisible); } if (_menuVisible && CartPortInput.GetKeyDown((KeyCode)27)) { SetMenuVisible(visible: false); } if (_menuVisible) { HandleSummonDigits(); HandlePanelMouseClick(); } } private void HandleSummonDigits() { for (int i = 0; i < _structures.Count && i < 9; i++) { if (CartPortInput.WasDigitRowPressed(i + 1)) { Structure val = _structures[i]; if ((Object)(object)val != (Object)null) { DoSummon(val); } break; } } } private void HandlePanelMouseClick() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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_0060: 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_010d: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Expected O, but got Unknown //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_0140: Unknown result type (might be due to invalid IL or missing references) if (!CartPortInput.WasLeftClickPressed()) { return; } Vector2 val = CartPortInput.MouseGuiPosition(); if (!((Rect)(ref _panelRect)).Contains(val)) { return; } Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(val.x - ((Rect)(ref _panelRect)).x, val.y - ((Rect)(ref _panelRect)).y); if (((Rect)(ref _refreshRect)).width > 0f && ((Rect)(ref _refreshRect)).Contains(val2)) { RefreshList(); return; } if (((Rect)(ref _forceModeRect)).width > 0f && ((Rect)(ref _forceModeRect)).Contains(val2)) { _forceMode = !_forceMode; if (!_forceMode) { CartPortPersistentSummonOverride.CancelAll(); } ManualLogSource log = CartPortPlugin.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(22, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("CartPort: Force Mode "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(_forceMode ? "ON" : "OFF"); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("."); } log.LogInfo(val3); return; } if (((Rect)(ref _closeRect)).width > 0f && ((Rect)(ref _closeRect)).Contains(val2)) { SetMenuVisible(visible: false); return; } for (int i = 0; i < _summonRects.Count; i++) { var (val4, val5) = _summonRects[i]; if (((Rect)(ref val4)).Contains(val2) && (Object)(object)val5 != (Object)null) { DoSummon(val5); break; } } } internal void ScheduleDeferredSummon(Structure structure, Vector3 pos, Quaternion rot, bool clientPredictionAfterServerSummonRelay = false) { //IL_0036: 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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) int num = 0; if (CartPortPlugin.RequestFusionAuthority.Value) { num = Mathf.Max(0, CartPortPlugin.FusionAuthorityWaitFrames.Value); } _deferSummonDueFrame = Time.frameCount + 1 + num; _deferSummonStructure = structure; _deferSummonPos = pos; _deferSummonRot = rot; _deferSummonClientPredictionAfterServerRelay = clientPredictionAfterServerSummonRelay; } private void LateUpdate() { ProcessDeferredSummon(); if (_menuVisible) { if (CartPortPlugin.SuspendGameplayInputWhileMenuOpen.Value) { CartPortGameplayInputSuspend.ReassertGameplayDisabled(); } Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; } } private void ProcessDeferredSummon() { //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_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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) if (_deferSummonDueFrame >= 0 && Time.frameCount >= _deferSummonDueFrame) { Structure deferSummonStructure = _deferSummonStructure; Vector3 deferSummonPos = _deferSummonPos; Quaternion deferSummonRot = _deferSummonRot; bool deferSummonClientPredictionAfterServerRelay = _deferSummonClientPredictionAfterServerRelay; _deferSummonDueFrame = -1; _deferSummonStructure = null; _deferSummonClientPredictionAfterServerRelay = false; CartSummon.ApplyDeferredTeleport(deferSummonStructure, deferSummonPos, deferSummonRot, deferSummonClientPredictionAfterServerRelay); } } private void OnDisable() { if (_menuVisible) { SetMenuVisible(visible: false); } } private void SetMenuVisible(bool visible) { //IL_002d: 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_0073: Unknown result type (might be due to invalid IL or missing references) if (_menuVisible == visible) { return; } bool menuVisible = _menuVisible; _menuVisible = visible; if (visible) { if (CartPortPlugin.SuspendGameplayInputWhileMenuOpen.Value) { CartPortGameplayInputSuspend.Push(); } _savedCursorLockMode = Cursor.lockState; _savedCursorVisible = Cursor.visible; _haveSavedCursor = true; Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; } else if (menuVisible) { if (CartPortPlugin.SuspendGameplayInputWhileMenuOpen.Value) { CartPortGameplayInputSuspend.Pop(); } if (_haveSavedCursor) { Cursor.lockState = _savedCursorLockMode; Cursor.visible = _savedCursorVisible; _haveSavedCursor = false; } } } private void OnGUI() { //IL_007e: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Invalid comparison between Unknown and I4 //IL_00c0: 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_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Invalid comparison between Unknown and I4 //IL_0287: Unknown result type (might be due to invalid IL or missing references) if (!_menuVisible) { return; } GUI.depth = 2147483583; float num = 480f; float num2 = 70f; float num3 = 92f + (float)Mathf.Max(1, _structures.Count) * num2 + 24f; num3 = Mathf.Clamp(num3, 220f, (float)Screen.height - 48f); Rect val = default(Rect); ((Rect)(ref val))..ctor(((float)Screen.width - num) * 0.5f, ((float)Screen.height - num3) * 0.5f, num, num3); _panelRect = val; if ((int)Event.current.type == 7) { _summonRects.Clear(); _refreshRect = default(Rect); _forceModeRect = default(Rect); _closeRect = default(Rect); } GUILayout.BeginArea(val, GUI.skin.box); GUILayout.Label("CartPort — click Summon or press 1–9 for rows 1–9. (Uses Unity Input System.)", WrappedLabelStyle, Array.Empty()); GUILayout.BeginHorizontal(Array.Empty()); DrawToolbarButton("Refresh list", 110f, ref _refreshRect); GUILayout.Space(6f); DrawToolbarButton(_forceMode ? "Force: ON [!]" : "Force: OFF", 110f, ref _forceModeRect); GUILayout.Space(6f); DrawToolbarButton("Close (Esc)", 100f, ref _closeRect); GUILayout.EndHorizontal(); if (_forceMode) { GUILayout.Label("Force Mode: ignores authority — re-applies position every frame for ~10 s. Use for bugged/orphaned carts.", WrappedLabelStyle, Array.Empty()); } GUILayout.Space(6f); for (int i = 0; i < _structures.Count; i++) { Structure val2 = _structures[i]; if (!((Object)(object)val2 == (Object)null)) { GUILayout.BeginHorizontal(GUI.skin.box, Array.Empty()); GUILayout.Label(DescribeStructure(val2, i), WrappedLabelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(288f) }); GUILayout.FlexibleSpace(); string text = ((i < 9) ? $" [{i + 1}]" : string.Empty); Rect rect = GUILayoutUtility.GetRect(172f, 26f, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(172f), GUILayout.MinHeight(26f) }); GUI.Label(rect, "Summon" + text, GUI.skin.button); if ((int)Event.current.type == 7) { _summonRects.Add((rect, val2)); } GUILayout.EndHorizontal(); } } if (_structures.Count == 0) { GUILayout.Label("No carts or sleds found. Place one in the world or click Refresh.", WrappedLabelStyle, Array.Empty()); } GUILayout.EndArea(); } private void DrawToolbarButton(string text, float w, ref Rect slot) { //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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Invalid comparison between Unknown and I4 //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) Rect rect = GUILayoutUtility.GetRect(w, 24f, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(w), GUILayout.MinHeight(24f) }); GUI.Label(rect, text, GUI.skin.button); if ((int)Event.current.type == 7) { slot = rect; } } private void DoSummon(Structure st) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: 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_0048: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)st == (Object)null) { return; } if (_forceMode) { if (!CartSummon.TryGetSummonPlacement(st, out var position, out var yawDegrees)) { CartPortPlugin.Log.LogWarning((object)"CartPort: Force summon — no placement (no gameplay camera or ray miss). Enable VerboseLogging for details."); return; } Quaternion rot = Quaternion.Euler(0f, yawDegrees, 0f); CartSummon.TrySummon(st); CartPortPersistentSummonOverride.AddOrRefresh(st, position, rot, CartPortPlugin.ForceSummonPersistDurationFrames.Value); } else if (!CartSummon.TrySummon(st)) { CartPortPlugin.Log.LogWarning((object)"CartPort: Summon failed — no gameplay camera or placement ray miss. Enable Debug.VerboseLogging for details."); } } private void OnEnable() { RefreshList(); } private static string DescribeStructure(Structure st, int index) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) GameObject gameObject = ((Component)st).gameObject; Vector3 position = gameObject.transform.position; string name = ((object)st).GetType().Name; StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(index + 1).Append(". ").Append(((Object)gameObject).name); stringBuilder.Append("\n").Append(name); stringBuilder.Append("\n").AppendFormat(CultureInfo.InvariantCulture, "Pos: {0:F1}, {1:F1}, {2:F1}", position.x, position.y, position.z); try { NetworkObject val = gameObject.GetComponent() ?? gameObject.GetComponentInParent(); if ((Object)(object)val != (Object)null) { stringBuilder.Append(val.HasStateAuthority ? " [Auth]" : " [No Auth]"); } } catch { } if (CartPortPersistentSummonOverride.IsActive(st)) { stringBuilder.Append(" [Forcing...]"); } return stringBuilder.ToString(); } private void RefreshList() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown _structures.Clear(); _structures.AddRange(CartRegistry.FindPlacedCartsAndSleds()); if (CartPortPlugin.VerboseLogging.Value) { ManualLogSource log = CartPortPlugin.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(43, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("CartPort: Refresh found "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(_structures.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" cart(s) / sled(s)."); } log.LogInfo(val); } } } internal static class CartRegistry { internal static List FindPlacedCartsAndSleds() { //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) List result = new List(); HashSet seen = new HashSet(); foreach (CartStructure item in Resources.FindObjectsOfTypeAll()) { TryAdd((Structure)(object)item); } foreach (Structure item2 in Resources.FindObjectsOfTypeAll()) { Scene scene = ((Component)item2).gameObject.scene; if (((Scene)(ref scene)).IsValid() && ((object)item2).GetType().Name.IndexOf("sled", StringComparison.OrdinalIgnoreCase) >= 0) { TryAdd(item2); } } result.Sort((Structure a, Structure b) => string.Compare(((Object)((Component)a).gameObject).name, ((Object)((Component)b).gameObject).name, StringComparison.OrdinalIgnoreCase)); return result; void TryAdd(Structure s) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)s == (Object)null)) { Scene scene2 = ((Component)s).gameObject.scene; if (((Scene)(ref scene2)).IsValid()) { int instanceID = ((Object)s).GetInstanceID(); if (seen.Add(instanceID)) { result.Add(s); } } } } } } internal static class CartSummon { private const float MinGroundNormalDotUp = 0.35f; internal static bool TrySummon(Structure structure) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_008f: 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_0060: 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_0055: 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) if (!TryGetSummonPlacement(structure, out var position, out var yawDegrees)) { return false; } Quaternion val = Quaternion.Euler(0f, yawDegrees, 0f); if (CartPortFusionSession.TrySummonAuthoritative(structure, position, val, out var clientSentReliableAwaitingHost)) { if (!clientSentReliableAwaitingHost) { return true; } if (CartPortPlugin.DeferSummonApply.Value && (Object)(object)CartPortUiBehaviour.Instance != (Object)null) { TryRequestFusionAuthority(structure); CartPortUiBehaviour.Instance.ScheduleDeferredSummon(structure, position, val, clientSentReliableAwaitingHost); } else { ApplySummonImmediate(structure, position, val, clientSentReliableAwaitingHost); } return true; } if (CartPortPlugin.DeferSummonApply.Value && (Object)(object)CartPortUiBehaviour.Instance != (Object)null) { TryRequestFusionAuthority(structure); CartPortUiBehaviour.Instance.ScheduleDeferredSummon(structure, position, val); return true; } ApplySummonImmediate(structure, position, val); return true; } internal static void ApplySummonOnAuthority(Structure structure, Vector3 pos, Quaternion rot) { //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Expected O, but got Unknown //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Expected O, but got Unknown //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_0110: 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_0127: Expected O, but got Unknown //IL_0177: 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_0153: 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) if (!IsUnityObjectAlive((Object)(object)structure)) { return; } NetworkRunner val = CartPortFusionSession.TryGetRunningRunner(); NetworkObject val2 = ((Component)structure).GetComponent() ?? ((Component)structure).GetComponentInParent(); if ((Object)(object)val != (Object)null && CartPortFusionSession.IsAuthoritativeServerPeer(val) && (Object)(object)val2 != (Object)null) { NetworkId id = val2.Id; if (((NetworkId)(ref id)).IsValid && !val2.HasStateAuthority) { bool flag = default(bool); if (CartPortPlugin.ServerAllowAuthorityOverrideOnSummon.Value) { try { val2.AllowStateAuthorityOverride = true; } catch (Exception ex) { ManualLogSource log = CartPortPlugin.Log; BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(41, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("CartPort: AllowStateAuthorityOverride ("); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(ex.Message); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(")."); } log.LogWarning(val3); } } try { val2.RequestStateAuthority(); } catch (Exception ex2) { ManualLogSource log2 = CartPortPlugin.Log; BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(35, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("CartPort: RequestStateAuthority ("); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(ex2.Message); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(")."); } log2.LogWarning(val3); } CartPortServerSummonQueue.Enqueue(val2.Id, pos, rot); ManualLogSource log3 = CartPortPlugin.Log; BepInExInfoLogInterpolatedStringHandler val4 = new BepInExInfoLogInterpolatedStringHandler(87, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("CartPort: Server summon queued — waiting for Fusion state authority on '"); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(SafeObjectName(structure)); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("' (NetworkId "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(val2.Id.Raw); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(")."); } log3.LogInfo(val4); return; } } ApplySummonOnAuthorityImmediate(structure, pos, rot); } internal static void ApplySummonOnAuthorityImmediate(Structure structure, Vector3 pos, Quaternion rot) { //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown //IL_006a: 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) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Expected O, but got Unknown //IL_00ff: Unknown result type (might be due to invalid IL or missing references) if (!IsUnityObjectAlive((Object)(object)structure)) { return; } NetworkRunner val = CartPortFusionSession.TryGetRunningRunner(); NetworkObject val2 = ((Component)structure).GetComponent() ?? ((Component)structure).GetComponentInParent(); if ((Object)(object)val != (Object)null && CartPortFusionSession.IsAuthoritativeServerPeer(val) && (Object)(object)val2 != (Object)null && CartPortPlugin.ServerAllowAuthorityOverrideOnSummon.Value) { try { val2.AllowStateAuthorityOverride = true; } catch { } } Transform val3 = ResolveSummonRootTransform(structure); if (!IsUnityObjectAlive((Object)(object)val3)) { return; } LogSummonRootChoice(structure, val3); bool flag = default(bool); try { ApplyWorldPose(val3, pos, rot); } catch (Exception ex) { ManualLogSource log = CartPortPlugin.Log; BepInExWarningLogInterpolatedStringHandler val4 = new BepInExWarningLogInterpolatedStringHandler(47, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("CartPort: Authoritative summon apply failed ("); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(ex.Message); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(")."); } log.LogWarning(val4); } if (CartPortPlugin.VerboseLogging.Value) { ManualLogSource log2 = CartPortPlugin.Log; BepInExInfoLogInterpolatedStringHandler val5 = new BepInExInfoLogInterpolatedStringHandler(36, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("CartPort: Authoritative summon '"); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(SafeTransformName(val3)); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("' → "); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(pos); } log2.LogInfo(val5); } } internal static void ApplyDeferredTeleport(Structure structure, Vector3 pos, Quaternion rot, bool clientPredictionAfterServerSummonRelay = false) { //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_019f: Expected O, but got Unknown //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Expected O, but got Unknown //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Expected O, but got Unknown if (!IsUnityObjectAlive((Object)(object)structure)) { return; } TryRequestFusionAuthority(structure); bool flag = default(bool); if (!ShouldApplySummonTeleport(structure, out var netObj) && !clientPredictionAfterServerSummonRelay) { ManualLogSource log = CartPortPlugin.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(157, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("CartPort: Skipped summon for '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(SafeObjectName(structure)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' — no Fusion state authority (SummonWithoutAuthorityFallback is false). Host-driven carts may require authority before moving."); } log.LogWarning(val); return; } Transform val2 = ResolveSummonRootTransform(structure); if (!IsUnityObjectAlive((Object)(object)val2)) { return; } LogSummonRootChoice(structure, val2); try { ApplyWorldPose(val2, pos, rot); } catch (Exception ex) { ManualLogSource log2 = CartPortPlugin.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(67, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("CartPort: Summon apply failed ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("); cart may be invalid or destroyed."); } log2.LogWarning(val); } if ((Object)(object)netObj != (Object)null && CartPortPlugin.RequestFusionAuthority.Value && !netObj.HasStateAuthority && CartPortPlugin.VerboseLogging.Value) { if (clientPredictionAfterServerSummonRelay) { ManualLogSource log3 = CartPortPlugin.Log; BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(108, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("CartPort: Applied client prediction for '"); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(SafeObjectName(structure)); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("' after server summon relay (you may not have state authority yet)."); } log3.LogInfo(val3); } else if (CartPortPlugin.SummonWithoutAuthorityFallback.Value) { ManualLogSource log4 = CartPortPlugin.Log; BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(113, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("CartPort: Applied local summon for '"); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(SafeObjectName(structure)); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("' without Fusion authority (fallback; co-op host may still correct the cart)."); } log4.LogInfo(val3); } } if (CartPortPlugin.VerboseLogging.Value) { ManualLogSource log5 = CartPortPlugin.Log; BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(25, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("CartPort: Summoned '"); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(SafeTransformName(val2)); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("' to "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(pos); } log5.LogInfo(val3); } } private static void ApplySummonImmediate(Structure structure, Vector3 pos, Quaternion rot, bool clientPredictionAfterServerSummonRelay = false) { //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_006a: 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) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Expected O, but got Unknown //IL_00fa: Unknown result type (might be due to invalid IL or missing references) TryRequestFusionAuthority(structure); bool flag = default(bool); if (!ShouldApplySummonTeleport(structure, out var _) && !clientPredictionAfterServerSummonRelay) { ManualLogSource log = CartPortPlugin.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(187, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("CartPort: Skipped summon for '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(SafeObjectName(structure)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' — no Fusion state authority (SummonWithoutAuthorityFallback is false). Wait extra frames (DeferSummonApply + FusionAuthorityWaitFrames) or enable fallback."); } log.LogWarning(val); return; } Transform val2 = ResolveSummonRootTransform(structure); if (!IsUnityObjectAlive((Object)(object)val2)) { return; } LogSummonRootChoice(structure, val2); try { ApplyWorldPose(val2, pos, rot); } catch (Exception ex) { ManualLogSource log2 = CartPortPlugin.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(67, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("CartPort: Summon apply failed ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("); cart may be invalid or destroyed."); } log2.LogWarning(val); return; } if (CartPortPlugin.VerboseLogging.Value) { ManualLogSource log3 = CartPortPlugin.Log; BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(25, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("CartPort: Summoned '"); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(SafeTransformName(val2)); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("' to "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(pos); } log3.LogInfo(val3); } } internal static void BruteForceApplyTransform(Structure structure, Vector3 pos, Quaternion rot) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) if (!IsUnityObjectAlive((Object)(object)structure)) { return; } Transform val = ResolveSummonRootTransform(structure); if (!IsUnityObjectAlive((Object)(object)val)) { return; } TryApplyFusionNetworkPose(val, pos, rot, suppressAuthLogs: true); val.SetPositionAndRotation(pos, rot); foreach (Rigidbody componentsInChild in ((Component)val).GetComponentsInChildren(true)) { if (!((Object)(object)componentsInChild == (Object)null) && IsUnityObjectAlive((Object)(object)componentsInChild)) { if (!componentsInChild.isKinematic) { componentsInChild.linearVelocity = Vector3.zero; componentsInChild.angularVelocity = Vector3.zero; } componentsInChild.WakeUp(); } } } private static bool IsUnityObjectAlive(Object obj) { return obj != (Object)null; } private static string SafeObjectName(Structure st) { if (!IsUnityObjectAlive((Object)(object)st)) { return "(destroyed)"; } return ((Object)((Component)st).gameObject).name; } private static string SafeTransformName(Transform t) { if (!IsUnityObjectAlive((Object)(object)t)) { return "(destroyed)"; } return ((Object)t).name; } private static bool ShouldApplySummonTeleport(Structure structure, out NetworkObject netObj) { netObj = ((Component)structure).GetComponent() ?? ((Component)structure).GetComponentInParent(); if ((Object)(object)netObj == (Object)null) { return true; } if (!CartPortPlugin.RequestFusionAuthority.Value) { return true; } if (CartPortPlugin.SummonWithoutAuthorityFallback.Value) { return true; } return netObj.HasStateAuthority; } private static Transform ResolveSummonRootTransform(Structure structure) { if ((Object)(object)structure == (Object)null) { return null; } Transform transform = ((Component)structure).transform; NetworkObject componentInParent = ((Component)transform).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null) { return ((Component)componentInParent).transform; } Rigidbody componentInParent2 = ((Component)transform).GetComponentInParent(); if ((Object)(object)componentInParent2 != (Object)null) { return ((Component)componentInParent2).transform; } return transform; } private static void LogSummonRootChoice(Structure structure, Transform root) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown if (!((Object)(object)structure == (Object)null) && !((Object)(object)root == (Object)null) && !((Object)(object)((Component)root).gameObject == (Object)(object)((Component)structure).gameObject)) { ManualLogSource log = CartPortPlugin.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(151, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("CartPort: Summon target is physics/network root '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(SafeTransformName(root)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' (Structure was on '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(SafeObjectName(structure)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'). If the cart still doesn't move, try Fusion authority or check host ownership."); } log.LogInfo(val); } } private static void TryRequestFusionAuthority(Structure structure) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown NetworkObject val = ((Component)structure).GetComponent() ?? ((Component)structure).GetComponentInParent(); if ((Object)(object)val == (Object)null || !CartPortPlugin.RequestFusionAuthority.Value) { return; } try { if (!val.HasStateAuthority) { val.RequestStateAuthority(); } } catch (Exception ex) { ManualLogSource log = CartPortPlugin.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(70, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("CartPort: Fusion authority request failed ("); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex.Message); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("); moving transform anyway."); } log.LogWarning(val2); } } private static RaycastHit[] CollectHitsAlongRay(Vector3 origin, Vector3 direction, float maxDistance, int layerMask, Transform excludeRoot) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_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_005f: 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_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_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_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) List list = new List(); Vector3 normalized = ((Vector3)(ref direction)).normalized; Vector3 val = origin; float num = maxDistance; RaycastHit item = default(RaycastHit); for (int i = 0; i < 24; i++) { if (!(num > 0.03f)) { break; } if (!Physics.Raycast(val, normalized, ref item, num)) { break; } Collider collider = ((RaycastHit)(ref item)).collider; if ((Object)(object)collider == (Object)null) { break; } if (collider.isTrigger) { val = ((RaycastHit)(ref item)).point + normalized * 0.03f; num -= ((RaycastHit)(ref item)).distance + 0.03f; continue; } int num2 = 1 << ((Component)collider).gameObject.layer; if ((layerMask & num2) == 0) { val = ((RaycastHit)(ref item)).point + normalized * 0.03f; num -= ((RaycastHit)(ref item)).distance + 0.03f; } else if ((Object)(object)excludeRoot != (Object)null && IsUnderTransform(((Component)collider).transform, excludeRoot)) { val = ((RaycastHit)(ref item)).point + normalized * 0.03f; num -= ((RaycastHit)(ref item)).distance + 0.03f; } else { list.Add(item); val = ((RaycastHit)(ref item)).point + normalized * 0.03f; num -= ((RaycastHit)(ref item)).distance + 0.03f; } } if (list.Count != 0) { return list.ToArray(); } return Array.Empty(); } internal static bool TryGetSummonPlacement(Structure excludeHitsFromThis, out Vector3 position, out float yawDegrees) { //IL_0001: 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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: 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) //IL_00dc: 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_00ed: 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_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_012b: 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_0167: 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_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018b: 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_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0216: 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_0227: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: 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_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Expected O, but got Unknown //IL_0300: Unknown result type (might be due to invalid IL or missing references) position = default(Vector3); yawDegrees = 0f; Camera val = ResolveGameplayCamera(); if ((Object)(object)val == (Object)null) { CartPortPlugin.Log.LogWarning((object)"CartPort: No usable Camera (MainCamera missing or disabled). Cannot compute summon position."); return false; } Transform val2 = ResolvePlayerAnchorTransform(val); Vector3 val3 = (((Object)(object)val2 != (Object)null) ? val2.position : ((Component)val).transform.position); Vector3 val4 = default(Vector3); ((Vector3)(ref val4))..ctor(((Component)val).transform.forward.x, 0f, ((Component)val).transform.forward.z); if (((Vector3)(ref val4)).sqrMagnitude < 1E-06f) { val4 = ((Component)val).transform.TransformDirection(Vector3.forward); val4.y = 0f; } if (((Vector3)(ref val4)).sqrMagnitude < 1E-06f) { val4 = Vector3.forward; } ((Vector3)(ref val4)).Normalize(); Vector3 val5 = val3 + val4 * CartPortPlugin.ForwardDistance.Value; RaycastHit[] obj = CollectHitsAlongRay(val5 + Vector3.up * CartPortPlugin.GroundRaycastHeight.Value, maxDistance: Mathf.Min(CartPortPlugin.GroundRaycastHeight.Value + 400f, 2500f), layerMask: -5, excludeRoot: ((Object)(object)excludeHitsFromThis != (Object)null) ? ResolveSummonRootTransform(excludeHitsFromThis) : null, direction: Vector3.down); float value = CartPortPlugin.SummonVerticalOffset.Value; RaycastHit? val6 = null; RaycastHit? val7 = null; RaycastHit[] array = obj; for (int i = 0; i < array.Length; i++) { RaycastHit value2 = array[i]; if (!val7.HasValue) { val7 = value2; } Vector3 normal = ((RaycastHit)(ref value2)).normal; if (Vector3.Dot(((Vector3)(ref normal)).normalized, Vector3.up) >= 0.35f) { val6 = value2; break; } } RaycastHit value3; if (val6.HasValue) { value3 = val6.Value; } else { if (!val7.HasValue) { position = new Vector3(val5.x, val3.y + 1f, val5.z); yawDegrees = ((Component)val).transform.eulerAngles.y; if (CartPortPlugin.VerboseLogging.Value) { CartPortPlugin.Log.LogWarning((object)"CartPort: Ground raycast hit nothing; using fallback height near player anchor."); } return true; } value3 = val7.Value; if (CartPortPlugin.VerboseLogging.Value) { CartPortPlugin.Log.LogInfo((object)"CartPort: No upward-facing ground hit; using first solid hit (may be steep — tweak SummonVerticalOffset / GroundRaycastStartHeight)."); } } position = ((RaycastHit)(ref value3)).point + ((RaycastHit)(ref value3)).normal * value; yawDegrees = ((Component)val).transform.eulerAngles.y; if (CartPortPlugin.VerboseLogging.Value) { ManualLogSource log = CartPortPlugin.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val8 = new BepInExInfoLogInterpolatedStringHandler(45, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val8).AppendLiteral("CartPort: Ground hit '"); ((BepInExLogInterpolatedStringHandler)val8).AppendFormatted(((Object)((Component)((RaycastHit)(ref value3)).collider).gameObject).name); ((BepInExLogInterpolatedStringHandler)val8).AppendLiteral("' layer="); ((BepInExLogInterpolatedStringHandler)val8).AppendFormatted(((Component)((RaycastHit)(ref value3)).collider).gameObject.layer); ((BepInExLogInterpolatedStringHandler)val8).AppendLiteral(" y="); ((BepInExLogInterpolatedStringHandler)val8).AppendFormatted(((RaycastHit)(ref value3)).point.y, "F2"); ((BepInExLogInterpolatedStringHandler)val8).AppendLiteral(" → placed y="); ((BepInExLogInterpolatedStringHandler)val8).AppendFormatted(position.y, "F2"); } log.LogInfo(val8); } return true; } private static Camera ResolveGameplayCamera() { //IL_006b: 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_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_0118: 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_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) Camera main = Camera.main; if ((Object)(object)main != (Object)null && ((Behaviour)main).enabled && ((Component)main).gameObject.activeInHierarchy) { return main; } Camera val = null; float num = float.MinValue; Scene scene; foreach (Camera item in Resources.FindObjectsOfTypeAll()) { if ((Object)(object)item == (Object)null || !((Behaviour)item).enabled || !((Component)item).gameObject.activeInHierarchy) { continue; } scene = ((Component)item).gameObject.scene; if (!((Scene)(ref scene)).IsValid()) { continue; } scene = ((Component)item).gameObject.scene; if (((Scene)(ref scene)).isLoaded) { float num2 = item.depth; if (!item.orthographic) { num2 += 1000f; } if (num2 > num) { num = num2; val = item; } } } if ((Object)(object)val != (Object)null) { return val; } foreach (Camera item2 in Resources.FindObjectsOfTypeAll()) { if ((Object)(object)item2 == (Object)null || !((Behaviour)item2).enabled || !((Component)item2).gameObject.activeInHierarchy) { continue; } scene = ((Component)item2).gameObject.scene; if (((Scene)(ref scene)).IsValid()) { scene = ((Component)item2).gameObject.scene; if (((Scene)(ref scene)).isLoaded) { return item2; } } } return null; } private static Transform ResolvePlayerAnchorTransform(Camera cam) { //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_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)cam == (Object)null) { return null; } Transform val = ((Component)cam).transform; while ((Object)(object)val != (Object)null) { CharacterController component = ((Component)val).GetComponent(); if ((Object)(object)component != (Object)null && ((Collider)component).enabled) { return val; } val = val.parent; } try { GameObject val2 = GameObject.FindGameObjectWithTag("Player"); if ((Object)(object)val2 != (Object)null) { return val2.transform; } } catch { } foreach (CharacterController item in Resources.FindObjectsOfTypeAll()) { if ((Object)(object)item == (Object)null || !((Collider)item).enabled || !((Component)item).gameObject.activeInHierarchy) { continue; } Scene scene = ((Component)item).gameObject.scene; if (((Scene)(ref scene)).IsValid()) { scene = ((Component)item).gameObject.scene; if (((Scene)(ref scene)).isLoaded) { return ((Component)item).transform; } } } return ((Component)cam).transform; } private static void ApplyWorldPose(Transform root, Vector3 worldPos, Quaternion worldRot) { //IL_000a: 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_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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_0058: Unknown result type (might be due to invalid IL or missing references) if (!IsUnityObjectAlive((Object)(object)root) || TryApplyFusionNetworkPose(root, worldPos, worldRot)) { return; } root.SetPositionAndRotation(worldPos, worldRot); foreach (Rigidbody componentsInChild in ((Component)root).GetComponentsInChildren(true)) { if (!((Object)(object)componentsInChild == (Object)null) && IsUnityObjectAlive((Object)(object)componentsInChild)) { if (!componentsInChild.isKinematic) { componentsInChild.linearVelocity = Vector3.zero; componentsInChild.angularVelocity = Vector3.zero; } componentsInChild.WakeUp(); } } } private static bool TryApplyFusionNetworkPose(Transform root, Vector3 worldPos, Quaternion worldRot, bool suppressAuthLogs = false) { //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Expected O, but got Unknown //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_0074: Expected O, but got Unknown //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Expected O, but got Unknown //IL_013b: 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_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Expected O, but got Unknown //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) Transform networkObjectSearchRoot = GetNetworkObjectSearchRoot(root); NetworkRunner val = CartPortFusionSession.TryGetRunningRunner(); bool flag = !suppressAuthLogs && (Object)(object)val != (Object)null && CartPortFusionSession.IsAuthoritativeServerPeer(val) && CartPortPlugin.VerboseLogging.Value; NetworkTransform val2 = SelectBestNetworkTransform(networkObjectSearchRoot); NetworkRigidbody val3 = SelectPrimaryFusionNetworkRigidbody(networkObjectSearchRoot); bool flag2 = false; bool flag3 = default(bool); if ((Object)(object)val2 != (Object)null && ((SimulationBehaviour)val2).HasStateAuthority) { ((NetworkPosition)val2).WritePosition(worldPos); ((NetworkPositionRotation)val2).WriteRotation(worldRot); ManualLogSource log = CartPortPlugin.Log; BepInExInfoLogInterpolatedStringHandler val4 = new BepInExInfoLogInterpolatedStringHandler(59, 3, ref flag3); if (flag3) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("CartPort: Fusion NetworkTransform teleport '"); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(SafeTransformName(networkObjectSearchRoot)); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("' (NT on '"); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(((Object)((Component)val2).gameObject).name); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("') → "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(worldPos); } log.LogInfo(val4); flag2 = true; } else if ((Object)(object)val2 != (Object)null && flag) { ManualLogSource log2 = CartPortPlugin.Log; BepInExWarningLogInterpolatedStringHandler val5 = new BepInExWarningLogInterpolatedStringHandler(56, 1, ref flag3); if (flag3) { ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("CartPort: NetworkTransform on '"); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(((Object)((Component)val2).gameObject).name); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("' has no state authority."); } log2.LogWarning(val5); } if ((Object)(object)val3 != (Object)null && ((SimulationBehaviour)val3).HasStateAuthority) { val3.WriteRigidbodyPosition(worldPos); val3.WriteRigidbodyRotation(worldRot); Rigidbody rigidbody = val3.Rigidbody; if ((Object)(object)rigidbody != (Object)null && !rigidbody.isKinematic) { val3.WriteVelocity(Vector3.zero); val3.WriteAngularVelocity(Vector3.zero); } ManualLogSource log3 = CartPortPlugin.Log; BepInExInfoLogInterpolatedStringHandler val4 = new BepInExInfoLogInterpolatedStringHandler(69, 4, ref flag3); if (flag3) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("CartPort: Fusion NetworkRigidbody teleport '"); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(SafeTransformName(networkObjectSearchRoot)); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("' (NR on '"); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(((Object)((Component)val3).gameObject).name); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("', rb mass="); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted((rigidbody != null) ? rigidbody.mass : 0f); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(") → "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(worldPos); } log3.LogInfo(val4); flag2 = true; } else if ((Object)(object)val3 != (Object)null && flag) { ManualLogSource log4 = CartPortPlugin.Log; BepInExWarningLogInterpolatedStringHandler val5 = new BepInExWarningLogInterpolatedStringHandler(64, 1, ref flag3); if (flag3) { ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("CartPort: Primary NetworkRigidbody on '"); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(((Object)((Component)val3).gameObject).name); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("' has no state authority."); } log4.LogWarning(val5); } if (!flag2 && flag) { LogFusionTeleportDiagnostics(networkObjectSearchRoot); } return flag2; } private static Transform GetNetworkObjectSearchRoot(Transform root) { if ((Object)(object)root == (Object)null) { return null; } NetworkObject val = ((Component)root).GetComponent() ?? ((Component)root).GetComponentInParent(); if (!((Object)(object)val != (Object)null)) { return root; } return ((Component)val).transform; } private static NetworkTransform SelectBestNetworkTransform(Transform root) { if ((Object)(object)root == (Object)null) { return null; } Il2CppArrayBase componentsInChildren = ((Component)root).GetComponentsInChildren(true); if (componentsInChildren == null || componentsInChildren.Length == 0) { return null; } NetworkTransform val = null; int num = int.MaxValue; foreach (NetworkTransform item in componentsInChildren) { if (!((Object)(object)item == (Object)null)) { if ((Object)(object)((Component)item).transform == (Object)(object)root) { return item; } int num2 = DepthUnderRoot(root, ((Component)item).transform); if (num2 >= 0 && num2 < num) { num = num2; val = item; } } } return val ?? componentsInChildren[0]; } private static int DepthUnderRoot(Transform root, Transform descendant) { if ((Object)(object)root == (Object)null || (Object)(object)descendant == (Object)null) { return -1; } int num = 0; Transform val = descendant; while ((Object)(object)val != (Object)null) { if ((Object)(object)val == (Object)(object)root) { return num; } num++; val = val.parent; } return -1; } private static void LogFusionTeleportDiagnostics(Transform root) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Expected O, but got Unknown //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Expected O, but got Unknown ManualLogSource log = CartPortPlugin.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(104, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("CartPort: Fusion teleport skipped — no writable NT/NR with state authority under '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(SafeTransformName(root)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'. Dumping components:"); } log.LogWarning(val); foreach (NetworkTransform componentsInChild in ((Component)root).GetComponentsInChildren(true)) { if (!((Object)(object)componentsInChild == (Object)null)) { ManualLogSource log2 = CartPortPlugin.Log; val = new BepInExWarningLogInterpolatedStringHandler(50, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("CartPort: NetworkTransform '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(((Object)((Component)componentsInChild).gameObject).name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' HasStateAuthority="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(((SimulationBehaviour)componentsInChild).HasStateAuthority); } log2.LogWarning(val); } } foreach (NetworkRigidbody componentsInChild2 in ((Component)root).GetComponentsInChildren(true)) { if (!((Object)(object)componentsInChild2 == (Object)null)) { Rigidbody rigidbody = componentsInChild2.Rigidbody; ManualLogSource log3 = CartPortPlugin.Log; val = new BepInExWarningLogInterpolatedStringHandler(71, 5, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("CartPort: NetworkRigidbody '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(((Object)((Component)componentsInChild2).gameObject).name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' HasStateAuthority="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(((SimulationBehaviour)componentsInChild2).HasStateAuthority); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" rb="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(((Object)(object)rigidbody != (Object)null) ? ((Object)((Component)rigidbody).gameObject).name : "null"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" kinematic="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted((Object)(object)rigidbody != (Object)null && rigidbody.isKinematic); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" mass="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted((rigidbody != null) ? rigidbody.mass : 0f); } log3.LogWarning(val); } } } private static NetworkRigidbody SelectPrimaryFusionNetworkRigidbody(Transform root) { if ((Object)(object)root == (Object)null) { return null; } Il2CppArrayBase componentsInChildren = ((Component)root).GetComponentsInChildren(true); if (componentsInChildren == null || componentsInChildren.Length == 0) { return null; } NetworkRigidbody result = null; float num = float.MinValue; foreach (NetworkRigidbody item in componentsInChildren) { if (!((Object)(object)((item != null) ? item.Rigidbody : null) == (Object)null)) { Rigidbody rigidbody = item.Rigidbody; string name = ((Object)((Component)rigidbody).gameObject).name; float num2 = rigidbody.mass; if ((Object)(object)((Component)rigidbody).transform == (Object)(object)root) { num2 += 100000f; } if (NameLooksLikePhysicsHelper(name)) { num2 -= 50000f; } if (num2 > num) { num = num2; result = item; } } } return result; } private static bool NameLooksLikePhysicsHelper(string name) { if (string.IsNullOrEmpty(name)) { return false; } if (!name.Contains("Buoy", StringComparison.OrdinalIgnoreCase) && !name.Contains("buoyancy", StringComparison.OrdinalIgnoreCase)) { return name.Contains("Bobber", StringComparison.OrdinalIgnoreCase); } return true; } private static bool IsUnderTransform(Transform candidate, Transform ancestor) { if ((Object)(object)ancestor == (Object)null || (Object)(object)candidate == (Object)null) { return false; } Transform val = candidate; while ((Object)(object)val != (Object)null) { if ((Object)(object)val == (Object)(object)ancestor) { return true; } val = val.parent; } return false; } } public static class MyPluginInfo { public const string PLUGIN_GUID = "com.cartport.aska"; public const string PLUGIN_NAME = "CartPort"; public const string PLUGIN_VERSION = "1.0.0"; } [HarmonyPatch] internal static class NetworkRunner_Lifecycle_CachePatch { private static MethodBase _targetMethod; [HarmonyPrepare] private static bool Prepare() { _targetMethod = AccessTools.Method(typeof(NetworkRunner), "Awake", (Type[])null, (Type[])null) ?? AccessTools.Method(typeof(NetworkRunner), "Start", (Type[])null, (Type[])null) ?? AccessTools.Method(typeof(NetworkRunner), "OnEnable", (Type[])null, (Type[])null); return _targetMethod != null; } [HarmonyTargetMethod] private static MethodBase TargetMethod() { return _targetMethod; } private static void Postfix(NetworkRunner __instance) { CartPortFusionSession.NotifyRunnerSeen(__instance); } } [BepInPlugin("com.cartport.aska", "CartPort", "1.0.0")] public class CartPortPlugin : BasePlugin { internal static Harmony HarmonyInstance; internal static ManualLogSource Log; internal static ConfigEntry ToggleMenuKey; internal static ConfigEntry ForwardDistance; internal static ConfigEntry GroundRaycastHeight; internal static ConfigEntry RequestFusionAuthority; internal static ConfigEntry SummonWithoutAuthorityFallback; internal static ConfigEntry FusionAuthorityWaitFrames; internal static ConfigEntry VerboseLogging; internal static ConfigEntry SummonVerticalOffset; internal static ConfigEntry DeferSummonApply; internal static ConfigEntry SuspendGameplayInputWhileMenuOpen; internal static ConfigEntry ServerAuthoritativeSummon; internal static ConfigEntry ServerSummonAuthorityWaitFrames; internal static ConfigEntry ServerSummonAuthorityRetryIntervalFrames; internal static ConfigEntry ServerAllowAuthorityOverrideOnSummon; internal static ConfigEntry ServerSummonUnityPhysicsFallbackAfterQueueTimeout; internal static ConfigEntry ForceSummonPersistDurationFrames; internal static ConfigEntry ForceSummonServerQueueFallbackPersist; internal static ConfigEntry PatchAssemblyCSharpReliableCallbacks; internal static ConfigEntry EnableHarmonyFusionReliablePatches; internal static ConfigEntry EnableHarmonySimulationSocketPatch; internal static ConfigEntry RegisterFusionInboundRunnerCallbacks; internal static bool FusionInboundCallbacksClassInjectorOk; internal static bool FusionInboundCallbacksUseInjectPath; private static bool _spawnedCartPortUi; private static readonly object FusionInboundInjectorSync = new object(); private static bool _fusionInboundInjectorGiveUp; private static int _fusionInboundInjectorDeferredAttempts; private static int _fusionInboundInjectorDeferredLastFrame = -1; private static bool FusionInjectFailureShouldTrySubclass(Exception exInject) { if (exInject == null) { return false; } string text = exInject.Message ?? string.Empty; if (text.IndexOf("Some of the interfaces", StringComparison.OrdinalIgnoreCase) < 0 && text.IndexOf("are not interfaces", StringComparison.OrdinalIgnoreCase) < 0) { return text.IndexOf("doesn't have an IL2CPP class pointer", StringComparison.OrdinalIgnoreCase) >= 0; } return true; } private static bool InjectorFailureLooksLikeIl2CppInteropNotReady(Exception ex) { if (ex == null) { return false; } string text = ex.Message ?? string.Empty; if (text.IndexOf("does not inherit from a class registered in il2cpp", StringComparison.OrdinalIgnoreCase) >= 0) { return text.IndexOf("System.Object", StringComparison.Ordinal) >= 0; } return false; } internal static void EnsureFusionInboundClassInjectorRegistered() { //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Expected O, but got Unknown //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Expected O, but got Unknown //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Expected O, but got Unknown //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Expected O, but got Unknown lock (FusionInboundInjectorSync) { if (FusionInboundCallbacksClassInjectorOk || _fusionInboundInjectorGiveUp) { return; } try { ClassInjector.RegisterTypeInIl2Cpp(typeof(CartPortInboundFusionCallbacksInjected)); FusionInboundCallbacksClassInjectorOk = true; FusionInboundCallbacksUseInjectPath = true; Log.LogInfo((object)"CartPort: Fusion inbound callbacks ClassInjector OK (interface inject path)."); } catch (Exception ex) { bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val2; if (InjectorFailureLooksLikeIl2CppInteropNotReady(ex)) { int frameCount = Time.frameCount; if (frameCount != _fusionInboundInjectorDeferredLastFrame) { _fusionInboundInjectorDeferredLastFrame = frameCount; _fusionInboundInjectorDeferredAttempts++; } if (_fusionInboundInjectorDeferredAttempts <= 3) { ManualLogSource log = Log; BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(63, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("CartPort: Fusion inbound ClassInjector deferred (Il2Cpp init): "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); } log.LogDebug(val); } if (_fusionInboundInjectorDeferredAttempts >= 600) { _fusionInboundInjectorGiveUp = true; ManualLogSource log2 = Log; val2 = new BepInExErrorLogInterpolatedStringHandler(74, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("CartPort: Fusion inbound ClassInjector gave up after deferred attempts ("); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex.Message); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(")."); } log2.LogError(val2); } return; } if (FusionInjectFailureShouldTrySubclass(ex)) { try { ClassInjector.RegisterTypeInIl2Cpp(typeof(CartPortInboundFusionCallbacksSubclass)); FusionInboundCallbacksClassInjectorOk = true; FusionInboundCallbacksUseInjectPath = false; Log.LogInfo((object)"CartPort: Fusion inbound callbacks ClassInjector OK (subclass path)."); return; } catch (Exception ex2) { _fusionInboundInjectorGiveUp = true; ManualLogSource log3 = Log; val2 = new BepInExErrorLogInterpolatedStringHandler(109, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("CartPort: RegisterTypeInIl2Cpp Fusion inbound callbacks failed — AddCallbacks disabled. Inject: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex.Message); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(". Subclass: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex2.Message); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("."); } log3.LogError(val2); return; } } _fusionInboundInjectorGiveUp = true; ManualLogSource log4 = Log; val2 = new BepInExErrorLogInterpolatedStringHandler(85, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("CartPort: Fusion inbound inject-path ClassInjector failed — AddCallbacks disabled ("); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex.Message); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(")."); } log4.LogError(val2); } } } public override void Load() { //IL_035e: Unknown result type (might be due to invalid IL or missing references) //IL_0365: Expected O, but got Unknown //IL_03cc: Unknown result type (might be due to invalid IL or missing references) //IL_03d3: Expected O, but got Unknown //IL_059a: Unknown result type (might be due to invalid IL or missing references) //IL_05a1: Expected O, but got Unknown //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_039d: Unknown result type (might be due to invalid IL or missing references) //IL_03a3: Expected O, but got Unknown //IL_064c: Unknown result type (might be due to invalid IL or missing references) //IL_0651: Unknown result type (might be due to invalid IL or missing references) //IL_05f0: Unknown result type (might be due to invalid IL or missing references) //IL_05f6: Expected O, but got Unknown //IL_0676: Unknown result type (might be due to invalid IL or missing references) //IL_067c: Expected O, but got Unknown //IL_06ef: Unknown result type (might be due to invalid IL or missing references) //IL_06f5: Expected O, but got Unknown //IL_0492: Unknown result type (might be due to invalid IL or missing references) //IL_0498: Expected O, but got Unknown //IL_0526: Unknown result type (might be due to invalid IL or missing references) //IL_052c: Expected O, but got Unknown Log = ((BasePlugin)this).Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val; try { ManualLogSource log = Log; val = new BepInExInfoLogInterpolatedStringHandler(37, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("CartPort: Reading configuration from "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(((BasePlugin)this).Config.ConfigFilePath); } log.LogInfo(val); } catch { } ToggleMenuKey = ((BasePlugin)this).Config.Bind("General", "ToggleMenuKey", (KeyCode)290, "Open or close the cart / sled list."); ForwardDistance = ((BasePlugin)this).Config.Bind("Summon", "ForwardDistance", 4f, "How far ahead (horizontal) of the player/feet anchor to place the cart, along your camera look direction."); GroundRaycastHeight = ((BasePlugin)this).Config.Bind("Summon", "GroundRaycastStartHeight", 120f, "Raycast downward from this height above the target XZ to find ground."); SummonVerticalOffset = ((BasePlugin)this).Config.Bind("Summon", "SummonVerticalOffset", 0.35f, "Extra distance along the ground hit normal so the cart pivot sits slightly above the surface (reduces sinking / wrong colliders reading as underground)."); RequestFusionAuthority = ((BasePlugin)this).Config.Bind("Network", "RequestFusionStateAuthority", true, "Call NetworkObject.RequestStateAuthority() so this peer can replicate cart position (Fusion state authority — not AssignInputAuthority, which only routes player input). If authority is never granted, SummonWithoutAuthorityFallback controls whether to still apply a local teleport."); SummonWithoutAuthorityFallback = ((BasePlugin)this).Config.Bind("Network", "SummonWithoutAuthorityFallback", true, "When RequestFusionStateAuthority is true but Fusion never grants state authority (bugged/far/host-owned carts), still apply the local teleport so the summon completes. Set false for strict co-op-only moves (summon skipped if no authority)."); FusionAuthorityWaitFrames = ((BasePlugin)this).Config.Bind("Network", "FusionAuthorityWaitFrames", 2, "When deferring the summon (Summon.DeferSummonApply) and Fusion requests are enabled, wait this many extra Unity frames before applying so authority can arrive. Ignored when RequestFusionStateAuthority is false or defer is off."); ServerAuthoritativeSummon = ((BasePlugin)this).Config.Bind("Network", "ServerAuthoritativeSummon", true, "When online with Fusion, send summon placement to the server/host via ReliableData so carts move with simulation authority (recommended for multiplayer). When false or offline, use local teleport + RequestFusionStateAuthority / fallback settings instead."); ServerSummonAuthorityWaitFrames = ((BasePlugin)this).Config.Bind("Network", "ServerSummonAuthorityWaitFrames", 600, "Dedicated server / host only: max Unity frames to wait after RequestStateAuthority before giving up on a queued summon (bugged carts stuck without authority). ~600 ≈ 10 s @ 60 FPS."); ServerSummonAuthorityRetryIntervalFrames = ((BasePlugin)this).Config.Bind("Network", "ServerSummonAuthorityRetryIntervalFrames", 30, "Dedicated server / host only: how often to call RequestStateAuthority again while waiting for a queued summon."); ServerAllowAuthorityOverrideOnSummon = ((BasePlugin)this).Config.Bind("Network", "ServerAllowAuthorityOverrideOnSummon", true, "Dedicated server / host: set NetworkObject.AllowStateAuthorityOverride=true before RequestStateAuthority so Fusion can migrate authority for stuck carts (e.g. ocean floaters)."); ServerSummonUnityPhysicsFallbackAfterQueueTimeout = ((BasePlugin)this).Config.Bind("Network", "ServerSummonUnityPhysicsFallbackAfterQueueTimeout", true, "Dedicated / host: if Fusion never grants state authority before ServerSummonAuthorityWaitFrames (common for far ocean carts), still run ApplySummonOnAuthorityImmediate once using Unity transforms + rigidbody wake. May snap until authority migrates; often the only way to move host-owned carts."); ForceSummonPersistDurationFrames = ((BasePlugin)this).Config.Bind("Network", "ForceSummonPersistDurationFrames", 600, "Number of frames (~10 s at 60 FPS) to keep re-applying a brute-force cart teleport every frame. Used by Force Mode (UI toggle) and by the server queue fallback when Fusion never grants state authority. Increase if the cart keeps snapping back."); ForceSummonServerQueueFallbackPersist = ((BasePlugin)this).Config.Bind("Network", "ForceSummonServerQueueFallbackPersist", true, "After the server queue's authority-wait timeout fires the Unity physics fallback, automatically activate persistent override (ForceSummonPersistDurationFrames) so the position is re-applied every frame. Fixes bugged carts whose Fusion authority is permanently orphaned and the one-shot fallback gets overwritten by sync."); DeferSummonApply = ((BasePlugin)this).Config.Bind("Summon", "DeferSummonApply", true, "Apply the teleport on the next frame instead of immediately. Reduces rare server/client errors when moving a cart triggers Interaction.OnDisable / villager equipment cleanup in the same frame."); SuspendGameplayInputWhileMenuOpen = ((BasePlugin)this).Config.Bind("General", "SuspendGameplayInputWhileMenuOpen", true, "While the CartPort menu is open, disable Unity Input System gameplay maps (Player/Look/Move) so moving the mouse does not rotate the camera."); VerboseLogging = ((BasePlugin)this).Config.Bind("Debug", "VerboseLogging", false, "Extra BepInEx log output (placement, summon, input suspend diagnostics)."); ConfigEntry val2 = ((BasePlugin)this).Config.Bind("Network", "_NetworkingDefaultsVersion", 0, "Internal version for CartPort networking defaults migration. Do not edit."); PatchAssemblyCSharpReliableCallbacks = ((BasePlugin)this).Config.Bind("Network", "PatchAssemblyCSharpReliableCallbacks", true, "Discover and Harmony-patch ASKA OnReliableDataReceived / Fusion callbacks in Assembly-CSharp — often required on dedicated servers where Fusion simulation hooks never fire. Set false if startup crashes."); EnableHarmonyFusionReliablePatches = ((BasePlugin)this).Config.Bind("Network", "EnableHarmonyFusionReliablePatches", false, "Harmony postfix on NetworkRunner Fusion ReliableData - required on host/server for summon relay. OFF by default (Fusion+Harmony can hard-crash IL2CPP). Enable only after game starts cleanly."); EnableHarmonySimulationSocketPatch = ((BasePlugin)this).Config.Bind("Network", "EnableHarmonySimulationSocketPatch", false, "Harmony postfix on Simulation socket ReliableData - optional on dedicated server. OFF by default (high crash risk). Enable NetworkRunner hook first."); RegisterFusionInboundRunnerCallbacks = ((BasePlugin)this).Config.Bind("Network", "RegisterFusionInboundRunnerCallbacks", true, "Call NetworkRunner.AddCallbacks with CartPort's Fusion INetworkRunnerCallbacks implementation so summon ReliableData is received on dedicated/shared servers when Harmony never hooks Fusion simulation. Disable only if this causes crashes."); if (val2.Value < 4) { val2.Value = 4; try { ((BasePlugin)this).Config.Save(); } catch { } Log.LogInfo((object)"CartPort: Networking migration v4 - cfg hook flags preserved."); } try { ClassInjector.RegisterTypeInIl2Cpp(); } catch (Exception ex) { ManualLogSource log2 = Log; BepInExErrorLogInterpolatedStringHandler val3 = new BepInExErrorLogInterpolatedStringHandler(55, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("CartPort: RegisterTypeInIl2Cpp failed - UI disabled ("); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(ex.Message); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(")."); } log2.LogError(val3); } Harmony val4 = (HarmonyInstance = new Harmony("com.cartport.aska")); try { val4.PatchAll(typeof(CartPortPlugin).Assembly); } catch (Exception ex2) { ManualLogSource log3 = Log; BepInExErrorLogInterpolatedStringHandler val3 = new BepInExErrorLogInterpolatedStringHandler(73, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("CartPort: Harmony PatchAll failed - networking patches may be missing ("); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(ex2); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(")."); } log3.LogError(val3); } try { MethodInfo methodInfo = AccessTools.Method(typeof(NetworkRunner), "Fusion_Simulation_ICallbacks_OnReliableData", (Type[])null, (Type[])null); if (methodInfo == null) { Log.LogWarning((object)"CartPort: Could not resolve NetworkRunner.Fusion_Simulation_ICallbacks_OnReliableData - check Fusion interop."); } else if (EnableHarmonyFusionReliablePatches.Value) { int valueOrDefault = (Harmony.GetPatchInfo((MethodBase)methodInfo)?.Prefixes?.Count).GetValueOrDefault(); ManualLogSource log4 = Log; val = new BepInExInfoLogInterpolatedStringHandler(103, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("CartPort: ReliableData Harmony prefixes on NetworkRunner.Fusion_Simulation_ICallbacks_OnReliableData: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(valueOrDefault); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } log4.LogInfo(val); if (valueOrDefault == 0) { Log.LogWarning((object)"CartPort: Expected at least one prefix when EnableHarmonyFusionReliablePatches is true - check Harmony / Fusion.Runtime."); } } MethodInfo methodInfo2 = AccessTools.Method(typeof(Simulation), "Fusion_Sockets_INetPeerGroupCallbacks_OnReliableData", (Type[])null, (Type[])null); if (methodInfo2 != null && EnableHarmonyFusionReliablePatches.Value && EnableHarmonySimulationSocketPatch.Value) { Patches patchInfo = Harmony.GetPatchInfo((MethodBase)methodInfo2); ManualLogSource log5 = Log; val = new BepInExInfoLogInterpolatedStringHandler(60, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("CartPort: Simulation socket ReliableData Harmony prefixes: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted((patchInfo?.Prefixes?.Count).GetValueOrDefault()); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } log5.LogInfo(val); } } catch (Exception ex3) { ManualLogSource log6 = Log; BepInExWarningLogInterpolatedStringHandler val5 = new BepInExWarningLogInterpolatedStringHandler(50, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("CartPort: ReliableData hook diagnostics failed ("); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(ex3.Message); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(")."); } log6.LogWarning(val5); } try { Assembly assembly = typeof(NetworkRunner).Assembly; ManualLogSource log7 = Log; val = new BepInExInfoLogInterpolatedStringHandler(38, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("CartPort: Fusion assembly at runtime: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(assembly.Location); } log7.LogInfo(val); } catch { } SceneManager.sceneLoaded += UnityAction.op_Implicit((Action)OnSceneLoadedCartPortUi); Scene activeScene = SceneManager.GetActiveScene(); if (((Scene)(ref activeScene)).IsValid()) { EnsureCartPortUiSpawned(); } if (EnableHarmonyFusionReliablePatches.Value) { ManualLogSource log8 = Log; val = new BepInExInfoLogInterpolatedStringHandler(98, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("CartPort: Fusion ReliableData hooks ON - NetworkRunner postfix active; Simulation socket postfix "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(EnableHarmonySimulationSocketPatch.Value ? "active" : "OFF"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } log8.LogInfo(val); if (!EnableHarmonySimulationSocketPatch.Value) { Log.LogInfo((object)"CartPort: Simulation socket ReliableData hook is OFF — ASKA dedicated often delivers client summon bytes only via Simulation socket callbacks (not NetworkRunner). If the server never logs \"Server received summon\", set Network.EnableHarmonySimulationSocketPatch=true."); } } else { Log.LogInfo((object)"CartPort: Fusion ReliableData hooks OFF (default, safe). Set Network.EnableHarmonyFusionReliablePatches=true when you want server-authoritative summon relay."); } ManualLogSource log9 = Log; val = new BepInExInfoLogInterpolatedStringHandler(8, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("CartPort"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("1.0.0"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" loaded"); } log9.LogInfo(val); } private static void OnSceneLoadedCartPortUi(Scene scene, LoadSceneMode mode) { EnsureCartPortUiSpawned(); if (_spawnedCartPortUi) { SceneManager.sceneLoaded -= UnityAction.op_Implicit((Action)OnSceneLoadedCartPortUi); } } internal static void EnsureCartPortUiSpawned() { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown //IL_000e: 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_0019: Expected O, but got Unknown //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (_spawnedCartPortUi) { return; } try { GameObject val = new GameObject("CartPort_Ui"); Object.DontDestroyOnLoad((Object)val); ((Object)val).hideFlags = (HideFlags)61; val.AddComponent(); _spawnedCartPortUi = true; } catch (Exception ex) { ManualLogSource log = Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(53, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("CartPort: Failed to create CartPort UI GameObject ("); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex.Message); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(")."); } log.LogError(val2); } } } [HarmonyPatch(typeof(Simulation), "Fusion_Sockets_INetPeerGroupCallbacks_OnReliableData")] internal static class Simulation_OnReliableSocketData_Patch { private static bool _warnedRunnerMissing; [HarmonyPrepare] private static bool Prepare() { try { return CartPortPlugin.EnableHarmonyFusionReliablePatches.Value && CartPortPlugin.EnableHarmonySimulationSocketPatch.Value; } catch { return false; } } private static bool Prefix(Simulation __instance, IntPtr connection, int key, IntPtr data, int length) { //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Expected O, but got Unknown //IL_00d8: 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) if (length < CartPortSummonPayload.TotalByteCount || data == IntPtr.Zero) { return true; } byte[] array; try { array = new byte[length]; Marshal.Copy(data, array, 0, length); } catch { return true; } if (!CartPortSummonPayload.HasCartPortMagicPrefix(array, length)) { return true; } try { NetworkRunner val = CartPortFusionSession.TryGetRunnerForSimulation(__instance) ?? CartPortFusionSession.TryGetRunningRunner(); if ((Object)(object)val != (Object)null) { CartPortFusionSession.NotifyRunnerSeen(val); } if ((Object)(object)val == (Object)null || !val.IsRunning) { if (!_warnedRunnerMissing) { _warnedRunnerMissing = true; CartPortPlugin.Log.LogWarning((object)"CartPort: Simulation ReliableData arrived but NetworkRunner could not be resolved."); } return false; } if (!CartPortFusionSession.IsAuthoritativeServerPeer(val)) { CartPortFusionSession.TryLogSummonDroppedNonAuthority(val, "Simulation socket prefix"); return false; } Il2CppStructArray val2 = new Il2CppStructArray((long)length); for (int i = 0; i < length; i++) { ((Il2CppArrayBase)(object)val2)[i] = array[i]; } CartPortFusionSession.HandleReliableSummonFromSimulation(val, default(PlayerRef), val2); } catch (Exception ex) { ManualLogSource log = CartPortPlugin.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(51, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("CartPort: Simulation socket ReliableData prefix ("); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(ex.Message); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(")."); } log.LogWarning(val3); } return false; } } }