Decompiled source of Magrider v1.0.14
plugins/Magrider.dll
Decompiled 4 days 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.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Threading.Tasks; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using Dolso; using Dolso.RoO; using EntityStates; using EntityStates.Bandit2.Weapon; using EntityStates.Headstompers; using EntityStates.VagrantNovaItem; using HG.BlendableTypes; using HG.Reflection; using Magrider.Components; using Mono.Cecil; using Mono.Cecil.Cil; using MonoMod.Cil; using MonoMod.RuntimeDetour; using Rewired; using RiskOfOptions; using RiskOfOptions.Components.Options; using RiskOfOptions.OptionConfigs; using RiskOfOptions.Options; using RoR2; using RoR2.CameraModes; using RoR2.ContentManagement; using RoR2.HudOverlay; using RoR2.Networking; using RoR2.Projectile; using RoR2.Skills; using RoR2.UI; using TMPro; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.Events; using UnityEngine.Networking; using UnityEngine.ResourceManagement.AsyncOperations; using UnityEngine.UI; [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: CompilationRelaxations(8)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: OptIn] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] namespace Dolso { internal static class log { private static ManualLogSource logger; internal static void start(ManualLogSource logSource) { logger = logSource; } internal static void start(string name) { logger = Logger.CreateLogSource(name); } internal static void info(object data) { logger.LogInfo(data); } internal static void message(object data) { logger.LogMessage(data); } internal static void warning(object data) { logger.LogWarning(data); } internal static void error(object data) { logger.LogError(data); } internal static void fatal(object data) { logger.LogFatal(data); } internal static void LogError(this ILCursor c, object data) { logger.LogError((object)string.Format($"ILCursor failure, skipping: {data}\n{c}")); } internal static void LogErrorCaller(this ILCursor c, object data) { logger.LogError((object)string.Format($"ILCursor failed in {new StackFrame(1).GetMethod().Name}, skipping: {data}\n{c}")); } } internal static class HookManager { internal delegate bool ConfigEnabled<T>(T configValue); internal const BindingFlags allFlags = BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; private static readonly ConfigEnabled<bool> boolConfigEnabled = (bool configValue) => configValue; private static ILHookConfig ilHookConfig = new ILHookConfig { ManualApply = true }; private static HookConfig onHookConfig = new HookConfig { ManualApply = true }; internal static void Hook(Type typeFrom, string methodFrom, Manipulator ilHook) { HookInternal(GetMethod(typeFrom, methodFrom), ilHook); } internal static void Hook(MethodBase methodFrom, Manipulator ilHook) { HookInternal(methodFrom, ilHook); } internal static void Hook(Delegate from, Manipulator ilHook) { HookInternal(from.Method, ilHook); } internal static void Hook(Type typeFrom, string methodFrom, Delegate onHook) { HookInternal(GetMethod(typeFrom, methodFrom), onHook.Method, onHook.Target); } internal static void Hook(MethodBase methodFrom, MethodInfo onHook) { HookInternal(methodFrom, onHook, null); } internal static void Hook(MethodBase methodFrom, Delegate onHook) { HookInternal(methodFrom, onHook.Method, onHook.Target); } internal static void Hook(Delegate from, Delegate onHook) { HookInternal(from.Method, onHook.Method, onHook.Target); } internal static void Hook(Type typeFrom, string methodFrom, Delegate onHook, object instance) { HookInternal(GetMethod(typeFrom, methodFrom), onHook.Method, instance); } internal static void Hook(MethodBase methodFrom, MethodInfo onHook, object target) { HookInternal(methodFrom, onHook, target); } private static void HookInternal(MethodBase methodFrom, Manipulator ilHook) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) if (methodFrom == null) { log.error("null methodFrom for hook: " + ((Delegate)(object)ilHook).Method.Name); return; } try { new ILHook(methodFrom, ilHook, ref ilHookConfig).Apply(); } catch (Exception ex) { log.error($"Failed to apply ILHook: {methodFrom.DeclaringType}::{methodFrom.Name} - {((Delegate)(object)ilHook).Method.Name}\n{ex}"); } } private static void HookInternal(MethodBase methodFrom, MethodInfo onHook, object target) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) if (methodFrom == null) { log.error("null methodFrom for hook: " + onHook.Name); return; } try { new Hook(methodFrom, onHook, target, ref onHookConfig).Apply(); } catch (Exception ex) { log.error($"Failed to apply Hook: {methodFrom.DeclaringType}::{methodFrom.Name} - {onHook.Name}\n{ex}"); } } internal static void HookConfig(this ConfigEntry<bool> configEntry, Type typeFrom, string methodFrom, Manipulator ilHook) { configEntry.HookConfigInternal(boolConfigEnabled, GetMethod(typeFrom, methodFrom), (Delegate)(object)ilHook); } internal static void HookConfig(this ConfigEntry<bool> configEntry, MethodBase methodFrom, Manipulator ilHook) { configEntry.HookConfigInternal(boolConfigEnabled, methodFrom, (Delegate)(object)ilHook); } internal static void HookConfig(this ConfigEntry<bool> configEntry, Type typeFrom, string methodFrom, Delegate onHook) { configEntry.HookConfigInternal(boolConfigEnabled, GetMethod(typeFrom, methodFrom), onHook); } internal static void HookConfig(this ConfigEntry<bool> configEntry, MethodBase methodFrom, Delegate onHook) { configEntry.HookConfigInternal(boolConfigEnabled, methodFrom, onHook); } internal static void HookConfig<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, Type typeFrom, string methodFrom, Manipulator ilHook) { configEntry.HookConfigInternal(enabled, GetMethod(typeFrom, methodFrom), (Delegate)(object)ilHook); } internal static void HookConfig<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, MethodBase methodFrom, Manipulator ilHook) { configEntry.HookConfigInternal(enabled, methodFrom, (Delegate)(object)ilHook); } internal static void HookConfig<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, Type typeFrom, string methodFrom, Delegate onHook) { configEntry.HookConfigInternal(enabled, GetMethod(typeFrom, methodFrom), onHook); } internal static void HookConfig<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, MethodBase methodFrom, Delegate onHook) { configEntry.HookConfigInternal(enabled, methodFrom, onHook); } private static void HookConfigInternal<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, MethodBase methodFrom, Delegate hook) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown try { IDetour detour = ManualDetour(methodFrom, hook); EventHandler eventHandler = delegate(object sender, EventArgs _) { UpdateHook(detour, enabled((sender as ConfigEntry<T>).Value)); }; configEntry.SettingChanged += eventHandler; eventHandler(configEntry, (EventArgs)new SettingChangedEventArgs((ConfigEntryBase)(object)configEntry)); } catch (Exception ex) { log.error($"Failed to do config hook {methodFrom.DeclaringType}::{methodFrom.Name} - {hook.Method.Name}\n{ex}"); } } private static void UpdateHook(IDetour hook, bool enabled) { if (enabled) { if (!hook.IsApplied) { hook.Apply(); } } else if (hook.IsApplied) { hook.Undo(); } } internal static IDetour ManualDetour(Type typeFrom, string methodFrom, Delegate hook) { return ManualDetour(GetMethod(typeFrom, methodFrom), hook); } internal static IDetour ManualDetour(MethodBase methodFrom, Delegate hook) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown if (methodFrom == null) { log.error("null methodFrom for detour: " + hook.Method.Name); } else { try { Manipulator val = (Manipulator)(object)((hook is Manipulator) ? hook : null); if (val != null) { return (IDetour)new ILHook(methodFrom, val, ref ilHookConfig); } return (IDetour)new Hook(methodFrom, hook, ref onHookConfig); } catch (Exception ex) { log.error($"Failed to create detour {methodFrom.DeclaringType}::{methodFrom} - {hook.Method.Name}\n{ex}"); } } return null; } internal static MethodInfo GetMethod(Type typeFrom, string methodName) { if (typeFrom == null || methodName == null) { log.error($"Null argument in GetMethod: type={typeFrom}, name={methodName}"); return null; } MethodInfo[] array = (from predicate in typeFrom.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic) where predicate.Name == methodName select predicate).ToArray(); switch (array.Length) { case 1: return array[0]; case 0: log.error($"Failed to find method: {typeFrom}::{methodName}"); return null; default: { log.error($"{array.Length} ambiguous matches found for: {typeFrom}::{methodName}"); MethodInfo[] array2 = array; for (int i = 0; i < array2.Length; i++) { log.error(array2[i]); } return null; } } } internal static MethodInfo GetMethod(Type typeFrom, string methodName, params Type[] parameters) { if (typeFrom == null || methodName == null) { log.error($"Null argument in GetMethod: type={typeFrom}, name={methodName}"); return null; } MethodInfo? method = typeFrom.GetMethod(methodName, BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, parameters, null); if (method == null) { log.error($"Failed to find method: {typeFrom}::{methodName}_{parameters.Length}"); } return method; } internal static void SetPriority(string[] before = null, string[] after = null) { ilHookConfig.Before = before; onHookConfig.Before = before; ilHookConfig.After = after; onHookConfig.After = after; } } internal static class Utilities { private static GameObject _prefabParent; internal static GameObject CreatePrefab(GameObject gameObject, string name = null) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown if (!Object.op_Implicit((Object)(object)_prefabParent)) { _prefabParent = new GameObject("DolsoPrefabs"); Object.DontDestroyOnLoad((Object)(object)_prefabParent); ((Object)_prefabParent).hideFlags = (HideFlags)61; _prefabParent.SetActive(false); } GameObject val = Object.Instantiate<GameObject>(gameObject, _prefabParent.transform); if (name != null) { ((Object)val).name = name; } return val; } internal static Task<Obj> GetAddressableAsync<Obj>(string addressable) where Obj : Object { //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) return Addressables.LoadAssetAsync<Obj>((object)addressable).Task; } internal static Task<GameObject> GetAddressableAsync(string addressable) { //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) return Addressables.LoadAssetAsync<GameObject>((object)addressable).Task; } internal static void DoAddressable<Obj>(string addressable, Action<Obj> callback) where Obj : Object { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) AsyncOperationHandle<Obj> val = Addressables.LoadAssetAsync<Obj>((object)addressable); val.Completed += delegate(AsyncOperationHandle<Obj> a) { callback(a.Result); }; } internal static void DoAddressable(string addressable, Action<GameObject> callback) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) AsyncOperationHandle<GameObject> val = Addressables.LoadAssetAsync<GameObject>((object)addressable); val.Completed += delegate(AsyncOperationHandle<GameObject> a) { callback(a.Result); }; } internal static void AddressableAddComp<Comp>(string addressable) where Comp : Component { //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) AsyncOperationHandle<GameObject> val = Addressables.LoadAssetAsync<GameObject>((object)addressable); val.Completed += delegate(AsyncOperationHandle<GameObject> a) { a.Result.AddComponent<Comp>(); }; } internal static void AddressableAddComp<Comp>(string addressable, Action<Comp> callback) where Comp : Component { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) AsyncOperationHandle<GameObject> val = Addressables.LoadAssetAsync<GameObject>((object)addressable); val.Completed += delegate(AsyncOperationHandle<GameObject> a) { callback(a.Result.AddComponent<Comp>()); }; } internal static void AddressableAddCompSingle<Comp>(string addressable) where Comp : Component { //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) AsyncOperationHandle<GameObject> val = Addressables.LoadAssetAsync<GameObject>((object)addressable); val.Completed += delegate(AsyncOperationHandle<GameObject> a) { if (!Object.op_Implicit((Object)(object)a.Result.GetComponent<Comp>())) { a.Result.AddComponent<Comp>(); } }; } } internal static class RiskofOptions { internal const string rooGuid = "com.rune580.riskofoptions"; internal static bool enabled => Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions"); internal static void SetSprite(Sprite sprite) { ModSettingsManager.SetModIcon(sprite); } internal static void SetSpriteDefaultIcon() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) try { string fullName = new DirectoryInfo(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)).FullName; Texture2D val = new Texture2D(256, 256); if (ImageConversion.LoadImage(val, File.ReadAllBytes(Path.Combine(fullName, "icon.png")))) { ModSettingsManager.SetModIcon(Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f))); } else { log.error("Failed to load icon.png"); } } catch (Exception ex) { log.error("Failed to load icon.png\n" + ex); } } internal static void AddOption<T>(ConfigEntry<T> entry) { AddOption<T>(entry, "", "", restartRequired: false); } internal static void AddOption<T>(ConfigEntry<T> entry, string categoryName = "", string name = "", bool restartRequired = false) { //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Expected O, but got Unknown //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Expected O, but got Unknown //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Expected O, but got Unknown //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Expected O, but got Unknown //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Expected O, but got Unknown //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Expected O, but got Unknown //IL_0107: 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_00fa: Expected O, but got Unknown //IL_00f5: 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_00e5: Expected O, but got Unknown //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Expected O, but got Unknown //IL_00cb: Unknown result type (might be due to invalid IL or missing references) object obj; if (!(typeof(T) == typeof(float))) { obj = ((!(typeof(T) == typeof(string))) ? ((!(typeof(T) == typeof(bool))) ? ((!(typeof(T) == typeof(int))) ? ((!(typeof(T) == typeof(Color))) ? ((!(typeof(T) == typeof(KeyboardShortcut))) ? ((object)((!typeof(T).IsEnum) ? ((ChoiceOption)null) : new ChoiceOption((ConfigEntryBase)(object)entry, new ChoiceConfig()))) : ((object)new KeyBindOption(entry as ConfigEntry<KeyboardShortcut>, new KeyBindConfig()))) : ((object)new ColorOption(entry as ConfigEntry<Color>, new ColorOptionConfig()))) : ((object)new IntFieldOption(entry as ConfigEntry<int>, new IntFieldConfig()))) : ((object)new CheckBoxOption(entry as ConfigEntry<bool>, new CheckBoxConfig()))) : ((object)new StringInputFieldOption(entry as ConfigEntry<string>, new InputFieldConfig { submitOn = (SubmitEnum)6, lineType = (LineType)0 }))); } else { ConfigEntry<float> obj2 = entry as ConfigEntry<float>; FloatFieldConfig val = new FloatFieldConfig(); ((NumericFieldConfig<float>)val).FormatString = "{0:f2}"; ((BaseOptionConfig)val).description = ((ConfigEntryBase)(object)entry).DescWithDefault("{0:f2}"); obj = (object)new FloatFieldOption(obj2, val); } BaseOption val2 = (BaseOption)obj; if (val2 != null) { BaseOptionConfig config = val2.GetConfig(); config.category = categoryName; config.name = name; config.restartRequired = restartRequired; if (config.description == "") { config.description = ((ConfigEntryBase)(object)entry).DescWithDefault(); } ModSettingsManager.AddOption(val2); } } internal static void AddOption(ConfigEntry<float> entry, float min, float max, string format = "{0:f2}") { AddFloatSlider(entry, min, max, format); } internal static void AddFloatSlider(ConfigEntry<float> entry, float min, float max, string format = "{0:f2}", string categoryName = "") { //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_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown ModSettingsManager.AddOption((BaseOption)new SliderOption(entry, new SliderConfig { min = min, max = max, FormatString = format, category = categoryName, description = ((ConfigEntryBase)(object)entry).DescWithDefault(format) })); } internal static void AddIntSlider(ConfigEntry<int> entry, int min, int max, string categoryName = "") { //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_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown ModSettingsManager.AddOption((BaseOption)new IntSliderOption(entry, new IntSliderConfig { min = min, max = max, category = categoryName, description = ((ConfigEntryBase)(object)entry).DescWithDefault() })); } private static string DescWithDefault(this ConfigEntryBase entry) { return $"{entry.Description.Description}\n[Default: {entry.DefaultValue}]"; } private static string DescWithDefault(this ConfigEntryBase entry, string format) { return string.Format("{1}\n[Default: " + format + "]", entry.DefaultValue, entry.Description.Description); } } internal class TextHud { private static readonly Queue<TextHud> hudsToUpdate; private GameObject objhud; private HGTextMeshProUGUI textMesh; private readonly string hudName; private string textToUpdate; internal bool resetOnTargetChanged = true; internal TextAlignmentOptions alignment = (TextAlignmentOptions)257; internal readonly ConfigEntry<bool> toggleEntry; private readonly ConfigEntry<int> fontsizeEntry; private readonly ConfigEntry<Vector2> positionEntry; internal static HUD hud { get { if (HUD.instancesList.Count <= 0) { return null; } return HUD.instancesList[0]; } } internal bool enabled { get { if (toggleEntry == null) { return true; } return toggleEntry.Value; } } internal int fontSize { get { if (fontsizeEntry == null) { return -1; } return fontsizeEntry.Value; } } internal Vector2 position { get { //IL_001e: 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) if (positionEntry == null) { return new Vector2(1776.5f, 173f); } return positionEntry.Value; } } static TextHud() { hudsToUpdate = new Queue<TextHud>(); RoR2Application.onLateUpdate += LateUpdate; } private TextHud(string name, ConfigFile configFile, Vector2? defaultPosition, bool? defaultToggle, int? defaultFontSize) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) hudName = name; if (defaultPosition.HasValue) { positionEntry = configFile.Bind<Vector2>(name, "Position", defaultPosition.Value, "Position of " + name + ", starting from bottom left corner"); } if (defaultToggle.HasValue) { toggleEntry = configFile.Bind<bool>(name, "Toggle", defaultToggle.Value, "Toggles " + name); } if (defaultFontSize.HasValue) { fontsizeEntry = configFile.Bind<int>(name, "Font size", defaultFontSize.Value, "Font size of " + name); } DoHooks(configFile); } internal TextHud(ConfigFile configFile, string name) : this(name, configFile, null, null, null) { } internal TextHud(ConfigFile configFile, string name, Vector2 defaultPosition) : this(name, configFile, defaultPosition, null, null) { }//IL_0003: Unknown result type (might be due to invalid IL or missing references) internal TextHud(ConfigFile configFile, string name, Vector2 defaultPosition, bool defaultToggle) : this(name, configFile, defaultPosition, defaultToggle, null) { }//IL_0003: Unknown result type (might be due to invalid IL or missing references) internal TextHud(ConfigFile configFile, string name, Vector2 defaultPosition, int defaultFontSize) : this(name, configFile, defaultPosition, null, defaultFontSize) { }//IL_0003: Unknown result type (might be due to invalid IL or missing references) internal TextHud(ConfigFile configFile, string name, Vector2 defaultPosition, bool defaultToggle, int defaultFontSize) : this(name, configFile, defaultPosition, defaultToggle, defaultFontSize) { }//IL_0003: Unknown result type (might be due to invalid IL or missing references) internal void UpdateText(string text) { if (!hudsToUpdate.Contains(this)) { hudsToUpdate.Enqueue(this); } textToUpdate = text; } internal void ClearText() { if (Object.op_Implicit((Object)(object)objhud) && !string.IsNullOrEmpty(((TMP_Text)textMesh).text)) { UpdateText(string.Empty); } } private static void LateUpdate() { while (hudsToUpdate.Count > 0) { TextHud textHud = hudsToUpdate.Dequeue(); if (textHud.enabled) { if ((Object)(object)textHud.objhud == (Object)null) { textHud.InitHud(); } ((TMP_Text)textHud.textMesh).SetText(textHud.textToUpdate, true); } textHud.textToUpdate = null; } } internal void DestroyHUD() { Object.Destroy((Object)(object)objhud); } private void InitHud() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) objhud = new GameObject(hudName); RectTransform val = objhud.AddComponent<RectTransform>(); if (Object.op_Implicit((Object)(object)hud)) { SetTransform(val, hud); } val.sizeDelta = Vector2.zero; val.pivot = new Vector2(0.5f, 0.5f); val.anchoredPosition = position; textMesh = objhud.AddComponent<HGTextMeshProUGUI>(); ((TMP_Text)textMesh).fontSizeMin = 6f; if (fontSize >= 0) { ((TMP_Text)textMesh).fontSize = fontSize; } ((TMP_Text)textMesh).outlineColor = Color32.op_Implicit(Color.black); ((TMP_Text)textMesh).enableWordWrapping = false; ((TMP_Text)textMesh).alignment = alignment; } private void SetTransform(RectTransform textRect, HUD hud) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) Transform transform = hud.mainUIPanel.transform; RectTransform val = (RectTransform)(object)((transform is RectTransform) ? transform : null); ((Transform)textRect).SetParent(hud.mainUIPanel.transform, false); textRect.anchoredPosition3D = new Vector3(position.x, position.y, 0f - val.anchoredPosition3D.z); Vector2 anchorMax = (textRect.anchorMin = -val.anchorMin / (val.anchorMax - val.anchorMin)); textRect.anchorMax = anchorMax; } private void DoHooks(ConfigFile configFile) { HUD.onHudTargetChangedGlobal += Reset_OnHudTargetChanged; if (toggleEntry != null) { toggleEntry.SettingChanged += Toggle_Changed; } if (positionEntry != null) { positionEntry.SettingChanged += Position_Changed; } if (fontsizeEntry != null) { fontsizeEntry.SettingChanged += FontSize_Changed; } } private void Reset_OnHudTargetChanged(HUD obj) { if (Object.op_Implicit((Object)(object)objhud)) { if (!Object.op_Implicit((Object)(object)objhud.transform.parent)) { Transform transform = objhud.transform; SetTransform((RectTransform)(object)((transform is RectTransform) ? transform : null), hud); } if (resetOnTargetChanged) { ClearText(); } } } private void Toggle_Changed(object sender, EventArgs e) { if (Object.op_Implicit((Object)(object)objhud) && !enabled) { Object.Destroy((Object)(object)objhud); } } private void Position_Changed(object sender, EventArgs e) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)objhud)) { objhud.GetComponent<RectTransform>().anchoredPosition = position; } } private void FontSize_Changed(object sender, EventArgs e) { if (Object.op_Implicit((Object)(object)objhud) && fontSize > 0) { ((TMP_Text)textMesh).fontSize = fontSize; } } internal void AddRoOVector2Option() { AddRoOVector2Option(hudName); } internal void AddRoOVector2Option(string category) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Invalid comparison between Unknown and I4 //IL_003f: 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_004e: 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_0067: Unknown result type (might be due to invalid IL or missing references) new Vector2ScreenOption(positionEntry, hudName + " text", category, new Vector2ScreenOption.DotInfo(((int)alignment == 257) ? new Vector2(0f, 1f) : new Vector2(0.5f, 0.5f), new Vector2(0f, 0f), new Vector2(0.5f, 0.5f), Vector2.op_Implicit(Vector3.zero)), toggleEntry, fontsizeEntry); } } [AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = false)] internal class HookAttribute : Attribute { private readonly MethodInfo from; internal HookAttribute(Type typeFrom, string methodFrom) { from = HookManager.GetMethod(typeFrom, methodFrom); } internal HookAttribute(Type typeFrom, string methodFrom, params Type[] parameters) { from = HookManager.GetMethod(typeFrom, methodFrom, parameters); } internal static void ScanAndApply() { ScanAndApply(Assembly.GetExecutingAssembly().GetTypes()); } internal static void ScanAndApply(params Type[] types) { //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Expected O, but got Unknown for (int i = 0; i < types.Length; i++) { MethodInfo[] methods = types[i].GetMethods(BindingFlags.Static | BindingFlags.NonPublic); foreach (MethodInfo methodInfo in methods) { foreach (HookAttribute customAttribute in methodInfo.GetCustomAttributes<HookAttribute>(inherit: false)) { if (customAttribute.from == null) { if (methodInfo.GetParameters().Length == 0) { methodInfo.Invoke(null, null); } else { log.error("null methodFrom for hook: " + methodInfo.Name); } continue; } try { ParameterInfo[] parameters = methodInfo.GetParameters(); if (parameters.Length == 1 && parameters[0].ParameterType == typeof(ILContext)) { HookManager.Hook(customAttribute.from, (Manipulator)methodInfo.CreateDelegate(typeof(Manipulator))); } else { HookManager.Hook(customAttribute.from, methodInfo); } } catch (Exception ex) { log.error($"Failed to do HookAttribute: {customAttribute.from.DeclaringType}.{customAttribute.from.Name} - {methodInfo.Name}\n\n{ex}"); } } } } } } } namespace Dolso.RoO { internal class RooSliderInput2 : MonoBehaviour { internal UnityEvent<float> onValueChanged = new UnityEvent<float>(); internal string formatString = "F0"; private Slider slider; private TMP_InputField inputField; private float _value; internal float value { get { return _value; } set { if (_value != value) { _value = value; onValueChanged.Invoke(_value); } UpdateControls(); } } private void Awake() { slider = ((Component)this).GetComponentInChildren<Slider>(); inputField = ((Component)this).GetComponentInChildren<TMP_InputField>(); } internal void Setup(float min, float max) { slider.minValue = min; slider.maxValue = max; ((UnityEvent<float>)(object)slider.onValueChanged).AddListener((UnityAction<float>)SliderChanged); ((UnityEvent<string>)(object)inputField.onEndEdit).AddListener((UnityAction<string>)OnTextEdited); ((UnityEvent<string>)(object)inputField.onSubmit).AddListener((UnityAction<string>)OnTextEdited); } internal void SetWholeNumbers(bool wholeNumbers) { slider.wholeNumbers = wholeNumbers; } private void UpdateControls() { if (formatString.StartsWith("F")) { slider.value = value; inputField.text = value.ToString(formatString, CultureInfo.InvariantCulture); } else { int num = (int)value; slider.value = num; inputField.text = num.ToString(formatString, CultureInfo.InvariantCulture); } } private void SliderChanged(float newValue) { value = newValue; } private void OnTextEdited(string newText) { if (float.TryParse(newText, out var result)) { value = Mathf.Clamp(result, slider.minValue, slider.maxValue); } else { value = _value; } } } internal class Vector2ScreenBehaviour : MonoBehaviour { private static Sprite checkOn; private static Sprite checkOff; private RooSliderInput2 sliderX; private RooSliderInput2 sliderY; private RooSliderInput2 sliderSize; private ChildLocator childLocator; private RectTransform positionDot; private RectTransform positionRect; private Vector2ScreenOption option; private Image checkBox; private bool boxState; private Vector2ScreenOption.DotInfo dotinfo => option.dotInfo; private ConfigEntry<Vector2> positionEntry => option.positionEntry; private ConfigEntry<bool> toggleEntry => option.toggleEntry; private ConfigEntry<int> fontSizeEntry => option.fontSizeEntry; private ConfigEntry<float> scaleEntry => option.scaleEntry; internal static void LoadImages(AsyncOperationHandle<GameObject> handle) { CarouselController component = handle.Result.GetComponent<CarouselController>(); checkOn = component.choices[1].customSprite; checkOff = component.choices[0].customSprite; } internal void SetStartingValues(Vector2ScreenOption option) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: 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_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Expected O, but got Unknown //IL_036a: Unknown result type (might be due to invalid IL or missing references) //IL_036f: Unknown result type (might be due to invalid IL or missing references) this.option = option; positionDot.anchorMin = dotinfo.dotAnchor; positionDot.anchorMax = dotinfo.dotAnchor; positionDot.pivot = dotinfo.dotAnchor; positionRect.anchorMin = dotinfo.rectAnchor; positionRect.anchorMax = dotinfo.rectAnchor; positionRect.pivot = dotinfo.rectPivot; positionRect.sizeDelta = dotinfo.rectSize; Vector2 val = CalcMinMax(1920f, 0); sliderX = BuildSlider("PositionX", val.x, val.y); sliderX.formatString = "F0"; sliderX.onValueChanged.AddListener((UnityAction<float>)XChanged); Vector2 val2 = CalcMinMax(1080f, 1); sliderY = BuildSlider("PositionY", val2.x, val2.y); sliderY.formatString = "F0"; sliderY.onValueChanged.AddListener((UnityAction<float>)YChanged); sliderX.value = positionEntry.Value.x; sliderY.value = positionEntry.Value.y; if (toggleEntry != null) { boxState = toggleEntry.Value; ((UnityEvent)((Button)((Component)childLocator.FindChild("Toggle")).GetComponent<HGButton>()).onClick).AddListener(new UnityAction(ToggleChanged)); checkBox = ((Component)childLocator.FindChild("ToggleBox")).GetComponent<Image>(); checkBox.sprite = (boxState ? checkOn : checkOff); } else { ((Component)childLocator.FindChild("ToggleParent")).gameObject.SetActive(false); ((Component)childLocator.FindChild("ToggleText")).gameObject.SetActive(false); RectTransform component = ((Component)childLocator.FindChild("Size")).GetComponent<RectTransform>(); component.anchoredPosition += new Vector2(0f, 66f); } if (fontSizeEntry != null) { sliderSize = BuildSlider("Size", 5f, option.maxScale); sliderSize.formatString = "0"; sliderSize.onValueChanged.AddListener((UnityAction<float>)FontSizeChanged); sliderSize.value = fontSizeEntry.Value; } else if (scaleEntry != null) { sliderSize = BuildSlider("Size", 5f, option.maxScale); sliderSize.formatString = "F1"; sliderSize.onValueChanged.AddListener((UnityAction<float>)ScaleChanged); sliderSize.SetWholeNumbers(wholeNumbers: false); sliderSize.value = scaleEntry.Value; } else { ((Component)childLocator.FindChild("Size")).gameObject.SetActive(false); SetSize(option.maxScale * Vector2.one); } } private void Awake() { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Expected O, but got Unknown //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Expected O, but got Unknown //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Expected O, but got Unknown childLocator = ((Component)this).GetComponent<ChildLocator>(); positionDot = ((Component)childLocator.FindChild("PositionDot")).GetComponent<RectTransform>(); positionRect = ((Component)childLocator.FindChild("PositionRect")).GetComponent<RectTransform>(); ((UnityEvent)((Button)((Component)childLocator.FindChild("Apply")).GetComponent<HGButton>()).onClick).AddListener(new UnityAction(Apply)); ((UnityEvent)((Button)((Component)childLocator.FindChild("Cancel")).GetComponent<HGButton>()).onClick).AddListener(new UnityAction(Close)); ((UnityEvent)((Button)((Component)childLocator.FindChild("Default")).GetComponent<HGButton>()).onClick).AddListener(new UnityAction(SetToDefault)); ((Component)this).GetComponent<RooEscapeRouter>().escapePressed.AddListener(new UnityAction(Close)); } private RooSliderInput2 BuildSlider(string childName, float min, float max) { RooSliderInput2 rooSliderInput = ((Component)childLocator.FindChild(childName)).gameObject.AddComponent<RooSliderInput2>(); rooSliderInput.Setup(min, max); return rooSliderInput; } private Vector2 CalcMinMax(float length, int index) { //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_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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) Vector2 val = dotinfo.rectSize; float num = 0f - ((Vector2)(ref val))[index]; val = dotinfo.dotAnchor; float num2 = ((Vector2)(ref val))[index]; val = dotinfo.rectPivot; float num3 = num * (num2 - ((Vector2)(ref val))[index]); float num4 = 0f - length; val = dotinfo.rectAnchor; float num5 = num4 * ((Vector2)(ref val))[index] + num3; val = dotinfo.rectAnchor; float num6 = length * (1f - ((Vector2)(ref val))[index]) + num3; return new Vector2(num5, num6); } private void XChanged(float newValue) { //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_001a: Unknown result type (might be due to invalid IL or missing references) Vector2 anchoredPosition = positionRect.anchoredPosition; anchoredPosition.x = newValue; positionRect.anchoredPosition = anchoredPosition; } private void YChanged(float newValue) { //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_001a: Unknown result type (might be due to invalid IL or missing references) Vector2 anchoredPosition = positionRect.anchoredPosition; anchoredPosition.y = newValue; positionRect.anchoredPosition = anchoredPosition; } private void ToggleChanged() { boxState = !boxState; checkBox.sprite = (boxState ? checkOn : checkOff); } private void FontSizeChanged(float newValue) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) SetSize(newValue * Vector2.one); } private void ScaleChanged(float newValue) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) SetSize(newValue * dotinfo.rectSize); } private void SetSize(Vector2 size) { //IL_0031: 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_0020: Unknown result type (might be due to invalid IL or missing references) if (((Vector2)(ref size)).sqrMagnitude < 16f) { positionDot.sizeDelta = ((Vector2)(ref size)).normalized * 4f; } else { positionDot.sizeDelta = size; } } private void SetToDefault() { //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_0017: 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) Vector2 val = (Vector2)((ConfigEntryBase)positionEntry).DefaultValue; sliderX.value = val.x; sliderY.value = val.y; if (toggleEntry != null) { boxState = (bool)((ConfigEntryBase)toggleEntry).DefaultValue; checkBox.sprite = (boxState ? checkOn : checkOff); } if (fontSizeEntry != null) { sliderSize.value = (int)((ConfigEntryBase)fontSizeEntry).DefaultValue; } else if (scaleEntry != null) { sliderSize.value = (float)((ConfigEntryBase)scaleEntry).DefaultValue; } } private void Apply() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) positionEntry.Value = new Vector2((float)Math.Round(sliderX.value, 2), (float)Math.Round(sliderY.value, 2)); if (toggleEntry != null) { toggleEntry.Value = boxState; } if (fontSizeEntry != null) { fontSizeEntry.Value = Mathf.RoundToInt(sliderSize.value); } else if (scaleEntry != null) { scaleEntry.Value = sliderSize.value; } Close(); } private void Close() { Object.DestroyImmediate((Object)(object)((Component)this).gameObject); } } internal class Vector2ScreenOption { internal class DotInfo { internal readonly Vector2 dotAnchor; internal readonly Vector2 rectAnchor; internal readonly Vector2 rectPivot; internal readonly Vector2 rectSize; internal DotInfo(Vector2 dotAnchor, Vector2 rectAnchor, Vector2 rectPivot, Vector2 rectSize) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: 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_001c: 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) this.dotAnchor = dotAnchor; this.rectAnchor = rectAnchor; this.rectPivot = rectPivot; this.rectSize = rectSize; } } private static GameObject prefab; internal readonly ConfigEntry<Vector2> positionEntry; internal readonly ConfigEntry<bool> toggleEntry; internal readonly ConfigEntry<int> fontSizeEntry; internal readonly ConfigEntry<float> scaleEntry; internal readonly DotInfo dotInfo; internal readonly float maxScale; internal Vector2ScreenOption(ConfigEntry<Vector2> positionEntry, DotInfo dotInfo, float dotSize = 16f) : this(positionEntry, ((ConfigEntryBase)positionEntry).Definition.Key, ((ConfigEntryBase)positionEntry).Definition.Section, dotInfo, null, null, null, dotSize) { } internal Vector2ScreenOption(ConfigEntry<Vector2> positionEntry, string name, string category, DotInfo dotInfo, float dotSize = 16f) : this(positionEntry, name, category, dotInfo, null, null, null, dotSize) { } internal Vector2ScreenOption(ConfigEntry<Vector2> positionEntry, DotInfo dotInfo, ConfigEntry<float> scaleEntry, float maxScale = 3f) : this(positionEntry, ((ConfigEntryBase)positionEntry).Definition.Key, ((ConfigEntryBase)positionEntry).Definition.Section, dotInfo, null, null, scaleEntry, maxScale) { } internal Vector2ScreenOption(ConfigEntry<Vector2> positionEntry, string name, string category, DotInfo dotInfo, ConfigEntry<float> scaleEntry, float maxScale = 3f) : this(positionEntry, name, category, dotInfo, null, null, scaleEntry, maxScale) { } internal Vector2ScreenOption(ConfigEntry<Vector2> positionEntry, string name, string category, DotInfo dotInfo, ConfigEntry<bool> toggleEntry = null, ConfigEntry<int> fontSizeEntry = null) : this(positionEntry, name, category, dotInfo, toggleEntry, fontSizeEntry, null, (fontSizeEntry == null) ? 16 : 36) { } private Vector2ScreenOption(ConfigEntry<Vector2> positionEntry, string name, string category, DotInfo dotInfo, ConfigEntry<bool> toggleEntry, ConfigEntry<int> fontSizeEntry, ConfigEntry<float> scaleEntry, float maxScale) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown this.positionEntry = positionEntry; this.dotInfo = dotInfo; this.maxScale = maxScale; this.toggleEntry = toggleEntry; this.fontSizeEntry = fontSizeEntry; this.scaleEntry = scaleEntry; ModSettingsManager.AddOption((BaseOption)new GenericButtonOption(name, category, "Position of " + name, "Open", new UnityAction(CreateOptionWindow))); } internal static void LoadAssets(string assetFolder) { //IL_0005: 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) AsyncOperationHandle<GameObject> val = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/UI/SettingsEntryButton, Bool.prefab"); val.Completed += Vector2ScreenBehaviour.LoadImages; AssetBundle obj = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), assetFolder, "dolso")); prefab = obj.LoadAsset<GameObject>("TextHud Screen"); obj.Unload(false); } private void CreateOptionWindow() { Object.Instantiate<GameObject>(prefab).AddComponent<Vector2ScreenBehaviour>().SetStartingValues(this); } } } namespace Magrider { internal class CameraModeMagrider : CameraModePlayerBasic { public const float camMaxPitch = 40f; internal static readonly CameraModeMagrider playerMagrider = new CameraModeMagrider { isSpectatorMode = false }; internal static readonly CameraModeMagrider spectatorMagrider = new CameraModeMagrider { isSpectatorMode = true }; public override void ApplyLookInputInternal(object rawInstanceData, in CameraModeContext context, in ApplyLookInputArgs input) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown //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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: 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_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) MagriderMotor magriderMotor = default(MagriderMotor); if (!context.targetInfo.isViewerControlled || !Object.op_Implicit((Object)(object)context.targetInfo.target) || !context.targetInfo.target.TryGetComponent<MagriderMotor>(ref magriderMotor)) { ((CameraModePlayerBasic)this).ApplyLookInputInternal(rawInstanceData, ref context, ref input); return; } InstanceData val = (InstanceData)rawInstanceData; magriderMotor.rigidBody.AddRelativeTorque(0f, 2f * input.lookInput.x, 0f, (ForceMode)5); Quaternion rotation = ((Component)magriderMotor).transform.rotation; float num = 57.29578f * Mathf.Atan2(2f * (rotation.x * rotation.w - rotation.y * rotation.z), 1f - 2f * (rotation.x * rotation.x - rotation.z * rotation.z)); val.pitchYaw.pitch = Mathf.Clamp(val.pitchYaw.pitch - input.lookInput.y, num - 40f, num + 40f); if (Object.op_Implicit((Object)(object)context.targetInfo.networkedViewAngles) && context.targetInfo.networkedViewAngles.hasEffectiveAuthority) { context.targetInfo.networkedViewAngles.viewAngles = val.pitchYaw; } } public override void UpdateInternal(object rawInstanceData, in CameraModeContext context, out UpdateResult result) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown //IL_0031: 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) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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_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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) result = default(UpdateResult); CameraRigController cameraRigController = context.cameraInfo.cameraRigController; InstanceData val = (InstanceData)rawInstanceData; CameraTargetParams targetParams = context.targetInfo.targetParams; Quaternion val2 = context.cameraInfo.previousCameraState.rotation; Vector3 position = context.cameraInfo.previousCameraState.position; CharacterCameraParamsData basic = CharacterCameraParamsData.basic; basic.fov = BlendableFloat.op_Implicit(val.neutralFov); Vector2 val3 = Vector2.zero; float num; bool flag; if (Object.op_Implicit((Object)(object)targetParams)) { CharacterCameraParamsData.Blend(ref targetParams.currentCameraParamsData, ref basic, 1f); num = basic.fov.value; val3 = targetParams.recoil; flag = targetParams.currentCameraParamsData.isFirstPerson.value; } else { num = context.cameraInfo.baseFov; flag = false; } val.neutralFov = Mathf.SmoothDamp(val.neutralFov, num, ref val.neutralFovVelocity, 0.2f, float.PositiveInfinity, Time.deltaTime); float pitch = val.pitchYaw.pitch; pitch += val3.y; Vector3 val4 = MagCalculatePivotPosition(in context, flag); GameObject target = context.targetInfo.target; if (Object.op_Implicit((Object)(object)target)) { Quaternion rotation = target.transform.rotation; float num2 = 57.29578f * Mathf.Atan2(2f * (rotation.x * rotation.w - rotation.y * rotation.z), 1f - 2f * (rotation.x * rotation.x - rotation.z * rotation.z)); val2 = rotation * Quaternion.Euler(pitch - num2, 0f, 0f); if (!flag && !Config.tpCameraRotate.Value) { val2 = Quaternion.LookRotation(val2 * Vector3.forward, Vector3.up); } target.GetComponent<MagriderMotor>().cameraPitch = pitch - num2; if (!flag) { Vector3 val5 = val2 * basic.idealLocalCameraPos.value; float magnitude = ((Vector3)(ref val5)).magnitude; float num3 = (1f + Mathf.Clamp(val.pitchYaw.pitch, -90f, 90f) / -90f) * 0.5f; magnitude *= Mathf.Sqrt(1f - num3); if (magnitude < 0.25f) { magnitude = 0.25f; } float num4 = cameraRigController.Raycast(new Ray(val4, val5), magnitude, basic.wallCushion.value - 0.01f); if (val.currentCameraDistance >= num4) { val.currentCameraDistance = num4; val.cameraDistanceVelocity = 0f; } else { val.currentCameraDistance = Mathf.SmoothDamp(val.currentCameraDistance, num4, ref val.cameraDistanceVelocity, 0.2f); } position = val4 + ((Vector3)(ref val5)).normalized * val.currentCameraDistance; } else { position = val4; } } result.cameraState.position = position; result.cameraState.rotation = val2; result.cameraState.fov = num; result.showSprintParticles = false; result.firstPersonTarget = null; result.showDisabledSkillsParticles = context.targetInfo.skillsAreDisabled; result.showSecondaryElectricityParticles = context.targetInfo.showSecondaryElectricity; ((CameraModePlayerBasic)this).UpdateCrosshair(rawInstanceData, ref context, ref result.cameraState, ref val4, ref result.crosshairWorldPosition); } private static Vector3 MagCalculatePivotPosition(in CameraModeContext context, bool firstPerson) { //IL_0023: 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_0118: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: 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_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: 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_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) CameraRigController cameraRigController = context.cameraInfo.cameraRigController; CameraTargetParams targetParams = context.targetInfo.targetParams; Vector3 result = context.cameraInfo.previousCameraState.position; if (Object.op_Implicit((Object)(object)targetParams)) { Vector3 position = ((Component)targetParams).transform.position; Vector3 val = context.targetInfo.target.transform.rotation * new Vector3(0f, targetParams.currentCameraParamsData.pivotVerticalOffset.value, 0f); if (!firstPerson && !Config.tpCameraRotate.Value && val.y < 0.5f) { val.y = 0.5f; } Vector3 val2 = (Object.op_Implicit((Object)(object)targetParams.cameraPivotTransform) ? targetParams.cameraPivotTransform.position : position) + val; if (targetParams.dontRaycastToPivot) { result = val2; } else { Vector3 val3 = val2 - position; float magnitude = ((Vector3)(ref val3)).magnitude; Ray val4 = default(Ray); ((Ray)(ref val4))..ctor(position, val3); float num = cameraRigController.Raycast(val4, magnitude, targetParams.currentCameraParamsData.wallCushion.value); result = ((Ray)(ref val4)).GetPoint(num); } } return result; } public override void CollectLookInputInternal(object rawInstanceData, in CameraModeContext context, out CollectLookInputResult output) { //IL_0029: 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_0038: Unknown result type (might be due to invalid IL or missing references) ((CameraModePlayerBasic)this).CollectLookInputInternal(rawInstanceData, ref context, ref output); if (context.targetInfo.isSprinting && CameraRigController.enableSprintSensitivitySlowdown.value) { ref Vector2 lookInput = ref output.lookInput; lookInput *= 2f; } } } internal static class Config { private static ConfigFile configFile; internal static ConfigEntry<string> prevVersion; private const string WEAPONS = "Weapons"; internal static ConfigEntry<float> blasterDamage; internal static ConfigEntry<float> blasterReload; internal static ConfigEntry<float> cannonDamage; internal static ConfigEntry<float> cannonReload; private const string MAGBURNER = "Magburner"; internal static ConfigEntry<float> magburnerDuration; internal static ConfigEntry<float> magburnerRecharge; internal static ConfigEntry<float> magburnerCost; internal static ConfigEntry<float> jumpDuration; internal static ConfigEntry<float> jumpStrength; internal static ConfigEntry<float> jumpTorque; internal static ConfigEntry<bool> tpCameraRotate; internal static ConfigEntry<bool> scopeToggle; private const string STATS = "Stats"; internal static ConfigEntry<float> acceleration; internal static ConfigEntry<float> stickStrength; internal static ConfigEntry<float> collisionDamage; internal static ConfigEntry<float> collisionCooldown; internal static ConfigEntry<float> flatArmorPerLevel; private const string HORN = "Horn"; internal static ConfigEntry<MagriderHorn.HornName> hornName; internal static ConfigEntry<KeyboardShortcut> hornKey; internal static void DoConfig(ConfigFile bepConfigFile) { //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Unknown result type (might be due to invalid IL or missing references) configFile = bepConfigFile; prevVersion = configFile.Bind<string>("", "last saved version", "1.0.14", "If this is different from current mod version, overwrite config exluding camera settings"); blasterDamage = configFile.Bind<float>("Weapons", "Blaster damage", 6.5f, "Blaster's damage coefficient"); blasterReload = configFile.Bind<float>("Weapons", "Blaster reload time", 0.66f, "Time to reload a blaster shot in seconds"); cannonDamage = configFile.Bind<float>("Weapons", "Cannon damage", 11f, "Cannon's damage coefficient"); cannonReload = configFile.Bind<float>("Weapons", "Cannon reload time", 1.5f, "Time to reload a cannon shot in seconds"); magburnerDuration = configFile.Bind<float>("Magburner", "Magburner Capacity", 1.5f, "The duration capacity of Magburner in seconds"); magburnerCost = configFile.Bind<float>("Magburner", "Magburner Activation Cost", 0.3f, "The activation cost of Magburner in seconds"); magburnerRecharge = configFile.Bind<float>("Magburner", "Magburner Recharge", 10f, "How long it takes to recharge Magburner in seconds"); jumpDuration = configFile.Bind<float>("Jump", "Jump Duration", 3f, "The duration capacity of Jump in seconds"); jumpStrength = configFile.Bind<float>("Jump", "Jump Strength", 1f, "Vertical acceleration multiplier of Jump"); jumpTorque = configFile.Bind<float>("Jump", "Jump Torque", 3f, "Torque multiplier of Jump"); tpCameraRotate = configFile.Bind<bool>("Camera", "Third Person Camera Roll", true, "If the third person camera should be affected by the Magrider's roll"); scopeToggle = configFile.Bind<bool>("Camera", "Scope Toggle", true, "If scope should be a toggle instead of a hold"); acceleration = configFile.Bind<float>("Stats", "Acceleration", 22f, "Base acceleration of the Magrider. Can not be reloaded ingame"); stickStrength = configFile.Bind<float>("Stats", "Stick Strength", 6f, "How much the magrider will try to stick to walls"); collisionDamage = configFile.Bind<float>("Stats", "Collision Damage", 0.7f, "Damage multiplier for collisions against enemies"); collisionCooldown = configFile.Bind<float>("Stats", "Collision Cooldown", 0.2f, "Repeated collisions against the same enemy will have this cooldown in seconds"); flatArmorPerLevel = configFile.Bind<float>("Stats", "Flat Armor Per Level", 0.4f, "How much flat armor (same mechanic as Repulsion Plate) to gain per level"); hornKey = configFile.Bind<KeyboardShortcut>("Horn", "Horn Key", new KeyboardShortcut((KeyCode)120, Array.Empty<KeyCode>()), "Key to activate horn"); hornName = configFile.Bind<MagriderHorn.HornName>("Horn", "Horn Name", MagriderHorn.HornName.Colossus, "Which horn to use"); MagriderMotor.texthud = new TextHud(configFile, "Magrider Text", new Vector2(600f, 500f), defaultToggle: true, 16); if (prevVersion.Value != "1.0.14") { ResetConfig(); } else if (RiskofOptions.enabled) { DoRiskOfOptions(); } } private static void DoRiskOfOptions() { Vector2ScreenOption.LoadAssets("Assets"); RiskofOptions.AddOption<bool>(tpCameraRotate); RiskofOptions.AddOption<bool>(scopeToggle); RiskofOptions.AddOption<KeyboardShortcut>(hornKey); RiskofOptions.AddOption<MagriderHorn.HornName>(hornName); MagriderMotor.texthud.AddRoOVector2Option("Stats"); RiskofOptions.AddOption(collisionDamage, 0f, 2f); RiskofOptions.AddOption(collisionCooldown, 0f, 0.6f, "{0:0.00}s"); RiskofOptions.AddOption(stickStrength, 0f, 30f); RiskofOptions.AddOption(flatArmorPerLevel, 0f, 1f); RiskofOptions.AddOption(blasterDamage, 0f, 20f); RiskofOptions.AddOption(blasterReload, 0f, 3f, "{0:0.00}s"); RiskofOptions.AddOption(cannonDamage, 0f, 30f); RiskofOptions.AddOption(cannonReload, 0f, 5f, "{0:0.00}s"); RiskofOptions.AddOption(magburnerDuration, 0f, 5f, "{0:0.00}s"); RiskofOptions.AddOption(magburnerCost, 0f, 5f, "{0:0.00}s"); RiskofOptions.AddOption(magburnerRecharge, 0f, 30f, "{0:0.00}s"); RiskofOptions.AddFloatSlider(jumpDuration, 0f, 30f, "{0:0.00}s", "Magburner"); RiskofOptions.AddFloatSlider(jumpStrength, 0f, 50f, "{0:f2}", "Magburner"); RiskofOptions.AddFloatSlider(jumpTorque, 0f, 20f, "{0:f2}", "Magburner"); } private static void ResetConfig() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) log.info("Overwriting config"); bool value = tpCameraRotate.Value; bool value2 = scopeToggle.Value; KeyboardShortcut value3 = hornKey.Value; MagriderHorn.HornName value4 = hornName.Value; configFile.Clear(); DoConfig(configFile); tpCameraRotate.Value = value; scopeToggle.Value = value2; hornKey.Value = value3; hornName.Value = value4; } [ConCommand(/*Could not decode attribute arguments.*/)] private static void ReloadConfig(ConCommandArgs args) { configFile.Reload(); Debug.Log((object)"Reloaded Magrider config"); } } internal class Content : IContentPackProvider { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static BankCallback <>9__12_0; internal void <LoadSoundbankAsync>b__12_0(uint id, IntPtr ptr, AKRESULT akResult, object cookie) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 //IL_000e: Unknown result type (might be due to invalid IL or missing references) if ((int)akResult != 1) { log.error(string.Format("Error loading bank: {0}, Error code: {1}", "MagriderSoundBank.bnk", akResult)); } } } private static AssetBundle assetBundle; internal static ContentPack contentPack; internal static SkillDef cannonDef; internal static SkillDef blasterDef; internal static SkillDef magburnerDef; public string identifier => "dolso.magrdier"; private static string directory => Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Assets"); public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args) { AssetBundleCreateRequest assetBundleRequest = AssetBundle.LoadFromFileAsync(Path.Combine(directory, "magriderassets")); yield return LoadAsync((AsyncOperation)(object)assetBundleRequest, args); assetBundle = assetBundleRequest.assetBundle; AssetBundleRequest serializableContentPack = assetBundle.LoadAssetAsync<SerializableContentPack>("Magrider ContentPack"); yield return LoadAsync((AsyncOperation)(object)serializableContentPack, args); Object asset = serializableContentPack.asset; contentPack = ((SerializableContentPack)((asset is SerializableContentPack) ? asset : null)).CreateContentPack(); LoadSoundbankAsync(); yield return DoBody(); yield return DoProjectiles(); yield return DoSkills(); if (RiskofOptions.enabled) { yield return DoRiskOfOptions(); } static IEnumerator LoadAsync(AsyncOperation request, LoadStaticContentAsyncArgs args) { while (!request.isDone) { args.ReportProgress(request.progress); yield return null; } } } public IEnumerator GenerateContentPackAsync(GetContentPackAsyncArgs args) { ContentPack.Copy(contentPack, args.output); yield break; } public IEnumerator FinalizeAsync(FinalizeAsyncArgs args) { yield break; } internal static void LoadSoundbankAsync() { //IL_0005: 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_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Invalid comparison between Unknown and I4 //IL_0043: 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_0033: Expected O, but got Unknown AKRESULT val = AkSoundEngine.AddBasePath(directory); if ((int)val == 1) { object obj = <>c.<>9__12_0; if (obj == null) { BankCallback val2 = delegate(uint id, IntPtr ptr, AKRESULT akResult, object cookie) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 //IL_000e: Unknown result type (might be due to invalid IL or missing references) if ((int)akResult != 1) { log.error(string.Format("Error loading bank: {0}, Error code: {1}", "MagriderSoundBank.bnk", akResult)); } }; <>c.<>9__12_0 = val2; obj = (object)val2; } AkBankManager.LoadBankAsync("MagriderSoundBank.bnk", (BankCallback)obj); } else { log.error($"Error adding base path: {directory}, Error code: {val}"); } } private static IEnumerator DoBody() { AsyncOperationHandle<GameObject> crosshair = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Bandit2/Bandit2Crosshair.prefab"); AsyncOperationHandle<GameObject> pod = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Toolbot/RoboCratePod.prefab"); yield return crosshair; CharacterBody component = contentPack.bodyPrefabs.Find("MagriderBody").GetComponent<CharacterBody>(); component._defaultCrosshairPrefab = crosshair.Result; component.preferredPodPrefab = pod.Result; component.acceleration = Config.acceleration.Value; } private static IEnumerator DoProjectiles() { AsyncOperationHandle<GameObject> explosion = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/BleedOnHitAndExplode/BleedOnHitAndExplode_Explosion.prefab"); yield return explosion; GameObject obj = contentPack.projectilePrefabs.Find("MagCannon"); GameObject val = Utilities.CreatePrefab(explosion.Result, "CannonExplosion"); val.GetComponent<EffectComponent>().soundName = "magrider_explosion_medium"; val.GetComponent<VFXAttributes>().vfxPriority = (VFXPriority)2; obj.GetComponent<ProjectileImpactExplosion>().impactEffect = val; GameObject obj2 = contentPack.projectilePrefabs.Find("MagBlaster"); GameObject val2 = Utilities.CreatePrefab(explosion.Result, "BlasterExplosion"); val2.GetComponent<EffectComponent>().soundName = "magrider_explosion_small"; val2.GetComponent<VFXAttributes>().vfxPriority = (VFXPriority)2; obj2.GetComponent<ProjectileImpactExplosion>().impactEffect = val2; contentPack.effectDefs.Add((EffectDef[])(object)new EffectDef[2] { new EffectDef(val), new EffectDef(val2) }); } private static IEnumerator DoSkills() { AsyncOperationHandle<Sprite> rechargesprite = Addressables.LoadAssetAsync<Sprite>((object)"RoR2/Base/Cleanse/texWaterPackIcon.png"); yield return rechargesprite; contentPack.skillDefs.Find("MagRechargeDef").icon = rechargesprite.Result; cannonDef = contentPack.skillDefs.Find("MagCannonDef"); blasterDef = contentPack.skillDefs.Find("MagBlasterDef"); magburnerDef = contentPack.skillDefs.Find("MagBurnerDef"); } private static IEnumerator DoRiskOfOptions() { AssetBundleRequest sprite = assetBundle.LoadAssetAsync<Sprite>("icon"); yield return sprite; Object asset = sprite.asset; RiskofOptions.SetSprite((Sprite)(object)((asset is Sprite) ? asset : null)); } } internal static class Hooks { private static BodyIndex bodyIndex; static Hooks() { RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(OnRoR2Loaded)); VehicleSeat.onPassengerExitGlobal += InheritVelocity_VehicleSeat_onPassengerExitGlobal; } private static void OnRoR2Loaded() { //IL_0005: 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) bodyIndex = BodyCatalog.FindBodyIndex("MagriderBody"); } [Hook(typeof(CameraRigController), "set_cameraMode")] private static void ReplaceCamera_On_CameraRigController_set_cameraMode(Action<CameraRigController, CameraModeBase> orig, CameraRigController self, CameraModeBase value) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) bool flag; if (value == CameraModePlayerBasic.playerBasic) { flag = false; } else { if (value != CameraModePlayerBasic.spectator) { orig(self, value); return; } flag = true; } if (Object.op_Implicit((Object)(object)self.nextTarget)) { MagriderMotor magriderMotor = default(MagriderMotor); if ((Object)(object)self.nextTarget == (Object)(object)self.target) { if (!Object.op_Implicit((Object)(object)self.targetBody) || self.targetBody.bodyIndex != bodyIndex || Object.op_Implicit((Object)(object)self.targetBody.currentVehicle)) { goto IL_0095; } } else if (!self.nextTarget.TryGetComponent<MagriderMotor>(ref magriderMotor) || Object.op_Implicit((Object)(object)magriderMotor.characterBody.currentVehicle)) { goto IL_0095; } orig(self, (CameraModeBase)(object)(flag ? CameraModeMagrider.spectatorMagrider : CameraModeMagrider.playerMagrider)); return; } goto IL_0095; IL_0095: orig(self, value); } [Hook(typeof(CameraRigController), "set_rawScreenShakeDisplacement")] private static void DisableScreenShake_On_CameraRigController_set_rawScreenShakeDisplacement(Action<CameraRigController, Vector3> orig, CameraRigController self, Vector3 value) { //IL_002e: 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_0021: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)self.targetBody) && self.targetBody.bodyIndex == bodyIndex) { orig(self, Vector3.zero); } else { orig(self, value); } } [Hook(typeof(CharacterModel), "UpdateForCamera")] private static void AddPitchFade_IL_CharacterModel_UpdateForCamera(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); int num = default(int); if (!val.TryGotoNext(new Func<Instruction, bool>[2] { (Instruction a) => ILPatternMatchingExt.MatchLdcR4(a, 1f), (Instruction a) => ILPatternMatchingExt.MatchStloc(a, ref num) })) { val.LogErrorCaller("failed to il fade model"); return; } int index = val.Index; val.Index = index + 1; val.Emit(OpCodes.Pop); val.Emit(OpCodes.Ldarg_0); val.Emit<CharacterModel>(OpCodes.Ldfld, "body"); val.EmitDelegate<Func<CharacterBody, float>>((Func<CharacterBody, float>)delegate(CharacterBody body) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_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) if (Object.op_Implicit((Object)(object)body) && body.bodyIndex == bodyIndex) { MagriderMotor component = ((Component)body).GetComponent<MagriderMotor>(); if (!component.firstPerson) { if (component.cameraPitch < -12.5f) { return (52.5f + component.cameraPitch) / 40f; } if (component.cameraPitch > 30f && Vector3.Dot(((Component)component).transform.forward, Vector3.up) > 0.4f) { return (85f - component.cameraPitch) / 55f; } } } return 1f; }); } [Hook(typeof(JumpVolume), "OnTriggerStay")] private static void JumpPad_On_JumpVolume_OnTriggerStay(Action<JumpVolume, Collider> orig, JumpVolume self, Collider other) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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_005f: 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) MagriderMotor magriderMotor = default(MagriderMotor); if (!((Component)other).TryGetComponent<MagriderMotor>(ref magriderMotor)) { orig(self, other); } else if (Util.HasEffectiveAuthority(((Component)other).gameObject) && magriderMotor.dampingCooldown == 0f) { self.onJump.Invoke(); Util.PlaySound(self.jumpSoundString, ((Component)self).gameObject); Vector3 val = magriderMotor.velocityAuthority + self.jumpVelocity; if (val.y < self.jumpVelocity.y) { val.y = self.jumpVelocity.y; } magriderMotor.velocityAuthority = val; magriderMotor.dampingCooldown = 1f / 3f; magriderMotor.rigidBody.drag = 0f; magriderMotor.hasAirDrag = false; } } [Hook(typeof(TeleportHelper), "TeleportGameObject", new Type[] { typeof(GameObject), typeof(Vector3) })] private static void AddOffset_On_TeleportHelper_TeleportGameObject(Action<GameObject, Vector3> orig, GameObject gameObject, Vector3 newPosition) { //IL_0033: 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_001a: 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_0027: Unknown result type (might be due to invalid IL or missing references) MagriderMotor magriderMotor = default(MagriderMotor); if (gameObject.TryGetComponent<MagriderMotor>(ref magriderMotor)) { newPosition += new Vector3(0f, 2f, 0f); magriderMotor.velocityAuthority = Vector3.zero; } orig(gameObject, newPosition); } [Hook(typeof(Util), "GetBodyPrefabFootOffset")] private static float AddOffset_On_Util_GetBodyPrefabFootOffset(Func<GameObject, float> orig, GameObject prefab) { float num = orig(prefab); MagriderMotor magriderMotor = default(MagriderMotor); if (num == 0f && prefab.TryGetComponent<MagriderMotor>(ref magriderMotor)) { num = 2f; } return num; } [Hook(typeof(FrozenState), "OnEnter")] private static void PreserveVelocityAndFixFreeze_IL_FrozenState_OnEnter(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown //IL_0050: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); val.Body.Variables.Add(new VariableDefinition(((MemberReference)val.Body.Method).Module.TypeSystem.Boolean)); int num = val.Body.Variables.Count - 1; val.Emit(OpCodes.Ldarg_0); val.Emit<EntityState>(OpCodes.Callvirt, "get_characterBody"); val.Emit<CharacterBody>(OpCodes.Ldfld, "bodyIndex"); val.Emit(OpCodes.Ldsfld, typeof(Hooks).GetField("bodyIndex", (BindingFlags)(-1))); val.Emit(OpCodes.Ceq); val.Emit(OpCodes.Stloc, num); ILLabel brModelFalse = default(ILLabel); if (val.TryGotoNext(new Func<Instruction, bool>[1] { (Instruction a) => ILPatternMatchingExt.MatchLdfld<FrozenState>(a, "modelAnimator") }) && val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction a) => ILPatternMatchingExt.MatchBrfalse(a, ref brModelFalse) })) { Instruction next = val.Next; val.Index -= 1; val.Emit(OpCodes.Brtrue, next); val.Emit(OpCodes.Ldloc, num); val.Index += 1; ILLabel val2 = val.DefineLabel(); val.Emit(OpCodes.Br, (object)val2); if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction a) => ILPatternMatchingExt.MatchCallOrCallvirt<Behaviour>(a, "set_enabled") })) { val.MarkLabel(val2); } else { val.LogErrorCaller("freeze duration 2"); } } else { val.LogErrorCaller("freeze duration"); } ILLabel brfalse = null; if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[3] { (Instruction a) => ILPatternMatchingExt.MatchCallOrCallvirt<EntityState>(a, "get_rigidbody"), (Instruction a) => ILPatternMatchingExt.MatchCallOrCallvirt<Object>(a, "op_Implicit"), (Instruction a) => ILPatternMatchingExt.MatchBrfalse(a, ref brfalse) })) { val.Emit(OpCodes.Ldloc, num); val.Emit(OpCodes.Brtrue, (object)brfalse); } else { val.LogErrorCaller("freeze rigidbody"); } } [Hook(typeof(CrosshairManager), "UpdateCrosshair")] private static void RemoveSprint_IL_CrosshairManager_UpdateCrosshair(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<CharacterBody>(x, "get_isSprinting") })) { val.Emit(OpCodes.Ldarg_1); val.EmitDelegate<Func<CharacterBody, bool>>((Func<CharacterBody, bool>)((CharacterBody body) => body.bodyIndex != bodyIndex)); val.Emit(OpCodes.And); } else { val.LogErrorCaller("crosshair isSprinting"); } } [Hook(typeof(HealthComponent), "TakeDamageProcess")] private static void AddArmorPLates_IL_HealthComponent_TakeDamage(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); if (!val.TryGotoNext(new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdfld<ItemCounts>(x, "armorPlate") }) || !val.TryGotoPrev(new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<Mathf>(x, "Max") })) { val.LogErrorCaller("failed to il add armor plates"); return; } int index = val.Index; val.Index = index + 1; val.Emit(OpCodes.Ldarg_0); val.EmitDelegate<Func<HealthComponent, float>>((Func<HealthComponent, float>)((HealthComponent healthComponent) => (healthComponent.body.bodyIndex == bodyIndex) ? (2f + healthComponent.body.level * Config.flatArmorPerLevel.Value) : 0f)); val.Emit(OpCodes.Sub); } [Hook(typeof(BaseHeadstompersState), "get_isGrounded")] private static bool Magrider_On_HeadstompersBase_isGrounded(Func<BaseHeadstompersState, bool> orig, BaseHeadstompersState self) { MagriderMotor magriderMotor = default(MagriderMotor); if (!Object.op_Implicit((Object)(object)self.bodyMotor) && self.bodyGameObject.TryGetComponent<MagriderMotor>(ref magriderMotor)) { return magriderMotor.isGrounded; } return orig(self); } [Hook(typeof(HeadstompersFall), "FixedUpdateAuthority")] private static void ReplaceWithMagrider_On_HeadstompersFall_FixedUpdate(Action<HeadstompersFall> orig, HeadstompersFall self) { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0071: 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_0062: Expected O, but got Unknown //IL_015f: 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_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_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: 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_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) MagriderMotor magriderMotor = default(MagriderMotor); if (Object.op_Implicit((Object)(object)((BaseHeadstompersState)self).bodyMotor) || !((BaseHeadstompersState)self).bodyGameObject.TryGetComponent<MagriderMotor>(ref magriderMotor)) { orig(self); return; } self.stopwatch += Time.deltaTime; if (magriderMotor.isColliding) { self.DoStompExplosionAuthority(); return; } if (self.stopwatch >= HeadstompersFall.maxFallDuration) { ((EntityState)self).outer.SetNextState((EntityState)new HeadstompersCooldown()); return; } Vector3 velocity = magriderMotor.velocity; Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(0f, (velocity.y > -0.15f * HeadstompersFall.maxFallSpeed) ? (-0.5f * HeadstompersFall.accelerationY * Time.deltaTime) : 0f, 0f); if (Object.op_Implicit((Object)(object)self.seekTransform) && !self.seekLost) { Vector3 val2 = self.seekTransform.position - ((BaseHeadstompersState)self).body.footPosition; Vector3 normalized = ((Vector3)(ref val2)).normalized; if (Vector3.Dot(Vector3.down, normalized) >= Mathf.Cos(HeadstompersFall.seekCone * (MathF.PI / 180f))) { if (velocity.y < 0f) { Vector3 val3 = (0f - velocity.y) * normalized; val.x = val3.x * 2f * Time.deltaTime; val.z = val3.z * 2f * Time.deltaTime; } } else { self.seekLost = true; } } MagriderMotor magriderMotor2 = magriderMotor; PhysForceInfo physForceInfo = new PhysForceInfo { force = val * magriderMotor.mass }; magriderMotor2.ApplyForceImpulse(in physForceInfo); } [Hook(typeof(HeadstompersFall), "DoStompExplosionAuthority")] private static void AddNullCheck_IL_HeadstompersFall_DoStompExplosionAuthority(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: 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) ILCursor val = new ILCursor(il); if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[4] { (Instruction a) => ILPatternMatchingExt.MatchLdarg(a, 0), (Instruction a) => ILPatternMatchingExt.MatchLdfld<BaseHeadstompersState>(a, "bodyMotor"), (Instruction a) => ILPatternMatchingExt.MatchCallOrCallvirt<Vector3>(a, "get_zero"), (Instruction a) => ILPatternMatchingExt.MatchStfld<CharacterMotor>(a, "velocity") })) { Instruction next = val.Next; val.Index -= 4; val.Emit(OpCodes.Ldarg_0); val.Emit<BaseHeadstompersState>(OpCodes.Ldfld, "bodyMotor"); val.Emit<Object>(OpCodes.Call, "op_Implicit"); val.Emit(OpCodes.Brfalse, next); } else { val.LogErrorCaller("headstompers null check"); } } [Hook(typeof(GenericSkill), "CanApplyAmmoPack")] private static bool ApplyAmmoPack_On_GenericSkill_CanApplyAmmoPack(Func<GenericSkill, bool> orig, GenericSkill self) { //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) if (self.characterBody.bodyIndex != bodyIndex) { return orig(self); } SkillDef skillDef = self.skillDef; if ((Object)(object)skillDef == (Object)(object)Content.cannonDef || (Object)(object)skillDef == (Object)(object)Content.blasterDef) { self.stock = Mathf.Min(self.stock + 1, self.maxStock); } else { if (!((Object)(object)skillDef == (Object)(object)Content.magburnerDef)) { return orig(self); } ((Component)self).GetComponent<MagFuel>().RefillMagFuel(); } return false; } [Hook(typeof(BaseVagrantNovaItemState), "FindAttachedBodyMainRenderer")] private static SkinnedMeshRenderer DisableParticles_On_BaseVagrantNovaItemState_FindAttachedBodyMainRenderer(Func<BaseVagrantNovaItemState, SkinnedMeshRenderer> orig, BaseVagrantNovaItemState self) { //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) if (Object.op_Implicit((Object)(object)((BaseBodyAttachmentState)self).attachedBody) && ((BaseBodyAttachmentState)self).attachedBody.bodyIndex == bodyIndex) { Object.Destroy((Object)(object)self.chargeSparks); return null; } return orig(self); } [Hook(typeof(JetpackController), "FixedUpdate")] private static void AllowDisablingFlight_IL_JetpackController_FixedUpdate(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0068: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); int num = default(int); if (val.TryGotoNext(new Func<Instruction, bool>[1] { (Instruction a) => ILPatternMatchingExt.MatchCallOrCallvirt(a, typeof(CharacterMotor), "get_isGrounded") }) && val.TryGotoNext(new Func<Instruction, bool>[1] { (Instruction a) => ILPatternMatchingExt.MatchStloc(a, ref num) })) { val.Emit(OpCodes.Ldarg_0); val.EmitDelegate<Func<bool,