Some mods may be broken due to the recent Alloyed Collective update.
Decompiled source of SeeSaw v1.2.2
SeeSaw.dll
Decompiled a year agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; 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 HG.GeneralSerializer; using HG.Reflection; 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: 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 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, skipping: {data}\n{c}")); } internal static void LogErrorCaller(this ILCursor c, object data, [CallerMemberName] string callerName = "") { logger.LogError((object)string.Format($"ILCursor failure in {callerName}, skipping: {data}\n{c}")); } } internal static class HookManager { internal delegate bool ConfigEnabled<T>(ConfigEntry<T> configEntry); internal const BindingFlags allFlags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; private static ILHookConfig ilHookConfig = new ILHookConfig { ManualApply = true }; private static HookConfig onHookConfig = new HookConfig { ManualApply = true }; private static readonly ConfigEnabled<bool> boolConfigEnabled = (ConfigEntry<bool> configEntry) => configEntry.Value; 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<T>(Expression<Action<T>> from, Manipulator ilHook) { HookInternal(((MethodCallExpression)from.Body).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<T>(Expression<Action<T>> from, Delegate onHook) { HookInternal(((MethodCallExpression)from.Body).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 onHook: {methodFrom.DeclaringType}.{methodFrom.Name} - {onHook.Name}\n{ex}"); } } internal static void HookConfig<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, Type typeFrom, string methodFrom, Manipulator ilHook) { configEntry.AddHookConfig(enabled, GetMethod(typeFrom, methodFrom), ilHook); } internal static void HookConfig<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, MethodBase methodFrom, Manipulator ilHook) { configEntry.AddHookConfig(enabled, methodFrom, ilHook); } internal static void HookConfig<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, Type typeFrom, string methodFrom, Delegate onHook) { configEntry.AddHookConfig(enabled, GetMethod(typeFrom, methodFrom), onHook.Method, onHook.Target); } internal static void HookConfig<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, MethodBase methodFrom, Delegate onHook) { configEntry.AddHookConfig(enabled, methodFrom, onHook.Method, onHook.Target); } internal static void HookConfig(this ConfigEntry<bool> configEntry, Type typeFrom, string methodFrom, Manipulator ilHook) { configEntry.AddHookConfig(boolConfigEnabled, GetMethod(typeFrom, methodFrom), ilHook); } internal static void HookConfig(this ConfigEntry<bool> configEntry, MethodBase methodFrom, Manipulator ilHook) { configEntry.AddHookConfig(boolConfigEnabled, methodFrom, ilHook); } internal static void HookConfig(this ConfigEntry<bool> configEntry, Type typeFrom, string methodFrom, Delegate onHook) { configEntry.AddHookConfig(boolConfigEnabled, GetMethod(typeFrom, methodFrom), onHook.Method, onHook.Target); } internal static void HookConfig(this ConfigEntry<bool> configEntry, MethodBase methodFrom, Delegate onHook) { configEntry.AddHookConfig(boolConfigEnabled, methodFrom, onHook.Method, onHook.Target); } private static void AddHookConfig<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, MethodBase methodFrom, Manipulator ilHook) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown if (methodFrom == null) { log.error("null MethodFrom for hook: " + ((Delegate)(object)ilHook).Method.Name); return; } try { configEntry.AddHookConfig(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}"); } } private static void AddHookConfig<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, MethodBase methodFrom, MethodInfo onHook, object target) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown if (methodFrom == null) { log.error("null MethodFrom for hook: " + onHook.Name); return; } try { configEntry.AddHookConfig(enabled, (IDetour)new Hook(methodFrom, onHook, target, ref onHookConfig)); } catch (Exception ex) { log.error($"Failed to onHook {methodFrom.DeclaringType}.{methodFrom.Name} - {onHook.Name}\n{ex}"); } } private static void AddHookConfig<T>(this ConfigEntry<T> configEntry, ConfigEnabled<T> enabled, IDetour detour) { configEntry.SettingChanged += delegate(object sender, EventArgs args) { UpdateHook(detour, enabled(sender as ConfigEntry<T>)); }; if (enabled(configEntry)) { 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_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown try { return (IDetour)new Hook((MethodBase)GetMethod(typeFrom, methodFrom), onHook, ref onHookConfig); } catch (Exception ex) { log.error($"Failed to make onHook {typeFrom}.{methodFrom} - {onHook.Method.Name}\n{ex}"); } return null; } internal static MethodInfo GetMethod(Type typeFrom, string methodFrom) { if (typeFrom == null || methodFrom == null) { return null; } IEnumerable<MethodInfo> source = from predicate in typeFrom.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic) where predicate.Name == methodFrom select predicate; if (source.Count() == 1) { return source.First(); } if (source.Count() == 0) { log.error($"Failed to find method: {typeFrom}.{methodFrom}"); } if (source.Count() > 1) { log.error($"{source.Count()} ambiguous matches found for: {typeFrom}.{methodFrom}"); } 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); } GameObject obj = Object.Instantiate<GameObject>(gameObject, _prefabParent.transform); ((Object)obj).name = name; return obj; } internal static MethodInfo MakeGenericMethod<T>(this Type type, string methodName, params Type[] parameters) { return type.GetMethod(methodName, parameters).MakeGenericMethod(typeof(T)); } internal static MethodInfo MakeGenericGetComponentG<T>() where T : Component { return typeof(GameObject).GetMethod("GetComponent", Type.EmptyTypes).MakeGenericMethod(typeof(T)); } internal static MethodInfo MakeGenericGetComponentC<T>() where T : Component { return typeof(Component).GetMethod("GetComponent", Type.EmptyTypes).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<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 GetAddressable(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 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); } internal static bool IsKeyDown(this ConfigEntry<KeyboardShortcut> key) { //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_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) KeyboardShortcut value = key.Value; if (!Input.GetKey(((KeyboardShortcut)(ref value)).MainKey)) { return false; } value = key.Value; foreach (KeyCode modifier in ((KeyboardShortcut)(ref value)).Modifiers) { if (!Input.GetKey(modifier)) { return false; } } return true; } internal static bool IsKeyJustPressed(this ConfigEntry<KeyboardShortcut> key) { //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_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) KeyboardShortcut value = key.Value; if (!Input.GetKeyDown(((KeyboardShortcut)(ref value)).MainKey)) { return false; } value = key.Value; foreach (KeyCode modifier in ((KeyboardShortcut)(ref value)).Modifiers) { if (!Input.GetKey(modifier)) { return false; } } return true; } internal static bool ContainsString(string source, string value) { return CultureInfo.InvariantCulture.CompareInfo.IndexOf(source, value, CompareOptions.IgnoreCase | CompareOptions.IgnoreSymbols) >= 0; } } 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() { hudVisibility = true; hudsToUpdate = new Queue<TextHud>(); HookManager.Hook(typeof(HUD), "Awake", (Delegate)new Action<Action<HUD>, HUD>(On_HUD_Awake)); HookManager.Hook(typeof(HUD), "OnDisable", (Delegate)new Action<Action<HUD>, HUD>(On_HUD_OnDisable)); 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(); } public void ClearText() { if (Object.op_Implicit((Object)(object)objhud) && !string.IsNullOrEmpty(((TMP_Text)textMesh).text)) { UpdateText(""); } } 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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown //IL_007e: 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) DirectoryInfo directoryInfo = new DirectoryInfo(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)); string path = ((!(directoryInfo.Name == "plugins")) ? directoryInfo.FullName : directoryInfo.Parent.FullName); try { 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"); } } catch (Exception ex) { log.error("Failed to load icon.png\n" + ex); } } 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 AddBool(ConfigEntry<bool> entry, 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_001e: Expected O, but got Unknown //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(entry, new CheckBoxConfig { category = categoryName, 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(ConfigEntry<bool> entry, string categoryName) { AddBool(entry, categoryName); } 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 SeeSaw { [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("dolso.seesaw", "SeeSaw", "1.2.2")] public class Main : BaseUnityPlugin { internal static GameObject iconPrefab; private void Awake() { log.start(((BaseUnityPlugin)this).Logger); SSConfig.DoConfig(((BaseUnityPlugin)this).Config); SawSetup.DoSetup(); } internal static void BuildIconPrefab() { //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_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: 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_015b: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Expected O, but got Unknown //IL_018b: 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 = ((!SSConfig.iconPath.Value.Contains(".png")) ? LegacyResourcesAPI.Load<Sprite>(SSConfig.iconPath.Value) : Addressables.LoadAssetAsync<Sprite>((object)SSConfig.iconPath.Value).WaitForCompletion()); if (!Object.op_Implicit((Object)(object)val)) { Texture2D val2 = ((!SSConfig.iconPath.Value.Contains(".png")) ? LegacyResourcesAPI.Load<Texture2D>(SSConfig.iconPath.Value) : Addressables.LoadAssetAsync<Texture2D>((object)SSConfig.iconPath.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("SeeSawSprite") { layer = LayerIndex.ui.intVal }; val4.transform.localScale = Vector2.op_Implicit(SSConfig.iconScale.Value / 10f * Vector2.one); SpriteRenderer obj = val4.AddComponent<SpriteRenderer>(); obj.sprite = val; obj.color = SSConfig.iconColor.Value; if (Object.op_Implicit((Object)(object)iconPrefab)) { Object.Destroy((Object)(object)iconPrefab); } iconPrefab = Utilities.CreatePrefab(val4); Object.Destroy((Object)val4); } } internal class SawComponent : MonoBehaviour { private static List<SawComponent> instanceList = new List<SawComponent>(); internal static TextHud sawCountHud; private GameObject indicator; private void OnEnable() { instanceList.Add(this); UpdateCountText(); if (SSConfig.iconToggle.Value) { indicator = Object.Instantiate<GameObject>(Main.iconPrefab); if (!Object.op_Implicit((Object)(object)indicator)) { log.error("Saw indicator did not instantiate"); } } } private void OnDisable() { instanceList.Remove(this); UpdateCountText(); if (Object.op_Implicit((Object)(object)indicator)) { Object.Destroy((Object)(object)indicator); } } private static void UpdateCountText() { if (sawCountHud.enabled) { if (instanceList.Count != 0) { sawCountHud.UpdateText(instanceList.Count.ToString()); } else { sawCountHud.UpdateText(""); } } } internal static void OnCamUpdate_Update(UICamera uiCamera) { //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_0060: 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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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) //IL_009d: 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_00b2: Unknown result type (might be due to invalid IL or missing references) if (!SSConfig.iconToggle.Value) { return; } Camera sceneCam = uiCamera.cameraRigController.sceneCam; Camera camera = uiCamera.camera; foreach (SawComponent instance in instanceList) { if (Object.op_Implicit((Object)(object)instance.indicator)) { SpriteRenderer component = instance.indicator.GetComponent<SpriteRenderer>(); Vector3 position = ((Component)instance).transform.position; Vector3 val = sceneCam.WorldToScreenPoint(position); if (val.z <= 0f) { ((Renderer)component).enabled = false; continue; } ((Renderer)component).enabled = true; val.z = 1f; Vector3 val2 = camera.ScreenToWorldPoint(val); instance.indicator.transform.SetPositionAndRotation(val2, ((Component)camera).transform.rotation); } } } } internal static class SawSetup { internal static TextHud bleedTextHud; internal static int highestBleed; private static int sawIndex; internal static void DoSetup() { //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Expected O, but got Unknown TextHud.onOnDisable += delegate { if (highestBleed > 0) { log.message("Highest bleed was " + highestBleed); highestBleed = 0; } }; bleedTextHud.toggleEntry.SettingChanged += delegate { LoadBleedCounter(fromSetting: true); }; LoadBleedCounter(fromSetting: false); Utilities.GetAddressable("RoR2/Base/Saw/Sawmerang.prefab").AddComponent<SawComponent>(); SSConfig.shader.SettingChanged += delegate { LoadSawShader(fromSetting: true); }; LoadSawShader(fromSetting: false); SSConfig.occlusion.SettingChanged += delegate { LoadSawOcclusion(fromSetting: true); }; LoadSawOcclusion(fromSetting: false); SSConfig.iconToggle.SettingChanged += delegate { LoadIconToggle(fromSetting: true); }; LoadIconToggle(fromSetting: false); SSConfig.iconScale.SettingChanged += delegate { LoadIconValues(fromSetting: true); }; SSConfig.iconColor.SettingChanged += delegate { LoadIconValues(fromSetting: true); }; SSConfig.iconPath.SettingChanged += delegate { if (Object.op_Implicit((Object)(object)Main.iconPrefab)) { Object.Destroy((Object)(object)Main.iconPrefab); } Main.BuildIconPrefab(); }; HookManager.Hook(typeof(GlobalEventManager), "ProcessHitEnemy", new Manipulator(IL_GlobalEventManager_OnHitEnemy_FixSawSwap)); RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, (Action)delegate { sawIndex = ProjectileCatalog.FindProjectileIndex("Sawmerang"); }); } private static void LoadBleedCounter(bool fromSetting) { if (bleedTextHud.enabled) { GlobalEventManager.onClientDamageNotified += OnClientDamaged_UpdateBleed; } else if (fromSetting) { GlobalEventManager.onClientDamageNotified -= OnClientDamaged_UpdateBleed; } } private static void LoadSawShader(bool fromSetting) { Material addressable = Utilities.GetAddressable<Material>("RoR2/Base/Saw/matSawmerang.mat"); if (SSConfig.shader.Value) { addressable.shader = Utilities.GetAddressable<Shader>("RoR2/Base/Shaders/HGUIIgnoreZ.shader"); } else if (fromSetting) { addressable.shader = Utilities.GetAddressable<Shader>("RoR2/Base/Shaders/HGStandard.shader"); } } private static void LoadSawOcclusion(bool fromSetting) { MeshRenderer[] componentsInChildren = Utilities.GetAddressable<GameObject>("RoR2/Base/Saw/SawmerangGhost.prefab").GetComponentsInChildren<MeshRenderer>(); for (int i = 0; i < componentsInChildren.Length; i++) { ((Renderer)componentsInChildren[i]).allowOcclusionWhenDynamic = !SSConfig.occlusion.Value; } } private static void LoadIconToggle(bool fromSetting) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown if (SSConfig.iconToggle.Value) { if (!Object.op_Implicit((Object)(object)Main.iconPrefab)) { Main.BuildIconPrefab(); } UICamera.onUICameraPreCull += new UICameraDelegate(SawComponent.OnCamUpdate_Update); } else if (fromSetting) { UICamera.onUICameraPreCull -= new UICameraDelegate(SawComponent.OnCamUpdate_Update); } } private static void LoadIconValues(bool fromSetting) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: 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) if (Object.op_Implicit((Object)(object)Main.iconPrefab)) { Main.iconPrefab.transform.localScale = Vector2.op_Implicit(SSConfig.iconScale.Value / 10f * Vector2.one); Main.iconPrefab.GetComponent<SpriteRenderer>().color = SSConfig.iconColor.Value; } } private static void OnClientDamaged_UpdateBleed(DamageDealtMessage damageDealtMessage) { //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_001c: Invalid comparison between Unknown and I4 //IL_0048: Unknown result type (might be due to invalid IL or missing references) if (!bleedTextHud.enabled || (int)DamageTypeCombo.op_Implicit(damageDealtMessage.damageType) != 67108864 || !Object.op_Implicit((Object)(object)damageDealtMessage.victim)) { return; } CharacterBody component = damageDealtMessage.victim.GetComponent<CharacterBody>(); if (Object.op_Implicit((Object)(object)component)) { int buffCount = component.GetBuffCount(Buffs.Bleeding.buffIndex); if (buffCount > highestBleed) { highestBleed = buffCount; bleedTextHud.UpdateText(buffCount.ToString()); } } } private static void IL_GlobalEventManager_OnHitEnemy_FixSawSwap(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_005b: 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) ILCursor val = new ILCursor(il); if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[2] { (Instruction a) => ILPatternMatchingExt.MatchLdsfld(a, typeof(Equipment), "Saw"), (Instruction a) => ILPatternMatchingExt.MatchCallOrCallvirt(a, typeof(EquipmentDef), "get_equipmentIndex") })) { val.Emit(OpCodes.Ldarg_1); val.EmitDelegate<Func<EquipmentIndex, EquipmentIndex, DamageInfo, int>>((Func<EquipmentIndex, EquipmentIndex, DamageInfo, int>)delegate(EquipmentIndex currentEquip, EquipmentIndex sawEquipIndex, DamageInfo damageInfo) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) if (currentEquip == sawEquipIndex) { return 1; } ProjectileController component = damageInfo.inflictor.GetComponent<ProjectileController>(); return (Object.op_Implicit((Object)(object)component) && component.catalogIndex == sawIndex) ? 1 : 0; }); val.Emit(OpCodes.Ldc_I4, 1); } else { val.LogErrorCaller("", "IL_GlobalEventManager_OnHitEnemy_FixSawSwap"); } } } internal static class SSConfig { public static ConfigFile configFile; public static ConfigEntry<bool> shader; public static ConfigEntry<bool> occlusion; public static ConfigEntry<bool> iconToggle; public static ConfigEntry<float> iconScale; public static ConfigEntry<Color> iconColor; public static ConfigEntry<string> iconPath; internal static void DoConfig(ConfigFile bepConfigFile) { //IL_00a9: 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_0121: Unknown result type (might be due to invalid IL or missing references) configFile = bepConfigFile; shader = configFile.Bind<bool>("Saw Visibility", "Modify Sawmerang shader", true, "If Sawmerang's shader should be changed to one that can be seen through objects. Combined with no occlusion culling will make saws always visible"); occlusion = configFile.Bind<bool>("Saw Visibility", "Disable Sawmerang occlusion culling", true, "Prevent Sawmerang visuals from being culled when behind objects. Combined with shader change will make saws always visible"); iconToggle = configFile.Bind<bool>("Icon", "Icon Toggle", false, "If should add position indicator icon to saws"); iconScale = configFile.Bind<float>("Icon", "Scale", 0.25f, "Scale of icon"); iconColor = configFile.Bind<Color>("Icon", "Color", new Color(0.48f, 0.88f, 0.89f, 1f), "Color rgba of icon"); iconPath = configFile.Bind<string>("Icon", "Icon Path", "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."); SawComponent.sawCountHud = new TextHud(configFile, "Saw Counter", new Vector2(3f, 27f), defaultToggle: true, 12) { resetOnTargetChanged = false }; SawSetup.bleedTextHud = new TextHud(configFile, "Highest Bleed Counter", new Vector2(3f, 14f), defaultToggle: true, 12) { resetOnTargetChanged = false }; if (RiskofOptions.enabled) { DoOptions(); } } public static void DoOptions() { //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) RiskofOptions.SetSprite(Addressables.LoadAssetAsync<Sprite>((object)"RoR2/Base/Saw/texSawmerangIcon.png").WaitForCompletion()); Vector2ScreenBehaviour.LoadAssets(""); SawSetup.bleedTextHud.AddRoOVector2Option("Text"); SawComponent.sawCountHud.AddRoOVector2Option("Text"); RiskofOptions.AddOption(shader); RiskofOptions.AddOption(occlusion); RiskofOptions.AddOption(iconToggle); RiskofOptions.AddFloat(iconScale, 0f, 1f, "{0:0.0}"); RiskofOptions.AddOption(iconColor); RiskofOptions.AddOption(iconPath); } [ConCommand(/*Could not decode attribute arguments.*/)] private static void CCReloadConfig(ConCommandArgs args) { configFile.Reload(); Debug.Log((object)"SeeSaw config reloaded"); } } }