Some mods target the Mono version of the game, which is available by opting into the Steam beta branch "alternate"
Decompiled source of GuideArrows v1.0.1
Mods/GuideArrows_Il2Cpp.dll
Decompiled 3 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using GuideArrows; using GuideArrows.Render; using GuideArrows.Targets; using GuideArrows.UI; using HarmonyLib; using Il2CppInterop.Runtime; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppScheduleOne; using Il2CppScheduleOne.DevUtilities; using Il2CppScheduleOne.Economy; using Il2CppScheduleOne.EntityFramework; using Il2CppScheduleOne.GameTime; using Il2CppScheduleOne.ItemFramework; using Il2CppScheduleOne.Map; using Il2CppScheduleOne.NPCs; using Il2CppScheduleOne.Persistence; using Il2CppScheduleOne.PlayerScripts; using Il2CppScheduleOne.Property; using Il2CppScheduleOne.Quests; using Il2CppScheduleOne.Storage; using Il2CppScheduleOne.UI; using Il2CppScheduleOne.UI.Compass; using Il2CppScheduleOne.UI.MainMenu; using Il2CppScheduleOne.UI.Tooltips; using Il2CppSystem; using Il2CppSystem.Collections.Generic; using Il2CppSystem.Reflection; using Il2CppTMPro; using MelonLoader; using MelonLoader.Preferences; using MelonLoader.Utils; using Microsoft.CodeAnalysis; using S1Shared; using S1Shared.UI; using UnityEngine; using UnityEngine.Events; using UnityEngine.Rendering; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: MelonInfo(typeof(GuideArrowsMod), "GuideArrows", "1.0.1", "BbIJABNPOBATEJb", "https://github.com/BbIJABNPOBATEJb/ScheduleI-Mods")] [assembly: MelonGame("TVGS", "Schedule I")] [assembly: HarmonyDontPatchAll] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("GuideArrows_Il2Cpp")] [assembly: AssemblyConfiguration("Il2Cpp")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+6d02579b95b27e67a5127536582ba67848828bf5")] [assembly: AssemblyProduct("GuideArrows_Il2Cpp")] [assembly: AssemblyTitle("GuideArrows_Il2Cpp")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace S1Shared { internal sealed class CoRunner { private sealed class Routine { public readonly Stack<IEnumerator> Stack = new Stack<IEnumerator>(); public float WaitUntil; } private readonly List<Routine> _routines = new List<Routine>(); private readonly Action<Exception> _onError; public CoRunner(Action<Exception> onError) { _onError = onError; } public void Start(IEnumerator routine) { Routine routine2 = new Routine(); routine2.Stack.Push(routine); _routines.Add(routine2); } public void StopAll() { _routines.Clear(); } public void Tick() { float realtimeSinceStartup = Time.realtimeSinceStartup; for (int num = _routines.Count - 1; num >= 0; num--) { Routine routine = _routines[num]; if (!(realtimeSinceStartup < routine.WaitUntil)) { try { if (!Step(routine, realtimeSinceStartup)) { _routines.RemoveAt(num); } } catch (Exception obj) { _routines.RemoveAt(num); _onError(obj); } } } } private static bool Step(Routine r, float now) { while (r.Stack.Count > 0) { IEnumerator enumerator = r.Stack.Peek(); if (!enumerator.MoveNext()) { r.Stack.Pop(); continue; } object current = enumerator.Current; if (!(current is IEnumerator item)) { if (!(current is float num)) { if (current is int num2) { r.WaitUntil = Time.realtimeSinceStartup + (float)num2; return true; } return true; } r.WaitUntil = Time.realtimeSinceStartup + num; return true; } r.Stack.Push(item); } return false; } } internal static class SafePatcher { public static int Apply(Harmony harmony, Instance log) { int num = 0; Type[] typesFromAssembly = AccessTools.GetTypesFromAssembly(Assembly.GetExecutingAssembly()); foreach (Type type in typesFromAssembly) { if (type.GetCustomAttributes(typeof(HarmonyPatch), inherit: false).Any()) { try { harmony.CreateClassProcessor(type).Patch(); } catch (Exception ex) { num++; log.Warning("Patch " + type.FullName + " not applied: " + (ex.InnerException ?? ex).Message); } } } return num; } } internal static class UiKit { public static void OnClick(Button button, Action action) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown button.onClick = new ButtonClickedEvent(); ((UnityEvent)button.onClick).AddListener(DelegateSupport.ConvertDelegate<UnityAction>((Delegate)action)); } public static void OnValueChanged(Slider slider, Action<float> action) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown slider.onValueChanged = new SliderEvent(); ((UnityEvent<float>)(object)slider.onValueChanged).AddListener(DelegateSupport.ConvertDelegate<UnityAction<float>>((Delegate)action)); } public static void AddListener(Toggle toggle, Action<bool> action) { ((UnityEvent<bool>)(object)toggle.onValueChanged).AddListener(DelegateSupport.ConvertDelegate<UnityAction<bool>>((Delegate)action)); } public static T? Get<T>(Component c) where T : Component { Component component = c.GetComponent(Il2CppType.Of<T>()); if (component == null) { return default(T); } return ((Il2CppObjectBase)component).TryCast<T>(); } public static T? Get<T>(GameObject go) where T : Component { return Get<T>((Component)(object)go.transform); } public static T? InChildren<T>(Component c) where T : Component { return UnityQuery.GetComponentsInChildren<T>(c, includeInactive: true).FirstOrDefault(); } public static Transform? Find(Transform root, string name) { for (int i = 0; i < root.childCount; i++) { Transform child = root.GetChild(i); if (((Object)child).name == name) { return child; } Transform val = Find(child, name); if ((Object)(object)val != (Object)null) { return val; } } return null; } public static List<Transform> Children(Transform t) { List<Transform> list = new List<Transform>(); for (int i = 0; i < t.childCount; i++) { list.Add(t.GetChild(i)); } return list; } public static string Namespace(Component c) { return ((Object)c).GetIl2CppType().Namespace ?? ""; } public static void SetMember(object target, string name, object? value) { Type type = target.GetType(); while (type != null) { PropertyInfo property = type.GetProperty(name, BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (property != null && property.CanWrite) { property.SetValue(target, value); break; } FieldInfo field = type.GetField(name, BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { field.SetValue(target, value); break; } type = type.BaseType; } } } internal static class UnityQuery { public static List<T> ToManaged<T>(List<T>? list) { List<T> list2 = new List<T>(); if (list == null) { return list2; } for (int i = 0; i < list.Count; i++) { list2.Add(list[i]); } return list2; } public static List<T> FindAllIncludingAssets<T>() where T : Object { List<T> list = new List<T>(); foreach (Object item in (Il2CppArrayBase<Object>)(object)Resources.FindObjectsOfTypeAll(Il2CppType.Of<T>())) { T val = ((item != null) ? ((Il2CppObjectBase)item).TryCast<T>() : default(T)); if ((Object)(object)val != (Object)null) { list.Add(val); } } return list; } public static List<T> FindInScenes<T>() where T : Component { //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) List<T> list = new List<T>(); foreach (T item in UnityQuery.FindAllIncludingAssets<T>()) { Scene scene = ((Component)item).gameObject.scene; if (((Scene)(ref scene)).IsValid()) { list.Add(item); } } return list; } public static T? GetComponentInParent<T>(Component component) where T : Component { Component componentInParent = component.GetComponentInParent(Il2CppType.Of<T>()); if (componentInParent == null) { return default(T); } return ((Il2CppObjectBase)componentInParent).TryCast<T>(); } public static List<T> GetComponentsInChildren<T>(Component root, bool includeInactive) where T : Component { List<T> list = new List<T>(); foreach (Component item in (Il2CppArrayBase<Component>)(object)root.GetComponentsInChildren(Il2CppType.Of<T>(), includeInactive)) { T val = ((item != null) ? ((Il2CppObjectBase)item).TryCast<T>() : default(T)); if ((Object)(object)val != (Object)null) { list.Add(val); } } return list; } public static bool TryCastTo<T>(Object? obj, out T result) where T : Object { result = ((obj != null) ? ((Il2CppObjectBase)obj).TryCast<T>() : default(T)); return (Object)(object)result != (Object)null; } public static string TypeName(Object obj) { return ((MemberInfo)((Object)obj).GetIl2CppType()).Name; } public static string DumpHierarchy(Transform root, int maxDepth = 12) { StringBuilder sb = new StringBuilder(); Walk(root, 0); return sb.ToString(); void Walk(Transform t, int depth) { sb.Append(' ', depth * 2).Append(((Object)t).name).Append(((Component)t).gameObject.activeSelf ? "" : " [inactive]") .Append(" {"); foreach (Component component in ((Component)t).GetComponents<Component>()) { if (!((Object)(object)component == (Object)null)) { sb.Append(TypeName((Object)(object)component)).Append(' '); if (UnityQuery.TryCastTo<TMP_Text>((Object?)(object)component, out TMP_Text result)) { sb.Append("\"").Append(result.text?.Replace("\n", "\\n")).Append("\" "); } } } sb.Append("}\n"); if (depth < maxDepth) { for (int i = 0; i < t.childCount; i++) { Walk(t.GetChild(i), depth + 1); } } } } public static string PathOf(Transform t) { List<string> list = new List<string>(); Transform val = t; while ((Object)(object)val != (Object)null) { list.Add(((Object)val).name); val = val.parent; } list.Reverse(); return string.Join("/", list); } } } namespace S1Shared.UI { internal sealed class HudCanvas { private readonly string _name; private Canvas? _canvas; private CanvasScaler? _scaler; private TMP_FontAsset? _font; private Material? _outlineMaterial; public RectTransform? Root { get; private set; } public bool Visible { get { if ((Object)(object)_canvas != (Object)null) { return ((Behaviour)_canvas).enabled; } return false; } } public bool ShowWhilePaused { get; set; } public TMP_FontAsset? Font { get { if ((Object)(object)_font == (Object)null) { _font = FindHudFont(); } return _font; } } public Material? OutlineMaterial { get { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_0092: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_outlineMaterial == (Object)null && (Object)(object)Font != (Object)null) { _outlineMaterial = new Material(((TMP_Asset)Font).material) { name = _name + " Outline" }; _outlineMaterial.EnableKeyword("OUTLINE_ON"); _outlineMaterial.SetFloat("_OutlineWidth", 0.22f); _outlineMaterial.SetColor("_OutlineColor", new Color(0f, 0f, 0f, 0.9f)); _outlineMaterial.SetFloat("_FaceDilate", 0.1f); } return _outlineMaterial; } } public float ScaleFactor { get { if (!((Object)(object)_scaler != (Object)null) || !(_scaler.scaleFactor > 0.01f)) { return 1f; } return _scaler.scaleFactor; } } public Vector2 Size { get { //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_002e: 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) if (!((Object)(object)Root != (Object)null)) { return new Vector2((float)Screen.width, (float)Screen.height); } Rect rect = Root.rect; return ((Rect)(ref rect)).size; } } public HudCanvas(string name) { _name = name; } public bool Tick() { HUD instance = Singleton<HUD>.Instance; if ((Object)(object)_canvas == (Object)null) { if ((Object)(object)instance == (Object)null) { return false; } Create(); } Canvas val = (((Object)(object)instance != (Object)null) ? instance.canvas : null); PauseMenu instance2 = Singleton<PauseMenu>.Instance; bool flag = (Object)(object)instance2 != (Object)null && instance2.IsPaused; bool flag2 = (Object)(object)val != (Object)null && (ShowWhilePaused || (((Behaviour)val).enabled && !flag)); if (((Behaviour)_canvas).enabled != flag2) { ((Behaviour)_canvas).enabled = flag2; } if ((Object)(object)val != (Object)null) { _canvas.sortingOrder = (ShowWhilePaused ? 30000 : (val.sortingOrder + 1)); float scaleFactor = val.scaleFactor; if (scaleFactor > 0.01f && !Mathf.Approximately(_scaler.scaleFactor, scaleFactor)) { _scaler.scaleFactor = scaleFactor; } } return flag2; } private void Create() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown GameObject val = new GameObject(_name); Object.DontDestroyOnLoad((Object)(object)val); _canvas = val.AddComponent<Canvas>(); _canvas.renderMode = (RenderMode)0; _scaler = val.AddComponent<CanvasScaler>(); _scaler.uiScaleMode = (ScaleMode)0; Root = UiKit.Get<RectTransform>(val); } public RectTransform NewRect(string name, Transform? parent = null) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) RectTransform obj = new GameObject(name).AddComponent<RectTransform>(); ((Transform)obj).SetParent((Transform)(((object)parent) ?? ((object)Root)), false); return obj; } public Image NewImage(string name, Transform? parent, Color color, Sprite? sprite = null) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) Image val = ((Component)NewRect(name, parent)).gameObject.AddComponent<Image>(); val.sprite = sprite; if ((Object)(object)sprite != (Object)null && sprite.border != Vector4.zero) { val.type = (Type)1; } ((Graphic)val).color = color; ((Graphic)val).raycastTarget = false; return val; } public TextMeshProUGUI NewText(string name, Transform? parent, float size, Color color, bool outline = true) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) TextMeshProUGUI val = ((Component)NewRect(name, parent)).gameObject.AddComponent<TextMeshProUGUI>(); if ((Object)(object)Font != (Object)null) { ((TMP_Text)val).font = Font; } if (outline && (Object)(object)OutlineMaterial != (Object)null) { ((TMP_Text)val).fontSharedMaterial = OutlineMaterial; } ((TMP_Text)val).fontSize = size; ((Graphic)val).color = color; ((TMP_Text)val).alignment = (TextAlignmentOptions)514; ((TMP_Text)val).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)val).overflowMode = (TextOverflowModes)0; ((Graphic)val).raycastTarget = false; return val; } public Vector2 ScreenToCanvas(Vector2 screen) { //IL_0033: 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) float num = (((Object)(object)_scaler != (Object)null && _scaler.scaleFactor > 0.01f) ? _scaler.scaleFactor : 1f); return screen / num; } private static TMP_FontAsset? FindHudFont() { HUD instance = Singleton<HUD>.Instance; if ((Object)(object)instance != (Object)null) { TMP_Text val = ((IEnumerable<TMP_Text>)UnityQuery.GetComponentsInChildren<TMP_Text>((Component)(object)instance, includeInactive: true)).FirstOrDefault((Func<TMP_Text, bool>)((TMP_Text t) => (Object)(object)t.font != (Object)null)); if ((Object)(object)val != (Object)null) { return val.font; } } return TMP_Settings.defaultFontAsset; } } internal sealed class HudElement { private readonly Func<Vector2> _getPos; private readonly Action<Vector2> _setPos; private readonly Func<float> _getScale; private readonly Action<float> _setScale; public string Label { get; } public Vector2 DefaultPos { get; } public float DefaultScale { get; } public float MinScale { get; set; } = 0.4f; public float MaxScale { get; set; } = 3f; public RectTransform? Rect { get; set; } public Vector2 Position { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return _getPos(); } set { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) _setPos(new Vector2(Mathf.Clamp01(value.x), Mathf.Clamp01(value.y))); } } public float Scale { get { return _getScale(); } set { _setScale(Mathf.Clamp(value, MinScale, MaxScale)); } } public HudElement(string label, Vector2 defaultPos, float defaultScale, Func<Vector2> getPos, Action<Vector2> setPos, Func<float> getScale, Action<float> setScale) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) Label = label; DefaultPos = defaultPos; DefaultScale = defaultScale; _getPos = getPos; _setPos = setPos; _getScale = getScale; _setScale = setScale; } public void Apply() { //IL_0010: 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_0022: 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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) if (!((Object)(object)Rect == (Object)null)) { Vector2 position = Position; RectTransform? rect = Rect; Vector2 anchorMin = (Rect.anchorMax = position); rect.anchorMin = anchorMin; Rect.pivot = new Vector2(0.5f, 0.5f); Rect.anchoredPosition = Vector2.zero; ((Transform)Rect).localScale = Vector3.one * Scale; } } public void Reset() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) Position = DefaultPos; Scale = DefaultScale; Apply(); } } internal sealed class HudEditor { private static readonly Color FrameColor = new Color(1f, 0.82f, 0.25f, 1f); private readonly HudCanvas _canvas; private readonly SettingsWindow _window; private readonly IReadOnlyList<HudElement> _elements; private readonly List<GameObject> _decorations = new List<GameObject>(); private RectTransform? _panel; private RectTransform? _doneButton; private RectTransform? _resetButton; private HudElement? _dragging; private Vector2 _dragOffset; private bool _changed; public bool Active { get; private set; } public event Action? Started; public event Action<bool>? Finished; public HudEditor(HudCanvas canvas, SettingsWindow window, IReadOnlyList<HudElement> elements) { _canvas = canvas; _window = window; _elements = elements; } public void Begin() { if (Active || (Object)(object)_canvas.Root == (Object)null) { return; } Active = true; _changed = false; _window.SetHidden(hidden: true); _canvas.ShowWhilePaused = true; this.Started?.Invoke(); foreach (HudElement element in _elements) { Decorate(element); } BuildPanel(); } public void End() { if (!Active) { return; } Active = false; _dragging = null; foreach (GameObject decoration in _decorations) { if ((Object)(object)decoration != (Object)null) { Object.Destroy((Object)(object)decoration); } } _decorations.Clear(); _canvas.ShowWhilePaused = false; _window.SetHidden(hidden: false); this.Finished?.Invoke(_changed); } public void Tick() { if (!Active) { return; } if (!_window.IsOpen || (Object)(object)_canvas.Root == (Object)null) { End(); return; } try { HandleInput(); } catch (Exception ex) { MelonLogger.Warning("HUD editor input failed: " + ex.Message); End(); } } private void HandleInput() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0156: 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_0161: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0090: 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_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: 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_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) Vector2 val = Vector2.op_Implicit(Input.mousePosition); if (Input.GetKeyDown((KeyCode)13) || Input.GetKeyDown((KeyCode)271)) { End(); return; } if (Input.GetMouseButtonDown(0)) { if (Contains(_doneButton, val)) { End(); return; } if (Contains(_resetButton, val)) { foreach (HudElement element in _elements) { element.Reset(); } _changed = true; return; } HudElement hudElement = ElementAt(val); if (hudElement != null) { _dragging = hudElement; _dragOffset = val - Vector2.op_Implicit(((Transform)hudElement.Rect).position); } } if (_dragging != null) { if (Input.GetMouseButton(0)) { Vector2 val2 = val - _dragOffset; Vector2 position = default(Vector2); ((Vector2)(ref position))..ctor(val2.x / (float)Screen.width, val2.y / (float)Screen.height); if (Mathf.Abs(val2.x - (float)Screen.width * 0.5f) < 10f) { position.x = 0.5f; } _dragging.Position = position; _dragging.Apply(); _changed = true; } else { _dragging = null; } } HudElement hudElement2 = ElementAt(val); if (hudElement2 != null) { float y = Input.mouseScrollDelta.y; if (Mathf.Abs(y) > 0.01f) { hudElement2.Scale *= 1f + 0.08f * Mathf.Sign(y); hudElement2.Apply(); _changed = true; } if (Input.GetMouseButtonDown(1)) { hudElement2.Reset(); _changed = true; } } } private HudElement? ElementAt(Vector2 mouse) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) for (int num = _elements.Count - 1; num >= 0; num--) { HudElement hudElement = _elements[num]; if ((Object)(object)hudElement.Rect != (Object)null && ((Component)hudElement.Rect).gameObject.activeInHierarchy && Contains(hudElement.Rect, mouse)) { return hudElement; } } return null; } private static bool Contains(RectTransform? rect, Vector2 screen) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)rect != (Object)null) { return RectTransformUtility.RectangleContainsScreenPoint(rect, screen, (Camera)null); } return false; } private void Decorate(HudElement element) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: 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_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_014c: 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_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)element.Rect == (Object)null)) { RectTransform val = _canvas.NewRect("EditorFrame", (Transform?)(object)element.Rect); val.anchorMin = Vector2.zero; val.anchorMax = Vector2.one; val.offsetMin = new Vector2(-6f, -6f); val.offsetMax = new Vector2(6f, 6f); Image obj = ((Component)val).gameObject.AddComponent<Image>(); obj.sprite = SpriteKit.RoundedRect(6); obj.type = (Type)1; ((Graphic)obj).color = new Color(1f, 0.82f, 0.25f, 0.12f); ((Graphic)obj).raycastTarget = false; AddEdge(val, new Vector2(0f, 1f), new Vector2(1f, 1f), new Vector2(0f, -2f), Vector2.zero); AddEdge(val, Vector2.zero, new Vector2(1f, 0f), Vector2.zero, new Vector2(0f, 2f)); AddEdge(val, Vector2.zero, new Vector2(0f, 1f), Vector2.zero, new Vector2(2f, 0f)); AddEdge(val, new Vector2(1f, 0f), Vector2.one, new Vector2(-2f, 0f), Vector2.zero); TextMeshProUGUI obj2 = _canvas.NewText("EditorLabel", (Transform?)(object)val, 18f, FrameColor); RectTransform rectTransform = ((TMP_Text)obj2).rectTransform; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(0.5f, 1f); rectTransform.anchorMax = val2; rectTransform.anchorMin = val2; rectTransform.pivot = new Vector2(0.5f, 0f); rectTransform.anchoredPosition = new Vector2(0f, 4f); rectTransform.sizeDelta = new Vector2(300f, 24f); ((TMP_Text)obj2).text = element.Label; _decorations.Add(((Component)val).gameObject); } } private void AddEdge(RectTransform frame, Vector2 anchorMin, Vector2 anchorMax, Vector2 offsetMin, Vector2 offsetMax) { //IL_000c: 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_0024: 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_0032: Unknown result type (might be due to invalid IL or missing references) RectTransform rectTransform = ((Graphic)_canvas.NewImage("Edge", (Transform?)(object)frame, FrameColor)).rectTransform; rectTransform.anchorMin = anchorMin; rectTransform.anchorMax = anchorMax; rectTransform.offsetMin = offsetMin; rectTransform.offsetMax = offsetMax; } private void BuildPanel() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0141: 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_017f: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) Image val = _canvas.NewImage("HUD Editor", null, new Color(0.08f, 0.08f, 0.1f, 0.88f), SpriteKit.RoundedRect(10)); _panel = ((Graphic)val).rectTransform; RectTransform? panel = _panel; RectTransform? panel2 = _panel; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(0.5f, 0.66f); panel2.anchorMax = val2; panel.anchorMin = val2; _panel.pivot = new Vector2(0.5f, 0.5f); _panel.anchoredPosition = Vector2.zero; _panel.sizeDelta = new Vector2(760f, 104f); _decorations.Add(((Component)val).gameObject); TextMeshProUGUI obj = _canvas.NewText("Help", (Transform?)(object)_panel, 19f, Color.white, outline: false); RectTransform rectTransform = ((TMP_Text)obj).rectTransform; rectTransform.anchorMin = new Vector2(0f, 1f); rectTransform.anchorMax = new Vector2(1f, 1f); rectTransform.pivot = new Vector2(0.5f, 1f); rectTransform.anchoredPosition = new Vector2(0f, -10f); rectTransform.sizeDelta = new Vector2(-24f, 30f); ((TMP_Text)obj).text = "Drag to move • Mouse wheel to resize • Right-click to reset"; _resetButton = MakeButton("Reset all", new Vector2(-110f, 14f), new Color(0.35f, 0.35f, 0.38f, 1f)); _doneButton = MakeButton("Done", new Vector2(110f, 14f), new Color(0.2f, 0.55f, 0.95f, 1f)); } private RectTransform MakeButton(string title, Vector2 pos, Color color) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) RectTransform rectTransform = ((Graphic)_canvas.NewImage(title, (Transform?)(object)_panel, color, SpriteKit.RoundedRect(8))).rectTransform; Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(0.5f, 0f); rectTransform.anchorMax = val; rectTransform.anchorMin = val; rectTransform.pivot = new Vector2(0.5f, 0f); rectTransform.anchoredPosition = pos; rectTransform.sizeDelta = new Vector2(190f, 40f); TextMeshProUGUI obj = _canvas.NewText("Label", (Transform?)(object)rectTransform, 20f, Color.white, outline: false); RectTransform rectTransform2 = ((TMP_Text)obj).rectTransform; rectTransform2.anchorMin = Vector2.zero; rectTransform2.anchorMax = Vector2.one; val = (rectTransform2.offsetMin = (rectTransform2.offsetMax = Vector2.zero)); ((TMP_Text)obj).text = title; return rectTransform; } } internal sealed class PrefsFile { private readonly MelonPreferences_Category _category; private readonly List<Action> _resets = new List<Action>(); private readonly List<Action> _originals = new List<Action>(); private float _saveAt = -1f; public bool SavingDisabled { get; set; } public PrefsFile(string name) { _category = MelonPreferences.CreateCategory(name); } public MelonPreferences_Entry<T> Entry<T>(string id, T defaultValue, string description) { return _category.CreateEntry<T>(id, defaultValue, (string)null, description, false, false, (ValueValidator)null, (string)null); } public Setting<T> Add<T>(string id, T defaultValue, string description) { MelonPreferences_Entry<T> entry = Entry(id, defaultValue, description); Setting<T> setting = new Setting<T>(this, entry, defaultValue); _resets.Add(setting.Reset); T loaded = entry.Value; _originals.Add(delegate { entry.Value = loaded; }); return setting; } public void RestoreLoadedValues() { foreach (Action original in _originals) { original(); } } public void ResetAll() { foreach (Action reset in _resets) { reset(); } MarkDirty(); } public void MarkDirty() { _saveAt = Time.realtimeSinceStartup + 1f; } public void Tick() { if (_saveAt > 0f && Time.realtimeSinceStartup >= _saveAt) { SaveNow(); } } public void SaveNow() { _saveAt = -1f; if (!SavingDisabled) { _category.SaveToFile(false); } } } internal sealed class Setting<T> { private readonly PrefsFile _file; private readonly MelonPreferences_Entry<T> _entry; public T Default { get; } public T Value { get { return _entry.Value; } set { _entry.Value = value; _file.MarkDirty(); } } public Setting(PrefsFile file, MelonPreferences_Entry<T> entry, T defaultValue) { _file = file; _entry = entry; Default = defaultValue; } public void Reset() { _entry.Value = Default; } } internal static class Keys { private static bool _broken; public static bool Down(KeyCode key) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) if ((int)key == 0 || _broken) { return false; } try { if (GameInput.IsTyping) { return false; } return Input.GetKeyDown(key); } catch (Exception ex) { _broken = true; MelonLogger.Warning("Hotkeys disabled, legacy input unavailable: " + ex.Message); return false; } } } internal sealed class SettingsWindow { internal sealed class RowTemplates { public Transform? Slider; public Transform? Toggle; public Transform? Choice; public Transform? Button; public Transform? Hint; } private const int MaxTabs = 6; private const string CloneSuffix = "ModScreen"; private readonly string _screenName; private readonly string _buttonName; private readonly string _title; private readonly string? _pauseButtonTitle; private readonly List<SettingsTab> _tabs = new List<SettingsTab>(); private SettingsScreen? _screen; private RectTransform? _screenRect; private bool _buildFailed; private bool _openWhenPaused; private bool _wasOpen; private int _fitIn; private string? _subtitle; private TMP_Text? _subtitleLabel; public bool IsOpen { get { if ((Object)(object)_screen != (Object)null) { return ((MenuScreen)_screen).IsOpen; } return false; } } internal bool Syncing { get; private set; } public event Action? Closed; public event Action? Changed; public SettingsWindow(string id, string title, string? pauseButtonTitle) { _screenName = id + "ModScreen"; _buttonName = id + "Button"; _title = title; _pauseButtonTitle = pauseButtonTitle; } public SettingsTab Tab(string title) { if (_tabs.Count >= 6) { throw new InvalidOperationException("The settings screen has room for " + 6 + " tabs"); } SettingsTab settingsTab = new SettingsTab(this, title); _tabs.Add(settingsTab); return settingsTab; } public void SetSubtitle(string? text) { _subtitle = text; if ((Object)(object)_subtitleLabel != (Object)null) { _subtitleLabel.text = text ?? ""; } } public void Tick() { PauseMenu instance = Singleton<PauseMenu>.Instance; if ((Object)(object)_screen == (Object)null) { if (_wasOpen) { _wasOpen = false; this.Closed?.Invoke(); } if ((Object)(object)instance != (Object)null && !_buildFailed) { TryBuild(instance); } if ((Object)(object)instance == (Object)null) { _buildFailed = false; } return; } if (_openWhenPaused && (Object)(object)instance != (Object)null && instance.IsPaused) { _openWhenPaused = false; Open(); } bool isOpen = ((MenuScreen)_screen).IsOpen; if (_wasOpen && !isOpen) { this.Closed?.Invoke(); } _wasOpen = isOpen; if (_fitIn > 0 && --_fitIn == 0) { PlaceHints(); } } public void Toggle() { PauseMenu instance = Singleton<PauseMenu>.Instance; if (!((Object)(object)_screen == (Object)null) && !((Object)(object)instance == (Object)null)) { if (((MenuScreen)_screen).IsOpen) { ((MenuScreen)_screen).Close(); } else if (!instance.IsPaused) { instance.Pause(); _openWhenPaused = true; } else { Open(); } } } public void Open() { if ((Object)(object)_screen == (Object)null) { return; } Refresh(); foreach (ScrollRect componentsInChild in UnityQuery.GetComponentsInChildren<ScrollRect>((Component)(object)_screen, includeInactive: true)) { componentsInChild.verticalNormalizedPosition = 1f; } _fitIn = 2; ((MenuScreen)_screen).Open(); } public void SetHidden(bool hidden) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_screenRect == (Object)null)) { _screenRect.anchoredPosition = (Vector2)(hidden ? new Vector2(0f, 100000f) : Vector2.zero); } } public void Refresh() { if ((Object)(object)_screen == (Object)null) { return; } Syncing = true; try { foreach (SettingsTab tab in _tabs) { foreach (SettingsRow row in tab.Rows) { row.Sync(); } } } finally { Syncing = false; } } internal void NotifyChanged() { Refresh(); this.Changed?.Invoke(); } private void TryBuild(PauseMenu pause) { try { Build(pause); } catch (Exception value) { _buildFailed = true; _screen = null; MelonLogger.Error($"{_title} window could not be built: {value}"); } } private void Build(PauseMenu pause) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected O, but got Unknown SettingsScreen val = ((IEnumerable<SettingsScreen>)UnityQuery.GetComponentsInChildren<SettingsScreen>((Component)(object)pause, includeInactive: true)).FirstOrDefault((Func<SettingsScreen, bool>)((SettingsScreen s) => !((Object)s).name.EndsWith("ModScreen", StringComparison.Ordinal) && ((Object)s).name != "WorldRatesScreen")) ?? throw new InvalidOperationException("in-game Settings screen not found"); GameObject val2 = new GameObject(_title + " Holder"); val2.SetActive(false); GameObject val3 = Object.Instantiate<GameObject>(((Component)val).gameObject, val2.transform); ((Object)val3).name = _screenName; SettingsScreen val4 = UiKit.Get<SettingsScreen>(val3); GameObject val5 = new GameObject("Unused"); val5.transform.SetParent(val3.transform, false); val5.SetActive(false); RowTemplates rowTemplates = new RowTemplates { Slider = FindRow(val3.transform, "Master"), Toggle = (FindRow(val3.transform, "VSync") ?? FindRow(val3.transform, "PauseOnLoseFocus")), Choice = FindRow(val3.transform, "Units"), Button = UiKit.Find(val3.transform, "ViewCommands"), Hint = UiKit.Find(val3.transform, "Hint") }; if ((Object)(object)rowTemplates.Slider == (Object)null) { throw new InvalidOperationException("slider template not found"); } StripSettingsBindings(val3.transform); Transform[] array = (Transform[])(object)new Transform[5] { rowTemplates.Slider, rowTemplates.Toggle, rowTemplates.Choice, rowTemplates.Button, rowTemplates.Hint }; foreach (Transform obj in array) { if (obj != null) { obj.SetParent(val5.transform, false); } } Transform val6 = UiKit.Find(val3.transform, "Blocker"); if ((Object)(object)val6 != (Object)null) { Object.DestroyImmediate((Object)(object)((Component)val6).gameObject); } Il2CppReferenceArray<SettingsCategory> categories = val4.Categories; for (int num2 = 0; num2 < ((Il2CppArrayBase<SettingsCategory>)(object)categories).Length; num2++) { Transform val7 = UiKit.Find(((Il2CppArrayBase<SettingsCategory>)(object)categories)[num2].Panel.transform, "Vertical Layout"); if ((Object)(object)val7 == (Object)null) { continue; } foreach (Transform item in UiKit.Children(val7)) { item.SetParent(val5.transform, false); } } val4.HostOnlyGameObjects = Il2CppReferenceArray<GameObject>.op_Implicit((GameObject[])(object)new GameObject[0]); SetText(val3.transform, "Title", _title); Transform val8 = UiKit.Find(val3.transform, "Version"); _subtitleLabel = ((val8 != null) ? UiKit.Get<TMP_Text>((Component)(object)val8) : null); if ((Object)(object)_subtitleLabel != (Object)null) { _subtitleLabel.text = _subtitle ?? ""; } for (int num3 = 0; num3 < ((Il2CppArrayBase<SettingsCategory>)(object)categories).Length; num3++) { Toggle toggle = ((Il2CppArrayBase<SettingsCategory>)(object)categories)[num3].Toggle; if (num3 >= _tabs.Count) { ((Component)toggle).gameObject.SetActive(false); continue; } TMP_Text val9 = UiKit.InChildren<TMP_Text>((Component)(object)toggle); if ((Object)(object)val9 != (Object)null) { val9.text = _tabs[num3].Title; } UiKit.AddListener(toggle, delegate(bool on) { if (on) { _fitIn = 2; } }); Transform val10 = UiKit.Find(((Il2CppArrayBase<SettingsCategory>)(object)categories)[num3].Panel.transform, "Vertical Layout"); if ((Object)(object)val10 == (Object)null) { continue; } foreach (SettingsRow row in _tabs[num3].Rows) { row.Build(val10, rowTemplates); } } val3.transform.SetParent(((Component)val).transform.parent, false); val3.transform.SetSiblingIndex(((Component)val).transform.GetSiblingIndex() + 1); Object.Destroy((Object)(object)val2); val3.SetActive(true); _screen = val4; _screenRect = UiKit.Get<RectTransform>(val3); if (_pauseButtonTitle != null) { AddPauseButton(pause); } Refresh(); MelonLogger.Msg(_title + " window ready"); } private static void StripSettingsBindings(Transform root) { foreach (MonoBehaviour componentsInChild in UnityQuery.GetComponentsInChildren<MonoBehaviour>((Component)(object)root, includeInactive: true)) { if (!((Object)(object)componentsInChild == (Object)null)) { string text = UiKit.Namespace((Component)(object)componentsInChild); string text2 = UnityQuery.TypeName((Object)(object)componentsInChild); if (text.EndsWith("ScheduleOne.UI.Settings", StringComparison.Ordinal) || text2 == "GameSettingsWindow" || text2 == "VersionText") { Object.DestroyImmediate((Object)(object)componentsInChild); } } } } private static Transform? FindRow(Transform root, string name) { Transform val = UiKit.Find(root, name); if (!((Object)(object)val != (Object)null) || !((Object)(object)val.parent != (Object)null) || !(((Object)val.parent).name == "Vertical Layout")) { return null; } return val; } private void AddPauseButton(PauseMenu pause) { Transform val = UiKit.Find((Transform)(object)pause.Container, "Panel"); Transform val2 = ((val != null) ? val.Find("Settings") : null); if (!((Object)(object)val == (Object)null) && !((Object)(object)val2 == (Object)null) && !((Object)(object)val.Find(_buttonName) != (Object)null)) { GameObject obj = Object.Instantiate<GameObject>(((Component)val2).gameObject, val, false); ((Object)obj).name = _buttonName; obj.transform.SetSiblingIndex(val2.GetSiblingIndex() + 1); TMP_Text val3 = UiKit.Get<TMP_Text>((Component)(object)obj.transform.Find("ButtonText")); if ((Object)(object)val3 != (Object)null) { val3.text = _pauseButtonTitle; } UiKit.OnClick(UiKit.Get<Button>(obj), Open); } } private void PlaceHints() { foreach (SettingsTab tab in _tabs) { foreach (SettingsRow row in tab.Rows) { row.PlaceHint(); } } } private static void SetText(Transform root, string name, string text) { Transform val = UiKit.Find(root, name); TMP_Text val2 = (((Object)(object)val != (Object)null) ? UiKit.Get<TMP_Text>((Component)(object)val) : null); if ((Object)(object)val2 != (Object)null) { val2.text = text; } } } internal sealed class SettingsTab { private readonly SettingsWindow _window; internal readonly List<SettingsRow> Rows = new List<SettingsRow>(); public string Title { get; } internal SettingsTab(SettingsWindow window, string title) { _window = window; Title = title; } public SettingsTab Slider(string label, string? hint, float min, float max, float step, Func<float> get, Action<float> set, Func<float, string> format) { Rows.Add(new SliderRow(_window, label, hint, min, max, step, get, set, format)); return this; } public SettingsTab Toggle(string label, string? hint, Func<bool> get, Action<bool> set) { Rows.Add(new ToggleRow(_window, label, hint, get, set)); return this; } public SettingsTab Choice(string label, string? hint, string[] options, Func<int> get, Action<int> set) { Rows.Add(new ChoiceRow(_window, label, hint, options, get, set)); return this; } public SettingsTab Button(string title, Action onClick) { Rows.Add(new ButtonRow(title, onClick)); return this; } public SettingsTab Text(string text, bool header = false) { Rows.Add(new TextRow(text, header)); return this; } } internal abstract class SettingsRow { protected TMP_Text? LabelText; protected RectTransform? HintRect; public abstract void Build(Transform layout, SettingsWindow.RowTemplates templates); public virtual void Sync() { } public void PlaceHint() { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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_007f: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)HintRect == (Object)null) && !((Object)(object)LabelText == (Object)null) && ((Behaviour)LabelText).isActiveAndEnabled) { LabelText.ForceMeshUpdate(false, false); Bounds textBounds = LabelText.textBounds; float x = ((Bounds)(ref textBounds)).size.x; Rect rect = LabelText.rectTransform.rect; float num = Mathf.Min(x, ((Rect)(ref rect)).width); HintRect.anchoredPosition = new Vector2(num + 8f, 0f); } } protected static GameObject Clone(Transform template, Transform layout, string name) { GameObject obj = Object.Instantiate<GameObject>(((Component)template).gameObject, layout, false); ((Object)obj).name = name; obj.SetActive(true); return obj; } protected void AddHint(Transform? template, TMP_Text label, string? hint) { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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) if (!((Object)(object)template == (Object)null) && !string.IsNullOrEmpty(hint)) { GameObject obj = Object.Instantiate<GameObject>(((Component)template).gameObject, label.transform, false); obj.SetActive(true); Tooltip val = UiKit.Get<Tooltip>(obj); if ((Object)(object)val != (Object)null) { val.text = hint; } RectTransform val2 = UiKit.Get<RectTransform>(obj); Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(0f, 0.5f); val2.anchorMax = val3; val2.anchorMin = val3; val2.pivot = new Vector2(0f, 0.5f); val2.anchoredPosition = new Vector2(label.preferredWidth + 8f, 0f); HintRect = val2; } } private static float LeftEdgeIn(Transform row, RectTransform control) { //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_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) Rect rect = control.rect; float num = ((Rect)(ref rect)).xMin; Transform val = (Transform)(object)control; while ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)row) { num = val.localPosition.x + val.localScale.x * num; val = val.parent; } return num; } internal static void FitLabelColumn(Transform row, TMP_Text label, RectTransform control, bool roomForHint = true) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: 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_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) RectTransform val = UiKit.Get<RectTransform>((Component)(object)row); RectTransform rectTransform = label.rectTransform; float x = ((Transform)rectTransform).localPosition.x; Rect rect = rectTransform.rect; float num = x + ((Rect)(ref rect)).xMin; float num2 = LeftEdgeIn(row, control) - (roomForHint ? 30f : 12f); rect = rectTransform.rect; float height = ((Rect)(ref rect)).height; float y = ((Transform)rectTransform).localPosition.y; rect = rectTransform.rect; float num3 = y + ((Rect)(ref rect)).center.y; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(0f, 0.5f); rectTransform.anchorMax = val2; rectTransform.anchorMin = val2; rectTransform.pivot = new Vector2(0f, 0.5f); rectTransform.sizeDelta = new Vector2(Mathf.Max(60f, num2 - num), height); rect = val.rect; float num4 = num - ((Rect)(ref rect)).xMin; rect = val.rect; rectTransform.anchoredPosition = new Vector2(num4, num3 - ((Rect)(ref rect)).center.y); label.textWrappingMode = (TextWrappingModes)0; label.fontSizeMax = label.fontSize; label.fontSizeMin = label.fontSize * 0.6f; label.enableAutoSizing = true; } } internal sealed class SliderRow : SettingsRow { private readonly SettingsWindow _window; private readonly string _label; private readonly string? _hint; private readonly float _min; private readonly float _max; private readonly float _step; private readonly Func<float> _get; private readonly Action<float> _set; private readonly Func<float, string> _format; private Slider? _slider; private TMP_Text? _value; public SliderRow(SettingsWindow window, string label, string? hint, float min, float max, float step, Func<float> get, Action<float> set, Func<float, string> format) { _window = window; _label = label; _hint = hint; _min = min; _max = max; _step = step; _get = get; _set = set; _format = format; } public override void Build(Transform layout, SettingsWindow.RowTemplates templates) { GameObject obj = SettingsRow.Clone(templates.Slider, layout, _label); UISlider val = UiKit.Get<UISlider>(obj); if ((Object)(object)val != (Object)null) { UiKit.SetMember(val, "optionName", _label); UiKit.SetMember(val, "canUpdateValueText", false); } TMP_Text val2 = UiKit.Get<TMP_Text>((Component)(object)obj.transform.Find("Label")); val2.text = _label; Slider val3 = UiKit.InChildren<Slider>((Component)(object)obj.transform); SettingsRow.FitLabelColumn(obj.transform, val2, UiKit.Get<RectTransform>((Component)(object)((Component)val3).transform)); _value = UiKit.Get<TMP_Text>((Component)(object)((Component)val3).transform.Find("Value")); val3.wholeNumbers = true; val3.minValue = Mathf.Round(_min / _step); val3.maxValue = Mathf.Round(_max / _step); UiKit.OnValueChanged(val3, delegate(float v) { if (!_window.Syncing) { _set(v * _step); _window.NotifyChanged(); } }); _slider = val3; LabelText = val2; AddHint(templates.Hint, val2, _hint); } public override void Sync() { if (!((Object)(object)_slider == (Object)null)) { float num = _get(); _slider.value = Mathf.Round(num / _step); if ((Object)(object)_value != (Object)null) { _value.text = _format(num); } } } } internal sealed class ToggleRow : SettingsRow { private readonly SettingsWindow _window; private readonly string _label; private readonly string? _hint; private readonly Func<bool> _get; private readonly Action<bool> _set; private UIToggle? _toggle; public ToggleRow(SettingsWindow window, string label, string? hint, Func<bool> get, Action<bool> set) { _window = window; _label = label; _hint = hint; _get = get; _set = set; } public override void Build(Transform layout, SettingsWindow.RowTemplates templates) { if (!((Object)(object)templates.Toggle == (Object)null)) { GameObject val = SettingsRow.Clone(templates.Toggle, layout, _label); UIToggle val2 = UiKit.Get<UIToggle>(val); UiKit.SetMember(val2, "optionName", _label); TMP_Text val3 = UnityQuery.GetComponentsInChildren<TMP_Text>((Component)(object)val.transform, includeInactive: true).First((TMP_Text t) => ((Object)t).name.StartsWith("Option Name", StringComparison.Ordinal)); val3.text = _label; Transform val4 = val.transform.Find("Toggle (OffOn)"); if ((Object)(object)val4 != (Object)null) { SettingsRow.FitLabelColumn(val.transform, val3, UiKit.Get<RectTransform>((Component)(object)val4)); } val2.OnChanged.AddListener(DelegateSupport.ConvertDelegate<UnityAction<bool>>((Delegate)new Action<bool>(OnChanged))); _toggle = val2; LabelText = val3; AddHint(templates.Hint, val3, _hint); } } private void OnChanged(bool value) { if (!_window.Syncing) { _set(value); _window.NotifyChanged(); } } public override void Sync() { UIToggle? toggle = _toggle; if (toggle != null) { toggle.SetStateWithoutNotify(_get()); } } } internal sealed class ChoiceRow : SettingsRow { private readonly SettingsWindow _window; private readonly string _label; private readonly string? _hint; private readonly string[] _options; private readonly Func<int> _get; private readonly Action<int> _set; private TMP_Dropdown? _dropdown; public ChoiceRow(SettingsWindow window, string label, string? hint, string[] options, Func<int> get, Action<int> set) { _window = window; _label = label; _hint = hint; _options = options; _get = get; _set = set; } public override void Build(Transform layout, SettingsWindow.RowTemplates templates) { //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Expected O, but got Unknown if (!((Object)(object)templates.Choice == (Object)null)) { GameObject obj = SettingsRow.Clone(templates.Choice, layout, _label); TMP_Dropdown val = UnityQuery.GetComponentsInChildren<TMP_Dropdown>((Component)(object)obj.transform, includeInactive: true).First(); TMP_Text val2 = UnityQuery.GetComponentsInChildren<TMP_Text>((Component)(object)obj.transform, includeInactive: true).First((TMP_Text t) => ((Object)t).name.StartsWith("Option Name", StringComparison.Ordinal)); val2.text = _label; SettingsRow.FitLabelColumn(obj.transform, val2, UiKit.Get<RectTransform>((Component)(object)((Component)val).transform)); ((UnityEventBase)val.onValueChanged).RemoveAllListeners(); val.ClearOptions(); string[] options = _options; foreach (string text in options) { val.options.Add(new OptionData(text)); } ((UnityEvent<int>)(object)val.onValueChanged).AddListener(DelegateSupport.ConvertDelegate<UnityAction<int>>((Delegate)new Action<int>(OnSelected))); _dropdown = val; LabelText = val2; AddHint(templates.Hint, val2, _hint); } } private void OnSelected(int index) { if (!_window.Syncing && index >= 0 && index < _options.Length) { _set(index); _window.NotifyChanged(); } } public override void Sync() { if (!((Object)(object)_dropdown == (Object)null)) { _dropdown.SetValueWithoutNotify(Mathf.Clamp(_get(), 0, _options.Length - 1)); _dropdown.RefreshShownValue(); } } } internal sealed class ButtonRow : SettingsRow { private const float ButtonWidth = 460f; private readonly string _title; private readonly Action _onClick; public ButtonRow(string title, Action onClick) { _title = title; _onClick = onClick; } public override void Build(Transform layout, SettingsWindow.RowTemplates templates) { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)templates.Button == (Object)null)) { GameObject val = SettingsRow.Clone(templates.Button, layout, "Button " + _title); TMP_Text val2 = UiKit.InChildren<TMP_Text>((Component)(object)val.transform); if ((Object)(object)val2 != (Object)null) { val2.text = _title; val2.enableAutoSizing = true; val2.fontSizeMax = val2.fontSize; val2.fontSizeMin = val2.fontSize * 0.65f; } RectTransform val3 = UiKit.Get<RectTransform>(val); val3.sizeDelta = new Vector2(Mathf.Max(val3.sizeDelta.x, 460f), val3.sizeDelta.y); LayoutElement? obj = UiKit.Get<LayoutElement>(val) ?? val.AddComponent<LayoutElement>(); float minWidth = (obj.preferredWidth = 460f); obj.minWidth = minWidth; UiKit.OnClick(UiKit.Get<Button>(val), _onClick); } } } internal sealed class TextRow : SettingsRow { private readonly string _text; private readonly bool _header; public TextRow(string text, bool header) { _text = text; _header = header; } public override void Build(Transform layout, SettingsWindow.RowTemplates templates) { //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) GameObject obj = SettingsRow.Clone(templates.Slider, layout, _header ? "Header" : "Text"); UISlider val = UiKit.Get<UISlider>(obj); if ((Object)(object)val != (Object)null) { Object.DestroyImmediate((Object)(object)val); } Slider val2 = UiKit.InChildren<Slider>((Component)(object)obj.transform); if ((Object)(object)val2 != (Object)null) { Object.DestroyImmediate((Object)(object)((Component)val2).gameObject); } TMP_Text val3 = UiKit.Get<TMP_Text>((Component)(object)obj.transform.Find("Label")); RectTransform rectTransform = val3.rectTransform; rectTransform.anchorMin = new Vector2(0f, rectTransform.anchorMin.y); rectTransform.anchorMax = new Vector2(1f, rectTransform.anchorMax.y); rectTransform.offsetMax = new Vector2(-10f, rectTransform.offsetMax.y); val3.textWrappingMode = (TextWrappingModes)1; if (_header) { val3.fontStyle = (FontStyles)(val3.fontStyle | 1); } else { val3.fontStyle = (FontStyles)(val3.fontStyle | 2); } val3.text = _text; } } internal static class SpriteKit { private static readonly Dictionary<int, Sprite> Rounded = new Dictionary<int, Sprite>(); private static Sprite? _glow; private static Sprite? _arrow; public static Sprite RoundedRect(int radius) { //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) if (Rounded.TryGetValue(radius, out Sprite value) && (Object)(object)value != (Object)null) { return value; } int num = radius * 2 + 4; Color32[] array = (Color32[])(object)new Color32[num * num]; Rect val = default(Rect); ((Rect)(ref val))..ctor((float)radius + 0.5f, (float)radius + 0.5f, (float)(num - 2 * radius) - 1f, (float)(num - 2 * radius) - 1f); for (int i = 0; i < num; i++) { for (int j = 0; j < num; j++) { float num2 = (float)j + 0.5f; float num3 = (float)i + 0.5f; float num4 = Mathf.Max(new float[3] { ((Rect)(ref val)).xMin - num2, 0f, num2 - ((Rect)(ref val)).xMax }); float num5 = Mathf.Max(new float[3] { ((Rect)(ref val)).yMin - num3, 0f, num3 - ((Rect)(ref val)).yMax }); float num6 = Mathf.Sqrt(num4 * num4 + num5 * num5); float num7 = Mathf.Clamp01((float)radius - num6 + 0.5f); array[i * num + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)(num7 * 255f)); } } float num8 = (float)radius + 1f; Sprite val2 = MakeSprite("Rounded" + radius, num, num, array, new Vector4(num8, num8, num8, num8)); Rounded[radius] = val2; return val2; } public static Sprite Glow() { //IL_00d1: 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) if ((Object)(object)_glow != (Object)null) { return _glow; } Color32[] array = (Color32[])(object)new Color32[4096]; for (int i = 0; i < 64; i++) { for (int j = 0; j < 64; j++) { float num = ((float)j + 0.5f) / 64f * 2f - 1f; float num2 = ((float)i + 0.5f) / 64f * 2f - 1f; float num3 = Mathf.Clamp01(Mathf.Sqrt(num * num + num2 * num2)); float num4 = (1f - num3) * (1f - num3); array[i * 64 + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)(num4 * 255f)); } } _glow = MakeSprite("Glow", 64, 64, array, Vector4.zero); return _glow; } public static Sprite FlatArrow() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0133: 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_010c: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_arrow != (Object)null) { return _arrow; } Vector2[] poly = (Vector2[])(object)new Vector2[4] { new Vector2(32f, 62f), new Vector2(58f, 6f), new Vector2(32f, 20f), new Vector2(6f, 6f) }; Color32[] array = (Color32[])(object)new Color32[4096]; for (int i = 0; i < 64; i++) { for (int j = 0; j < 64; j++) { int num = 0; for (int k = 0; k < 4; k++) { for (int l = 0; l < 4; l++) { if (Inside(poly, new Vector2((float)j + ((float)l + 0.5f) / 4f, (float)i + ((float)k + 0.5f) / 4f))) { num++; } } } array[i * 64 + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)(num * 255 / 16)); } } _arrow = MakeSprite("FlatArrow", 64, 64, array, Vector4.zero); return _arrow; } private static bool Inside(Vector2[] poly, Vector2 p) { //IL_001b: 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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) bool flag = false; int num = 0; int num2 = poly.Length - 1; while (num < poly.Length) { if (poly[num].y > p.y != poly[num2].y > p.y && p.x < (poly[num2].x - poly[num].x) * (p.y - poly[num].y) / (poly[num2].y - poly[num].y) + poly[num].x) { flag = !flag; } num2 = num++; } return flag; } private static Sprite MakeSprite(string name, int width, int height, Color32[] pixels, Vector4 border) { //IL_0004: 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_001a: 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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(width, height, (TextureFormat)4, false) { name = "S1Mods " + name, filterMode = (FilterMode)1, wrapMode = (TextureWrapMode)1, hideFlags = (HideFlags)61 }; val.SetPixels32(Il2CppStructArray<Color32>.op_Implicit(pixels)); val.Apply(false, true); Sprite obj = Sprite.Create(val, new Rect(0f, 0f, (float)width, (float)height), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0, border); ((Object)obj).name = ((Object)val).name; ((Object)obj).hideFlags = (HideFlags)61; return obj; } } } namespace GuideArrows { internal enum ArrowMode { PerKind, Nearest, NearestFew } internal static class Config { public static PrefsFile Prefs = null; public static Setting<bool> Enabled = null; public static Setting<KeyCode> ToggleKey = null; public static Setting<int> Mode = null; public static Setting<int> MaxArrows = null; public static Setting<float> PosX = null; public static Setting<float> PosY = null; public static Setting<float> Scale = null; public static Setting<int> Size = null; public static Setting<int> Spacing = null; public static Setting<int> ViewAngle = null; public static Setting<bool> PitchToTarget = null; public static Setting<float> TurnSpeed = null; public static Setting<int> Opacity = null; public static Setting<bool> ShowDistance = null; public static Setting<bool> ShowLabels = null; public static Setting<int> HideWithin = null; public static Setting<int> MaxDistance = null; public static Setting<bool> QuestsTrackedOnly = null; public static Setting<int> HomeMode = null; private static readonly Dictionary<TargetKind, Setting<bool>> KindOn = new Dictionary<TargetKind, Setting<bool>>(); private static readonly Dictionary<TargetKind, Setting<int>> KindColor = new Dictionary<TargetKind, Setting<int>>(); public static readonly Vector2 DefaultPos = new Vector2(0.5f, 0.87f); public static ArrowMode ArrowMode => (ArrowMode)Mathf.Clamp(Mode.Value, 0, 2); public static void Init() { Prefs = new PrefsFile("GuideArrows"); Enabled = Prefs.Add("Enabled", defaultValue: true, "Show the arrows."); ToggleKey = Prefs.Add<KeyCode>("ToggleKey", (KeyCode)288, "Key that shows/hides the arrows. None disables it."); Mode = Prefs.Add("Mode", 0, "0 = one arrow per kind (the nearest of each), 1 = a single arrow to the nearest target, 2 = arrows to the nearest few targets."); MaxArrows = Prefs.Add("MaxArrows", 5, "Most arrows shown at once."); PosX = Prefs.Add("PositionX", DefaultPos.x, "Horizontal position of the arrows (0 = left, 1 = right)."); PosY = Prefs.Add("PositionY", DefaultPos.y, "Vertical position of the arrows (0 = bottom, 1 = top). Default: under the compass."); Scale = Prefs.Add("Scale", 1f, "Overall size of the arrow row."); Size = Prefs.Add("ArrowSize", 76, "Size of one arrow."); Spacing = Prefs.Add("Spacing", 18, "Space between arrows."); ViewAngle = Prefs.Add("ViewAngle", 52, "How steeply the arrows are seen from above (degrees)."); PitchToTarget = Prefs.Add("PitchToTarget", defaultValue: true, "Tilt the arrow up or down towards targets above or below you."); TurnSpeed = Prefs.Add("TurnSpeed", 7f, "How quickly arrows turn to a new direction."); Opacity = Prefs.Add("Opacity", 95, "Arrow opacity in percent."); ShowDistance = Prefs.Add("ShowDistance", defaultValue: true, "Show the distance under each arrow."); ShowLabels = Prefs.Add("ShowLabels", defaultValue: false, "Show what the arrow points at (customer, quest, stash...)."); HideWithin = Prefs.Add("HideWithin", 6, "Hide an arrow once you are closer than this (meters)."); MaxDistance = Prefs.Add("MaxDistance", 0, "Ignore targets further away than this (meters). 0 = no limit."); QuestsTrackedOnly = Prefs.Add("QuestsTrackedOnly", defaultValue: true, "Quest arrows only for quests you track in the journal."); HomeMode = Prefs.Add("HomeMode", 0, "Home base: 0 = where you last slept (else the most equipped property), 1 = only where you last slept, 2 = the property with the most valuable equipment."); TargetKind[] all = TargetKinds.All; for (int i = 0; i < all.Length; i++) { TargetKind targetKind = all[i]; KindOn[targetKind] = Prefs.Add("Show" + targetKind, defaultValue: true, "Arrows to " + TargetKinds.Name(targetKind).ToLowerInvariant() + "."); KindColor[targetKind] = Prefs.Add("Color" + targetKind, TargetKinds.DefaultColor(targetKind), "Color: 0 green, 1 red, 2 orange, 3 yellow, 4 purple, 5 blue, 6 cyan, 7 pink, 8 white."); } } public static bool KindEnabled(TargetKind kind) { return KindOn[kind].Value; } public static Setting<bool> KindSetting(TargetKind kind) { return KindOn[kind]; } public static Setting<int> ColorSetting(TargetKind kind) { return KindColor[kind]; } public static Color ColorOf(TargetKind kind) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) return Palette.Get(KindColor[kind].Value); } } public sealed class GuideArrowsMod : MelonMod { private CoRunner _runner; private string? _lastError; internal static bool SmokeActive { get; private set; } internal static HudCanvas Canvas { get; private set; } internal static ArrowStrip Strip { get; private set; } internal static SettingsWindow Window { get; private set; } internal static HudEditor Editor { get; private set; } public override void OnInitializeMelon() { SafePatcher.Apply(((MelonBase)this).HarmonyInstance, ((MelonBase)this).LoggerInstance); Config.Init(); Canvas = new HudCanvas("GuideArrows HUD"); Strip = new ArrowStrip(Canvas); Window = SettingsUi.Create(delegate { Editor.Begin(); }, delegate { Window.Refresh(); Strip.Element.Apply(); }); Editor = new HudEditor(Canvas, Window, new HudElement[1] { Strip.Element }); Editor.Started += delegate { Strip.Preview = true; }; Editor.Finished += delegate { Strip.Preview = false; }; _runner = new CoRunner(delegate(Exception ex) { ((MelonBase)this).LoggerInstance.Error((object)ex); }); ((MelonBase)this).LoggerInstance.Msg("GuideArrows 1.0.1 loaded"); } public override void OnUpdate() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) _runner.Tick(); HomeTracker.Tick(); Window.Tick(); Editor.Tick(); Config.Prefs.Tick(); if (Keys.Down(Config.ToggleKey.Value) && (Object)(object)Player.Local != (Object)null) { Config.Enabled.Value = !Config.Enabled.Value; Window.Refresh(); } } public override void OnLateUpdate() { try { if (Canvas.Tick()) { TargetScanner.Tick(Time.unscaledTime); Strip.Tick(MainCamera()); } } catch (Exception ex) { if (_lastError != ex.Message) { ((MelonBase)this).LoggerInstance.Warning($"Arrow update failed: {ex}"); } _lastError = ex.Message; } } public override void OnSceneWasLoaded(int buildIndex, string sceneName) { Strip.Clear(); } public override void OnApplicationQuit() { if (Config.Prefs.SavingDisabled) { Config.Prefs.RestoreLoadedValues(); } else { Config.Prefs.SaveNow(); } } internal static Camera? MainCamera() { PlayerCamera instance = PlayerSingleton<PlayerCamera>.Instance; if (!((Object)(object)instance != (Object)null)) { return Camera.main; } return instance.Camera; } } internal static class ModInfo { public const string Name = "GuideArrows"; public const string Version = "1.0.1"; public const string Author = "BbIJABNPOBATEJb"; public const string DownloadLink = "https://github.com/BbIJABNPOBATEJb/ScheduleI-Mods"; } } namespace GuideArrows.UI { internal sealed class ArrowStrip { private sealed class ArrowView { public string Key = ""; public TargetKind Kind; public Target? Target; public RectTransform Root; public CanvasGroup Group; public RawImage Image; public Image Flat; public Image Shadow; public TextMeshProUGUI Distance; public TextMeshProUGUI Label; public ArrowRenderer? Renderer; public float Yaw; public float YawVelocity; public float Pitch; public float PitchVelocity; public float Alpha; public float X; public float TargetX; public bool Wanted; public bool Placed; public float PulseAt = -10f; } private const float TextHeight = 38f; private readonly HudCanvas _canvas; private readonly List<ArrowView> _views = new List<ArrowView>(); private readonly List<(Target Target, float Distance)> _chosen = new List<(Target, float)>(); private RectTransform? _root; public HudElement Element { get; } public bool Preview { get; set; } public int VisibleCount => _views.Count((ArrowView v) => v.Wanted); public ArrowStrip(HudCanvas canvas) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) _canvas = canvas; Element = new HudElement("Guide arrows", Config.DefaultPos, 1f, () => new Vector2(Config.PosX.Value, Config.PosY.Value), delegate(Vector2 p) { //IL_0005: 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) Config.PosX.Value = p.x; Config.PosY.Value = p.y; }, () => Config.Scale.Value, delegate(float s) { Config.Scale.Value = s; }); } public void Clear() { foreach (ArrowView view in _views) { Destroy(view); } _views.Clear(); } public void Tick(Camera? camera) { //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_canvas.Root == (Object)null) { return; } if ((Object)(object)_root == (Object)null) { _root = _canvas.NewRect("Guide Arrows"); Element.Rect = _root; } Element.Apply(); float num = Config.Size.Value; float num2 = Config.Spacing.Value; Player local = Player.Local; bool flag = Preview || (Config.Enabled.Value && (Object)(object)camera != (Object)null && (Object)(object)local != (Object)null && CompassVisible()); _chosen.Clear(); if (Preview) { ChoosePreview(); } else if (flag) { Choose(((Component)local).transform.position); } foreach (ArrowView view in _views) { view.Wanted = false; } int num3 = 0; foreach (var item2 in _chosen) { Target item = item2.Target; string key = ((Config.ArrowMode == ArrowMode.PerKind || Preview) ? ("kind:" + item.Kind) : item.Key); ArrowView arrowView = _views.FirstOrDefault((ArrowView v) => v.Key == key) ?? Create(key); if (arrowView.Target == null || arrowView.Target.Key != item.Key) { arrowView.PulseAt = Time.unscaledTime; } arrowView.Target = item; arrowView.Kind = item.Kind; arrowView.Wanted = true; arrowView.TargetX = ((float)num3 - (float)(_chosen.Count - 1) * 0.5f) * (num + num2); if (!arrowView.Placed) { arrowView.X = arrowView.TargetX; arrowView.Placed = true; } num3++; } _root.sizeDelta = new Vector2((float)Mathf.Max(1, _chosen.Count) * (num + num2), num + 38f); float unscaledDeltaTime = Time.unscaledDeltaTime; for (int num4 = _views.Count - 1; num4 >= 0; num4--) { ArrowView arrowView2 = _views[num4]; arrowView2.Alpha = Mathf.MoveTowards(arrowView2.Alpha, (arrowView2.Wanted && flag) ? 1f : 0f, unscaledDeltaTime / 0.25f); if (arrowView2.Alpha <= 0f && !arrowView2.Wanted) { Destroy(arrowView2); _views.RemoveAt(num4); } else { arrowView2.X = Mathf.Lerp(arrowView2.X, arrowView2.TargetX, 1f - Mathf.Exp(-10f * unscaledDeltaTime)); UpdateView(arrowView2, camera, num); } } } private void Choose(Vector3 from) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) int value = Config.HideWithin.Value; int value2 = Config.MaxDistance.Value; List<(Target, float)> list = new List<(Target, float)>(); foreach (Target target in TargetScanner.Targets) { float num = Vector3.Distance(from, target.Position); if (!(num < (float)value) && (value2 <= 0 || !(num > (float)value2))) { list.Add((target, num)); } } int num2 = Mathf.Clamp(Config.MaxArrows.Value, 1, 8); switch (Config.ArrowMode) { case ArrowMode.PerKind: { TargetKind[] all = TargetKinds.All; foreach (TargetKind kind in all) { (Target, float) item = (from c in list where c.Item1.Kind == kind orderby c.Item2 select c).FirstOrDefault(); if (item.Item1 != null && _chosen.Count < num2) { _chosen.Add(item); } } break; } case ArrowMode.Nearest: { (Target, float) item2 = list.OrderBy(((Target, float) c) => c.Item2).FirstOrDefault(); if (item2.Item1 != null) { _chosen.Add(item2); } break; } default: _chosen.AddRange(from c in list.OrderBy(((Target, float) c) => c.Item2).Take(num2) orderby (int)c.Item1.Kind, c.Item2 select c); break; } } private void ChoosePreview() { TargetKind[] all = TargetKinds.All; for (int i = 0; i < all.Length; i++) { TargetKind targetKind = all[i]; if (Config.KindEnabled(targetKind)) { _chosen.Add((new Target { Kind = targetKind, Key = "preview:" + targetKind, Label = TargetKinds.Name(targetKind) }, 40f + 90f * (float)targetKind)); } } } private void UpdateView(ArrowView view, Camera? camera, float size) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_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_00e0: 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_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_0265: 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_015b: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) Target target = view.Target; view.Group.alpha = view.Alpha * Mathf.Clamp01((float)Config.Opacity.Value / 100f); view.Root.anchoredPosition = new Vector2(view.X, 19f); view.Root.sizeDelta = new Vector2(size, size); if (target == null) { return; } float num; float num2; float meters; if (Preview) { num = Time.unscaledTime * 40f + (float)view.Kind * 72f; num2 = 0f; meters = 40f + 90f * (float)view.Kind; } else { if (!((Object)(object)camera != (Object)null)) { return; } Vector3 position = ((Component)camera).transform.position; Vector3 val = target.Position - position; Vector3 val2 = Flat(((Component)camera).transform.forward); Vector3 val3 = Flat(val); num = Vector3.SignedAngle(val2, val3, Vector3.up); Vector2 val4 = new Vector2(val.x, val.z); float magnitude = ((Vector2)(ref val4)).magnitude; num2 = (Config.PitchToTarget.Value ? (Mathf.Clamp(Mathf.Atan2(val.y, magnitude) * 57.29578f, -45f, 45f) * 0.8f) : 0f); Player local = Player.Local; meters = Vector3.Distance(((Object)(object)local != (Object)null) ? ((Component)local).transform.position : position, target.Position); } float num3 = 1f / Mathf.Max(0.5f, Config.TurnSpeed.Value); view.Yaw = Mathf.SmoothDampAngle(view.Yaw, num, ref view.YawVelocity, num3, float.PositiveInfinity, Time.unscaledDeltaTime); view.Pitch = Mathf.SmoothDampAngle(view.Pitch, num2, ref view.PitchVelocity, num3, float.PositiveInfinity, Time.unscaledDeltaTime); Color color = Config.ColorOf(view.Kind); float num4 = Mathf.Clamp01(1f - (Time.unscaledTime - view.PulseAt) / 0.35f); float num5 = 1f + 0.18f * Mathf.Sin(num4 * (float)Math.PI); if (view.Renderer != null) { int size2 = Mathf.RoundToInt(size * Element.Scale * Mathf.Max(1f, _canvas.ScaleFactor) * 1.3f); view.Renderer.Render(size2, color, view.Yaw, view.Pitch, Config.ViewAngle.Value, num5); view.Image.texture = (Texture)(object)view.Renderer.Texture; } else { ((Graphic)view.Flat).color = color; ((Transform)((Graphic)view.Flat).rectTransform).localRotation = Quaternion.Euler(0f, 0f, 0f - view.Yaw); ((Transform)((Graphic)view.Flat).rectTransform).localScale = Vector3.one * (0.7f * num5); } ((Component)view.Distance).gameObject.SetActive(Config.ShowDistance.Value); if (Config.ShowDistance.Value) { ((TMP_Text)view.Distance).text = FormatDistance(meters); } string text = (Config.ShowLabels.Value ? LabelFor(target) : ""); ((Component)view.Label).gameObject.SetActive(text.Length > 0); if (text.Length > 0) { ((TMP_Text)view.Label).text = text; } } private static string LabelFor(Target target) { if (!string.IsNullOrEmpty(target.Label)) { return target.Label; } return TargetKinds.Name(target.Kind); } private ArrowView Create(string key) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: 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_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Unknown result type (might be due to invalid IL or missing references) ArrowView arrowView = new ArrowView { Key = key }; arrowView.Root = _canvas.NewRect("Arrow " + key, (Transform?)(object)_root); RectTransform root = arrowView.Root; RectTransform root2 = arrowView.Root; Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(0.5f, 0.5f); root2.anchorMax = val; root.anchorMin = val; arrowView.Root.pivot = new Vector2(0.5f, 0.5f); arrowView.Group = ((Component)arrowView.Root).gameObject.AddComponent<CanvasGroup>(); arrowView.Group.blocksRaycasts = false; arrowView.Group.alpha = 0f; arrowView.Shadow = _canvas.NewImage("Shadow", (Transform?)(object)arrowView.Root, new Color(0f, 0f, 0f, 0.28f), SpriteKit.Glow()); RectTransform rectTransform = ((Graphic)arrowView.Shadow).rectTransform; rectTransform.anchorMin = new Vector2(0.08f, 0.12f); rectTransform.anchorMax = new Vector2(0.92f, 0.52f); val = (rectTransform.offsetMin = (rectTransform.offsetMax = Vector2.zero)); RectTransform val3 = _canvas.NewRect("Arrow", (Transform?)(object)arrowView.Root); Stretch(val3); arrowView.Image = ((Component)val3).gameObject.AddComponent<RawImage>(); ((Graphic)arrowView.Image).raycastTarget = false; arrowView.Flat = _canvas.NewImage("Flat", (Transform?)(object)arrowView.Root, Color.white, SpriteKit.FlatArrow()); Stretch(((Graphic)arrowView.Flat).rectTransform); if (ArrowRenderer.Supported) { arrowView.Renderer = new ArrowRenderer(); ((Component)arrowView.Flat).gameObject.SetActive(false); } else { ((Component)arrowView.Image).gameObject.SetActive(false); } arrowView.Distance = _canvas.NewText("Distance", (Transform?)(object)arrowView.Root, 17f, Color.white); RectTransform rectTransform2 = ((TMP_Text)arrowView.Distance).rectTransform; ((Vector2)(ref val))..ctor(0.5f, 0f); rectTransform2.anchorMax = val; rectTransform2.anchorMin = val; rectTransform2.pivot = new Vector2(0.5f, 1f); rectTransform2.anchoredPosition = new Vector2(0f, 4f); rectTransform2.sizeDelta = new Vector2(120f, 22f); ((TMP_Text)arrowView.Distance).fontStyle = (FontStyles)1; arrowView.Label = _canvas.NewText("Label", (Transform?)(object)arrowView.Root, 14f, new Color(1f, 1f, 1f, 0.85f)); RectTransform rectTransform3 = ((TMP_Text)arrowView.Label).rectTransform; ((Vector2)(ref val))..ctor(0.5f, 0f); rectTransform3.anchorMax = val; rectTransform3.anchorMin = val; rectTransform3.pivot = new Vector2(0.5f, 1f); rectTransform3.anchoredPosition = new Vector2(0f, -15f); rectTransform3.sizeDelta = new Vector2(140f, 20f); ((TMP_Text)arrowView.Label).overflowMode = (TextOverflowModes)1; _views.Add(arrowView); return arrowView; } private static void Destroy(ArrowView view) { view.Renderer?.Dispose(); if ((Object)(object)view.Root != (Object)null) { Object.Destroy((Object)(object)((Component)view.Root).gameObject); } } private static bool CompassVisible() { CompassManager instance = Singleton<CompassManager>.Instance; if (!((Object)(object)instance == (Object)null) && !((Object)(object)instance.Container == (Object)null)) { return ((Component)instance.Container).gameObject.activeSelf; } return true; } private static string FormatDistance(float meters) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Invalid comparison between Unknown and I4 bool flag = false; try { Settings instance = Singleton<Settings>.Instance; flag = (Object)(object)instance != (Object)null && (int)instance.UnitType == 1; } catch (Exception) { } if (flag) { float num = meters * 3.28084f; if (!(num >= 2640f)) { return Mathf.RoundToInt(num) + " ft"; } return (num / 5280f).ToString("0.0", CultureInfo.InvariantCulture) + " mi"; } if (!(meters >= 1000f)) { return Mathf.RoundToInt(meters) + " m"; } return (meters / 1000f).ToString("0.0", CultureInfo.InvariantCulture) + " km"; } private static Vector3 Flat(Vector3 v) { //IL_0022: 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) v.y = 0f; if (!(((Vector3)(ref v)).sqrMagnitude > 1E-06f)) { return Vector3.forward; } return ((Vector3)(ref v)).normalized; } private static void Stretch(RectTransform r) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_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_001e: 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) r.anchorMin = Vector2.zero; r.anchorMax = Vector2.one; Vector2 offsetMin = (r.offsetMax = Vector2.zero); r.offsetMin = offsetMin; } } internal static class SettingsUi { public static SettingsWindow Create(Action editLayout, Action afterReset) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) SettingsWindow settingsWindow = new SettingsWindow("GuideArrows", "Guide Arrows", "Guide Arrows"); settingsWindow.Tab("General").Toggle("Show arrows", "Also toggled with the " + ((object)Config.ToggleKey.Value/*cast due to .constrained prefix*/).ToString() + " key (see UserData/MelonPreferences.cfg).", () => Config.Enabled.Value, delegate(bool v) { Config.Enabled.Value = v; }).Choice("Arrows", "One arrow per kind points at the nearest target of each kind; or a single arrow to the nearest target of any kind; or arrows to the nearest few.", new string[3] { "One per kind", "Nearest only", "Nearest few" }, () => Config.Mode.Value, delegate(int v) { Config.Mode.Value = v; }) .Slider("Max arrows", null, 1f, 8f, 1f, () => Config.MaxArrows.Value, delegate(float v) { Config.MaxArrows.Value = Mathf.RoundToInt(v); }, Whole) .Slider("Hide when closer than", "An arrow disappears once you are this close to its target.", 0f, 50f, 1f, () => Config.HideWithin.Value, delegate(float v) { Config.HideWithin.Value = Mathf.RoundToInt(v); }, Meters) .Slider("Ignore further than", "Targets further away get no arrow. Off = no limit.", 0f, 2000f, 50f, () => Config.MaxDistance.Value, delegate(float v) { Config.MaxDistance.Value = Mathf.RoundToInt(v); }, (float v) => (!(v <= 0f)) ? Meters(v) : "Off") .Button("Move and resize the arrows", editLayout) .Button("Reset all settings", delegate { Config.Prefs.ResetAll(); afterReset();