Decompiled source of PEAK Checkpoint Save v0.3.2
plugins/PEAK_Checkpoint_Save.dll
Decompiled 2 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using Peak.Network; using Photon.Pun; using Photon.Realtime; using TMPro; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; using Zorro.Core.Serizalization; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("PEAK_Checkpoint_Save")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.3.2.0")] [assembly: AssemblyInformationalVersion("0.3.2")] [assembly: AssemblyProduct("PEAK_Checkpoint_Save")] [assembly: AssemblyTitle("PEAK_Checkpoint_Save")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.3.2.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [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 BepInEx { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] internal sealed class BepInAutoPluginAttribute : Attribute { public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace BepInEx.Preloader.Core.Patching { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] internal sealed class PatcherAutoPluginAttribute : Attribute { public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace PEAK_Checkpoint_Save { [BepInPlugin("PEAK_Checkpoint_Save", "PEAK_Checkpoint_Save", "0.3.2")] public class Plugin : BaseUnityPlugin { [HarmonyPatch(typeof(Campfire))] public static class Campfire_AutoSave_Patch { [HarmonyPatch("Interact_CastFinished")] [HarmonyPostfix] public static void AutoSaveOnCampfire(Campfire __instance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) if ((int)__instance.advanceToSegment == 0) { return; } Instance.loadedSaveFileThisRound = true; if (RecentlyLitCampfire > Time.time) { return; } RecentlyLitCampfire = Time.time + 60f; if ((Object)(object)Instance == (Object)null) { Debug.LogError((object)"[Checkpoint_Save] Plugin.Instance is NULL! Autosave failed."); return; } ((BaseUnityPlugin)Instance).Logger.LogInfo((object)"[Checkpoint_Save] Campfire lit → Autosave triggered."); if (PhotonNetwork.OfflineMode) { Instance.SavePlayerOffline(); } else if (PhotonNetwork.IsMasterClient) { Instance.pv.RPC("RPC_RecentlyLitCampfire", (RpcTarget)1, Array.Empty<object>()); Instance.SavePlayerCoop(); } else { Instance.pv.RPC("RPC_RequestSave", (RpcTarget)2, Array.Empty<object>()); } } } [HarmonyPatch(typeof(CharacterMovement))] [HarmonyPatch("CheckFallDamage")] internal class Patch_FallDamage_Protection { private static bool Prefix(CharacterMovement __instance) { if (Time.time < NoFallDamageUntil) { return false; } return true; } } [Serializable] public class SaveData { public int settingsVersion; public float posX; public float posY; public float posZ; public string sceneName; public Segment segment; public bool hasBackpack; public bool isSkeleton; public List<SavedItemState> inventoryItemStates; public List<SavedBackpackItemState> backpackItemStates; public float[] afflictions_current; } [Serializable] public class SavedItemState { public int slotIndex; public ushort itemId; public Dictionary<string, SavedEntry> values = new Dictionary<string, SavedEntry>(); } [Serializable] public class SavedBackpackItemState { public byte slotIndex; public ushort itemId; public Dictionary<string, SavedEntry> values = new Dictionary<string, SavedEntry>(); } [Serializable] public class SavedEntry { public string type; public float value; } [CompilerGenerated] private sealed class <JumpToMapSegment>d__65 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Plugin <>4__this; public SaveData data; private int <i>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <JumpToMapSegment>d__65(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_002f: 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) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Expected I4, but got Unknown //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) int num = <>1__state; Plugin plugin = <>4__this; Vector3 pos = default(Vector3); Vector3 pos2 = default(Vector3); Segment segment; switch (num) { default: return false; case 0: <>1__state = -1; plugin.LoadingScreen(enableLoadingScreen: true, Color.cyan); if (!PhotonNetwork.OfflineMode) { plugin.pv.RPC("RPC_Loadingscreen", (RpcTarget)1, new object[3] { "true", Convert.ToString($"{Color.cyan.r},{Color.cyan.g},{Color.cyan.b}"), "Loading savegame..." }); } <i>5__2 = 0; goto IL_00db; case 1: <>1__state = -1; <i>5__2++; goto IL_00db; case 2: <>1__state = -1; <i>5__2++; goto IL_0161; case 3: { <>1__state = -1; <i>5__2++; goto IL_023c; } IL_0161: if (<i>5__2 < 60) { <>2__current = null; <>1__state = 2; return true; } pos.x = -14.954073f; pos.y = 288.4341f; pos.z = 100.45227f; ((MonoBehaviour)plugin).StartCoroutine(plugin.TeleportToPosition(pos)); break; IL_023c: if (<i>5__2 < 60) { <>2__current = null; <>1__state = 3; return true; } pos2.x = -0.91186905f; pos2.y = 840.8689f; pos2.z = 1713.6833f; ((MonoBehaviour)plugin).StartCoroutine(plugin.TeleportToPosition(pos2)); break; IL_00db: if (<i>5__2 < 30) { <>2__current = null; <>1__state = 1; return true; } segment = data.segment; switch (segment - 1) { case 0: break; case 1: plugin.pv.RPC("RPC_RequestFalldamageProtection", (RpcTarget)0, Array.Empty<object>()); MapHandler.JumpToSegment((Segment)2); goto end_IL_000f; case 2: plugin.pv.RPC("RPC_RequestFalldamageProtection", (RpcTarget)0, Array.Empty<object>()); MapHandler.JumpToSegment((Segment)3); goto end_IL_000f; case 3: goto IL_01f0; default: goto end_IL_000f; } plugin.pv.RPC("RPC_RequestFalldamageProtection", (RpcTarget)0, Array.Empty<object>()); if (plugin.configTeleportTropicsWorkaround.Value) { <i>5__2 = 0; goto IL_0161; } MapHandler.JumpToSegment((Segment)1); break; IL_01f0: plugin.pv.RPC("RPC_RequestFalldamageProtection", (RpcTarget)0, Array.Empty<object>()); MapHandler.JumpToSegment((Segment)3); <i>5__2 = 0; goto IL_023c; end_IL_000f: break; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <LoadInventoryDelayed>d__68 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Plugin <>4__this; private int <i>5__2; private Player[] <>7__wrap2; private Player <player>5__4; private List<Character>.Enumerator <>7__wrap4; private int <i>5__6; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <LoadInventoryDelayed>d__68(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 2) { try { } finally { <>m__Finally1(); } } <>7__wrap2 = null; <player>5__4 = null; <>7__wrap4 = default(List<Character>.Enumerator); <>1__state = -2; } private bool MoveNext() { //IL_03a1: Unknown result type (might be due to invalid IL or missing references) //IL_03d8: Unknown result type (might be due to invalid IL or missing references) //IL_03e7: Unknown result type (might be due to invalid IL or missing references) //IL_03f6: Unknown result type (might be due to invalid IL or missing references) try { int num = <>1__state; Plugin plugin = <>4__this; string playerSaveFile; Character current; PhotonView component; SaveData saveData; switch (num) { default: return false; case 0: <>1__state = -1; <i>5__2 = 0; goto IL_0067; case 1: <>1__state = -1; <i>5__2++; goto IL_0067; case 2: <>1__state = -3; <i>5__6++; goto IL_0305; case 3: { <>1__state = -1; <i>5__2++; break; } IL_0067: if (<i>5__2 < 30) { <>2__current = null; <>1__state = 1; return true; } <>7__wrap2 = Object.FindObjectsByType<Player>((FindObjectsSortMode)0); <i>5__2 = 0; goto IL_0346; IL_0305: if (<i>5__6 < 10) { <>2__current = null; <>1__state = 2; return true; } goto IL_030f; IL_0346: if (<i>5__2 < <>7__wrap2.Length) { <player>5__4 = <>7__wrap2[<i>5__2]; <>7__wrap4 = Character.AllCharacters.GetEnumerator(); <>1__state = -3; goto IL_030f; } <>7__wrap2 = null; <i>5__2 = 0; break; IL_00e7: playerSaveFile = plugin.GetPlayerSaveFile(NetworkingUtilities.UserId(current.player)); saveData = null; component = ((Component)<player>5__4).GetComponent<PhotonView>(); try { string text = File.ReadAllText(playerSaveFile); saveData = JsonConvert.DeserializeObject<SaveData>(text); } catch { string text = null; saveData = null; } if (plugin.configInventory.Value && saveData != null) { plugin.LoadPlayerInventory(saveData, <player>5__4, current, component); if ((Object)(object)component != (Object)null && component.Owner != null && saveData.backpackItemStates.Count > 0) { plugin.LoadBackpackFromSave(<player>5__4, saveData); } plugin.SendSyncInventory(<player>5__4); } if (plugin.configAfflictions.Value && saveData != null) { if (PhotonNetwork.OfflineMode) { try { try { if (saveData.isSkeleton) { current.data.SetSkeleton(true); } } catch { } CharacterAfflictions afflictions = current.refs.afflictions; if (saveData.afflictions_current != null && afflictions.currentStatuses != null && afflictions.currentStatuses.Length == saveData.afflictions_current.Length) { Array.Copy(saveData.afflictions_current, afflictions.currentStatuses, afflictions.currentStatuses.Length); } } catch { } } else if (PhotonNetwork.IsMasterClient && saveData.afflictions_current != null && saveData != null) { try { if (saveData.isSkeleton) { current.data.SetSkeleton(true); } } catch { } try { if ((Object)(object)component != (Object)null) { plugin.pv.RPC("RPC_ApplyAfflictions", component.Owner, new object[2] { NetworkingUtilities.UserId(<player>5__4), saveData.afflictions_current }); } else { ((BaseUnityPlugin)plugin).Logger.LogWarning((object)"[Checkpoint_Save] LoadInventoryDelayed: Player has no PhotonView, cannot send afflictions RPC."); } } catch (Exception ex) { ((BaseUnityPlugin)plugin).Logger.LogWarning((object)("[Checkpoint_Save] LoadInventoryDelayed: failed to send afflictions RPC: " + ex)); } } } <i>5__6 = 0; goto IL_0305; IL_030f: while (<>7__wrap4.MoveNext()) { current = <>7__wrap4.Current; if (!(NetworkingUtilities.UserId(current.player) == NetworkingUtilities.UserId(<player>5__4))) { continue; } goto IL_00e7; } <>m__Finally1(); <>7__wrap4 = default(List<Character>.Enumerator); <player>5__4 = null; <i>5__2++; goto IL_0346; } if (<i>5__2 < 30) { <>2__current = null; <>1__state = 3; return true; } plugin.LoadingScreen(enableLoadingScreen: false, Color.cyan); if (!PhotonNetwork.OfflineMode) { plugin.pv.RPC("RPC_Loadingscreen", (RpcTarget)1, new object[3] { "false", Convert.ToString($"{Color.cyan.r},{Color.cyan.g},{Color.cyan.b}"), "null" }); } return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; ((IDisposable)<>7__wrap4).Dispose(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <TeleportClientToHost>d__67 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Plugin <>4__this; private Vector3 <hostPos>5__2; private int <i>5__3; private List<Character>.Enumerator <>7__wrap3; private Character <ch>5__5; private float <startTime>5__6; private int <i>5__7; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <TeleportClientToHost>d__67(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 2) { try { } finally { <>m__Finally1(); } } <>7__wrap3 = default(List<Character>.Enumerator); <ch>5__5 = null; <>1__state = -2; } private bool MoveNext() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0247: 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_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) try { int num = <>1__state; Plugin plugin = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; <hostPos>5__2 = Character.localCharacter.Head; <i>5__3 = 0; goto IL_0073; case 1: <>1__state = -1; <i>5__3++; goto IL_0073; case 2: { <>1__state = -3; <i>5__7++; goto IL_02d0; } IL_0073: if (<i>5__3 < 60) { <>2__current = null; <>1__state = 1; return true; } <>7__wrap3 = Character.AllCharacters.GetEnumerator(); <>1__state = -3; goto IL_0307; IL_02e3: if (Time.time - <startTime>5__6 < (float)plugin.configTeleportTryTime.Value) { if (Mathf.Abs(<ch>5__5.Head.y - <hostPos>5__2.y) > plugin.configTeleportYOffset.Value) { try { Vector3 val = <hostPos>5__2 + new Vector3(0f, 0.5f, 0f); if ((Object)(object)((MonoBehaviourPun)<ch>5__5).photonView != (Object)null) { ((MonoBehaviourPun)<ch>5__5).photonView.RPC("WarpPlayerRPC", (RpcTarget)0, new object[2] { val, true }); } ((BaseUnityPlugin)plugin).Logger.LogInfo((object)$"[Checkpoint_Save] TeleportClientToHost: warped {((Object)<ch>5__5.player).name} to {val}"); } catch (Exception ex) { ((BaseUnityPlugin)plugin).Logger.LogWarning((object)("[Checkpoint_Save] TeleportClientToHost failed: " + ex)); plugin.ShowMessage("Something went wrong while teleporting =(", Color.red, 5f); } <i>5__3++; if (<i>5__3 <= plugin.configRetryTeleportCount.Value) { goto IL_029d; } } else if (!(Mathf.Abs(<ch>5__5.Head.x - <hostPos>5__2.x) < plugin.configTeleportXOffset.Value) || !(Mathf.Abs(<ch>5__5.Head.z - <hostPos>5__2.z) < plugin.configTeleportZOffset.Value)) { goto IL_029d; } } goto IL_0300; IL_0307: if (<>7__wrap3.MoveNext()) { <ch>5__5 = <>7__wrap3.Current; if ((Object)(object)<ch>5__5 != (Object)(object)Character.localCharacter && (Object)(object)<ch>5__5 != (Object)null) { ((MonoBehaviourPun)<ch>5__5).photonView.RPC("WarpPlayerRPC", (RpcTarget)0, new object[2] { <hostPos>5__2, true }); <startTime>5__6 = Time.time; <i>5__3 = 0; goto IL_02e3; } goto IL_0300; } <>m__Finally1(); <>7__wrap3 = default(List<Character>.Enumerator); return false; IL_02d0: if (<i>5__7 < plugin.configTeleportFramesToWait.Value) { <>2__current = null; <>1__state = 2; return true; } goto IL_02e3; IL_0300: <ch>5__5 = null; goto IL_0307; IL_029d: <i>5__7 = 0; goto IL_02d0; } } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; ((IDisposable)<>7__wrap3).Dispose(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <TeleportToPosition>d__66 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Vector3 pos; public Plugin <>4__this; private float <startTimeLocal>5__2; private int <triedTeleportLocal>5__3; private int <i>5__4; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <TeleportToPosition>d__66(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_0131: 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) int num = <>1__state; Plugin plugin = <>4__this; if (num != 0) { if (num != 1) { return false; } <>1__state = -1; <i>5__4++; goto IL_0246; } <>1__state = -1; if ((Object)(object)Character.localCharacter == (Object)null) { return false; } ((MonoBehaviourPun)Character.localCharacter).photonView.RPC("WarpPlayerRPC", (RpcTarget)0, new object[2] { pos, true }); <startTimeLocal>5__2 = Time.time; <triedTeleportLocal>5__3 = 0; goto IL_0259; IL_0246: if (<i>5__4 < plugin.configTeleportFramesToWait.Value) { <>2__current = null; <>1__state = 1; return true; } goto IL_0259; IL_0259: if (Time.time - <startTimeLocal>5__2 < (float)plugin.configTeleportTryTime.Value) { if ((Object)(object)Character.localCharacter == (Object)null) { return false; } if (Mathf.Abs(Character.localCharacter.Head.y - pos.y) > plugin.configTeleportYOffset.Value) { try { Vector3 val = pos + new Vector3(0f, 0.5f, 0f); if ((Object)(object)((MonoBehaviourPun)Character.localCharacter).photonView != (Object)null) { ((MonoBehaviourPun)Character.localCharacter).photonView.RPC("WarpPlayerRPC", (RpcTarget)0, new object[2] { val, true }); } ((BaseUnityPlugin)plugin).Logger.LogInfo((object)$"[Checkpoint_Save] TeleportClientToHost: warped {((Object)Character.localCharacter.player).name} to {val}"); } catch (Exception ex) { ((BaseUnityPlugin)plugin).Logger.LogWarning((object)("[Checkpoint_Save] TeleportClientToHost failed: " + ex)); plugin.ShowMessage("Something went wrong while teleporting =(", Color.red, 5f); } <triedTeleportLocal>5__3++; if (<triedTeleportLocal>5__3 > plugin.configRetryTeleportCount.Value) { return false; } } else if (Mathf.Abs(Character.localCharacter.Head.x - pos.x) < plugin.configTeleportXOffset.Value && Mathf.Abs(Character.localCharacter.Head.z - pos.z) < plugin.configTeleportZOffset.Value) { if (!PhotonNetwork.OfflineMode) { ((MonoBehaviour)plugin).StartCoroutine(plugin.TeleportClientToHost()); } return false; } <i>5__4 = 0; goto IL_0246; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public readonly int settingsVersion = 3; public ConfigEntry<KeyboardShortcut> configLoadKey; public ConfigEntry<bool> configAfflictions; public ConfigEntry<bool> configInventory; public ConfigEntry<bool> configItemStats; public ConfigEntry<bool> configOnetimeLoad; public ConfigEntry<bool> configEnableLoadingscreen; public ConfigEntry<float> configLoadingscreenTextXPosition; public ConfigEntry<float> configLoadingscreenTextYPosition; public ConfigEntry<int> configLoadingscreenTextFontsize; public ConfigEntry<float> configTextmessageXPosition; public ConfigEntry<float> configTextmessageYPosition; public ConfigEntry<int> configTextmessageFontsize; public ConfigEntry<bool> configLegacyLoad; public ConfigEntry<bool> configLegacySaveFile; public ConfigEntry<int> configTeleportFramesToWait; public ConfigEntry<int> configRetryTeleportCount; public ConfigEntry<int> configTeleportTryTime; public ConfigEntry<float> configTeleportYOffset; public ConfigEntry<float> configTeleportXOffset; public ConfigEntry<float> configTeleportZOffset; public ConfigEntry<bool> configTeleportTropicsWorkaround; public static Plugin Instance; private Harmony _harmony; private Player cachedPlayer; private AudioClip msgSound; private PhotonView pv; public List<ulong> playerList; public bool sent_userID; private GameObject _loadingOverlay; private TextMeshProUGUI _loadingTMP; private Image _loadingImage; private Text _loadingText; private GameObject _messageOverlay; private TextMeshProUGUI _messageTMP; private float _messageHideTime; internal static float NoFallDamageUntil = 0f; internal static float RecentlyLoaded = 0f; internal static float RecentlyLitCampfire = 0f; private int loadedSaveFile; private readonly HashSet<int> _readyActors = new HashSet<int>(); private bool _localReadySent; private bool _doingWorldReset; private bool loadedSaveFileThisRound; private Vector2 msgPosition = new Vector2(0.5f, 0.1f); private static MethodInfo _playerAddItemMethod; private static readonly FieldInfo _iidDataField = typeof(ItemInstanceData).GetField("data", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); public const string Id = "PEAK_Checkpoint_Save"; internal static ManualLogSource Log { get; private set; } = null; public static string Name => "PEAK_Checkpoint_Save"; public static string Version => "0.3.2"; internal static void ActivateFallDamageProtection(float seconds) { NoFallDamageUntil = Time.time + seconds; } private void Awake() { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown //IL_00c4: Unknown result type (might be due to invalid IL or missing references) if (!Directory.Exists(Paths.PluginPath + "\\Checkpoint_Save")) { Directory.CreateDirectory(Paths.PluginPath + "\\Checkpoint_Save"); } if (!Directory.Exists(Paths.PluginPath + "\\Checkpoint_Save\\Coop")) { Directory.CreateDirectory(Paths.PluginPath + "\\Checkpoint_Save\\Coop"); } CheckConfigVersion(); _harmony = new Harmony("peak.checkpoint.save.harmony"); _harmony.PatchAll(); Instance = this; playerList = new List<ulong>(); pv = ((Component)this).gameObject.AddComponent<PhotonView>(); pv.ViewID = 742; configLoadKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", "loadKey", new KeyboardShortcut((KeyCode)287, Array.Empty<KeyCode>()), "Key for loading your save game (Default: F6)"); configAfflictions = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "enableAfflictions", true, "Enable save/load of your current afflictions. (hunger, poison, cold, sleep, skeleton...)"); configInventory = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "enableInventory", true, "Enable save/load of your inventory and backpack items."); configItemStats = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "enableItemStats", true, "Enable save/load of the item stats. (cooking amount, fuel, rope length...)"); configOnetimeLoad = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "enableOnetimeLoad", false, "If enabled, you can only load once, until you reach the next checkpoint to save again. (Call it hardmode or so)"); configEnableLoadingscreen = ((BaseUnityPlugin)this).Config.Bind<bool>("Loadingscreen", "enableLoadingscreen", true, "If enabled, you will see a loading screen while loading the savegame"); configLoadingscreenTextXPosition = ((BaseUnityPlugin)this).Config.Bind<float>("Loadingscreen", "loadingscreenTextXPosition", 0f, "the X position for the text in the loadingscreen. Example: 0.5 = middle of the screen | 1 = right | 0 = left"); configLoadingscreenTextYPosition = ((BaseUnityPlugin)this).Config.Bind<float>("Loadingscreen", "loadingscreenTextYPosition", 0f, "the Y position for the text in the loadingscreen. Example: 0.5 = middle of the screen | 1 = top | 0 = bottom"); configLoadingscreenTextFontsize = ((BaseUnityPlugin)this).Config.Bind<int>("Loadingscreen", "loadingscreenFontsize", 64, "the fontsize of the text in the loadingscreen."); configTextmessageXPosition = ((BaseUnityPlugin)this).Config.Bind<float>("Textmessage", "TextmessageXPosition", 0f, "the X position for the textmessage. Example: 0.5 = middle of the screen | 1 = right | 0 = left"); configTextmessageYPosition = ((BaseUnityPlugin)this).Config.Bind<float>("Textmessage", "TextmessageYPosition", 0f, "the Y position for the textmessage. Example: 0.5 = middle of the screen | 1 = top | 0 = bottom"); configTextmessageFontsize = ((BaseUnityPlugin)this).Config.Bind<int>("Textmessage", "TextmessageFontsize", 64, "the fontsize of the textmessage."); configLegacyLoad = ((BaseUnityPlugin)this).Config.Bind<bool>("Legacy Options", "enableLegacyLoad", false, "If enabled, you can load more than once in the current round (use at your own risk)"); configLegacySaveFile = ((BaseUnityPlugin)this).Config.Bind<bool>("Legacy Options", "enableLegacySaveFile", false, "If enabled, you have just one save file which works for every difficulty (like it was before version 0.3.0)"); configTeleportFramesToWait = ((BaseUnityPlugin)this).Config.Bind<int>("Teleport (DO NOT CHANGE IF YOU DO NOT KNOW WHAT YOU DO!)", "teleportFramesToWait", 30, "Game frames to wait between teleport tries"); configRetryTeleportCount = ((BaseUnityPlugin)this).Config.Bind<int>("Teleport (DO NOT CHANGE IF YOU DO NOT KNOW WHAT YOU DO!)", "retryTeleportCount", 30, "How often it will try to teleport the client to the save location"); configTeleportTryTime = ((BaseUnityPlugin)this).Config.Bind<int>("Teleport (DO NOT CHANGE IF YOU DO NOT KNOW WHAT YOU DO!)", "timeToTryTeleportation", 30, "How long will it try to teleport (in seconds)"); configTeleportYOffset = ((BaseUnityPlugin)this).Config.Bind<float>("Teleport (DO NOT CHANGE IF YOU DO NOT KNOW WHAT YOU DO!)", "teleportYOffset", 2f, "the Y offset for teleportation check"); configTeleportXOffset = ((BaseUnityPlugin)this).Config.Bind<float>("Teleport (DO NOT CHANGE IF YOU DO NOT KNOW WHAT YOU DO!)", "teleportXOffset", 6f, "the X offset for teleportation check"); configTeleportZOffset = ((BaseUnityPlugin)this).Config.Bind<float>("Teleport (DO NOT CHANGE IF YOU DO NOT KNOW WHAT YOU DO!)", "teleportZOffset", 6f, "the Z offset for teleportation check"); configTeleportTropicsWorkaround = ((BaseUnityPlugin)this).Config.Bind<bool>("Teleport (DO NOT CHANGE IF YOU DO NOT KNOW WHAT YOU DO!)", "teleportTropicsWorkaround", false, "If enabled, tries to teleport to the first campfire instead of loading the next map segment"); } private void Update() { //IL_0006: 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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) KeyboardShortcut value = configLoadKey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { if (PhotonNetwork.OfflineMode) { LoadPlayerOffline(); } else { LoadPlayerCoop(); } } if ((Object)(object)_messageOverlay != (Object)null && _messageOverlay.activeSelf && Time.unscaledTime > _messageHideTime) { _messageOverlay.SetActive(false); } Scene activeScene = SceneManager.GetActiveScene(); if (((Scene)(ref activeScene)).name == "Airport") { loadedSaveFileThisRound = false; } } private bool AllPlayersReady() { if (PhotonNetwork.OfflineMode) { return true; } if (!PhotonNetwork.IsMasterClient) { return false; } Player[] array = PhotonNetwork.PlayerList; if (array == null || array.Length == 0) { return false; } Player[] array2 = array; foreach (Player val in array2) { if (!val.IsInactive && !_readyActors.Contains(val.ActorNumber)) { return false; } } return true; } public void CheckConfigVersion() { if (File.Exists(Paths.PluginPath + "\\Checkpoint_Save\\settingsVersion")) { int num = Convert.ToInt32(File.ReadAllText(Paths.PluginPath + "\\Checkpoint_Save\\settingsVersion")); if (num >= settingsVersion) { return; } try { File.Delete(Path.Combine(Paths.PluginPath + "\\Checkpoint_Save\\peak_save_offline.json")); } catch { } File.WriteAllText(Paths.PluginPath + "\\Checkpoint_Save\\settingsVersion", settingsVersion.ToString()); try { string[] files = Directory.GetFiles(Path.Combine(Paths.PluginPath + "\\Checkpoint_Save\\Coop")); string[] array = files; foreach (string path in array) { File.Delete(path); } return; } catch { return; } } File.WriteAllText(Paths.PluginPath + "\\Checkpoint_Save\\settingsVersion", settingsVersion.ToString()); try { File.Delete(Path.Combine(Paths.PluginPath + "\\Checkpoint_Save\\peak_save_offline.json")); } catch { } try { string[] files2 = Directory.GetFiles(Path.Combine(Paths.PluginPath + "\\Checkpoint_Save\\Coop")); string[] array2 = files2; foreach (string path2 in array2) { File.Delete(path2); } } catch { } } public void ShowMessage(string text, Color color, float duration = 2.5f) { //IL_0001: 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) EnsureMessageOverlay(color); ((TMP_Text)_messageTMP).text = text.ToUpperInvariant(); ((Graphic)_messageTMP).color = color; _messageOverlay.SetActive(true); _messageHideTime = Time.unscaledTime + duration; } private void EnsureLoadingOverlay(Color color) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: 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_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Expected O, but got Unknown //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_loadingOverlay != (Object)null)) { GameObject val = new GameObject("CheckpointSave_LoadingOverlay"); Object.DontDestroyOnLoad((Object)(object)val); _loadingOverlay = val; Canvas val2 = val.AddComponent<Canvas>(); val2.renderMode = (RenderMode)0; val2.sortingOrder = 9999; val.AddComponent<CanvasScaler>(); val.AddComponent<GraphicRaycaster>(); GameObject val3 = new GameObject("Panel"); val3.transform.SetParent(val.transform, false); _loadingImage = val3.AddComponent<Image>(); ((Graphic)_loadingImage).color = new Color(0f, 0f, 0f, 1f); RectTransform component = val3.GetComponent<RectTransform>(); component.anchorMin = Vector2.zero; component.anchorMax = Vector2.one; component.offsetMin = Vector2.zero; component.offsetMax = Vector2.zero; GameObject val4 = new GameObject("Text"); val4.transform.SetParent(val3.transform, false); _loadingTMP = val4.AddComponent<TextMeshProUGUI>(); ((TMP_Text)_loadingTMP).text = "Loading savegame..."; ((TMP_Text)_loadingTMP).alignment = (TextAlignmentOptions)514; ((TMP_Text)_loadingTMP).fontSize = configLoadingscreenTextFontsize.Value; ((Graphic)_loadingTMP).color = color; ((TMP_Text)_loadingTMP).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)_loadingTMP).fontStyle = (FontStyles)16; ((TMP_Text)_loadingTMP).characterSpacing = 6f; ((TMP_Text)_loadingTMP).wordSpacing = 0f; ((TMP_Text)_loadingTMP).lineSpacing = 0f; ((TMP_Text)_loadingTMP).font = FindTMPFont("DarumaDropOne-Regular SDF", "Pangolin-Regular SDF", "Montserrat-Medium SDF", "LiberationSans SDF"); if ((Object)(object)((TMP_Text)_loadingTMP).font == (Object)null) { ((TMP_Text)_loadingTMP).font = Resources.FindObjectsOfTypeAll<TMP_FontAsset>().FirstOrDefault(); } RectTransform component2 = val4.GetComponent<RectTransform>(); component2.anchorMin = new Vector2((configLoadingscreenTextXPosition.Value != 0f) ? configLoadingscreenTextXPosition.Value : 0f, (configLoadingscreenTextYPosition.Value != 0f) ? configLoadingscreenTextYPosition.Value : 0.85f); component2.anchorMax = new Vector2((configLoadingscreenTextXPosition.Value != 0f) ? configLoadingscreenTextXPosition.Value : 1f, (configLoadingscreenTextYPosition.Value != 0f) ? configLoadingscreenTextYPosition.Value : 0.95f); component2.offsetMin = Vector2.zero; component2.offsetMax = Vector2.zero; val.SetActive(false); } } private void EnsureMessageOverlay(Color color) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_messageOverlay != (Object)null)) { GameObject val = new GameObject("CheckpointSave_MessageOverlay"); Object.DontDestroyOnLoad((Object)(object)val); _messageOverlay = val; Canvas val2 = val.AddComponent<Canvas>(); val2.renderMode = (RenderMode)0; val2.sortingOrder = 9998; val.AddComponent<CanvasScaler>(); val.AddComponent<GraphicRaycaster>(); GameObject val3 = new GameObject("MessageText"); val3.transform.SetParent(val.transform, false); _messageTMP = val3.AddComponent<TextMeshProUGUI>(); ((TMP_Text)_messageTMP).alignment = (TextAlignmentOptions)514; ((TMP_Text)_messageTMP).fontSize = configTextmessageFontsize.Value; ((Graphic)_messageTMP).color = color; ((TMP_Text)_messageTMP).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)_messageTMP).fontStyle = (FontStyles)16; ((TMP_Text)_messageTMP).characterSpacing = 6f; ((TMP_Text)_messageTMP).font = FindTMPFont("DarumaDropOne-Regular SDF", "Pangolin-Regular SDF", "Montserrat-Medium SDF", "LiberationSans SDF"); RectTransform rectTransform = ((TMP_Text)_messageTMP).rectTransform; rectTransform.anchorMin = new Vector2((configTextmessageXPosition.Value != 0f) ? configTextmessageXPosition.Value : 0f, (configTextmessageYPosition.Value != 0f) ? configTextmessageYPosition.Value : 0.85f); rectTransform.anchorMax = new Vector2((configTextmessageXPosition.Value != 0f) ? configTextmessageXPosition.Value : 1f, (configTextmessageYPosition.Value != 0f) ? configTextmessageYPosition.Value : 0.95f); rectTransform.offsetMin = Vector2.zero; rectTransform.offsetMax = Vector2.zero; val.SetActive(false); } } private TMP_FontAsset FindTMPFont(params string[] fontNames) { foreach (string name in fontNames) { TMP_FontAsset val = ((IEnumerable<TMP_FontAsset>)Resources.FindObjectsOfTypeAll<TMP_FontAsset>()).FirstOrDefault((Func<TMP_FontAsset, bool>)((TMP_FontAsset x) => ((Object)x).name.Equals(name, StringComparison.OrdinalIgnoreCase))); if ((Object)(object)val != (Object)null) { return val; } } return null; } private void LoadingScreen(bool enableLoadingScreen, Color color, string msg = "Loading savegame...") { //IL_0011: Unknown result type (might be due to invalid IL or missing references) if (!configEnableLoadingscreen.Value) { return; } if (enableLoadingScreen) { EnsureLoadingOverlay(color); if ((Object)(object)_loadingTMP != (Object)null) { ((TMP_Text)_loadingTMP).text = msg; } _loadingOverlay.SetActive(true); } else if ((Object)(object)_loadingOverlay != (Object)null) { _loadingOverlay.SetActive(false); } } private MapHandler GetMapHandler() { return Object.FindFirstObjectByType<MapHandler>(); } private Player GetLocalPlayer() { if ((Object)(object)cachedPlayer != (Object)null) { return cachedPlayer; } Player[] array = Object.FindObjectsByType<Player>((FindObjectsSortMode)0); Player[] array2 = array; foreach (Player val in array2) { PhotonView component = ((Component)val).GetComponent<PhotonView>(); if ((Object)(object)component != (Object)null && component.IsMine) { cachedPlayer = val; ((BaseUnityPlugin)this).Logger.LogInfo((object)"[Checkpoint_Save] Local Player via PhotonView.IsMine found."); return cachedPlayer; } } if (array.Length != 0) { cachedPlayer = array[0]; ((BaseUnityPlugin)this).Logger.LogWarning((object)"[Checkpoint_Save] Local Player randomised (used first Player)."); } return cachedPlayer; } private string GetPlayerSaveFile(string userId) { if (configLegacySaveFile.Value) { try { if (PhotonNetwork.OfflineMode) { return Path.Combine(Paths.PluginPath + "\\Checkpoint_Save\\peak_save_offline.json"); } return Path.Combine(Paths.PluginPath + "\\Checkpoint_Save\\Coop\\peak_save_" + userId + ".json"); } catch { return null; } } try { if (PhotonNetwork.OfflineMode) { return Path.Combine($"{Paths.PluginPath}\\Checkpoint_Save\\peak_save_{Ascents.currentAscent}_offline.json"); } return Path.Combine($"{Paths.PluginPath}\\Checkpoint_Save\\Coop\\peak_save_{Ascents.currentAscent}_{userId}.json"); } catch { return null; } } [IteratorStateMachine(typeof(<JumpToMapSegment>d__65))] private IEnumerator JumpToMapSegment(SaveData data) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <JumpToMapSegment>d__65(0) { <>4__this = this, data = data }; } [IteratorStateMachine(typeof(<TeleportToPosition>d__66))] private IEnumerator TeleportToPosition(Vector3 pos) { //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) //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <TeleportToPosition>d__66(0) { <>4__this = this, pos = pos }; } [IteratorStateMachine(typeof(<TeleportClientToHost>d__67))] private IEnumerator TeleportClientToHost() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <TeleportClientToHost>d__67(0) { <>4__this = this }; } [IteratorStateMachine(typeof(<LoadInventoryDelayed>d__68))] private IEnumerator LoadInventoryDelayed() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <LoadInventoryDelayed>d__68(0) { <>4__this = this }; } private void SendSyncInventory(Player player, bool immediate = true) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) try { if (!((Object)(object)player == (Object)null)) { PhotonView component = ((Component)player).GetComponent<PhotonView>(); if (!((Object)(object)component == (Object)null)) { InventorySyncData val = default(InventorySyncData); ((InventorySyncData)(ref val))..ctor(player.itemSlots, player.backpackSlot, player.tempFullSlot); byte[] array = IBinarySerializable.ToManagedArray<InventorySyncData>(val); component.RPC("SyncInventoryRPC", (RpcTarget)1, new object[2] { array, immediate }); } } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("[Checkpoint_Save] SendSyncInventory failed: " + ex)); } } private void LoadPlayerInventory(SaveData data, Player player, Character ch, PhotonView playerview) { //IL_0162: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"[Checkpoint_Save] LoadPlayerInventory: no player."); return; } if (player.itemSlots != null) { ItemSlot[] itemSlots = player.itemSlots; foreach (ItemSlot val in itemSlots) { if (val != null) { try { val.EmptyOut(); } catch { } } } } try { ((ItemSlot)player.backpackSlot).EmptyOut(); } catch { } if ((Object)(object)ch == (Object)null || (Object)(object)((MonoBehaviourPun)ch).photonView == (Object)null) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"[Checkpoint_Save] LoadPlayerInventory: missing Character or photonView."); return; } if (data.hasBackpack) { try { AddItemToInventory(player, 6); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("[Checkpoint_Save] SpawnBackpackItemsFromSave: instantiate failed for 'Backpack': " + ex)); } } if (data.inventoryItemStates.Count <= 0) { return; } foreach (SavedItemState inventoryItemState in data.inventoryItemStates) { if (inventoryItemState == null || !AddItemToInventory_GetSlot(player, inventoryItemState.itemId, out ItemSlot createdSlot) || createdSlot == null) { continue; } ItemInstanceData data2 = createdSlot.data; if (data2 == null || !configItemStats.Value) { continue; } foreach (KeyValuePair<string, SavedEntry> value2 in inventoryItemState.values) { if (TryGetKey(value2.Key, out var key)) { SavedEntry value = value2.Value; if (value != null && !TrySetOrCreateEntry(data2, key, value.type, value.value)) { ((BaseUnityPlugin)this).Logger.LogInfo((object)$"[Checkpoint_Save] Load: could not apply '{value2.Key}' for item {inventoryItemState.itemId}"); } } } } } private void LoadBackpackFromSave(Player player, SaveData data) { //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Expected O, but got Unknown //IL_0139: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null || data == null || data.backpackItemStates == null || data.backpackItemStates.Count == 0) { return; } BackpackData backpackData = GetBackpackData(player); if (backpackData == null || backpackData.itemSlots == null) { return; } for (int i = 0; i < backpackData.itemSlots.Length; i++) { ItemSlot obj = backpackData.itemSlots[i]; if (obj != null) { obj.EmptyOut(); } } Item val = default(Item); foreach (SavedBackpackItemState backpackItemState in data.backpackItemStates) { if (backpackItemState == null || backpackItemState.slotIndex >= backpackData.itemSlots.Length || !ItemDatabase.TryGetItem(backpackItemState.itemId, ref val) || (Object)(object)val == (Object)null) { continue; } ItemInstanceData val2 = new ItemInstanceData(Guid.NewGuid()); ItemInstanceDataHandler.AddInstanceData(val2); backpackData.AddItem(val, val2, backpackItemState.slotIndex); ItemInstanceData val3 = backpackData.itemSlots[backpackItemState.slotIndex]?.data; if (val3 == null || !configItemStats.Value) { continue; } foreach (KeyValuePair<string, SavedEntry> value2 in backpackItemState.values) { if (TryGetKey(value2.Key, out var key)) { SavedEntry value = value2.Value; if (value != null) { TrySetOrCreateEntry(val3, key, value.type, value.value); } } } } ((BaseUnityPlugin)this).Logger.LogInfo((object)$"[Checkpoint_Save] Backpack states loaded for {NetworkingUtilities.UserId(player)} (items={data.backpackItemStates.Count})."); } private BackpackData GetBackpackData(Player p) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)p == (Object)null || p.backpackSlot == null || !p.backpackSlot.hasBackpack) { return null; } ItemSlot backpackSlot = (ItemSlot)(object)p.backpackSlot; if (backpackSlot.data == null) { return null; } BackpackData val = null; DataEntryKey val2 = (DataEntryKey)7; if (!backpackSlot.data.TryGetDataEntry<BackpackData>(val2, ref val) || val == null) { backpackSlot.data.RegisterNewEntry<BackpackData>(val2); backpackSlot.data.TryGetDataEntry<BackpackData>(val2, ref val); } return val; } private bool AddItemToInventory(Player player, ushort itemId) { //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Expected O, but got Unknown if ((Object)(object)player == (Object)null) { return false; } try { if (_playerAddItemMethod == null) { _playerAddItemMethod = typeof(Player).GetMethod("AddItem", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[3] { typeof(ushort), typeof(ItemInstanceData), typeof(ItemSlot).MakeByRefType() }, null); if (_playerAddItemMethod == null) { ((BaseUnityPlugin)this).Logger.LogError((object)"[Checkpoint_Save] AddItemToInventory: Player.AddItem(...) method not found."); return false; } } ItemInstanceData val = new ItemInstanceData(Guid.NewGuid()); ItemSlot val2 = null; object[] parameters = new object[3] { itemId, val, val2 }; _playerAddItemMethod.Invoke(player, parameters); return true; } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("[Checkpoint_Save] AddItemToInventory error: " + ex)); return false; } } private bool TryGetEntryObject(ItemInstanceData inst, DataEntryKey key, out object entryObj) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) entryObj = null; if (inst == null) { return false; } object obj = _iidDataField?.GetValue(inst); if (!(obj is IDictionary dictionary)) { return false; } if (!dictionary.Contains(key)) { return false; } entryObj = dictionary[key]; return entryObj != null; } private bool TryReadEntryNumeric(object entryObj, out float value) { value = 0f; if (entryObj == null) { return false; } Type type = entryObj.GetType(); PropertyInfo property = type.GetProperty("Value", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (property != null) { object value2; try { value2 = property.GetValue(entryObj); } catch { return false; } return TryConvertToFloat(value2, out value); } FieldInfo field = type.GetField("Value", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { object value3; try { value3 = field.GetValue(entryObj); } catch { return false; } return TryConvertToFloat(value3, out value); } return false; } private bool TrySetOrCreateEntry(ItemInstanceData inst, DataEntryKey key, string entryTypeName, float value) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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) if (inst == null) { return false; } object obj = _iidDataField?.GetValue(inst); if (!(obj is IDictionary dictionary)) { return false; } object obj2 = null; if (dictionary.Contains(key)) { obj2 = dictionary[key]; } if (obj2 == null) { Type type = ((!string.IsNullOrEmpty(entryTypeName)) ? Type.GetType(entryTypeName, throwOnError: false) : null); if (type == null) { ((BaseUnityPlugin)this).Logger.LogWarning((object)$"[Checkpoint_Save] Cannot resolve entry type '{entryTypeName}' for key {key}"); return false; } try { obj2 = Activator.CreateInstance(type); dictionary[key] = obj2; } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("[Checkpoint_Save] Failed to create entry type '" + type.FullName + "': " + ex.Message)); return false; } } return TryWriteEntryNumeric(obj2, value); } private bool TryConvertToFloat(object v, out float value) { value = 0f; if (v == null) { return false; } try { if (!(v is float num)) { if (!(v is double num2)) { if (!(v is int num3)) { if (!(v is long num4)) { if (!(v is short num5)) { if (v is byte b) { value = (int)b; return true; } value = Convert.ToSingle(v); return true; } value = num5; return true; } value = num4; return true; } value = num3; return true; } value = (float)num2; return true; } value = num; return true; } catch { return false; } } private static bool TryGetKey(string name, out DataEntryKey key) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected I4, but got Unknown //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected I4, but got Unknown try { key = (DataEntryKey)(int)(DataEntryKey)Enum.Parse(typeof(DataEntryKey), name, ignoreCase: true); return true; } catch { string[] names = Enum.GetNames(typeof(DataEntryKey)); foreach (string text in names) { if (text.IndexOf(name, StringComparison.OrdinalIgnoreCase) >= 0) { key = (DataEntryKey)(int)(DataEntryKey)Enum.Parse(typeof(DataEntryKey), text); return true; } } key = (DataEntryKey)0; return false; } } private bool TryWriteEntryNumeric(object entryObj, float value) { if (entryObj == null) { return false; } Type type = entryObj.GetType(); PropertyInfo property = type.GetProperty("Value", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (property != null && property.CanWrite) { Type propertyType = property.PropertyType; object value2 = Convert.ChangeType(value, propertyType); try { property.SetValue(entryObj, value2); return true; } catch { } } FieldInfo field = type.GetField("Value", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { Type fieldType = field.FieldType; object value3 = Convert.ChangeType(value, fieldType); try { field.SetValue(entryObj, value3); return true; } catch { } } return false; } private bool AddItemToInventory_GetSlot(Player player, ushort itemId, out ItemSlot createdSlot) { createdSlot = null; if ((Object)(object)player == (Object)null) { return false; } try { if (_playerAddItemMethod == null) { _playerAddItemMethod = typeof(Player).GetMethod("AddItem", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[3] { typeof(ushort), typeof(ItemInstanceData), typeof(ItemSlot).MakeByRefType() }, null); if (_playerAddItemMethod == null) { ((BaseUnityPlugin)this).Logger.LogError((object)"[Checkpoint_Save] Player.AddItem not found."); return false; } } ItemSlot val = null; object[] array = new object[3] { itemId, null, val }; _playerAddItemMethod.Invoke(player, array); object obj = array[2]; createdSlot = (ItemSlot)((obj is ItemSlot) ? obj : null); return createdSlot != null; } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("[Checkpoint_Save] AddItemToInventory_GetSlot error: " + ex)); return false; } } public void ResetMapSegment() { if (!PhotonNetwork.OfflineMode && !PhotonNetwork.IsMasterClient) { return; } try { int num = 0; int num2 = 0; MonoBehaviour[] array = Object.FindObjectsOfType<MonoBehaviour>(true); foreach (MonoBehaviour val in array) { if (!((Object)(object)val == (Object)null)) { Type type = ((object)val).GetType(); string name = type.Name; if (name.IndexOf("Luggage", StringComparison.OrdinalIgnoreCase) >= 0) { num++; ResetLootObjectGeneric(val, new string[6] { "ResetRecievedData", "SetKinematicAndResetSyncData", "Reset", "Refresh", "Rebuild", "Invalidate" }); } else if (name.IndexOf("RespawnChest", StringComparison.OrdinalIgnoreCase) >= 0 || (name.IndexOf("Chest", StringComparison.OrdinalIgnoreCase) >= 0 && name.IndexOf("Respawn", StringComparison.OrdinalIgnoreCase) >= 0)) { num2++; ResetLootObjectGeneric(val, new string[4] { "Reset", "Refresh", "Rebuild", "Invalidate" }); } } } ((BaseUnityPlugin)this).Logger.LogInfo((object)$"[Checkpoint_Save] ResetWorldLoot: touched luggage={num}, chests={num2}"); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("[Checkpoint_Save] ResetWorldLoot failed: " + ex)); } try { int num3 = 0; int num4 = 0; PhotonView[] array2 = Object.FindObjectsOfType<PhotonView>(true); PhotonView[] array3 = array2; foreach (PhotonView val2 in array3) { if ((Object)(object)val2 == (Object)null) { continue; } bool flag = false; try { flag = val2.IsRoomView; } catch { num4++; continue; } if (flag) { continue; } GameObject gameObject = ((Component)val2).gameObject; if ((Object)(object)gameObject == (Object)null) { continue; } if ((Object)(object)gameObject.GetComponentInParent<Player>(true) != (Object)null || (Object)(object)gameObject.GetComponentInParent<Character>(true) != (Object)null) { num4++; continue; } if (!((Object)(object)gameObject.GetComponentInChildren<Rigidbody>(true) != (Object)null) || (!((Object)(object)gameObject.GetComponent("Item") != (Object)null) && !((Object)(object)gameObject.GetComponent("ItemPickup") != (Object)null) && ((Object)gameObject).name.IndexOf("Item", StringComparison.OrdinalIgnoreCase) < 0 && ((Object)gameObject).name.IndexOf("Pickup", StringComparison.OrdinalIgnoreCase) < 0 && ((Object)gameObject).name.IndexOf("Drop", StringComparison.OrdinalIgnoreCase) < 0)) { num4++; continue; } if (!PhotonNetwork.OfflineMode) { PhotonNetwork.Destroy(val2); } else { Object.Destroy((Object)(object)gameObject); } num3++; } ((BaseUnityPlugin)this).Logger.LogInfo((object)$"[Checkpoint_Save] ResetDroppedRuntimeItems: destroyed={num3}, skipped={num4}"); } catch (Exception ex2) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("[Checkpoint_Save] ResetDroppedRuntimeItems failed: " + ex2)); } } private void ResetLootObjectGeneric(MonoBehaviour obj, string[] methodNames) { Type type = ((object)obj).GetType(); TrySetBoolFieldOrProp(obj, "opened", value: false); TrySetBoolFieldOrProp(obj, "isOpened", value: false); TrySetBoolFieldOrProp(obj, "hasOpened", value: false); TrySetBoolFieldOrProp(obj, "looted", value: false); TrySetBoolFieldOrProp(obj, "isLooted", value: false); TrySetEnumToDefault(obj, "state"); TrySetEnumToDefault(obj, "luggageState"); foreach (string methodName in methodNames) { if (TryInvokeNoArg(obj, methodName)) { break; } } TrySetBoolFieldOrProp(obj, "canInteract", value: true); TrySetBoolFieldOrProp(obj, "interactable", value: true); } private bool TryInvokeNoArg(object inst, string methodName) { try { Type type = inst.GetType(); MethodInfo method = type.GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (method == null || method.GetParameters().Length != 0) { return false; } method.Invoke(inst, null); return true; } catch { return false; } } private void TrySetBoolFieldOrProp(object inst, string name, bool value) { try { Type type = inst.GetType(); FieldInfo field = type.GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null && field.FieldType == typeof(bool)) { field.SetValue(inst, value); return; } PropertyInfo property = type.GetProperty(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (property != null && property.CanWrite && property.PropertyType == typeof(bool)) { property.SetValue(inst, value); } } catch { } } private void TrySetEnumToDefault(object inst, string name) { try { Type type = inst.GetType(); FieldInfo field = type.GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null && field.FieldType.IsEnum) { object value = Enum.ToObject(field.FieldType, 0); field.SetValue(inst, value); return; } PropertyInfo property = type.GetProperty(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (property != null && property.CanWrite && property.PropertyType.IsEnum) { object value2 = Enum.ToObject(property.PropertyType, 0); property.SetValue(inst, value2); } } catch { } } public void SavePlayerOffline() { //IL_0c2a: 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_0b3a: Unknown result type (might be due to invalid IL or missing references) //IL_0b46: Unknown result type (might be due to invalid IL or missing references) //IL_0b52: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0b75: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0b7a: Unknown result type (might be due to invalid IL or missing references) //IL_0b9b: Expected O, but got I4 //IL_0bb0: Expected O, but got I4 //IL_0bb8: Expected O, but got I4 //IL_0bc0: Expected O, but got I4 //IL_0bd2: Expected O, but got I4 //IL_0bd4: Expected O, but got I4 //IL_0be8: Unknown result type (might be due to invalid IL or missing references) //IL_0c02: Unknown result type (might be due to invalid IL or missing references) //IL_011e: 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_01de: Unknown result type (might be due to invalid IL or missing references) //IL_0663: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_06cb: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_0723: Unknown result type (might be due to invalid IL or missing references) //IL_02f6: Unknown result type (might be due to invalid IL or missing references) //IL_078b: Unknown result type (might be due to invalid IL or missing references) //IL_034e: Unknown result type (might be due to invalid IL or missing references) //IL_07e3: Unknown result type (might be due to invalid IL or missing references) //IL_03a6: Unknown result type (might be due to invalid IL or missing references) //IL_083b: Unknown result type (might be due to invalid IL or missing references) //IL_03fe: Unknown result type (might be due to invalid IL or missing references) //IL_0893: Unknown result type (might be due to invalid IL or missing references) //IL_0456: Unknown result type (might be due to invalid IL or missing references) //IL_08eb: Unknown result type (might be due to invalid IL or missing references) //IL_04ae: Unknown result type (might be due to invalid IL or missing references) //IL_0943: Unknown result type (might be due to invalid IL or missing references) //IL_0506: Unknown result type (might be due to invalid IL or missing references) //IL_099b: Unknown result type (might be due to invalid IL or missing references) //IL_055e: Unknown result type (might be due to invalid IL or missing references) //IL_09f3: Unknown result type (might be due to invalid IL or missing references) //IL_0a4b: Unknown result type (might be due to invalid IL or missing references) //IL_0aa3: Unknown result type (might be due to invalid IL or missing references) //IL_0b7a->IL0b7a: Incompatible stack types: O vs I4 //IL_0b73->IL0b7a: Incompatible stack types: I4 vs O //IL_0b73->IL0b7a: Incompatible stack types: O vs I4 try { Player localPlayer = GetLocalPlayer(); if ((Object)(object)localPlayer == (Object)null) { ShowMessage("No Player found – cannot save progress!", Color.red, 5f); ((BaseUnityPlugin)this).Logger.LogError((object)"[Checkpoint_Save] no Player found – cannot save progress."); return; } string playerSaveFile = GetPlayerSaveFile(NetworkingUtilities.UserId(localPlayer)); Character localCharacter = Character.localCharacter; Vector3 val; if ((Object)(object)localCharacter != (Object)null) { val = localCharacter.Head; } else { ((BaseUnityPlugin)this).Logger.LogWarning((object)"[Checkpoint_Save] Character.localCharacter is null – used player.transform as fallback."); val = ((Component)localPlayer).transform.position; } Scene activeScene = SceneManager.GetActiveScene(); string name = ((Scene)(ref activeScene)).name; List<SavedItemState> list = new List<SavedItemState>(); if (localPlayer.itemSlots != null) { int num = 0; ItemSlot[] itemSlots = localPlayer.itemSlots; foreach (ItemSlot val2 in itemSlots) { if (val2 == null || val2.IsEmpty() || (Object)(object)val2.prefab == (Object)null) { continue; } ItemInstanceData data = val2.data; if (data != null) { SavedItemState savedItemState = new SavedItemState { itemId = val2.prefab.itemID, slotIndex = num }; if (TryGetKey("ItemUses", out var key) && TryGetEntryObject(data, key, out object entryObj) && TryReadEntryNumeric(entryObj, out var value) && val2.prefab.itemID != 66) { savedItemState.values["ItemUses"] = new SavedEntry { type = entryObj.GetType().AssemblyQualifiedName, value = value }; } if (TryGetKey("PetterItemUses", out var key2) && TryGetEntryObject(data, key2, out object entryObj2) && TryReadEntryNumeric(entryObj2, out var value2)) { savedItemState.values["PetterItemUses"] = new SavedEntry { type = entryObj2.GetType().AssemblyQualifiedName, value = value2 }; } if (TryGetKey("UseRemainingPercentage", out var key3) && TryGetEntryObject(data, key3, out object entryObj3) && TryReadEntryNumeric(entryObj3, out var value3) && val2.prefab.itemID != 66) { savedItemState.values["UseRemainingPercentage"] = new SavedEntry { type = entryObj3.GetType().AssemblyQualifiedName, value = value3 }; } if (TryGetKey("CookedAmount", out var key4) && TryGetEntryObject(data, key4, out object entryObj4) && TryReadEntryNumeric(entryObj4, out var value4)) { savedItemState.values["CookedAmount"] = new SavedEntry { type = entryObj4.GetType().AssemblyQualifiedName, value = value4 }; } if (TryGetKey("Fuel", out var key5) && TryGetEntryObject(data, key5, out object entryObj5) && TryReadEntryNumeric(entryObj5, out var value5)) { savedItemState.values["Fuel"] = new SavedEntry { type = entryObj5.GetType().AssemblyQualifiedName, value = value5 }; } if (TryGetKey("Color", out var key6) && TryGetEntryObject(data, key6, out object entryObj6) && TryReadEntryNumeric(entryObj6, out var value6)) { savedItemState.values["Color"] = new SavedEntry { type = entryObj6.GetType().AssemblyQualifiedName, value = value6 }; } if (TryGetKey("Scale", out var key7) && TryGetEntryObject(data, key7, out object entryObj7) && TryReadEntryNumeric(entryObj7, out var value7)) { savedItemState.values["Scale"] = new SavedEntry { type = entryObj7.GetType().AssemblyQualifiedName, value = value7 }; } if (TryGetKey("value__", out var key8) && TryGetEntryObject(data, key8, out object entryObj8) && TryReadEntryNumeric(entryObj8, out var value8)) { savedItemState.values["value__"] = new SavedEntry { type = entryObj8.GetType().AssemblyQualifiedName, value = value8 }; } if (TryGetKey("Used", out var key9) && TryGetEntryObject(data, key9, out object entryObj9) && TryReadEntryNumeric(entryObj9, out var value9)) { savedItemState.values["Used"] = new SavedEntry { type = entryObj9.GetType().AssemblyQualifiedName, value = value9 }; } if (TryGetKey("SpawnedBees", out var key10) && TryGetEntryObject(data, key10, out object entryObj10) && TryReadEntryNumeric(entryObj10, out var value10)) { savedItemState.values["SpawnedBees"] = new SavedEntry { type = entryObj10.GetType().AssemblyQualifiedName, value = value10 }; } if (TryGetKey("ScreamTime", out var key11) && TryGetEntryObject(data, key11, out object entryObj11) && TryReadEntryNumeric(entryObj11, out var value11)) { savedItemState.values["ScreamTime"] = new SavedEntry { type = entryObj11.GetType().AssemblyQualifiedName, value = value11 }; } if (TryGetKey("FlareActive", out var key12) && TryGetEntryObject(data, key12, out object entryObj12) && TryReadEntryNumeric(entryObj12, out var value12)) { savedItemState.values["FlareActive"] = new SavedEntry { type = entryObj12.GetType().AssemblyQualifiedName, value = value12 }; } if (TryGetKey("InstanceID", out var key13) && TryGetEntryObject(data, key13, out object entryObj13) && TryReadEntryNumeric(entryObj13, out var value13)) { savedItemState.values["InstanceID"] = new SavedEntry { type = entryObj13.GetType().AssemblyQualifiedName, value = value13 }; } list.Add(savedItemState); num++; } } } BackpackData backpackData = GetBackpackData(localPlayer); List<SavedBackpackItemState> list2 = new List<SavedBackpackItemState>(); try { if (backpackData != null && backpackData.itemSlots != null) { for (byte b = 0; b < backpackData.itemSlots.Length; b++) { ItemSlot val3 = backpackData.itemSlots[b]; if (val3 != null && !val3.IsEmpty() && !((Object)(object)val3.prefab == (Object)null)) { ItemInstanceData data2 = val3.data; if (data2 != null) { SavedBackpackItemState savedBackpackItemState = new SavedBackpackItemState { slotIndex = b, itemId = val3.prefab.itemID }; if (TryGetKey("ItemUses", out var key14) && TryGetEntryObject(data2, key14, out object entryObj14) && TryReadEntryNumeric(entryObj14, out var value14) && val3.prefab.itemID != 66) { savedBackpackItemState.values["ItemUses"] = new SavedEntry { type = entryObj14.GetType().AssemblyQualifiedName, value = value14 }; } if (TryGetKey("PetterItemUses", out var key15) && TryGetEntryObject(data2, key15, out object entryObj15) && TryReadEntryNumeric(entryObj15, out var value15)) { savedBackpackItemState.values["PetterItemUses"] = new SavedEntry { type = entryObj15.GetType().AssemblyQualifiedName, value = value15 }; } if (TryGetKey("UseRemainingPercentage", out var key16) && TryGetEntryObject(data2, key16, out object entryObj16) && TryReadEntryNumeric(entryObj16, out var value16) && val3.prefab.itemID != 66) { savedBackpackItemState.values["UseRemainingPercentage"] = new SavedEntry { type = entryObj16.GetType().AssemblyQualifiedName, value = value16 }; } if (TryGetKey("CookedAmount", out var key17) && TryGetEntryObject(data2, key17, out object entryObj17) && TryReadEntryNumeric(entryObj17, out var value17)) { savedBackpackItemState.values["CookedAmount"] = new SavedEntry { type = entryObj17.GetType().AssemblyQualifiedName, value = value17 }; } if (TryGetKey("Fuel", out var key18) && TryGetEntryObject(data2, key18, out object entryObj18) && TryReadEntryNumeric(entryObj18, out var value18)) { savedBackpackItemState.values["Fuel"] = new SavedEntry { type = entryObj18.GetType().AssemblyQualifiedName, value = value18 }; } if (TryGetKey("Color", out var key19) && TryGetEntryObject(data2, key19, out object entryObj19) && TryReadEntryNumeric(entryObj19, out var value19)) { savedBackpackItemState.values["Color"] = new SavedEntry { type = entryObj19.GetType().AssemblyQualifiedName, value = value19 }; } if (TryGetKey("Scale", out var key20) && TryGetEntryObject(data2, key20, out object entryObj20) && TryReadEntryNumeric(entryObj20, out var value20)) { savedBackpackItemState.values["Scale"] = new SavedEntry { type = entryObj20.GetType().AssemblyQualifiedName, value = value20 }; } if (TryGetKey("value__", out var key21) && TryGetEntryObject(data2, key21, out object entryObj21) && TryReadEntryNumeric(entryObj21, out var value21)) { savedBackpackItemState.values["value__"] = new SavedEntry { type = entryObj21.GetType().AssemblyQualifiedName, value = value21 }; } if (TryGetKey("Used", out var key22) && TryGetEntryObject(data2, key22, out object entryObj22) && TryReadEntryNumeric(entryObj22, out var value22)) { savedBackpackItemState.values["Used"] = new SavedEntry { type = entryObj22.GetType().AssemblyQualifiedName, value = value22 }; } if (TryGetKey("SpawnedBees", out var key23) && TryGetEntryObject(data2, key23, out object entryObj23) && TryReadEntryNumeric(entryObj23, out var value23)) { savedBackpackItemState.values["SpawnedBees"] = new SavedEntry { type = entryObj23.GetType().AssemblyQualifiedName, value = value23 }; } if (TryGetKey("ScreamTime", out var key24) && TryGetEntryObject(data2, key24, out object entryObj24) && TryReadEntryNumeric(entryObj24, out var value24)) { savedBackpackItemState.values["ScreamTime"] = new SavedEntry { type = entryObj24.GetType().AssemblyQualifiedName, value = value24 }; } if (TryGetKey("FlareActive", out var key25) && TryGetEntryObject(data2, key25, out object entryObj25) && TryReadEntryNumeric(entryObj25, out var value25)) { savedBackpackItemState.values["FlareActive"] = new SavedEntry { type = entryObj25.GetType().AssemblyQualifiedName, value = value25 }; } if (TryGetKey("InstanceID", out var key26) && TryGetEntryObject(data2, key26, out object entryObj26) && TryReadEntryNumeric(entryObj26, out var value26)) { savedBackpackItemState.values["InstanceID"] = new SavedEntry { type = entryObj26.GetType().AssemblyQualifiedName, value = value26 }; } list2.Add(savedBackpackItemState); } } } } } catch { } CharacterAfflictions afflictions = Character.localCharacter.refs.afflictions; MapHandler mapHandler = GetMapHandler(); object obj2 = new SaveData { settingsVersion = settingsVersion, posX = val.x, posY = val.y, posZ = val.z, sceneName = name }; object obj3 = obj2; int num2; if ((Object)(object)mapHandler != (Object)null) { obj2 = mapHandler.GetCurrentSegment(); num2 = (int)obj2; } else { num2 = 0; obj2 = num2; num2 = (int)obj2; } ((SaveData)obj3).segment = (Segment)obj2; ((SaveData)num2).hasBackpack = localPlayer.backpackSlot != null && localPlayer.backpackSlot.hasBackpack; ((SaveData)num2).isSkeleton = Character.localCharacter.data.isSkeleton; ((SaveData)num2).inventoryItemStates = list; ((SaveData)num2).backpackItemStates = list2; ((SaveData)num2).afflictions_current = afflictions.currentStatuses.ToArray(); SaveData saveData = (SaveData)num2; File.WriteAllText(playerSaveFile, JsonConvert.SerializeObject((object)saveData, (Formatting)1)); ShowMessage("Saved game progress", Color.green, 4f); ((BaseUnityPlugin)this).Logger.LogInfo((object)$"[Checkpoint_Save] Position + inventory saved. Pos: {val} Scene: {name}, Items: {list.Count}"); } catch (Exception ex) { ShowMessage("Something went wrong while saving progress =(", Color.red, 5f); ((BaseUnityPlugin)this).Logger.LogError((object)("[Checkpoint_Save] Error while saving progress: " + ex)); } } public void SavePlayerCoop() { //IL_0db4: Unknown result type (might be due to invalid IL or missing references) //IL_0c2d: Unknown result type (might be due to invalid IL or missing references) //IL_0c3a: Unknown result type (might be due to invalid IL or missing references) //IL_0c47: Unknown result type (might be due to invalid IL or missing references) //IL_0c6b: Unknown result type (might be due to invalid IL or missing references) //IL_0c70: Unknown result type (might be due to invalid IL or missing references) //IL_0c93: Expected O, but got I4 //IL_0ca5: Expected O, but got I4 //IL_0cad: Expected O, but got I4 //IL_0cb5: Expected O, but got I4 //IL_0cc7: Expected O, but got I4 //IL_0cc9: Expected O, but got I4 //IL_0cde: Unknown result type (might be due to invalid IL or missing references) //IL_0d0e: Unknown result type (might be due to invalid IL or missing references) //IL_0d1d: Unknown result type (might be due to invalid IL or missing references) //IL_0d2c: Unknown result type (might be due to invalid IL or missing references) //IL_0d5e: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_016e: 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_0213: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_0759: Unknown result type (might be due to invalid IL or missing references) //IL_033b: Unknown result type (might be due to invalid IL or missing references) //IL_07c1: Unknown result type (might be due to invalid IL or missing references) //IL_0393: Unknown result type (might be due to invalid IL or missing references) //IL_0819: Unknown result type (might be due to invalid IL or missing references) //IL_03eb: Unknown result type (might be due to invalid IL or missing references) //IL_0881: Unknown result type (might be due to invalid IL or missing references) //IL_0443: Unknown result type (might be due to invalid IL or missing references) //IL_08d9: Unknown result type (might be due to invalid IL or missing references) //IL_049b: Unknown result type (might be due to invalid IL or missing references) //IL_0931: Unknown result type (might be due to invalid IL or missing references) //IL_04f3: Unknown result type (might be due to invalid IL or missing references) //IL_0989: Unknown result type (might be due to invalid IL or missing references) //IL_054b: Unknown result type (might be due to invalid IL or missing references) //IL_09e1: Unknown result type (might be due to invalid IL or missing references) //IL_05a3: Unknown result type (might be due to invalid IL or missing references) //IL_0a39: Unknown result type (might be due to invalid IL or missing references) //IL_05fb: Unknown result type (might be due to invalid IL or missing references) //IL_0a91: Unknown result type (might be due to invalid IL or missing references) //IL_0653: Unknown result type (might be due to invalid IL or missing references) //IL_0ae9: Unknown result type (might be due to invalid IL or missing references) //IL_0b41: Unknown result type (might be due to invalid IL or missing references) //IL_0b99: Unknown result type (might be due to invalid IL or missing references) //IL_0c70->IL0c70: Incompatible stack types: O vs I4 //IL_0c69->IL0c70: Incompatible stack types: I4 vs O //IL_0c69->IL0c70: Incompatible stack types: O vs I4 try { try { if (PhotonNetwork.IsMasterClient) { string[] files = Directory.GetFiles(Path.Combine(Paths.PluginPath + "\\Checkpoint_Save\\Coop")); string[] array = files; foreach (string text in array) { if (!configLegacySaveFile.Value) { if (text.Contains($"peak_save_{Ascents.currentAscent}_")) { File.Delete(text); } } else if (text.Contains("peak_save_765")) { File.Delete(text); } } } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("[Checkpoint_Save] Error while deleting save files: " + ex)); } Player[] array2 = Object.FindObjectsOfType<Player>(); foreach (Player val in array2) { foreach (Character allCharacter in Character.AllCharacters) { if (!(NetworkingUtilities.UserId(allCharacter.player) == NetworkingUtilities.UserId(val))) { continue; } if ((Object)(object)val == (Object)null) { ShowMessage("No Player found – cannot save progress!", Color.red, 5f); ((BaseUnityPlugin)this).Logger.LogError((object)"[Checkpoint_Save] no Player found – cannot save progress."); return; } string playerSaveFile = GetPlayerSaveFile(NetworkingUtilities.UserId(val)); Vector3 val2; if ((Object)(object)allCharacter != (Object)null) { val2 = allCharacter.Head; } else { ((BaseUnityPlugin)this).Logger.LogWarning((object)"[Checkpoint_Save] Character.localCharacter is null – used player.transform as fallback."); val2 = ((Component)val).transform.position; } Scene activeScene = SceneManager.GetActiveScene(); string name = ((Scene)(ref activeScene)).name; List<SavedItemState> list = new List<SavedItemState>(); if (val.itemSlots != null) { int num = 0; ItemSlot[] itemSlots = val.itemSlots; foreach (ItemSlot val3 in itemSlots) { if (val3 == null || val3.IsEmpty() || (Object)(object)val3.prefab == (Object)null) { continue; } ItemInstanceData data = val3.data; if (data != null) { SavedItemState savedItemState = new SavedItemState { itemId = val3.prefab.itemID, slotIndex = num }; if (TryGetKey("ItemUses", out var key) && TryGetEntryObject(data, key, out object entryObj) && TryReadEntryNumeric(entryObj, out var value) && val3.prefab.itemID != 66) { savedItemState.values["ItemUses"] = new SavedEntry { type = entryObj.GetType().AssemblyQualifiedName, value = value }; } if (TryGetKey("PetterItemUses", out var key2) && TryGetEntryObject(data, key2, out object entryObj2) && TryReadEntryNumeric(entryObj2, out var value2)) { savedItemState.values["PetterItemUses"] = new SavedEntry { type = entryObj2.GetType().AssemblyQualifiedName, value = value2 }; } if (TryGetKey("UseRemainingPercentage", out var key3) && TryGetEntryObject(data, key3, out object entryObj3) && TryReadEntryNumeric(entryObj3, out var value3) && val3.prefab.itemID != 66) { savedItemState.values["UseRemainingPercentage"] = new SavedEntry { type = entryObj3.GetType().AssemblyQualifiedName, value = value3 }; } if (TryGetKey("CookedAmount", out var key4) && TryGetEntryObject(data, key4, out object entryObj4) && TryReadEntryNumeric(entryObj4, out var value4)) { savedItemState.values["CookedAmount"] = new SavedEntry { type = entryObj4.GetType().AssemblyQualifiedName, value = value4 }; } if (TryGetKey("Fuel", out var key5) && TryGetEntryObject(data, key5, out object entryObj5) && TryReadEntryNumeric(entryObj5, out var value5)) { savedItemState.values["Fuel"] = new SavedEntry { type = entryObj5.GetType().AssemblyQualifiedName, value = value5 }; } if (TryGetKey("Color", out var key6) && TryGetEntryObject(data, key6, out object entryObj6) && TryReadEntryNumeric(entryObj6, out var value6)) { savedItemState.values["Color"] = new SavedEntry { type = entryObj6.GetType().AssemblyQualifiedName, value = value6 }; } if (TryGetKey("Scale", out var key7) && TryGetEntryObject(data, key7, out object entryObj7) && TryReadEntryNumeric(entryObj7, out var value7)) { savedItemState.values["Scale"] = new SavedEntry { type = entryObj7.GetType().AssemblyQualifiedName, value = value7 }; } if (TryGetKey("value__", out var key8) && TryGetEntryObject(data, key8, out object entryObj8) && TryReadEntryNumeric(entryObj8, out var value8)) { savedItemState.values["value__"] = new SavedEntry { type = entryObj8.GetType().AssemblyQualifiedName, value = value8 }; } if (TryGetKey("Used", out var key9) && TryGetEntryObject(data, key9, out object entryObj9) && TryReadEntryNumeric(entryObj9, out var value9)) { savedItemState.values["Used"] = new SavedEntry { type = entryObj9.GetType().AssemblyQualifiedName, value = value9 }; } if (TryGetKey("SpawnedBees", out var key10) && TryGetEntryObject(data, key10, out object entryObj10) && TryReadEntryNumeric(entryObj10, out var value10)) { savedItemState.values["SpawnedBees"] = new SavedEntry { type = entryObj10.GetType().AssemblyQualifiedName, value = value10 }; } if (TryGetKey("ScreamTime", out var key11) && TryGetEntryObject(data, key11, out object entryObj11) && TryReadEntryNumeric(entryObj11, out var value11)) { savedItemState.values["ScreamTime"] = new SavedEntry { type = entryObj11.GetType().AssemblyQualifiedName, value = value11 }; } if (TryGetKey("FlareActive", out var key12) && TryGetEntryObject(data, key12, out object entryObj12) && TryReadEntryNumeric(entryObj12, out var value12)) { savedItemState.values["FlareActive"] = new SavedEntry { type = entryObj12.GetType().AssemblyQualifiedName, value = value12 }; } if (TryGetKey("InstanceID", out var key13) && TryGetEntryObject(data, key13, out object entryObj13) && TryReadEntryNumeric(entryObj13, out var value13)) { savedItemState.values["InstanceID"] = new SavedEntry { type = entryObj13.GetType().AssemblyQualifiedName, value = value13 }; } list.Add(savedItemState); num++; } } } BackpackData backpackData = GetBackpackData(val); List<SavedBackpackItemState> list2 = new List<SavedBackpackItemState>(); try { if (backpackData != null && backpackData.itemSlots != null) { for (byte b = 0; b < backpackData.itemSlots.Length; b++) { ItemSlot val4 = backpackData.itemSlots[b]; if (val4 != null && !val4.IsEmpty() && !((Object)(object)val4.prefab == (Object)null)) { ItemInstanceData data2 = val4.data; if (data2 != null) { SavedBackpackItemState savedBackpackItemState = new SavedBackpackItemState { slotIndex = b, itemId = val4.prefab.itemID }; if (TryGetKey("ItemUses", out var key14) && TryGetEntryObject(data2, key14, out object entryObj14) && TryReadEntryNumeric(entryObj14, out var value14) && val4.prefab.itemID != 66) { savedBackpackItemState.values["ItemUses"] = new SavedEntry { type = entryObj14.GetType().AssemblyQualifiedName, value = value14 }; } if (TryGetKey("PetterItemUses", out var key15) && TryGetEntryObject(data2, key15, out object entryObj15) && TryReadEntryNumeric(entryObj15, out var value15)) { savedBackpackItemState.values["PetterItemUses"] = new SavedEntry { type = entryObj15.GetType().AssemblyQualifiedName, value = value15 }; } if (TryGetKey("UseRemainingPercentage", out var key16) && TryGetEntryObject(data2, key16, out object entryObj16) && TryReadEntryNumeric(entryObj16, out var value16) && val4.prefab.itemID != 66) { savedBackpackItemState.values["UseRemainingPercentage"] = new SavedEntry { type = entryObj16.GetType().AssemblyQualifiedName, value = value16 }; } if (TryGetKey("CookedAmount", out var key17) && TryGetEntryObject(data2, key17, out object entryObj17) && TryReadEntryNumeric(entryObj17, out var value17)) { savedBackpackItemState.values["CookedAmount"] = new SavedEntry { type = entryObj17.GetType().AssemblyQualifiedName, value = value17 }; } if (TryGetKey("Fuel", out var key18) && TryGetEntryObject(data2, key18, out object entryObj18) && TryReadEntryNumeric(entryObj18, out var value18)) { savedBackpackItemState.values["Fuel"] = new SavedEntry { type = entryObj18.GetType().AssemblyQualifiedName, value = value18 }; } if (TryGetKey("Color", out var key19) && TryGetEntryObject(data2, key19, out object entryObj19) && TryReadEntryNumeric(entryObj19, out var value19)) { savedBackpackItemState.values["Color"] = new SavedEntry { type = entryObj19.GetType().AssemblyQualifiedName, value = value19 }; } if (TryGetKey("Scale", out var key20) && TryGetEntryObject(data2, key20, out object entryObj20) && TryReadEntryNumeric(entryObj20, out var value20)) { savedBackpackItemState.values["Scale"] = new SavedEntry { type = entryObj20.GetType().AssemblyQualifiedName, value = value20 }; } if (TryGetKey("value__", out var key21) && TryGetEntryObject(data2, key21, out object entryObj21) && TryReadEntryNumeric(entryObj21, out var value21)) { savedBackpackItemState.values["value__"] = new SavedEntry { type = entryObj21.GetType().AssemblyQualifiedName, value = value21 }; } if (TryGetKey("Used", out var key22) && TryGetEntryObject(data2, key22, out object entryObj22) && TryReadEntryNumeric(entryObj22, out var value22)) { savedBackpackItemState.values["Used"] = new SavedEntry { type = entryObj22.GetType().AssemblyQualifiedName, value = value22 }; } if (TryGetKey("SpawnedBees", out var key23) && TryGetEntryObject(data2, key23, out object entryObj23) && TryReadEntryNumeric(entryObj23, out var value23)) { savedBackpackItemState.values["SpawnedBees"] = new SavedEntry { type = entryObj23.GetType().AssemblyQualifiedName, value = value23 }; } if (TryGetKey("ScreamTime", out var key24) && TryGetEntryObject(data2, key24, out object entryObj24) && TryReadEntryNumeric(entryObj24, out var value24)) { savedBackpackItemState.values["ScreamTime"] = new SavedEntry { type = entryObj24.GetType().AssemblyQualifiedName, value = value24 }; } if (TryGetKey("FlareActive", out var key25) && TryGetEntryObject(data2, key25, out object entryObj25) && TryReadEntryNumeric(entryObj25, out var value25)) { savedBackpackItemState.values["FlareActive"] = new SavedEntry { type = entryObj25.GetType().AssemblyQualifiedName, value = value25 }; } if (TryGetKey("InstanceID", out var key26) && TryGetEntryObject(data2, key26, out object entryObj26) && TryReadEntryNumeric(entryObj26, out var value26)) { savedBackpackItemState.values["InstanceID"] = new SavedEntry { type = entryObj26.GetType().AssemblyQualifiedName, value = value26 }; } list2.Add(savedBackpackItemState); } } } } } catch { } CharacterAfflictions afflictions = allCharacter.refs.afflictions; MapHandler mapHandler = GetMapHandler(); object obj2 = new SaveData { settingsVersion = settingsVersion, posX = val2.x, posY = val2.y, posZ = val2.z, sceneName = name }; object obj3 = obj2; int num2; if ((Object)(object)mapHandler != (Object)null) { obj2 = mapHandler.GetCurrentSegment(); num2 = (int)obj2; } else { num2 = 0; obj2 = num2; num2 = (int)obj2; } ((SaveData)obj3).segment = (Segment)obj2; ((SaveData)num2).hasBackpack = val.backpackSlot != null && val.backpackSlot.hasBackpack; ((SaveData)num2).isSkeleton = allCharacter.data.isSkeleton; ((SaveData)num2).inventoryItemStates = list; ((SaveData)num2).backpackItemStates = list2;