using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using CommonAPI;
using CommonAPI.Phone;
using GeoSaver.Apps;
using GeoSaver.Patches;
using HarmonyLib;
using MapStation.API;
using Reptile;
using Reptile.Phone;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("BRC_GeoSaver")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BRC_GeoSaver")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("32955761-5b97-4968-9c6d-aca3855af53e")]
[assembly: AssemblyFileVersion("1.1.1.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.1.0")]
[module: UnverifiableCode]
namespace GeoSaver
{
public class GeoSaverApp : CustomApp
{
private static Sprite IconSprite;
public static void Init()
{
string text = Path.Combine(GeoSaverPlugin.Instance.Dir, "GeoSaver_Icon.png");
try
{
IconSprite = TextureUtility.LoadSprite(text);
PhoneAPI.RegisterApp<GeoSaverApp>("GeoSaver", IconSprite);
}
catch (Exception ex)
{
Console.WriteLine("Error loading icon sprite: " + ex.Message);
PhoneAPI.RegisterApp<GeoSaverApp>("GeoSaver", (Sprite)null);
}
}
public override void OnAppInit()
{
((CustomApp)this).OnAppInit();
((CustomApp)this).CreateIconlessTitleBar("GeoSaver", 80f);
base.ScrollView = PhoneScrollView.Create((CustomApp)(object)this, 275f, 1600f);
string[] array = GeoSaverPlugin.MenuOrder.Value.Split(new char[1] { ',' });
string[] array2 = array;
foreach (string text in array2)
{
switch (text.Trim())
{
case "Save":
AddSaveButton();
break;
case "Load":
AddLoadButton();
break;
case "TempSave":
AddTempSaveButton();
break;
case "TempLoad":
AddTempLoadButton();
break;
}
}
}
private void AddSaveButton()
{
SimplePhoneButton val = PhoneUIUtility.CreateSimpleButton("Save Location");
((PhoneButton)val).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val).OnConfirm, (Action)delegate
{
((App)this).MyPhone.OpenApp(typeof(SaveApp));
});
base.ScrollView.AddButton((PhoneButton)(object)val);
}
private void AddLoadButton()
{
SimplePhoneButton val = PhoneUIUtility.CreateSimpleButton("Load Location");
((PhoneButton)val).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val).OnConfirm, (Action)delegate
{
((App)this).MyPhone.OpenApp(typeof(LoadApp));
});
base.ScrollView.AddButton((PhoneButton)(object)val);
}
private void AddTempSaveButton()
{
SimplePhoneButton val = PhoneUIUtility.CreateSimpleButton("Save Temp Location");
((PhoneButton)val).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val).OnConfirm, (Action)delegate
{
GeoSaverPlugin.TempSaveButton();
});
base.ScrollView.AddButton((PhoneButton)(object)val);
}
private void AddTempLoadButton()
{
SimplePhoneButton val = PhoneUIUtility.CreateSimpleButton("Load Last Location");
((PhoneButton)val).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val).OnConfirm, (Action)delegate
{
GeoSaverPlugin.TempLoadButton();
});
base.ScrollView.AddButton((PhoneButton)(object)val);
}
}
internal class LocationFileManager
{
public class SaveData
{
public Vector3 Location { get; set; }
public Quaternion Rotation { get; set; }
public string Stage { get; set; }
public float Storage { get; set; }
public float Boost { get; set; }
public MoveStyle EquippedMoveStyle { get; set; }
public MoveStyle CurrentMoveStyle { get; set; }
public string Serialize()
{
//IL_0010: 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_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
return string.Join("|", FormatVector3(Location), FormatQuaternion(Rotation), Stage.ToString(), Storage.ToString(CultureInfo.InvariantCulture), Boost.ToString(CultureInfo.InvariantCulture), $"{EquippedMoveStyle},{CurrentMoveStyle}");
}
private string FormatVector3(Vector3 vector)
{
//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_0021: Unknown result type (might be due to invalid IL or missing references)
return string.Format(CultureInfo.InvariantCulture, "{0},{1},{2}", vector.x, vector.y, vector.z);
}
private string FormatQuaternion(Quaternion quaternion)
{
//IL_0013: 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_002f: 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)
return string.Format(CultureInfo.InvariantCulture, "{0},{1},{2},{3}", quaternion.x, quaternion.y, quaternion.z, quaternion.w);
}
public static SaveData Deserialize(string data)
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: 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_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
string[] array = data.Split(new char[1] { '|' });
SaveData saveData = new SaveData
{
Location = ParseVector3(array[0]),
Rotation = ParseQuaternion(array[1]),
Stage = array[2],
Storage = ((array.Length > 3) ? ParseFloat(array[3]) : 0f),
Boost = ((array.Length > 4) ? ParseFloat(array[4]) : 0f)
};
if (array.Length > 5)
{
(saveData.EquippedMoveStyle, saveData.CurrentMoveStyle) = ParseMoveStyles(array[5]);
}
else
{
MoveStyle equippedMoveStyle = (MoveStyle)2;
saveData.CurrentMoveStyle = (MoveStyle)2;
saveData.EquippedMoveStyle = equippedMoveStyle;
}
return saveData;
}
}
private static string configFolderPath = Path.GetDirectoryName(((BaseUnityPlugin)GeoSaverPlugin.Instance).Config.ConfigFilePath);
private static string locationsFolderPath = Path.Combine(configFolderPath, "Locations");
public static void SaveLocation(string customFolderPath = null)
{
//IL_0013: 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_007c: 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_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: 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_0173: Unknown result type (might be due to invalid IL or missing references)
//IL_0181: Unknown result type (might be due to invalid IL or missing references)
//IL_018f: Unknown result type (might be due to invalid IL or missing references)
Player player = GeoSaverPlugin.player;
SaveData saveData = new SaveData
{
Location = player.tf.position,
Rotation = player.tf.rotation,
Stage = ((object)(Stage)(ref Core.instance.baseModule.stageManager.baseModule.currentStage)).ToString(),
Storage = player.wallrunAbility.lastSpeed,
Boost = player.boostCharge,
EquippedMoveStyle = player.moveStyleEquipped,
CurrentMoveStyle = player.moveStyle
};
string text = customFolderPath ?? locationsFolderPath;
if (!Directory.Exists(text))
{
Directory.CreateDirectory(text);
}
Vector3 val = default(Vector3);
((Vector3)(ref val))..ctor(Mathf.Round(saveData.Location.x), Mathf.Round(saveData.Location.y), Mathf.Round(saveData.Location.z));
string text2 = $"{saveData.Stage}_{val.x}_{val.y}_{val.z}.txt";
text2 = string.Join("_", text2.Split(Path.GetInvalidFileNameChars()));
string path = Path.Combine(text, text2);
int num = 1;
while (File.Exists(path))
{
path = Path.Combine(text, $"{saveData.Stage}_{val.x}_{val.y}_{val.z}_{num}.txt");
num++;
}
File.WriteAllText(path, saveData.Serialize());
}
public static bool LoadLocation(string name)
{
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: 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_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
string text = Path.Combine(locationsFolderPath, name + ".txt");
if (!File.Exists(text))
{
Debug.LogWarning((object)("Save file not found at " + text));
return false;
}
try
{
string data = File.ReadAllText(text);
SaveData saveData = SaveData.Deserialize(data);
Player player = GeoSaverPlugin.player;
if ((Object)(object)player == (Object)null)
{
Debug.LogError((object)"Player reference is null");
return false;
}
GeoSaverPlugin.desLoc = saveData.Location;
GeoSaverPlugin.desRot = saveData.Rotation;
GeoSaverPlugin.desStg = saveData.Stage.ToString();
GeoSaverPlugin.desStorage = saveData.Storage;
GeoSaverPlugin.desBoost = saveData.Boost;
GeoSaverPlugin.desEquippedMoveStyle = saveData.EquippedMoveStyle;
GeoSaverPlugin.desCurrentMoveStyle = saveData.CurrentMoveStyle;
if (saveData.Stage.ToString().StartsWith("mapstation/"))
{
HandleMapstationLoad(saveData);
}
else
{
HandleNormalLoad(saveData);
}
return true;
}
catch (Exception ex)
{
Debug.LogError((object)("Error loading location: " + ex.Message));
return false;
}
}
private static void HandleMapstationLoad(SaveData saveData)
{
//IL_00b1: 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_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
if (saveData.Stage.ToString() != ((object)(Stage)(ref Core.instance.baseModule.stageManager.baseModule.currentStage)).ToString())
{
GeoSaverPlugin.moveMe = true;
string text = saveData.Stage.ToString().Remove(0, "mapstation/".Length);
int stageID = APIManager.API.GetStageID(text);
if (APIManager.API.GetCustomStageByID(stageID) != null)
{
Stage val = (Stage)stageID;
Core.instance.baseModule.stageManager.ExitCurrentStage(val, (Stage)(-1));
}
else
{
Debug.LogError((object)("Stage not found: " + text));
}
}
else
{
GeoSaverPlugin.PlacePlayer(saveData.Location, saveData.Rotation, saveData.Storage, saveData.Boost, saveData.EquippedMoveStyle, saveData.CurrentMoveStyle, velSave: true);
}
}
private static void HandleNormalLoad(SaveData saveData)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: 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_0058: 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_0070: 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_0045: Unknown result type (might be due to invalid IL or missing references)
Stage val = ParseStage(saveData.Stage.ToString());
if (val != Core.instance.baseModule.stageManager.baseModule.currentStage)
{
Core.instance.baseModule.stageManager.ExitCurrentStage(val, (Stage)(-1));
GeoSaverPlugin.moveMe = true;
}
else
{
GeoSaverPlugin.PlacePlayer(saveData.Location, saveData.Rotation, saveData.Storage, saveData.Boost, saveData.EquippedMoveStyle, saveData.CurrentMoveStyle, velSave: true);
}
}
public static Stage ParseStage(string stageName)
{
//IL_0012: 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_001a: Unknown result type (might be due to invalid IL or missing references)
return (Stage)Enum.Parse(typeof(Stage), stageName, ignoreCase: true);
}
public static MoveStyle ParseMovestyle(string moveStyle)
{
//IL_0012: 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_001a: Unknown result type (might be due to invalid IL or missing references)
return (MoveStyle)Enum.Parse(typeof(MoveStyle), moveStyle, ignoreCase: true);
}
private static (MoveStyle Equipped, MoveStyle Current) ParseMoveStyles(string moveStylesString)
{
//IL_001d: 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)
string[] array = moveStylesString.Split(new char[1] { ',' });
int num = ((array.Length == 0) ? 2 : ((int)ParseMovestyle(array[0])));
num = ((array.Length > 1) ? ((int)ParseMovestyle(array[1])) : 0);
return ((MoveStyle)num, (MoveStyle)num);
}
private static Vector3 ParseVector3(string vectorString)
{
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
string[] array = vectorString.Split(new char[1] { ',' });
return new Vector3(float.Parse(array[0], CultureInfo.InvariantCulture), float.Parse(array[1], CultureInfo.InvariantCulture), float.Parse(array[2], CultureInfo.InvariantCulture));
}
private static Quaternion ParseQuaternion(string quaternionString)
{
//IL_0047: 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_004f: Unknown result type (might be due to invalid IL or missing references)
string[] array = quaternionString.Split(new char[1] { ',' });
return new Quaternion(float.Parse(array[0], CultureInfo.InvariantCulture), float.Parse(array[1], CultureInfo.InvariantCulture), float.Parse(array[2], CultureInfo.InvariantCulture), float.Parse(array[3], CultureInfo.InvariantCulture));
}
private static float ParseFloat(string floatString)
{
return float.Parse(floatString, CultureInfo.InvariantCulture);
}
}
[BepInPlugin("com.Yuri.GeoSaver", "GeoSaver", "1.1.1")]
public class GeoSaverPlugin : BaseUnityPlugin
{
public const string MyGUID = "com.Yuri.GeoSaver";
private const string PluginName = "GeoSaver";
private const string VersionString = "1.1.1";
private Harmony harmony;
public static Player player;
public static ConfigEntry<bool> EnableVelSave;
public static ConfigEntry<bool> EnableVelForward;
public static ConfigEntry<bool> EnableUnground;
public static ConfigEntry<bool> EnableBoostRefill;
public static ConfigEntry<bool> EnableBoostLoad;
public static ConfigEntry<bool> EnableMovestyleLoad;
public static ConfigEntry<bool> EnableStorageLoad;
public static ConfigEntry<KeyboardShortcut> LoadKey;
public static ConfigEntry<KeyboardShortcut> SaveKey;
public static ConfigEntry<string> MenuOrder;
public static bool moveMe;
public static Vector3 desLoc;
public static Quaternion desRot;
public static string desStg;
public static float desStorage;
public static float desBoost;
public static MoveStyle desEquippedMoveStyle;
public static MoveStyle desCurrentMoveStyle;
public static GeoSaverPlugin Instance { get; private set; }
public string Dir => Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
private void Awake()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
harmony = new Harmony("com.Yuri.GeoSaver");
harmony.PatchAll(typeof(PlayerPatch));
Instance = this;
InitConfig();
GeoSaverApp.Init();
LoadApp.Init();
SaveApp.Init();
}
private void InitConfig()
{
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
EnableVelSave = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable Velocity Retention", false, "Retains current velocity when loading a state in the same stage.");
EnableVelForward = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable Forward Velocity Correction", true, "When velocity is retained adjust the returned velocity to the players new forward direction.");
EnableUnground = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable Force Unground", false, "Will force the player to be airborne for a moment when loading a position, this will often make storage goons trigger automatically.");
EnableBoostRefill = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable Boost Refill", true, "Refills the boost meter when loading.");
EnableBoostLoad = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable Boost Loading", false, "Loads the saved boost you had when making the save.");
EnableStorageLoad = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable Storage Loading", true, "Loads saved goon storage you had when making the save.");
EnableMovestyleLoad = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable Movestyle Loading", false, "Loads the movestyle you had when making the save.");
LoadKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Controls", "Load last Location Key", new KeyboardShortcut((KeyCode)120, Array.Empty<KeyCode>()), "Hotkey to load the last loaded location, this only applies if the location is in the current stage.");
SaveKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Controls", "Temp Save Location Key", new KeyboardShortcut((KeyCode)122, Array.Empty<KeyCode>()), "Hotkey to make a temporary save, this does not make a file but can be loaded with the load last location button.");
MenuOrder = ((BaseUnityPlugin)this).Config.Bind<string>("General", "Menu Order", "Load, Save, TempLoad, TempSave", "Order of the main app menu. List the name seperated by a comma, options can be left out if you don't need them. Valid options are: Load, Save, TempLoad, TempSave");
}
private void Update()
{
//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_004c: 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_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)player != (Object)null))
{
return;
}
KeyboardShortcut value;
if (desStg == ((object)(Stage)(ref Core.instance.baseModule.stageManager.baseModule.currentStage)).ToString())
{
value = LoadKey.Value;
if (((KeyboardShortcut)(ref value)).IsDown())
{
TempLoadButton();
}
if (moveMe)
{
PlacePlayer(desLoc, desRot, desStorage, desBoost, desEquippedMoveStyle, desCurrentMoveStyle, velSave: false);
moveMe = false;
}
}
value = SaveKey.Value;
if (((KeyboardShortcut)(ref value)).IsDown())
{
TempSaveButton();
}
}
public static void TempSaveButton()
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: 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_0024: 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_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_008e: Unknown result type (might be due to invalid IL or missing references)
desLoc = player.tf.position;
desRot = player.tf.rotation;
desStg = ((object)(Stage)(ref Core.instance.baseModule.stageManager.baseModule.currentStage)).ToString();
desStorage = player.wallrunAbility.lastSpeed;
desBoost = player.boostCharge;
desEquippedMoveStyle = player.moveStyleEquipped;
desCurrentMoveStyle = player.moveStyle;
}
public static void TempLoadButton()
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: 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)
PlacePlayer(desLoc, desRot, desStorage, desBoost, desEquippedMoveStyle, desCurrentMoveStyle, velSave: true);
}
public static void PlacePlayer(Vector3 loc, Quaternion rot, float storage, float boost, MoveStyle EquippedMoveStyle, MoveStyle CurrentMoveStyle, bool velSave)
{
//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_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_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: 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_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: 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_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Invalid comparison between Unknown and I4
//IL_0156: 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_0153: 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_016d: Unknown result type (might be due to invalid IL or missing references)
//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
Vector3 velocity = player.GetVelocity();
WorldHandler.instance.PlacePlayerAt(player, loc, rot, true);
if (EnableStorageLoad.Value)
{
player.wallrunAbility.lastSpeed = storage;
((Ability)player.wallrunAbility).customVelocity = storage * ((Vector3)(ref ((Ability)player.wallrunAbility).customVelocity)).normalized;
}
if (EnableBoostLoad.Value)
{
player.boostCharge = boost;
}
else if (EnableBoostRefill.Value)
{
player.boostCharge = 100f;
}
if (EnableMovestyleLoad.Value)
{
try
{
player.moveStyleEquipped = EquippedMoveStyle;
player.InitMovement(EquippedMoveStyle);
bool flag = (int)CurrentMoveStyle > 0;
player.SwitchToEquippedMovestyle(flag, false, true, false);
}
catch
{
player.moveStyleEquipped = (MoveStyle)0;
player.InitMovement((MoveStyle)0);
player.SwitchToEquippedMovestyle(false, false, true, false);
}
}
if (EnableUnground.Value)
{
player.ForceUnground(true);
}
if (EnableVelSave.Value && velSave)
{
Vector3 val = (EnableVelForward.Value ? AlignVelocityWithForward(velocity, ((Component)player).transform.forward) : velocity);
if (val.y > 0f || EnableUnground.Value)
{
player.ForceUnground(true);
}
player.SetVelocity(val);
}
}
private static Vector3 AlignVelocityWithForward(Vector3 velocity, Vector3 forward)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: 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_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
Vector3 val = Vector3.up * velocity.y;
Vector3 val2 = Vector3.ProjectOnPlane(velocity, Vector3.up);
float magnitude = ((Vector3)(ref val2)).magnitude;
return forward * magnitude + val;
}
}
}
namespace GeoSaver.Patches
{
internal static class PlayerPatch
{
[HarmonyPatch(typeof(Player), "Init")]
[HarmonyPostfix]
private static void Player_Init_Postfix(Player __instance)
{
if (!__instance.isAI)
{
GeoSaverPlugin.player = __instance;
}
}
}
}
namespace GeoSaver.Apps
{
public class SaveApp : CustomApp
{
public static List<string> currentPath = new List<string>();
public override bool Available => false;
public static void Init()
{
PhoneAPI.RegisterApp<SaveApp>("Save Location", (Sprite)null);
}
public override void OnAppInit()
{
((CustomApp)this).OnAppInit();
((CustomApp)this).CreateIconlessTitleBar("Save Location", 80f);
}
public override void OnAppEnable()
{
((App)this).OnAppEnable();
if ((Object)(object)base.ScrollView == (Object)null)
{
base.ScrollView = PhoneScrollView.Create((CustomApp)(object)this, 275f, 1600f);
}
else
{
base.ScrollView.RemoveAllButtons();
}
PopulateList();
}
public override void OnAppDisable()
{
((App)this).OnAppDisable();
currentPath.Clear();
}
private void PopulateList()
{
var (list, list2) = GetAvailableLocations(currentPath);
if (currentPath.Count > 0)
{
SimplePhoneButton val = PhoneUIUtility.CreateSimpleButton("..");
((PhoneButton)val).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val).OnConfirm, (Action)delegate
{
currentPath.RemoveAt(currentPath.Count - 1);
((App)this).OnAppEnable();
});
base.ScrollView.AddButton((PhoneButton)(object)val);
}
SimplePhoneButton val2 = PhoneUIUtility.CreateSimpleButton("Save Here");
((PhoneButton)val2).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val2).OnConfirm, (Action)delegate
{
SaveLocation();
});
base.ScrollView.AddButton((PhoneButton)(object)val2);
foreach (string item in list)
{
SimplePhoneButton val3 = CreateFolderButton(item);
base.ScrollView.AddButton((PhoneButton)(object)val3);
}
}
public static (List<string> folders, List<string> files) GetAvailableLocations(List<string> path)
{
GeoSaverPlugin instance = GeoSaverPlugin.Instance;
string path2 = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)instance).Config.ConfigFilePath), "Locations");
path2 = Path.Combine(path2, Path.Combine(path.ToArray()));
List<string> list = new List<string>();
List<string> list2 = new List<string>();
if (Directory.Exists(path2))
{
string[] directories = Directory.GetDirectories(path2);
string[] array = directories;
foreach (string path3 in array)
{
list.Add(Path.GetFileName(path3));
}
string[] files = Directory.GetFiles(path2, "*.txt");
string[] array2 = files;
foreach (string path4 in array2)
{
list2.Add(Path.GetFileNameWithoutExtension(path4));
}
}
else
{
Directory.CreateDirectory(path2);
}
return (list, list2);
}
private SimplePhoneButton CreateFolderButton(string folderName)
{
SimplePhoneButton val = PhoneUIUtility.CreateSimpleButton(folderName + "/");
((PhoneButton)val).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val).OnConfirm, (Action)delegate
{
currentPath.Add(folderName);
((App)this).OnAppEnable();
});
return val;
}
private void SaveLocation()
{
GeoSaverPlugin instance = GeoSaverPlugin.Instance;
string path = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)instance).Config.ConfigFilePath), "Locations");
string customFolderPath = Path.Combine(path, Path.Combine(currentPath.ToArray()));
LocationFileManager.SaveLocation(customFolderPath);
((App)this).MyPhone.CloseCurrentApp();
}
}
public class LoadApp : CustomApp
{
private static List<string> currentPath = new List<string>();
private static string stage;
public override bool Available => false;
public static void Init()
{
PhoneAPI.RegisterApp<LoadApp>("Load Location", (Sprite)null);
}
public override void OnAppInit()
{
((CustomApp)this).OnAppInit();
((CustomApp)this).CreateIconlessTitleBar("Load Location", 80f);
}
public override void OnAppEnable()
{
((App)this).OnAppEnable();
if ((Object)(object)base.ScrollView == (Object)null)
{
base.ScrollView = PhoneScrollView.Create((CustomApp)(object)this, 275f, 1600f);
}
else
{
base.ScrollView.RemoveAllButtons();
}
if (stage != ((object)(Stage)(ref Core.instance.baseModule.stageManager.baseModule.currentStage)).ToString() && stage != null)
{
currentPath.Clear();
}
stage = ((object)(Stage)(ref Core.instance.baseModule.stageManager.baseModule.currentStage)).ToString();
PopulateList();
}
private void PopulateList()
{
var (list, list2) = GetAvailableLocations(currentPath);
if (currentPath.Count > 0)
{
SimplePhoneButton val = PhoneUIUtility.CreateSimpleButton("..");
((PhoneButton)val).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val).OnConfirm, (Action)delegate
{
currentPath.RemoveAt(currentPath.Count - 1);
((App)this).OnAppEnable();
});
base.ScrollView.AddButton((PhoneButton)(object)val);
}
foreach (string item in list)
{
SimplePhoneButton val2 = CreateFolderButton(item);
base.ScrollView.AddButton((PhoneButton)(object)val2);
}
foreach (string item2 in list2)
{
SimplePhoneButton val3 = CreateLocationButton(item2);
base.ScrollView.AddButton((PhoneButton)(object)val3);
}
}
public static (List<string> folders, List<string> files) GetAvailableLocations(List<string> path)
{
GeoSaverPlugin instance = GeoSaverPlugin.Instance;
string path2 = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)instance).Config.ConfigFilePath), "Locations");
path2 = Path.Combine(path2, Path.Combine(path.ToArray()));
List<string> list = new List<string>();
List<string> list2 = new List<string>();
if (Directory.Exists(path2))
{
string[] directories = Directory.GetDirectories(path2);
string[] array = directories;
foreach (string path3 in array)
{
list.Add(Path.GetFileName(path3));
}
string[] files = Directory.GetFiles(path2, "*.txt");
string[] array2 = files;
foreach (string path4 in array2)
{
list2.Add(Path.GetFileNameWithoutExtension(path4));
}
}
return (list, list2);
}
private SimplePhoneButton CreateFolderButton(string folderName)
{
SimplePhoneButton val = PhoneUIUtility.CreateSimpleButton(folderName + "/");
((PhoneButton)val).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val).OnConfirm, (Action)delegate
{
currentPath.Add(folderName);
((App)this).OnAppEnable();
});
return val;
}
private static SimplePhoneButton CreateLocationButton(string preset)
{
SimplePhoneButton val = PhoneUIUtility.CreateSimpleButton(preset);
((PhoneButton)val).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val).OnConfirm, (Action)delegate
{
LocationFileManager.LoadLocation(Path.Combine(Path.Combine(currentPath.ToArray()), preset));
});
return val;
}
}
}