Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of LoaderRuler v1.1.1
plugins/LoaderRuler.dll
Decompiled 2 years agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq.Expressions; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using Dolso; using Dolso.RiskofOptions; using EntityStates; using EntityStates.Loader; using HG.GeneralSerializer; using HG.Reflection; using Mono.Cecil; using Mono.Cecil.Cil; using MonoMod.Cil; using MonoMod.RuntimeDetour; using RiskOfOptions; using RiskOfOptions.Components.Options; using RiskOfOptions.OptionConfigs; using RiskOfOptions.Options; using RoR2; using RoR2.Projectile; using RoR2.UI; using TMPro; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.Events; using UnityEngine.ResourceManagement.AsyncOperations; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: OptIn] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("LoaderRuler")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+3d2a6753a22fa5569e757a66b68d86891bc97849")] [assembly: AssemblyProduct("LoaderRuler")] [assembly: AssemblyTitle("LoaderRuler")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.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 debug(object data) { logger.LogDebug(data); } 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: {data}\n{c}")); } internal static void LogErrorCaller(this ILCursor c, object data, [CallerMemberName] string callerName = "") { logger.LogError((object)string.Format($"ILCursor failure in {callerName}: {data}\n{c}")); } } internal static class HookManager { internal const BindingFlags allFlags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; private static readonly List<IDetour> hooks = new List<IDetour>(); 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) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown try { ILHook val = new ILHook((MethodBase)typeFrom.GetMethod(methodFrom, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic), ilHook, ref ilHookConfig); try { val.Apply(); hooks.Add((IDetour)(object)val); } catch (Exception ex) { log.error($"Failed to apply ILHook: {val.Method.DeclaringType}.{val.Method.Name} - {((Delegate)(object)ilHook).Method.Name}\n{ex}"); } } catch (Exception ex2) { log.error($"Failed to make ILHook {typeFrom}.{methodFrom} - {((Delegate)(object)ilHook).Method.Name}\n{ex2}"); } } internal static void Hook(MethodBase methodFrom, Manipulator ilHook) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown try { ILHook val = new ILHook(methodFrom, ilHook, ref ilHookConfig); try { val.Apply(); hooks.Add((IDetour)(object)val); } catch (Exception ex) { log.error($"Failed to apply ILHook: {val.Method.DeclaringType}.{val.Method.Name} - {((Delegate)(object)ilHook).Method.Name}\n{ex}"); } } catch (Exception ex2) { log.error($"Failed to make ILHook {methodFrom.DeclaringType}.{methodFrom.Name} - {((Delegate)(object)ilHook).Method.Name}\n{ex2}"); } } internal static void Hook(Delegate from, Manipulator ilHook) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown try { ILHook val = new ILHook((MethodBase)from.Method, ilHook, ref ilHookConfig); try { val.Apply(); hooks.Add((IDetour)(object)val); } catch (Exception ex) { log.error($"Failed to apply ILHook: {val.Method.DeclaringType}.{val.Method.Name} - {((Delegate)(object)ilHook).Method.Name}\n{ex}"); } } catch (Exception ex2) { log.error($"Failed to make ILHook {from.Method.DeclaringType}.{from.Method.Name} - {((Delegate)(object)ilHook).Method.Name}\n{ex2}"); } } internal static void Hook<T>(Expression<Action<T>> from, Manipulator ilHook) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown MethodInfo method = ((MethodCallExpression)from.Body).Method; try { ILHook val = new ILHook((MethodBase)method, ilHook, ref ilHookConfig); try { val.Apply(); hooks.Add((IDetour)(object)val); } catch (Exception ex) { log.error($"Failed to apply ILHook: {val.Method.DeclaringType}.{val.Method.Name} - {((Delegate)(object)ilHook).Method.Name}\n{ex}"); } } catch (Exception ex2) { log.error($"Failed to make ILHook: {method.DeclaringType}.{method.Name} - {((Delegate)(object)ilHook).Method.Name}\n{ex2}"); } } internal static void Hook(Type typeFrom, string methodFrom, Delegate onHook) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown try { Hook val = new Hook((MethodBase)typeFrom.GetMethod(methodFrom, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic), onHook, ref onHookConfig); try { val.Apply(); hooks.Add((IDetour)(object)val); } catch (Exception ex) { log.error($"Failed to apply onHook: {val.Method.DeclaringType}.{val.Method.Name} - {onHook.Method.Name}\n{ex}"); } } catch (Exception ex2) { log.error($"Failed to make onHook {typeFrom}.{methodFrom} - {onHook.Method.Name}\n{ex2}"); } } internal static void Hook(MethodInfo methodFrom, MethodInfo onHook) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown try { Hook val = new Hook((MethodBase)methodFrom, onHook, ref onHookConfig); try { val.Apply(); hooks.Add((IDetour)(object)val); } catch (Exception ex) { log.error($"Failed to apply onHook: {val.Method.DeclaringType}.{val.Method.Name} - {val.Target.Name}\n{ex}"); } } catch (Exception ex2) { log.error($"Failed to make onHook {methodFrom.DeclaringType}.{methodFrom.Name} - {onHook.Name}\n{ex2}"); } } internal static void Hook(MethodBase methodFrom, Delegate onHook) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown try { Hook val = new Hook(methodFrom, onHook, ref onHookConfig); try { val.Apply(); hooks.Add((IDetour)(object)val); } catch (Exception ex) { log.error($"Failed to apply onHook: {val.Method.DeclaringType}.{val.Method.Name} - {onHook.Method.Name}\n{ex}"); } } catch (Exception ex2) { log.error($"Failed to make onHook {methodFrom.DeclaringType}.{methodFrom.Name} - {onHook.Method.Name}\n{ex2}"); } } internal static void Hook(Delegate from, Delegate onHook) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown try { Hook val = new Hook((MethodBase)from.Method, onHook, ref onHookConfig); try { val.Apply(); hooks.Add((IDetour)(object)val); } catch (Exception ex) { log.error($"Failed to apply onHook: {val.Method.DeclaringType}.{val.Method.Name} - {onHook.Method.Name}\n{ex}"); } } catch (Exception ex2) { log.error($"Failed to make onHook {from.Method.DeclaringType}.{from.Method.Name} - {onHook.Method.Name}\n{ex2}"); } } internal static void Hook<T>(Expression<Action<T>> from, Delegate onto) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown try { Hook val = new Hook((MethodBase)((MethodCallExpression)from.Body).Method, onto, ref onHookConfig); try { val.Apply(); hooks.Add((IDetour)(object)val); } catch (Exception ex) { log.error($"Failed to apply onHook: {val.Method.DeclaringType}.{val.Method.Name} - {onto.Method.Name}\n{ex}"); } } catch (Exception ex2) { log.error($"Failed to make onHook {((MethodCallExpression)from.Body).Method.DeclaringType}.{((MethodCallExpression)from.Body).Method.Name} - {onto.Method.Name}\n{ex2}"); } } internal static void Hook(Type typeFrom, string methodFrom, Delegate onHook, object instance) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown try { Hook val = new Hook((MethodBase)typeFrom.GetMethod(methodFrom, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic), onHook.Method, instance, ref onHookConfig); try { val.Apply(); hooks.Add((IDetour)(object)val); } catch (Exception ex) { log.error($"Failed to apply onHook: {val.Method.DeclaringType}.{val.Method.Name} - {onHook.Method.Name}\n{ex}"); } } catch (Exception ex2) { log.error($"Failed to make onHook {typeFrom}.{methodFrom} - {onHook.Method.Name}\n{ex2}"); } } internal static void HookConfig<T>(this ConfigEntry<T> configEntry, Func<bool> enabled, Type typeFrom, string methodFrom, Manipulator ilHook) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown try { configEntry.AddHookConfig<T>(enabled, (IDetour)new ILHook((MethodBase)typeFrom.GetMethod(methodFrom, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic), ilHook, ref ilHookConfig)); } catch (Exception ex) { log.error($"Failed to ILHook {typeFrom}.{methodFrom} - {((Delegate)(object)ilHook).Method.Name}\n{ex}"); } } internal static void HookConfig<T>(this ConfigEntry<T> configEntry, Func<bool> enabled, MethodBase methodFrom, Manipulator ilHook) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown try { configEntry.AddHookConfig<T>(enabled, (IDetour)new ILHook(methodFrom, ilHook, ref ilHookConfig)); } catch (Exception ex) { log.error($"Failed to ILHook {methodFrom.DeclaringType}.{methodFrom.Name} - {((Delegate)(object)ilHook).Method.Name}\n{ex}"); } } internal static void HookConfig<T>(this ConfigEntry<T> configEntry, Func<bool> enabled, Type typeFrom, string methodFrom, Delegate onHook) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown try { configEntry.AddHookConfig<T>(enabled, (IDetour)new Hook((MethodBase)typeFrom.GetMethod(methodFrom, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic), onHook, ref onHookConfig)); } catch (Exception ex) { log.error($"Failed to onHook {typeFrom}.{methodFrom} - {onHook.Method.Name}\n{ex}"); } } internal static void HookConfig<T>(this ConfigEntry<T> configEntry, Func<bool> enabled, MethodBase methodFrom, Delegate onHook) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown try { configEntry.AddHookConfig<T>(enabled, (IDetour)new Hook(methodFrom, onHook, ref onHookConfig)); } catch (Exception ex) { log.error($"Failed to onHook {methodFrom.DeclaringType}.{methodFrom.Name} - {onHook.Method.Name}\n{ex}"); } } internal static void HookConfig(this ConfigEntry<bool> configEntry, Type typeFrom, string methodFrom, Manipulator ilHook) { configEntry.HookConfig<bool>(() => configEntry.Value, typeFrom, methodFrom, ilHook); } internal static void HookConfig(this ConfigEntry<bool> configEntry, MethodBase methodFrom, Manipulator ilHook) { configEntry.HookConfig<bool>(() => configEntry.Value, methodFrom, ilHook); } internal static void HookConfig(this ConfigEntry<bool> configEntry, Type typeFrom, string methodFrom, Delegate onHook) { configEntry.HookConfig<bool>(() => configEntry.Value, typeFrom, methodFrom, onHook); } internal static void HookConfig(this ConfigEntry<bool> configEntry, MethodBase methodFrom, Delegate onHook) { configEntry.HookConfig<bool>(() => configEntry.Value, methodFrom, onHook); } private static void AddHookConfig<T>(this ConfigEntry<T> configEntry, Func<bool> enabled, IDetour detour) { hooks.Add(detour); configEntry.SettingChanged += delegate { UpdateHook(detour, enabled()); }; if (enabled()) { detour.Apply(); } } private static void UpdateHook(IDetour hook, bool enabled) { if (enabled) { if (!hook.IsApplied) { hook.Apply(); } } else if (hook.IsApplied) { hook.Undo(); } } internal static void PriorityFirst() { ilHookConfig.Before = new string[1] { "*" }; onHookConfig.Before = new string[1] { "*" }; } internal static void PriorityLast() { ilHookConfig.After = new string[1] { "*" }; onHookConfig.After = new string[1] { "*" }; } internal static void PriorityNormal() { ilHookConfig.Before = null; onHookConfig.Before = null; ilHookConfig.After = null; onHookConfig.After = null; } internal static IDetour ManualDetour(Type typeFrom, string methodFrom, Delegate onHook) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown try { return (IDetour)new Hook((MethodBase)typeFrom.GetMethod(methodFrom, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic), onHook, ref onHookConfig); } catch (Exception ex) { log.error($"Failed to make onHook {typeFrom}.{methodFrom} - {onHook.Method.Name}\n{ex}"); } return null; } } internal static class Utilities { private static GameObject _prefabParent; internal static GameObject CreatePrefab(GameObject gameObject) { //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); } return Object.Instantiate<GameObject>(gameObject, _prefabParent.transform); } internal static GameObject CreatePrefab(GameObject gameObject, string name) { //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); } return Object.Instantiate<GameObject>(gameObject, _prefabParent.transform); } internal static MethodInfo GetGenericMethod<T>(this Type type, string methodName, params Type[] parameters) { return type.GetMethod(methodName, parameters).MakeGenericMethod(typeof(T)); } internal static AssetBundle LoadAssetBundle(string bundlePathName) { AssetBundle result = null; try { result = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), bundlePathName)); } catch (Exception ex) { log.error("Failed to load assetbundle\n" + ex); } return result; } internal static Obj GetAddressable<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).WaitForCompletion(); } internal static GameObject GetAddressable(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).WaitForCompletion(); } internal static void GetAddressable<Obj>(string addressable, Action<AsyncOperationHandle<Obj>> callback) 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) AsyncOperationHandle<Obj> val = Addressables.LoadAssetAsync<Obj>((object)addressable); val.Completed += callback; } internal static void GetAddressable(string addressable, Action<AsyncOperationHandle<GameObject>> callback) { //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 += callback; } 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 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 void SetStateConfigIndex(this EntityStateConfiguration stateConfig, string fieldName, string newValue) { ref SerializedField[] serializedFields = ref stateConfig.serializedFieldsCollection.serializedFields; for (int i = 0; i < serializedFields.Length; i++) { if (serializedFields[i].fieldName == fieldName) { serializedFields[i].fieldValue.stringValue = newValue; return; } } log.error("failed to find " + fieldName + " for " + ((Object)stateConfig).name); } internal static void SetStateConfigIndex(this EntityStateConfiguration stateConfig, string fieldName, Object newValue) { ref SerializedField[] serializedFields = ref stateConfig.serializedFieldsCollection.serializedFields; for (int i = 0; i < serializedFields.Length; i++) { if (serializedFields[i].fieldName == fieldName) { serializedFields[i].fieldValue.objectValue = newValue; return; } } log.error("failed to find " + fieldName + " for " + ((Object)stateConfig).name); } } public class TextHud { public static HUD hud; private static bool hudVisibility; private static Queue<TextHud> hudsToUpdate; private GameObject objhud; private readonly string hudName; private HGTextMeshProUGUI textMesh; private string textToUpdate; private ConfigEntry<int> fontsizeEntry; private ConfigEntry<Vector2> positionEntry; public ConfigEntry<bool> toggleEntry { get; private set; } public bool resetOnTargetChanged { set { if (value) { HUD.onHudTargetChangedGlobal += OnHudTargetChanged_DoReset; } else { HUD.onHudTargetChangedGlobal -= OnHudTargetChanged_DoReset; } } } public bool enabled { get { if (toggleEntry == null) { return true; } return toggleEntry.Value; } } public int fontSize { get { if (fontsizeEntry == null) { return -1; } return fontsizeEntry.Value; } } public 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; } } public static event Action onAwake; public static event Action onOnDisable; public static event Action<bool> onVisibilityChanged; static TextHud() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0081: 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) hudVisibility = true; hudsToUpdate = new Queue<TextHud>(); HookConfig val = new HookConfig { ManualApply = false }; new Hook((MethodBase)typeof(HUD).GetMethod("Awake", BindingFlags.Instance | BindingFlags.NonPublic), typeof(TextHud).GetMethod("On_HUD_Awake", BindingFlags.Static | BindingFlags.NonPublic), val); new Hook((MethodBase)typeof(HUD).GetMethod("OnDisable", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic), typeof(TextHud).GetMethod("On_HUD_OnDisable", BindingFlags.Static | BindingFlags.NonPublic), val); RoR2Application.onLateUpdate += LateUpdate; } private TextHud(string name, ConfigFile configFile, Vector2? defaultPosition, bool? defaultToggle, int? defaultFontSize) { //IL_0020: 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); } public TextHud(ConfigFile configFile, string name) : this(name, configFile, null, null, null) { } public 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) public 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) public 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) public 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) public void UpdateText(string text) { if (!hudsToUpdate.Contains(this)) { hudsToUpdate.Enqueue(this); } textToUpdate = text; } public void UpdateText(StringBuilder text) { if (!hudsToUpdate.Contains(this)) { hudsToUpdate.Enqueue(this); } textToUpdate = text.ToString(); } 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; } if (Object.op_Implicit((Object)(object)hud) && hud.mainUIPanel.activeInHierarchy != hudVisibility) { hudVisibility = hud.mainUIPanel.activeInHierarchy; TextHud.onVisibilityChanged?.Invoke(hudVisibility); } } public 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_0049: 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_005f: 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_007f: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) objhud = new GameObject(hudName); if (Object.op_Implicit((Object)(object)hud)) { objhud.transform.SetParent(hud.mainContainer.transform, false); } RectTransform obj = objhud.AddComponent<RectTransform>(); obj.anchorMin = Vector2.zero; obj.anchorMax = Vector2.zero; obj.sizeDelta = Vector2.zero; obj.pivot = new Vector2(0.5f, 0.5f); obj.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).outlineWidth = 0.1f; ((TMP_Text)textMesh).enableWordWrapping = false; } private void DoHooks(ConfigFile configFile) { onAwake += HUDAwakened; HUD.onHudTargetChangedGlobal += OnHudTargetChanged_DoReset; onVisibilityChanged += OnHudVisibilityChanged; if (toggleEntry != null) { toggleEntry.SettingChanged += EntryToggle_Changed; } if (positionEntry != null) { positionEntry.SettingChanged += EntryPosition_Changed; } if (fontsizeEntry != null) { fontsizeEntry.SettingChanged += EntryFontSize_Changed; } } private void HUDAwakened() { if (Object.op_Implicit((Object)(object)objhud)) { objhud.transform.SetParent(hud.mainContainer.transform, false); } } private void OnHudTargetChanged_DoReset(HUD obj) { if (Object.op_Implicit((Object)(object)objhud)) { UpdateText(""); } } private void OnHudVisibilityChanged(bool visibility) { if (Object.op_Implicit((Object)(object)objhud)) { objhud.SetActive(visibility); } } private void EntryToggle_Changed(object sender, EventArgs e) { if (Object.op_Implicit((Object)(object)objhud) && !enabled) { Object.Destroy((Object)(object)objhud); } } private void EntryPosition_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 EntryFontSize_Changed(object sender, EventArgs e) { if (Object.op_Implicit((Object)(object)objhud) && fontSize > 0) { ((TMP_Text)textMesh).fontSize = fontSize; } } private static void On_HUD_Awake(Action<HUD> orig, HUD self) { orig(self); hud = self; TextHud.onAwake?.Invoke(); } private static void On_HUD_OnDisable(Action<HUD> orig, HUD self) { orig(self); hud = null; TextHud.onOnDisable?.Invoke(); } public void AddRoOVector2Option() { AddRoOVector2Option(hudName); } public void AddRoOVector2Option(string category) { //IL_0021: 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) new Vector2ScreenOption(positionEntry, hudName + " text", category, new Vector2ScreenOption.DotInfo(new Vector2(0f, 1f), new Vector2(0f, 0f), new Vector2(0.5f, 0.5f), Vector2.op_Implicit(Vector3.zero)), toggleEntry, fontsizeEntry); } } } namespace Dolso.RiskofOptions { 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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) DirectoryInfo directoryInfo = new DirectoryInfo(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)); string path = ((!(directoryInfo.Name == "plugins")) ? directoryInfo.FullName : directoryInfo.Parent.FullName); Texture2D val = new Texture2D(256, 256); if (ImageConversion.LoadImage(val, File.ReadAllBytes(Path.Combine(path, "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"); } } internal static void AddBool(ConfigEntry<bool> entry) { //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_0017: Expected O, but got Unknown //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(entry, new CheckBoxConfig { description = ((ConfigEntryBase)(object)entry).DescWithDefault() })); } internal static void AddBool(ConfigEntry<bool> entry, string categoryName, string name) { //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_0025: Expected O, but got Unknown //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(entry, new CheckBoxConfig { category = categoryName, name = name, description = ((ConfigEntryBase)(object)entry).DescWithDefault() })); } internal static void AddEnum<T>(ConfigEntry<T> entry) where T : Enum { //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_0017: Expected O, but got Unknown //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown ModSettingsManager.AddOption((BaseOption)new ChoiceOption((ConfigEntryBase)(object)entry, new ChoiceConfig { description = ((ConfigEntryBase)(object)entry).DescWithDefault() })); } internal static void AddColor(ConfigEntry<Color> entry) { //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_0017: Expected O, but got Unknown //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown ModSettingsManager.AddOption((BaseOption)new ColorOption(entry, new ColorOptionConfig { description = ((ConfigEntryBase)(object)entry).DescWithDefault() })); } internal static void AddKey(ConfigEntry<KeyboardShortcut> entry) { //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_0017: Expected O, but got Unknown //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown ModSettingsManager.AddOption((BaseOption)new KeyBindOption(entry, new KeyBindConfig { description = ((ConfigEntryBase)(object)entry).DescWithDefault() })); } internal static void AddFloat(ConfigEntry<float> entry, float min, float max, string format = "{0:f2}") { //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_002d: Expected O, but got Unknown //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown ModSettingsManager.AddOption((BaseOption)new SliderOption(entry, new SliderConfig { min = min, max = max, formatString = format, description = ((ConfigEntryBase)(object)entry).DescWithDefault(format) })); } internal static void AddFloat(ConfigEntry<float> entry, string categoryName, float min, float max, string format = "{0:f2}") { //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_001c: 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_0036: Expected O, but got Unknown //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003b: 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 AddFloatField(ConfigEntry<float> entry, float min = float.MinValue, float max = float.MaxValue, string format = "{0:f2}") { //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: Expected O, but got Unknown //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown FloatFieldConfig val = new FloatFieldConfig(); ((NumericFieldConfig<float>)val).Min = min; ((NumericFieldConfig<float>)val).Max = max; ((BaseOptionConfig)val).description = ((ConfigEntryBase)(object)entry).DescWithDefault(format); ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(entry, val)); } internal static void AddInt(ConfigEntry<int> entry, int min = int.MinValue, int max = int.MaxValue) { //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: Expected O, but got Unknown //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown IntFieldConfig val = new IntFieldConfig(); ((NumericFieldConfig<int>)val).Min = min; ((NumericFieldConfig<int>)val).Max = max; ((BaseOptionConfig)val).description = ((ConfigEntryBase)(object)entry).DescWithDefault(); ModSettingsManager.AddOption((BaseOption)new IntFieldOption(entry, val)); } internal static void AddIntSlider(ConfigEntry<int> entry, int min, int max) { //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_0025: Expected O, but got Unknown //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown ModSettingsManager.AddOption((BaseOption)new IntSliderOption(entry, new IntSliderConfig { min = min, max = max, description = ((ConfigEntryBase)(object)entry).DescWithDefault() })); } internal static void AddIntSlider(ConfigEntry<int> entry, string categoryName, int min, int max) { //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() })); } internal static void AddString(ConfigEntry<string> entry) { //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_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(entry, new InputFieldConfig { submitOn = (SubmitEnum)6, lineType = (LineType)0, description = ((ConfigEntryBase)(object)entry).DescWithDefault() })); } internal static void AddOption(ConfigEntry<bool> entry) { AddBool(entry); } internal static void AddOption(ConfigEntry<bool> entry, string categoryName, string name) { AddBool(entry, categoryName, name); } internal static void AddOption<T>(ConfigEntry<T> entry) where T : Enum { AddEnum<T>(entry); } internal static void AddOption(ConfigEntry<Color> entry) { AddColor(entry); } internal static void AddOption(ConfigEntry<KeyboardShortcut> entry) { AddKey(entry); } internal static void AddOption(ConfigEntry<int> entry) { AddInt(entry); } internal static void AddOption(ConfigEntry<string> entry) { AddString(entry); } 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); } } public class RooSliderInput2 : MonoBehaviour { [Serializable] public class SliderInputEvent : UnityEvent<float> { } public Slider slider; public TMP_InputField inputField; public string formatString = "{0}"; public float sliderMin; public float sliderMax; public float valueMin; public float valueMax; public SliderInputEvent onValueChanged = new SliderInputEvent(); private float _value; public float Value { get { return _value; } set { if (_value != value) { _value = value; ((UnityEvent<float>)onValueChanged).Invoke(_value); } UpdateControls(); } } public void SetUnmappedValue(float value) { Value = value; } public void Setup(float min, float max) { valueMin = min; sliderMin = min; slider.minValue = min; valueMax = max; sliderMax = max; 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); } 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 = string.Format(CultureInfo.InvariantCulture, formatString, num); } } private void SliderChanged(float newValue) { Value = newValue; } private void OnTextEdited(string newText) { if (float.TryParse(newText, out var result)) { result = Mathf.Clamp(result, slider.minValue, slider.maxValue); Value = result; } else { Value = _value; } } } public class Vector2ScreenBehaviour : MonoBehaviour { public static GameObject prefab; private static Sprite checkOn; private static Sprite checkOff; private ChildLocator childLocator; private RectTransform positionDot; private RectTransform positionRect; private Vector2ScreenOption option; private RooSliderInput2 sliderX; private RooSliderInput2 sliderY; private RooSliderInput2 sliderSize; private Image checkBox; private bool boxState; private ConfigEntry<Vector2> positionEntry => option.positionEntry; private Vector2ScreenOption.DotInfo dotinfo => option.dotInfo; private ConfigEntry<bool> toggleEntry => option.toggleEntry; private ConfigEntry<int> fontSizeEntry => option.fontSizeEntry; private ConfigEntry<float> scaleEntry => option.scaleEntry; public static void LoadAssets(string assetFolder) { AssetBundle obj = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), assetFolder, "dolso")); prefab = obj.LoadAsset<GameObject>("TextHud Screen"); obj.Unload(false); LoadImages(); } public static void LoadAssets(GameObject vector2WindowPrefab) { prefab = vector2WindowPrefab; LoadImages(); } private static void LoadImages() { //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) CarouselController component = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/UI/SettingsEntryButton, Bool.prefab").WaitForCompletion().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_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Expected O, but got Unknown //IL_0377: Unknown result type (might be due to invalid IL or missing references) //IL_037c: 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; sliderX = BuildSlider("PositionX"); CalcAndSetSliderMinMax(sliderX, 1920f, 0); sliderX.formatString = "F0"; ((UnityEvent<float>)sliderX.onValueChanged).AddListener((UnityAction<float>)XChanged); sliderY = BuildSlider("PositionY"); CalcAndSetSliderMinMax(sliderY, 1080f, 1); sliderY.formatString = "F0"; ((UnityEvent<float>)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"); sliderSize.Setup(5f, option.maxScale); sliderSize.formatString = "{0}"; ((UnityEvent<float>)sliderSize.onValueChanged).AddListener((UnityAction<float>)FontSizeChanged); sliderSize.Value = fontSizeEntry.Value; } else if (scaleEntry != null) { sliderSize = BuildSlider("Size"); sliderSize.Setup(0f, option.maxScale); sliderSize.formatString = "F1"; ((UnityEvent<float>)sliderSize.onValueChanged).AddListener((UnityAction<float>)ScaleChanged); sliderSize.slider.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) { Transform val = childLocator.FindChild(childName); RooSliderInput2 rooSliderInput = ((Component)val).gameObject.AddComponent<RooSliderInput2>(); rooSliderInput.slider = ((Component)val).GetComponentInChildren<Slider>(); rooSliderInput.inputField = ((Component)val).GetComponentInChildren<TMP_InputField>(); return rooSliderInput; } private void CalcAndSetSliderMinMax(RooSliderInput2 slider, float length, int index) { float num = (0f - ((Vector2)(ref dotinfo.rectSize))[index]) * (((Vector2)(ref dotinfo.dotAnchor))[index] - ((Vector2)(ref dotinfo.rectPivot))[index]); float min = (0f - length) * ((Vector2)(ref dotinfo.rectAnchor))[index] + num; float max = length * (1f - ((Vector2)(ref dotinfo.rectAnchor))[index]) + num; slider.Setup(min, max); } 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 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 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 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); } } public class Vector2ScreenOption { public class DotInfo { internal Vector2 dotAnchor; internal Vector2 rectAnchor; internal Vector2 rectPivot; internal Vector2 rectSize; public 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; } } internal ConfigEntry<Vector2> positionEntry; internal ConfigEntry<bool> toggleEntry; internal ConfigEntry<int> fontSizeEntry; internal ConfigEntry<float> scaleEntry; internal DotInfo dotInfo; internal float maxScale; public Vector2ScreenOption(ConfigEntry<Vector2> positionEntry, DotInfo dotInfo, float dotSize = 16f) : this(positionEntry, ((ConfigEntryBase)positionEntry).Definition.Key, ((ConfigEntryBase)positionEntry).Definition.Section, dotInfo, null, null, null, dotSize) { } public Vector2ScreenOption(ConfigEntry<Vector2> positionEntry, string name, string category, DotInfo dotInfo, float dotSize = 16f) : this(positionEntry, name, category, dotInfo, null, null, null, dotSize) { } public 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) { } public 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) { } public 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))); } private void CreateOptionWindow() { Object.Instantiate<GameObject>(Vector2ScreenBehaviour.prefab).AddComponent<Vector2ScreenBehaviour>().SetStartingValues(this); } } } namespace LoaderRuler { internal class Grapple { private static readonly IDetour[] hooks = (IDetour[])(object)new IDetour[2]; internal static TextHud grappleDurationHud; internal static TextHud grappleLengthHud; private static float lastHeight = 0f; private static bool eenabled { get { if (!grappleDurationHud.enabled) { return grappleLengthHud.enabled; } return true; } } [SetupElement] private static void SetupElement() { hooks[0] = HookManager.ManualDetour(typeof(ProjectileGrappleController), "OnDestroy", new Action<Action<ProjectileGrappleController>, ProjectileGrappleController>(On_Grapple_OnDestroy)); hooks[1] = HookManager.ManualDetour(typeof(BaseState), "FixedUpdate", new Action<Action<BaseState>, BaseState>(On_State_FixedUpdate)); grappleDurationHud.toggleEntry.SettingChanged += delegate { LoadElement(fromSetting: true); }; grappleLengthHud.toggleEntry.SettingChanged += delegate { LoadElement(fromSetting: true); }; LoadElement(fromSetting: false); } private static void LoadElement(bool fromSetting) { if (eenabled) { IDetour[] array = hooks; foreach (IDetour val in array) { if (!val.IsApplied) { val.Apply(); } } } else { if (!fromSetting) { return; } IDetour[] array = hooks; foreach (IDetour val2 in array) { if (val2.IsApplied) { val2.Undo(); } } } } private static void On_State_FixedUpdate(Action<BaseState> orig, BaseState self) { //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0152: 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) orig(self); BaseState val = (BaseState)(object)((self is BaseState) ? self : null); GameObject gameObject = val.owner.gameObject; HUD hud = TextHud.hud; if ((Object)(object)gameObject != (Object)(object)((hud != null) ? hud.targetBodyObject : null)) { return; } ProjectileSimple projectileSimple = val.grappleController.projectileSimple; float num = 1f - projectileSimple.stopwatch / projectileSimple.lifetime; Color val2 = default(Color); ((Color)(ref val2))..ctor(1f, 3f * num, 3f * num); float num2 = projectileSimple.lifetime - projectileSimple.stopwatch; grappleDurationHud.UpdateText(Util.GenerateColoredString(num2.ToString("0"), Color32.op_Implicit(val2))); if (!grappleLengthHud.enabled) { return; } float num3 = Vector3.Distance(val.aimOrigin, val.position); StringBuilder stringBuilder = new StringBuilder(); if (LRConfig.GLLengthToggle.Value) { if (num3 < 10f) { stringBuilder.AppendLine(num3.ToString("0.0")); } else { stringBuilder.AppendLine(num3.ToString("0")); } } if ((Object)(object)((EntityState)self).characterBody == (Object)(object)LocalUserManager.GetFirstLocalUser().cachedBody || LRConfig.GLEnergyToggle.Value) { Ray val3 = new Ray(val.owner.characterBody.footPosition, Vector3.down); LayerIndex world = LayerIndex.world; RaycastHit val4 = default(RaycastHit); if (Physics.Raycast(val3, ref val4, 300f, LayerMask.op_Implicit(((LayerIndex)(ref world)).mask), (QueryTriggerInteraction)2)) { lastHeight = ((RaycastHit)(ref val4)).distance; } float num4 = ((LRConfig.GLSlamToggle.Value && val.owner.characterMotor.airControl == GroundSlam.airControl) ? GroundSlam.verticalAcceleration : 0f); stringBuilder.Append(((((Vector3)(ref val.owner.characterMotor.velocity)).sqrMagnitude / 2f + val.grappleController.acceleration * num3 - (Physics.gravity.y + num4) * lastHeight) / 100f).ToString("0")); } grappleLengthHud.UpdateText(stringBuilder); } private static void On_Grapple_OnDestroy(Action<ProjectileGrappleController> orig, ProjectileGrappleController self) { orig(self); if (grappleDurationHud.enabled) { grappleDurationHud.UpdateText(""); } if (grappleLengthHud.enabled) { grappleLengthHud.UpdateText(""); } } } internal class LoaderFixes { private class ApplyListenersToLoaderChargingCrosshair : MonoBehaviour { public Image image; private void Awake() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown LoaderHookCrosshairController component = ((Component)this).GetComponent<LoaderHookCrosshairController>(); image = ((Component)((Component)this).transform.Find("HookIndicatorInRange(Clone)")).GetComponent<Image>(); component.onEnterRange = new UnityEvent(); component.onExitRange = new UnityEvent(); component.onEnterRange.AddListener(new UnityAction(EnableImage)); component.onExitRange.AddListener(new UnityAction(DisableImage)); } private void EnableImage() { ((Behaviour)image).enabled = LRConfig.improveCrosshair.Value; } private void DisableImage() { ((Behaviour)image).enabled = false; } } private static GameObject chargeFistCrosshair; private static BodyIndex loaderBodyIndex = (BodyIndex)(-1); [SetupElement] private static void SetupElement() { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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 LRConfig.fixGrappleLength.HookConfig(typeof(FlyState), "FixedUpdateBehavior", (Delegate)new Action<Action<FlyState>, FlyState>(On_FlyState_FixedUpdate_ModifyDuration)); LRConfig.improveCrosshair.SettingChanged += delegate { LoadCrosshairToggle(fromSetting: true); }; LRConfig.improveCrosshair.HookConfig(typeof(CrosshairManager), "UpdateCrosshair", new Manipulator(IL_Crosshair_Update_DisableSprint)); LRConfig.improveCrosshair.HookConfig(typeof(LoaderHookCrosshairController), "Update", new Manipulator(IL_LoaderCrosshair_Update_FixLength)); LoadCrosshairToggle(fromSetting: false); } private static void LoadCrosshairToggle(bool fromSetting) { if (LRConfig.improveCrosshair.Value) { if (!Object.op_Implicit((Object)(object)chargeFistCrosshair)) { chargeFistCrosshair = Utilities.CreatePrefab(Utilities.GetAddressable("RoR2/Base/UI/StraightBracketCrosshair.prefab"), "LoaderChargingCrosshair"); chargeFistCrosshair.AddComponent<ApplyListenersToLoaderChargingCrosshair>(); chargeFistCrosshair.AddComponent<LoaderHookCrosshairController>().range = 80f; Object.Instantiate<GameObject>(((Component)Utilities.GetAddressable("RoR2/Base/Loader/LoaderCrosshair.prefab").transform.Find("HookIndicatorInRange")).gameObject, chargeFistCrosshair.transform); } EntityStateConfiguration addressable = Utilities.GetAddressable<EntityStateConfiguration>("RoR2/Base/Loader/EntityStates.Loader.BaseChargeFist.asset"); addressable.SetStateConfigIndex("crosshairOverridePrefab", (Object)(object)chargeFistCrosshair); if (fromSetting) { EntityStateCatalog.ApplyEntityStateConfiguration(addressable); } } else if (fromSetting) { EntityStateConfiguration addressable2 = Utilities.GetAddressable<EntityStateConfiguration>("RoR2/Base/Loader/EntityStates.Loader.BaseChargeFist.asset"); addressable2.SetStateConfigIndex("crosshairOverridePrefab", (Object)(object)Utilities.GetAddressable("RoR2/Base/UI/StraightBracketCrosshair.prefab")); EntityStateCatalog.ApplyEntityStateConfiguration(addressable2); } } private static void IL_Crosshair_Update_DisableSprint(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0098: 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>[2] { (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 1), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<CharacterBody>(x, "get_isSprinting") })) { log.error("Failed to IL hook sprint crosshair"); return; } val.Emit(OpCodes.Ldarg_1); val.EmitDelegate<Func<CharacterBody, bool>>((Func<CharacterBody, bool>)delegate(CharacterBody body) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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) if ((int)loaderBodyIndex == -1) { loaderBodyIndex = BodyCatalog.FindBodyIndex("LoaderBody"); } return (!LRConfig.improveCrosshair.Value || body.bodyIndex != loaderBodyIndex) ? true : false; }); val.Emit(OpCodes.And); } private static void IL_LoaderCrosshair_Update_FixLength(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_0073: 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_010d: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); if (val.TryGotoNext(new Func<Instruction, bool>[2] { (Instruction a) => ILPatternMatchingExt.MatchCallOrCallvirt<GenericSkill>(a, "CanExecute"), (Instruction a) => ILPatternMatchingExt.MatchCallOrCallvirt<LoaderHookCrosshairController>(a, "SetAvailable") })) { int index = val.Index; val.Index = index + 1; val.Emit(OpCodes.Pop); Instruction next = val.Next; FieldReference val5 = default(FieldReference); if (val.TryGotoPrev(new Func<Instruction, bool>[2] { (Instruction a) => ILPatternMatchingExt.MatchLdarg(a, 0), (Instruction a) => ILPatternMatchingExt.MatchLdfld(a, ref val5) })) { val.Emit(OpCodes.Dup); val.EmitDelegate<Func<LoaderHookCrosshairController, bool>>((Func<LoaderHookCrosshairController, bool>)((LoaderHookCrosshairController self) => self.hudElement.targetCharacterBody.skillLocator.secondary.stateMachine.IsInMainState() || self.hudElement.targetCharacterBody.skillLocator.utility.stateMachine.IsInMainState())); val.Emit(OpCodes.Br, next); int flag = 0; ILLabel branchTarget = null; if (val.TryGotoNext(new Func<Instruction, bool>[2] { (Instruction a) => ILPatternMatchingExt.MatchLdcI4(a, 0), (Instruction a) => ILPatternMatchingExt.MatchStloc(a, ref flag) }) && val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[3] { (Instruction a) => ILPatternMatchingExt.MatchLdarg(a, 0), (Instruction a) => ILPatternMatchingExt.MatchLdfld<LoaderHookCrosshairController>(a, "isAvailable"), (Instruction a) => ILPatternMatchingExt.MatchBrfalse(a, ref branchTarget) })) { val.Emit(OpCodes.Ldarg_0); val.EmitDelegate<Func<LoaderHookCrosshairController, bool>>((Func<LoaderHookCrosshairController, bool>)delegate(LoaderHookCrosshairController self) { //IL_001d: 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_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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) CharacterBody targetCharacterBody = self.hudElement.targetCharacterBody; GameObject targetBodyObject = self.hudElement.targetBodyObject; Ray val2 = new Ray(targetCharacterBody.inputBank.aimOrigin, targetCharacterBody.inputBank.aimDirection); float num = self.range + 4f; LayerIndex val3 = LayerIndex.world; int num2 = LayerMask.op_Implicit(((LayerIndex)(ref val3)).mask); val3 = LayerIndex.entityPrecise; RaycastHit val4 = default(RaycastHit); return Util.CharacterSpherecast(targetBodyObject, val2, 0.25f, ref val4, num, LayerMask.op_Implicit(num2 | LayerMask.op_Implicit(((LayerIndex)(ref val3)).mask)), (QueryTriggerInteraction)1); }); val.Emit(OpCodes.Stloc, flag); val.Emit(OpCodes.Br, (object)branchTarget); return; } } } log.error("Failed to IL hook fix loader crosshair"); } private static void On_FlyState_FixedUpdate_ModifyDuration(Action<FlyState> orig, FlyState self) { //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) if (((EntityState)self).isAuthority) { Vector3 velocity = ((EntityState)self).rigidbody.velocity; if (((Vector3)(ref velocity)).sqrMagnitude == 0f) { self.duration += Time.fixedDeltaTime / 2f; } } orig(self); } } internal static class LRConfig { public static ConfigFile configFile; private const string PUNCH = "PunchHud"; public static ConfigEntry<int> LRPunchHudCount; private const string GRAPPLE = "Grapple Length"; public static ConfigEntry<bool> GLLengthToggle; public static ConfigEntry<bool> GLEnergyToggle; public static ConfigEntry<bool> GLSlamToggle; private const string VELOCITY = "VelocityIndicator"; public static ConfigEntry<bool> velocityToggle; public static ConfigEntry<float> velocityScale; public static ConfigEntry<string> velocityIcon; public static ConfigEntry<bool> velocityStaticColor; public static ConfigEntry<Color> velocityColor; private const string SPEED = "Speed Text"; public static ConfigEntry<int> speedFontSize; public static ConfigEntry<float> speedDot; private const string FIXES = "Fixes"; public static ConfigEntry<bool> improveCrosshair; public static ConfigEntry<bool> fixGrappleLength; internal static void DoConfig(ConfigFile bepConfigFile) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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_019a: Unknown result type (might be due to invalid IL or missing references) configFile = bepConfigFile; PunchText.punchTextHud = new TextHud(configFile, "PunchHud", new Vector2(650f, 250f), defaultToggle: true); Grapple.grappleDurationHud = new TextHud(configFile, "GrappleDurationHud", new Vector2(750f, 650f), defaultToggle: true, 15); Grapple.grappleLengthHud = new TextHud(configFile, "Grapple Length", new Vector2(1070f, 490f), defaultToggle: false, 15); SpeedText.speedTextHud = new TextHud(configFile, "Speed Text", new Vector2(870f, 590f), defaultToggle: true); LRPunchHudCount = configFile.Bind<int>("PunchHud", "Count", 3, "How many previous punches to display"); GLLengthToggle = configFile.Bind<bool>("Grapple Length", "Length text", false, "Display length text"); GLEnergyToggle = configFile.Bind<bool>("Grapple Length", "Energy text", true, "Display your \"energy\". Kinetic + grapple length * grapple acceleration + height * gravity"); GLSlamToggle = configFile.Bind<bool>("Grapple Length", "Include Slam energy", true, "If in slam state, include slam acceleration in gravity potential"); velocityToggle = configFile.Bind<bool>("VelocityIndicator", "Toggle", true, "Toggle display of velocity indicator, may require game restart"); velocityScale = configFile.Bind<float>("VelocityIndicator", "Scale", 0.25f, "Scale of icon"); velocityStaticColor = configFile.Bind<bool>("VelocityIndicator", "Static Color", false, "If color of icon should be static"); velocityColor = configFile.Bind<Color>("VelocityIndicator", "Color", new Color(0.49f, 1f, 0.49f, 0f), "Color rgba of icon. Static Color must be enabled for this to apply"); velocityIcon = configFile.Bind<string>("VelocityIndicator", "IconPath", "Textures/MiscIcons/texBarrelIcon", "Path to icon. Must be sprite or Texture2D.\nAddressables at: https://xiaoxiao921.github.io/GithubActionCacheTest/assetPathsDump.html filter for '.png', include full path."); speedFontSize = configFile.Bind<int>("Speed Text", "Font size", 15, "Base font size of speed text"); speedDot = configFile.Bind<float>("Speed Text", "Punch angle duration", 1f, "How long after punching should the 'angle :' portion linger"); improveCrosshair = configFile.Bind<bool>("Fixes", "Improve Crosshair", true, "Improves the grapple crosshair so that it correctly shows grapple range, work while charging fist, and not get overridden by sprinting"); fixGrappleLength = configFile.Bind<bool>("Fixes", "Fix Grapple Range", true, "Fixes grapple range getting reduced by network latency. Client-side"); if (RiskofOptions.enabled) { DoOptions(); } } private static void DoOptions() { RiskofOptions.SetSpriteDefaultIcon(); Vector2ScreenBehaviour.LoadAssets("Assets"); PunchText.punchTextHud.AddRoOVector2Option(); Grapple.grappleDurationHud.AddRoOVector2Option("Grapple"); Grapple.grappleLengthHud.AddRoOVector2Option("Grapple"); SpeedText.speedTextHud.AddRoOVector2Option(); RiskofOptions.AddOption(LRPunchHudCount); RiskofOptions.AddBool(GLLengthToggle, "Grapple", ((ConfigEntryBase)GLLengthToggle).Definition.Key); RiskofOptions.AddBool(GLEnergyToggle, "Grapple", ((ConfigEntryBase)GLEnergyToggle).Definition.Key); RiskofOptions.AddBool(GLSlamToggle, "Grapple", ((ConfigEntryBase)GLSlamToggle).Definition.Key); RiskofOptions.AddOption(velocityToggle); RiskofOptions.AddFloat(velocityScale, 0f, 1.5f); RiskofOptions.AddOption(velocityStaticColor); RiskofOptions.AddOption(velocityColor); RiskofOptions.AddOption(velocityIcon); RiskofOptions.AddOption(speedFontSize); RiskofOptions.AddFloat(speedDot, 0f, 3f); RiskofOptions.AddOption(improveCrosshair); RiskofOptions.AddOption(fixGrappleLength); } [ConCommand(/*Could not decode attribute arguments.*/)] private static void LRReloadConfig(ConCommandArgs args) { configFile.Reload(); } } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("dolso.loaderruler", "LoaderRuler", "1.1.1")] public class LRMain : BaseUnityPlugin { private void Awake() { log.start(((BaseUnityPlugin)this).Logger); LRConfig.DoConfig(((BaseUnityPlugin)this).Config); SetupElementAttribute.ScanAndExecute(); log.info("LoaderRuler finished"); } } internal class PunchText { internal class PunchTrack { internal string normal; internal bool slamedFirst; internal bool hasHit; internal void Reset(float dot) { //IL_0056: 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) if (dot < 0f) { dot = 0f; } normal = (dot * 100f).ToString("0"); Color val = default(Color); ((Color)(ref val))..ctor(2f * (1f - dot), 2f * (dot - 0.5f), 0f); normal = Util.GenerateColoredString(normal, Color32.op_Implicit(val)); slamedFirst = false; hasHit = false; } internal PunchTrack() { normal = string.Empty; slamedFirst = false; hasHit = true; } } internal static TextHud punchTextHud; private static PunchTrack punchTrack = new PunchTrack(); private static List<string> textlist = new List<string>(); private static bool eenabled => punchTextHud.enabled; [SetupElement] private static void SetupElement() { punchTextHud.toggleEntry.SettingChanged += delegate { LoadElement(fromSetting: true); }; punchTextHud.toggleEntry.HookConfig(typeof(BaseSwingChargedFist), "OnEnter", (Delegate)new Action<Action<BaseSwingChargedFist>, BaseSwingChargedFist>(On_BaseSwingChargedFist_OnEnter_Start)); punchTextHud.toggleEntry.HookConfig(typeof(GroundSlam), "DetonateAuthority", (Delegate)new Func<Func<GroundSlam, Result>, GroundSlam, Result>(On_GroundSlam_DetonateAuthority_Failure)); LoadElement(fromSetting: false); } private static void LoadElement(bool fromSetting) { if (eenabled) { TextHud.onOnDisable += ClearTextList; BaseSwingChargedFist.onHitAuthorityGlobal += _BaseSwingChargedFist_OnMeleeHitAuthority_Hit; } else if (fromSetting) { TextHud.onOnDisable -= ClearTextList; BaseSwingChargedFist.onHitAuthorityGlobal -= _BaseSwingChargedFist_OnMeleeHitAuthority_Hit; } } private static void UpdatePunchText(string text) { int value = LRConfig.LRPunchHudCount.Value; if (textlist.Count >= value) { textlist.RemoveRange(value - 1, textlist.Count - value + 1); } textlist.Insert(0, text); string text2 = ""; foreach (string item in textlist) { text2 = text2 + "\n" + item; } punchTextHud.UpdateText(text2); } private static void On_BaseSwingChargedFist_OnEnter_Start(Action<BaseSwingChargedFist> orig, BaseSwingChargedFist self) { //IL_002a: 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_0035: 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) //IL_0064: 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_0078: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)((EntityState)self).characterBody != (Object)(object)LocalUserManager.GetFirstLocalUser().cachedBody) { orig(self); return; } Vector3 normalized = ((Vector3)(ref ((EntityState)self).characterMotor.velocity)).normalized; Ray aimRay = ((BaseState)self).GetAimRay(); float dot = Vector3.Dot(normalized, ((Ray)(ref aimRay)).direction); orig(self); punchTrack.Reset(dot); SpeedText.recentNormal = punchTrack.normal; SpeedText.timestamp = TimeStamp.now + LRConfig.speedDot.Value; } private static Result On_GroundSlam_DetonateAuthority_Failure(Func<GroundSlam, Result> orig, GroundSlam self) { //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) //IL_0028: 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) Result val = orig(self); if (!punchTrack.hasHit && val.hitCount > 0) { punchTrack.slamedFirst = true; } return val; } private static void _BaseSwingChargedFist_OnMeleeHitAuthority_Hit(BaseSwingChargedFist self) { //IL_0037: 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)((EntityState)self).characterBody != (Object)(object)LocalUserManager.GetFirstLocalUser().cachedBody) && !punchTrack.hasHit) { Color val = (punchTrack.slamedFirst ? Color.gray : Color.white); int num = (punchTrack.slamedFirst ? 16 : ((int)(30.0 - 15.0 * Math.Cos(Math.Min(self.punchSpeed, 600f) * 0.005f)))); string arg = self.punchSpeed.ToString("0"); UpdatePunchText(Util.GenerateColoredString($"<size=16>{punchTrack.normal} : <size={num}>{arg}</size></size>", Color32.op_Implicit(val))); punchTrack.hasHit = true; } } private static void ClearTextList() { textlist.Clear(); } } [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] internal class SetupElementAttribute : Attribute { public static void ScanAndExecute() { Type[] types = Assembly.GetExecutingAssembly().GetTypes(); foreach (Type type in types) { MethodInfo[] methods = type.GetMethods(BindingFlags.Static | BindingFlags.NonPublic); foreach (MethodInfo methodInfo in methods) { if (methodInfo.IsDefined(typeof(SetupElementAttribute))) { try { methodInfo.Invoke(null, null); } catch (Exception ex) { log.error(type.Name + " failed to setup\r\n\r\n" + ex); } } } } } } internal class SpeedText : MonoBehaviour { internal static TextHud speedTextHud; internal static string recentNormal = ""; internal static TimeStamp timestamp = TimeStamp.negativeInfinity; private CharacterMotor motor; private Vector3 prevposition = Vector3.zero; private void OnEnable() { motor = ((Component)this).GetComponent<CharacterMotor>(); if (!Object.op_Implicit((Object)(object)motor)) { log.error("failed to get motor"); } } private void FixedUpdate() { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) if (!speedTextHud.enabled) { return; } HUD hud = TextHud.hud; if ((Object)(object)((hud != null) ? hud.targetBodyObject : null) != (Object)(object)((Component)this).gameObject) { return; } float num; if ((Object)(object)((Component)this).gameObject == (Object)(object)LocalUserManager.GetFirstLocalUser().cachedBodyObject && Object.op_Implicit((Object)(object)motor)) { num = ((Vector3)(ref motor.velocity)).magnitude; } else { Vector3 val = ((Component)this).transform.position - prevposition; num = ((Vector3)(ref val)).magnitude / Time.fixedDeltaTime; prevposition = ((Component)this).transform.position; } int num2 = (int)((double)LRConfig.speedFontSize.Value * (2.0 - Math.Cos(Math.Min(num, MathF.PI * 200f) * 0.005f))); if (recentNormal != "") { speedTextHud.UpdateText($"<size={LRConfig.speedFontSize.Value}>{recentNormal} : <size={num2}>{num:0}</size></size>"); if (((TimeStamp)(ref timestamp)).hasPassed) { recentNormal = ""; } } else { speedTextHud.UpdateText($"<size={num2}>{num:0}</size>"); } } } internal class VelocityVectorDisplay : MonoBehaviour { private static GameObject prefab; private GameObject indicator; private CharacterMotor motor; private Vector3 prevposition = Vector3.zero; private static bool eenabled { get { if (!LRConfig.velocityToggle.Value) { return SpeedText.speedTextHud.enabled; } return true; } } [SetupElement] private static void SetupElement() { LRConfig.velocityToggle.SettingChanged += delegate { LoadElement(fromSetting: true); }; SpeedText.speedTextHud.toggleEntry.SettingChanged += delegate { LoadElement(fromSetting: true); }; LoadElement(fromSetting: false); LRConfig.velocityIcon.SettingChanged += delegate { DoPrefab(); }; LRConfig.velocityScale.SettingChanged += delegate { DoPrefab(); }; } private static void LoadElement(bool fromSetting) { if (eenabled) { GameObject addressable = Utilities.GetAddressable("RoR2/Base/Loader/LoaderBody.prefab"); if (LRConfig.velocityToggle.Value) { if (!Object.op_Implicit((Object)(object)addressable.GetComponent<VelocityVectorDisplay>())) { addressable.AddComponent<VelocityVectorDisplay>(); } if (!Object.op_Implicit((Object)(object)prefab)) { DoPrefab(); } } if (SpeedText.speedTextHud.enabled && !Object.op_Implicit((Object)(object)addressable.GetComponent<SpeedText>())) { addressable.AddComponent<SpeedText>(); } } else if (fromSetting && Object.op_Implicit((Object)(object)prefab)) { Object.Destroy((Object)(object)prefab); } } internal static void DoPrefab() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0145: 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_015c: Expected O, but got Unknown //IL_0166: Expected O, but got Unknown //IL_00ba: 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) log.info("Loading sprite"); Sprite val = ((!LRConfig.velocityIcon.Value.Contains(".png")) ? LegacyResourcesAPI.Load<Sprite>(LRConfig.velocityIcon.Value) : Addressables.LoadAssetAsync<Sprite>((object)LRConfig.velocityIcon.Value).WaitForCompletion()); if (!Object.op_Implicit((Object)(object)val)) { Texture2D val2 = ((!LRConfig.velocityIcon.Value.Contains(".png")) ? LegacyResourcesAPI.Load<Texture2D>(LRConfig.velocityIcon.Value) : Addressables.LoadAssetAsync<Texture2D>((object)LRConfig.velocityIcon.Value).WaitForCompletion()); if (Object.op_Implicit((Object)(object)val2)) { Rect val3 = default(Rect); ((Rect)(ref val3))..ctor(0f, 0f, (float)((Texture)val2).width, (float)((Texture)val2).height); val = Sprite.Create(val2, val3, new Vector2(0.5f, 0.5f)); } } if (!Object.op_Implicit((Object)(object)val)) { Debug.LogError((object)"Failed to load sprite, using default instead"); val = LegacyResourcesAPI.Load<Sprite>("Textures/MiscIcons/texBarrelIcon"); } else { log.info("Loaded " + ((Object)val).name); } GameObject val4 = new GameObject("VelocitySprite") { layer = LayerIndex.ui.intVal }; Transform transform = val4.transform; transform.localScale *= LRConfig.velocityScale.Value / 10f; val4.AddComponent<SpriteRenderer>().sprite = val; prefab = Utilities.CreatePrefab(val4, "VelocitySprite"); Object.Destroy((Object)val4); } private void OnEnable() { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown indicator = Object.Instantiate<GameObject>(prefab); if (!Object.op_Implicit((Object)(object)indicator)) { log.error("vi indicator did not instantiate"); return; } motor = ((Component)this).GetComponent<CharacterMotor>(); if (!Object.op_Implicit((Object)(object)motor)) { log.error("failed to get motor"); return; } UICamera.onUICameraPreCull += new UICameraDelegate(CamUpdate); CameraRigController.onCameraTargetChanged += CamTargetChanged; } private void OnDestroy() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown Object.Destroy((Object)(object)indicator); UICamera.onUICameraPreCull -= new UICameraDelegate(CamUpdate); CameraRigController.onCameraTargetChanged -= CamTargetChanged; } internal void CamUpdate(UICamera uiCamera) { //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: 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_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00db: 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_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) if (!LRConfig.velocityToggle.Value) { return; } CameraRigController cameraRigController = uiCamera.cameraRigController; if ((Object)(object)cameraRigController.target != (Object)(object)((Component)this).gameObject) { return; } Camera sceneCam = cameraRigController.sceneCam; Camera camera = uiCamera.camera; SpriteRenderer component = indicator.GetComponent<SpriteRenderer>(); float num; Vector3 normalized; if ((Object)(object)LocalUserManager.GetFirstLocalUser().cachedBodyObject == (Object)(object)((Component)this).gameObject) { num = ((Vector3)(ref motor.velocity)).magnitude; normalized = ((Vector3)(ref motor.velocity)).normalized; } else { Vector3 val = ((Component)this).transform.position - prevposition; num = ((Vector3)(ref val)).magnitude / Time.fixedDeltaTime; normalized = ((Vector3)(ref val)).normalized; prevposition = ((Component)this).transform.position; } Vector3 val2 = ((Component)cameraRigController).transform.position + normalized * 100f; Vector3 val3 = sceneCam.WorldToScreenPoint(val2); if (val3.z <= 0f) { ((Renderer)component).enabled = false; return; } val3.z = 1f; Vector3 val4 = camera.ScreenToWorldPoint(val3); InputBankTest component2 = ((Component)this).GetComponent<InputBankTest>(); if (LRConfig.velocityStaticColor.Value || !Object.op_Implicit((Object)(object)component2)) { component.color = LRConfig.velocityColor.Value + new Color(0f, 0f, 0f, num / 100f); } else { float num2 = Vector3.Dot(normalized, component2.aimDirection); component.color = new Color(2f * (1f - num2), 2f * (num2 - 0.5f), 0f, num / 100f); } ((Renderer)component).enabled = true; indicator.transform.SetPositionAndRotation(val4, ((Component)uiCamera).transform.rotation); } private void CamTargetChanged(CameraRigController camrig, GameObject target) { ((Renderer)indicator.GetComponent<SpriteRenderer>()).enabled = false; } } }