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 MioGame; using MioModLoader; using MioModdingApi; using On.MioGame; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETCoreApp,Version=v8.0", FrameworkDisplayName = ".NET 8.0")] [assembly: AssemblyCompany("GateWarp")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+2c8f5c4469371103a1e849c53f0ee865460ea0c4")] [assembly: AssemblyProduct("GateWarp")] [assembly: AssemblyTitle("GateWarp")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace GateWarp; public class GateWarp : Mod { private static Dictionary gateNames = new Dictionary(); private static Dictionary gatePositions = new Dictionary(); private static ModMenuPage? modPage; private static ChoiceOption? warpLocation; private static ToggleOption? unlockNecessity; private static ToggleOption? overseerNecessity; private static ChoiceOption? wheelBehavior; private bool queuedWarp; public override void Initialize() { Hooks(); ReloadData(); ConnectMenus(); } public static void ReloadData() { //IL_0053: 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_0061: Unknown result type (might be due to invalid IL or missing references) using StreamReader streamReader = File.OpenText(".\\mods\\GateWarp\\warps.dat"); string[] array = streamReader.ReadToEnd().Split("\n"); foreach (string text in array) { if (!string.IsNullOrEmpty(text)) { string[] array2 = text.Split(":"); string key = array2[0]; string value = array2[1]; gateNames[key] = value; Vec_float_2 value2 = VectFromString(array2[2]); gatePositions[key] = value2; } } } public void ConnectMenus() { modPage = ModMenu.RegisterMod((Mod)(object)this, "GateWarp", ""); modPage.RegisterButton("warp", "Warp", (Action)Warp, (string)null); IReadOnlyList readOnlyList = gateNames.Values.ToList(); warpLocation = modPage.RegisterChoice("warp_loc", "Warp Location", readOnlyList, 0, "The location to warp to"); unlockNecessity = modPage.RegisterToggle("need_unlock", "Visit Necessity", false, "Wether you need to have visited the checkpoint in order to warp."); overseerNecessity = modPage.RegisterToggle("need_overseer", "Overseer Necessity", false, "Wether you need the overseer for the checkpoint in order to warp."); wheelBehavior = modPage.RegisterChoice("wheel_behavior", "Wheel Behavior", (IReadOnlyList)new <>z__ReadOnlyArray(new string[3] { "Disallow", "Reset", "Allow" }), 1, "How teleporting between the halves of the vessel is handled; Reset resets the wheel on teleport."); } private void Hooks() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown fixed_update.Prefix += new orig_fixed_update(Fixed_update_Prefix); } private unsafe void Fixed_update_Prefix(Game* __this) { //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) if (!queuedWarp) { return; } try { ref Mio reference = ref ((Game)__this).mio; ref Save reference2 = ref ((Game)__this).save; if ((unlockNecessity.Value && !HasSaveEntry("CHECKPOINT:" + GetSelected(), ref reference2)) || (overseerNecessity.Value && !HasSaveEntry("OVERSEER:" + GetSelected(), ref reference2))) { queuedWarp = false; } else { if (reference.cutscene.active || (int)reference.checkpoint.state._value != 0) { return; } ref Game_cam reference3 = ref ((Game)__this).game_cam; Vec_float_3 warpPosition = GetWarpPosition(); if (DifferentHalves(reference3.position, warpPosition)) { switch (wheelBehavior.SelectedIndex) { case 0: queuedWarp = false; return; case 1: reference2.halyn_align.configuration_discrete = 2; break; } } ((Mio)(ref reference)).move_to(warpPosition); reference3.position = warpPosition; reference3.position.z = 35f; queuedWarp = false; } } catch (Exception ex) { ((Mod)this).LogMessage("Could not warp: " + ex); } } public void Warp() { queuedWarp = true; } private static string GetSelected() { if (warpLocation == null) { return ""; } return gateNames.FirstOrDefault>((KeyValuePair x) => x.Value == warpLocation.Value).Key; } private static Vec_float_3 GetWarpPosition() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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) if (warpLocation == null) { return default(Vec_float_3); } return GetWorldPos(gatePositions[GetSelected()]); } private unsafe bool HasSaveEntry(string entry, ref Save save) { //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) String val = Util.StringToMioString(entry); return Unsafe.AsRef((void*)((Hashmap_String_Save_entry)(ref save.entries)).lookup(&val, false)).value.count > 0; } private static Vec_float_2 VectFromString(string str) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) str = str.Substring(1, str.Length - 2); string[] array = str.Split(", "); return new Vec_float_2 { x = float.Parse(array[0]), y = float.Parse(array[1]) }; } private static Vec_float_3 GetWorldPos(Vec_float_2 coords) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) return new Vec_float_3 { x = coords.x, y = coords.y }; } private static bool IsLowerHalf(Vec_float_3 pos) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return IsLowerHalf(pos.y); } private static bool IsLowerHalf(float y) { return y < 1087f; } private static bool DifferentHalves(Vec_float_3 pos1, Vec_float_3 pos2) { //IL_0000: 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) return DifferentHalves(pos1.y, pos2.y); } private static bool DifferentHalves(float y1, float y2) { return IsLowerHalf(y1) == IsLowerHalf(y2); } } [CompilerGenerated] internal sealed class <>z__ReadOnlyArray : IEnumerable, ICollection, IList, IEnumerable, IReadOnlyCollection, IReadOnlyList, ICollection, IList { int ICollection.Count => _items.Length; bool ICollection.IsSynchronized => false; object ICollection.SyncRoot => this; object? IList.this[int index] { get { return _items[index]; } set { throw new NotSupportedException(); } } bool IList.IsFixedSize => true; bool IList.IsReadOnly => true; int IReadOnlyCollection.Count => _items.Length; T IReadOnlyList.this[int index] => _items[index]; int ICollection.Count => _items.Length; bool ICollection.IsReadOnly => true; T IList.this[int index] { get { return _items[index]; } set { throw new NotSupportedException(); } } public <>z__ReadOnlyArray(T[] items) { _items = items; } IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)_items).GetEnumerator(); } void ICollection.CopyTo(Array array, int index) { ((ICollection)_items).CopyTo(array, index); } int IList.Add(object? value) { throw new NotSupportedException(); } void IList.Clear() { throw new NotSupportedException(); } bool IList.Contains(object? value) { return ((IList)_items).Contains(value); } int IList.IndexOf(object? value) { return ((IList)_items).IndexOf(value); } void IList.Insert(int index, object? value) { throw new NotSupportedException(); } void IList.Remove(object? value) { throw new NotSupportedException(); } void IList.RemoveAt(int index) { throw new NotSupportedException(); } IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)_items).GetEnumerator(); } void ICollection.Add(T item) { throw new NotSupportedException(); } void ICollection.Clear() { throw new NotSupportedException(); } bool ICollection.Contains(T item) { return ((ICollection)_items).Contains(item); } void ICollection.CopyTo(T[] array, int arrayIndex) { ((ICollection)_items).CopyTo(array, arrayIndex); } bool ICollection.Remove(T item) { throw new NotSupportedException(); } int IList.IndexOf(T item) { return ((IList)_items).IndexOf(item); } void IList.Insert(int index, T item) { throw new NotSupportedException(); } void IList.RemoveAt(int index) { throw new NotSupportedException(); } }