Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of WesleysJourneyMap v0.5.0
WesleysJourneyMap.dll
Decompiled 2 hours agousing 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.RegularExpressions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LethalLevelLoader; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("WesleysJourneyMap")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.5.0.0")] [assembly: AssemblyInformationalVersion("0.5.0")] [assembly: AssemblyProduct("WesleysJourneyMap")] [assembly: AssemblyTitle("WesleysJourneyMap")] [assembly: AssemblyVersion("0.5.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [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 WesleysJourneyMap { public struct Rgba { public byte R; public byte G; public byte B; public byte A; public Rgba(byte r, byte g, byte b, byte a = byte.MaxValue) { R = r; G = g; B = b; A = a; } public Rgba Scale(float k) { return new Rgba((byte)Math.Min(255f, (float)(int)R * k), (byte)Math.Min(255f, (float)(int)G * k), (byte)Math.Min(255f, (float)(int)B * k), A); } public static Rgba Over(Rgba dst, Rgba src, float a) { float sa = (float)(int)src.A / 255f * Math.Min(1f, Math.Max(0f, a)); float da = (float)(int)dst.A / 255f; float oa = sa + da * (1f - sa); if (oa <= 0f) { return default(Rgba); } return new Rgba(Mix(src.R, dst.R), Mix(src.G, dst.G), Mix(src.B, dst.B), (byte)(oa * 255f)); byte Mix(byte s, byte d) { return (byte)(((float)(int)s * sa + (float)(int)d * da * (1f - sa)) / oa); } } } public class Palette { public Rgba Panel = new Rgba(8, 10, 9, 238); public Rgba Accent = new Rgba(byte.MaxValue, 100, 30); public Rgba Green = new Rgba(3, 231, 21); public Rgba Dark = new Rgba(3, 12, 6); public Rgba Dim => Green.Scale(0.55f); } public class LevelInfo { public bool Found; public bool Locked = true; public int Price; public string Risk; public string Weather; public string Text; public Rgba? WeatherColor; } public class Planet { public string Name; public float X; public float Y; public float R; public float Phase; public bool Star; public bool Square; public bool Base; public bool Got; public bool Hub; public LevelInfo Info; } public class Label { public string Text; public float X; public float Y; public float Size; public float W; public Rgba Color; public bool Bold; public int Align; } public class Canvas { public int W; public int H; public Rgba[] Px; public Canvas(int w, int h, Rgba fill = default(Rgba)) { W = w; H = h; Px = Enumerable.Repeat(fill, w * h).ToArray(); } public void Area(float cx, float cy, float ext, Func<float, float, float> alpha, Rgba c) { for (int i = (int)Math.Max(0f, cy - ext); (float)i <= Math.Min(H - 1, cy + ext); i++) { for (int j = (int)Math.Max(0f, cx - ext); (float)j <= Math.Min(W - 1, cx + ext); j++) { float num = alpha((float)j + 0.5f - cx, (float)i + 0.5f - cy); if (num > 0f) { Px[i * W + j] = Rgba.Over(Px[i * W + j], c, num); } } } } private static float D(float x, float y) { return (float)Math.Sqrt(x * x + y * y); } public void Disc(float cx, float cy, float r, Rgba c) { Area(cx, cy, r + 1f, (float x, float y) => r - D(x, y) + 0.5f, c); } public void Circle(float cx, float cy, float r, float w, Rgba c) { Area(cx, cy, r + w + 1f, (float x, float y) => w / 2f - Math.Abs(D(x, y) - r) + 0.5f, c); } public void Square(float cx, float cy, float h, float w, Rgba c) { Area(cx, cy, h + w + 1f, (float x, float y) => w / 2f - Math.Abs(Math.Max(Math.Abs(x), Math.Abs(y)) - h) + 0.5f, c); } public void Box(float x0, float y0, float x1, float y1, Rgba c, float a = 1f) { Area((x0 + x1) / 2f, (y0 + y1) / 2f, Math.Max(x1 - x0, y1 - y0) / 2f + 1f, (float value, float value2) => Math.Min(Math.Min((x1 - x0) / 2f - Math.Abs(value) + 0.5f, (y1 - y0) / 2f - Math.Abs(value2) + 0.5f), 1f) * a, c); } public void Star(float cx, float cy, float R, Rgba c) { (float x, float y)[] pts = Enumerable.Range(0, 10).Select(delegate(int k) { double num = -Math.PI / 2.0 + (double)k * Math.PI / 5.0; float num2 = ((k % 2 == 1) ? (R * 0.45f) : R); return (x: num2 * (float)Math.Cos(num), y: num2 * (float)Math.Sin(num)); }).ToArray(); Area(cx, cy, R + 1f, (float x, float y) => In(x - 0.25f, y - 0.25f) + In(x + 0.25f, y - 0.25f) + In(x - 0.25f, y + 0.25f) + In(x + 0.25f, y + 0.25f), c); float In(float x, float y) { bool flag = false; int num = 0; int num2 = pts.Length - 1; while (num < pts.Length) { if (pts[num].y > y != pts[num2].y > y && x < (pts[num2].x - pts[num].x) * (y - pts[num].y) / (pts[num2].y - pts[num].y) + pts[num].x) { flag = !flag; } num2 = num++; } if (!flag) { return 0f; } return 0.25f; } } public void Checker(float cx, float cy, float r, float s, Palette pal) { Disc(cx, cy, r, pal.Dark); Area(cx, cy, r + 1f, (float x, float y) => (((int)Math.Floor((x + 99f) / s / 4f) + (int)Math.Floor((y + 99f) / s / 4f)) % 2 != 0) ? 0f : (r - D(x, y) + 0.5f), pal.Dim); Circle(cx, cy, r, 1.4f * s, pal.Dim); } public void Frame(Rgba c, float s) { float num = Math.Max(1.5f, 2f * s); float num2 = 26f * s; float num3 = Math.Max(2f, 3.5f * s); Box(0f, 0f, W, num, c, 0.55f); Box(0f, (float)H - num, W, H, c, 0.55f); Box(0f, 0f, num, H, c, 0.55f); Box((float)W - num, 0f, W, H, c, 0.55f); Box(0f, 0f, num2, num3, c); Box(0f, 0f, num3, num2, c); Box((float)W - num2, 0f, W, num3, c); Box((float)W - num3, 0f, W, num2, c); Box(0f, (float)H - num3, num2, H, c); Box(0f, (float)H - num2, num3, H, c); Box((float)W - num2, (float)H - num3, W, H, c); Box((float)W - num3, (float)H - num2, W, H, c); } } public class Sprite { public Canvas C; public float X; public float Y; public List<Label> Labels = new List<Label>(); } public class Frame { public int Side; public float S; public Canvas Bg; public Canvas Halo; public List<Sprite> Rings = new List<Sprite>(); public List<Sprite> Planets = new List<Sprite>(); public List<Label> Labels = new List<Label>(); } public class MapCore { public float Size; public float Center; public List<float> Rings = new List<float>(); public List<Planet> Planets = new List<Planet>(); public string Hint = "M"; public static string Key(string s) { return new string(s.ToLowerInvariant().Where(char.IsLetterOrDigit).ToArray()); } private static float Num(string s) { return float.Parse(s.Trim(), CultureInfo.InvariantCulture); } public static MapCore Build(IEnumerable<KeyValuePair<string, string>> rings, IEnumerable<KeyValuePair<string, string>> planets, Func<string, LevelInfo> level) { MapCore mapCore = new MapCore(); Dictionary<int, float> dictionary = new Dictionary<int, float>(); foreach (KeyValuePair<string, string> ring in rings) { string[] array = ring.Value.Split(','); float num = Num(array[0]); dictionary[int.Parse(ring.Key.Replace("Ring", "").Trim())] = num; if (array.Length <= 1 || !array[1].Trim().Equals("hidden", StringComparison.OrdinalIgnoreCase)) { mapCore.Rings.Add(num); } } mapCore.Center = ((dictionary.Count > 0) ? dictionary.Values.Max() : 0f) + 90f; mapCore.Size = 2f * mapCore.Center; foreach (KeyValuePair<string, string> planet2 in planets) { List<string> list = (from x in planet2.Value.Split(',') select x.Trim().ToLowerInvariant()).ToList(); LevelInfo levelInfo = level(Key(planet2.Key)) ?? new LevelInfo(); Planet planet = new Planet { Name = planet2.Key, Info = levelInfo, Star = list.Contains("star"), Square = (list.Contains("circle") || list.Contains("square")), Base = list.Contains("base"), Phase = (float)(planet2.Key.Sum((char ch) => ch) % 628) / 100f }; planet.Got = planet.Base || (levelInfo.Found && !levelInfo.Locked); float val = (float)Math.Sqrt(Math.Max(0, levelInfo.Price)) / 5f; if (list[0] == "center") { planet.X = (planet.Y = mapCore.Center); planet.R = 25.5f; planet.Hub = true; } else { if (list.Count < 2 || !dictionary.TryGetValue((int)Num(list[0]), out var value)) { continue; } double num2 = (double)Num(list[1]) * Math.PI / 180.0; planet.X = mapCore.Center + (float)Math.Cos(num2) * value; planet.Y = mapCore.Center + (float)Math.Sin(num2) * value; planet.R = 0.85f * (planet.Base ? (13f + Math.Min(8f, val)) : (15f + Math.Min(9f, val))); } mapCore.Planets.Add(planet); } return mapCore; } public static float RingAngle(int i, float t) { return (float)((i % 2 == 0) ? 1 : (-1)) * t * 3f / (1f + 0.3f * (float)i); } public (float x, float y) Wobble(int i, float t) { Planet planet = Planets[i]; return (x: 1.6f * (float)Math.Sin(t * 0.9f + planet.Phase), y: 1.6f * (float)Math.Cos(t * 1.13f + planet.Phase * 1.7f)); } public int HitTest(float mx, float my, float t) { for (int i = 0; i < Planets.Count; i++) { (float, float) tuple = Wobble(i, t); float num = mx - Planets[i].X - tuple.Item1; float num2 = my - Planets[i].Y - tuple.Item2; if ((double)(num * num + num2 * num2) <= Math.Pow(Math.Max(Planets[i].R + 4f, 12f), 2.0)) { return i; } } return -1; } public Frame Render(int side, Palette pal) { float s = (float)side / Size; float num = 22f * s; Frame f = new Frame { Side = side, S = s, Bg = new Canvas(side, side, pal.Panel) }; f.Bg.Frame(pal.Accent, s); foreach (float ring in Rings) { float num2 = ring * s; int num3 = (int)Math.Ceiling(Math.PI * 2.0 * (double)ring / 7.0); int num4 = (int)Math.Ceiling(2f * num2 + 6f); Canvas canvas = new Canvas(num4, num4); for (int i = 0; i < num3; i++) { double num5 = (double)(i * 2) * Math.PI / (double)num3; canvas.Disc((float)num4 / 2f + (float)Math.Cos(num5) * num2, (float)num4 / 2f + (float)Math.Sin(num5) * num2, 0.9f * s, pal.Dim.Scale(0.8f)); } f.Rings.Add(new Sprite { C = canvas, X = Center * s, Y = Center * s }); } int num6 = (int)Math.Ceiling(80f * s); f.Halo = new Canvas(num6, num6); f.Halo.Circle((float)num6 / 2f, (float)num6 / 2f, 34f * s, 3f * s, pal.Accent); foreach (Planet planet in Planets) { float num7 = planet.R * s; int num8 = (int)Math.Ceiling(2f * num7 + 6f); Canvas canvas2 = new Canvas(num8, num8); float num9 = (float)num8 / 2f; if (planet.Base) { canvas2.Checker(num9, num9, num7, s, pal); } else { canvas2.Disc(num9, num9, num7, planet.Got ? pal.Green : pal.Dark); canvas2.Circle(num9, num9, num7, 1.8f * s, planet.Got ? pal.Green : pal.Dim.Scale(1.4f)); } Rgba c = ((planet.Got && !planet.Base) ? pal.Dark : pal.Green); if (planet.Square) { canvas2.Square(num9, num9, Math.Max(6f, planet.R * 0.42f) * s, 2.6f * s, c); } if (planet.Star) { canvas2.Star(num9, num9, Math.Max(8f, planet.R * 0.62f) * s, c); } Sprite sprite = new Sprite { C = canvas2, X = planet.X * s, Y = planet.Y * s }; Rgba c2 = (planet.Base ? pal.Dim : (planet.Got ? pal.Green : pal.Dim.Scale(1.25f))); if (planet.Hub) { Text(sprite.Labels, planet.Name.ToUpperInvariant(), 0f, 0f - num7 - 19f * s, 15f * s, c2, bold: true); } else { Text(sprite.Labels, planet.Name.ToUpperInvariant(), 0f, num7 + 1f * s, 15f * s, c2, !planet.Base); Text(sprite.Labels, planet.Info.Price.ToString(CultureInfo.InvariantCulture), 0f, num7 + 15f * s, 13f * s, (planet.Got && !planet.Base) ? pal.Green.Scale(0.9f) : pal.Dim); } f.Planets.Add(sprite); } Text(f.Labels, "JOURNEY MAP", num, num, 24f * s, pal.Accent, bold: true, -1); Text(f.Labels, "WESLEY'S MOONS", num, num + 28f * s, 13f * s, pal.Dim, bold: false, -1); float num10 = num + 9f * s; float num11 = (float)side - num - 110f * s; float num12 = 22f * s; float ir = 7f * s; (string, Action<float, float>)[] array = new(string, Action<float, float>)[5] { ("UNLOCKED", delegate(float x, float y) { f.Bg.Disc(x, y, ir, pal.Green); }), ("LOCKED", delegate(float x, float y) { f.Bg.Disc(x, y, ir, pal.Dark); f.Bg.Circle(x, y, ir, 1.8f * s, pal.Dim.Scale(1.4f)); }), ("DESTINY ITEM", delegate(float x, float y) { f.Bg.Star(x, y, ir * 1.2f, pal.Green); }), ("APPARATUS ITEM", delegate(float x, float y) { f.Bg.Square(x, y, ir * 0.7f, 2.4f * s, pal.Green); }), ("BASE GAME", delegate(float x, float y) { f.Bg.Checker(x, y, ir, s, pal); }) }; for (int num13 = 0; num13 < array.Length; num13++) { float num14 = num11 + (float)num13 * num12; array[num13].Item2(num10, num14 + 8f * s); Text(f.Labels, array[num13].Item1, num10 + 16f * s, num14, 13f * s, pal.Dim.Scale(1.3f), bold: false, -1); } Text(f.Labels, "[" + Hint + "] / [ESC] CLOSE", (float)side - num, (float)side - num - 16f * s, 13f * s, pal.Dim.Scale(1.3f), bold: false, 1); return f; static void Text(List<Label> into, string t, float x, float y, float size, Rgba color, bool bold = false, int align = 0) { into.Add(new Label { Text = t, X = x, Y = y, Size = size, Color = color, Bold = bold, Align = align }); } } public static (int side, float mapX, float mapY, float infoX, int infoW) Layout(int sw, int sh) { int num = (int)Math.Min(0.92f * (float)sh, 0.96f * (float)sw / 1.42f); int num2 = (int)(0.4f * (float)num); float num3 = 0.02f * (float)num; float num4 = (float)(sw - num) / 2f; if (num4 + (float)num + num3 + (float)num2 > 0.98f * (float)sw) { num4 = ((float)(sw - num) - num3 - (float)num2) / 2f; } return (side: num, mapX: num4, mapY: (float)(sh - num) / 2f, infoX: num4 + (float)num + num3, infoW: num2); } public static Canvas InfoPanel(int w, int h, Palette pal, float s) { Canvas canvas = new Canvas(w, h, pal.Panel); canvas.Frame(pal.Accent, s); return canvas; } public static string Clean(string t) { if (t != null) { return Regex.Replace(Regex.Replace(Regex.Replace(t, "<[^>]*>", ""), "\\r", ""), "\\n{3,}", "\n\n").Trim(); } return null; } public static List<Label> Info(Planet p, float w, float s, Palette pal) { List<Label> l = new List<Label>(); float pad = 22f * s; float y = pad; float kw = 0.42f * (w - 2f * pad); if (p == null) { Add("MOON INFO", pad, 24f * s, pal.Accent, bold: true); y += 34f * s; Add("Point at a moon to see its terminal INFO.", pad, 13f * s, pal.Dim.Scale(1.3f), bold: false, -1, w - 2f * pad); return l; } LevelInfo info = p.Info; Add(p.Name.ToUpperInvariant(), pad, 24f * s, pal.Accent, bold: true); y += 38f * s; Row("RISK LEVEL", info.Risk, pal.Accent); Row("ROUTE PRICE", p.Hub ? null : info.Price.ToString(CultureInfo.InvariantCulture), pal.Green); Row("STATUS", p.Got ? "UNLOCKED" : "LOCKED", p.Got ? pal.Green : pal.Dim.Scale(1.4f)); Row("WEATHER", info.Weather, info.WeatherColor ?? pal.Green); Row("SPECIAL", string.Join(", ", new string[3] { p.Star ? "DESTINY ITEM" : null, p.Square ? "APPARATUS ITEM" : null, p.Base ? "BASE GAME" : null }.Where((string x) => x != null)), pal.Green); y += 10f * s; Add(string.IsNullOrEmpty(info.Text) ? "No terminal info." : info.Text, pad, 13f * s, pal.Dim.Scale(1.45f), bold: false, -1, w - 2f * pad); return l; void Add(string t, float x, float size, Rgba c, bool bold = false, int align = -1, float width = 0f) { l.Add(new Label { Text = t, X = x, Y = y, Size = size, Color = c, Bold = bold, Align = align, W = width }); } void Row(string k, string v, Rgba c) { if (!string.IsNullOrEmpty(v)) { Add(k, pad, 13f * s, pal.Green); Add(v, pad + kw, 15f * s, c, bold: true); y += 22f * s; } } } } public class MapOverlay : MonoBehaviour { private static MapOverlay inst; private bool open; private bool openedMenu; private MapCore map; private Palette palette; private Frame frame; private Texture2D bg; private Texture2D halo; private Texture2D info; private Texture2D[] rings; private Texture2D[] planets; private int texSide; private Font font; private readonly Dictionary<string, GUIStyle> styles = new Dictionary<string, GUIStyle>(); private QuickMenuManager menu; private GameObject hiddenPanel; private void Awake() { inst = this; } public static void Toggle(QuickMenuManager m = null) { if (inst.open) { inst.Close(); } else { inst.Show(m); } } public static void Hide() { if (!((Object)(object)inst == (Object)null) && inst.open) { inst.open = false; inst.openedMenu = false; if ((Object)(object)inst.hiddenPanel != (Object)null) { inst.hiddenPanel.SetActive(true); } inst.hiddenPanel = null; } } private void Close() { if (openedMenu && (Object)(object)menu != (Object)null && menu.isMenuOpen) { menu.CloseQuickMenu(); } Hide(); } private void Show(QuickMenuManager m) { menu = (((Object)(object)m != (Object)null) ? m : Object.FindObjectOfType<QuickMenuManager>()); if ((Object)(object)menu != (Object)null && !menu.isMenuOpen && (Object)(object)GameNetworkManager.Instance != (Object)null && (Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null) { menu.OpenQuickMenu(); openedMenu = true; } if ((Object)(object)menu != (Object)null && (Object)(object)menu.mainButtonsPanel != (Object)null && menu.mainButtonsPanel.activeSelf) { hiddenPanel = menu.mainButtonsPanel; hiddenPanel.SetActive(false); } Dictionary<string, ExtendedLevel> levels = new Dictionary<string, ExtendedLevel>(); foreach (ExtendedLevel extendedLevel in PatchedContent.ExtendedLevels) { levels[MapCore.Key(extendedLevel.NumberlessPlanetName)] = extendedLevel; } map = MapCore.Build(Plugin.Rings.Select((ConfigEntry<string> e) => new KeyValuePair<string, string>(((ConfigEntryBase)e).Definition.Key, e.Value)), Plugin.Planets.Select((ConfigEntry<string> e) => new KeyValuePair<string, string>(((ConfigEntryBase)e).Definition.Key, e.Value)), (string k) => (!levels.TryGetValue(k, out var value)) ? null : Info(value)); map.Hint = ((object)Unsafe.As<Key, Key>(ref Plugin.ToggleKey)/*cast due to .constrained prefix*/).ToString(); if (palette == null) { palette = GamePalette(menu); } frame = null; open = true; } private static LevelInfo Info(ExtendedLevel l) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) SelectableLevel selectableLevel = l.SelectableLevel; string text = (((int)selectableLevel.currentWeather == -1) ? "Clear" : ((object)Unsafe.As<LevelWeatherType, LevelWeatherType>(ref selectableLevel.currentWeather)/*cast due to .constrained prefix*/).ToString()); string text2 = null; try { text2 = (((Object)(object)l.InfoNode != (Object)null) ? l.InfoNode.displayText : null); } catch (Exception) { } int result; LevelInfo levelInfo = new LevelInfo { Found = true, Locked = l.IsRouteLocked, Price = l.RoutePrice, Risk = selectableLevel.riskLevel, Weather = (int.TryParse(text, out result) ? null : text), Text = MapCore.Clean(string.IsNullOrWhiteSpace(text2) ? selectableLevel.LevelDescription : text2) }; try { object w = Type.GetType("WeatherRegistry.WeatherManager, WeatherRegistry")?.GetMethod("GetCurrentLevelWeather", new Type[1] { typeof(SelectableLevel) })?.Invoke(null, new object[1] { selectableLevel }); if (w != null) { if (Get("Name") is string { Length: >0 } text3) { levelInfo.Weather = ((text3 == "None") ? "Clear" : text3); } if (Get("Color") is Color c) { levelInfo.WeatherColor = From(c); } } object Get(string n) { object obj = w.GetType().GetProperty(n)?.GetValue(w); if (obj == null) { FieldInfo? field = w.GetType().GetField(n); if ((object)field == null) { return null; } obj = field.GetValue(w); } return obj; } } catch (Exception ex2) { Plugin.Log.LogDebug((object)ex2.Message); } return levelInfo; } private Palette GamePalette(QuickMenuManager m) { //IL_00a9: Unknown result type (might be due to invalid IL or missing references) Palette palette = new Palette(); TMP_Text val = (((Object)(object)m != (Object)null && (Object)(object)m.mainButtonsPanel != (Object)null) ? m.mainButtonsPanel.GetComponentsInChildren<TMP_Text>(true).FirstOrDefault() : null); if ((Object)(object)val != (Object)null && (Object)(object)val.font != (Object)null && (Object)(object)val.font.sourceFontFile != (Object)null) { font = val.font.sourceFontFile; } Terminal val2 = Object.FindObjectOfType<Terminal>(); if ((Object)(object)val2 != (Object)null && (Object)(object)val2.screenText != (Object)null && (Object)(object)val2.screenText.textComponent != (Object)null) { palette.Green = From(((Graphic)val2.screenText.textComponent).color); } if ((Object)(object)font == (Object)null) { font = Font.CreateDynamicFontFromOSFont(new string[2] { "Consolas", "Courier New" }, 16); } Plugin.Log.LogInfo((object)("Palette accent #" + Hex(palette.Accent) + " green #" + Hex(palette.Green) + " font " + ((Object)font).name)); return palette; } private static Rgba From(Color c) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) Color32 val = Color32.op_Implicit(c); return new Rgba(val.r, val.g, val.b); } private static string Hex(Rgba c) { return $"{c.R:X2}{c.G:X2}{c.B:X2}"; } private void Update() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) Keyboard current = Keyboard.current; if (current == null) { return; } if (open && ((ButtonControl)current.escapeKey).wasPressedThisFrame && (Object)(object)menu == (Object)null) { Hide(); } else { if (!((ButtonControl)current[Plugin.ToggleKey]).wasPressedThisFrame) { return; } PlayerControllerB val = (((Object)(object)GameNetworkManager.Instance != (Object)null) ? GameNetworkManager.Instance.localPlayerController : null); if (!((Object)(object)val != (Object)null) || (!val.isTypingChat && !val.inTerminalMenu)) { if (open) { Close(); } else { Show(null); } } } } private static Texture2D Tex(Canvas c) { //IL_008f: 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_009b: 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_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Expected O, but got Unknown //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) Color32[] array = (Color32[])(object)new Color32[c.W * c.H]; for (int i = 0; i < c.H; i++) { for (int j = 0; j < c.W; j++) { Rgba rgba = c.Px[i * c.W + j]; array[(c.H - 1 - i) * c.W + j] = new Color32(rgba.R, rgba.G, rgba.B, rgba.A); } } Texture2D val = new Texture2D(c.W, c.H, (TextureFormat)4, false) { filterMode = (FilterMode)1, wrapMode = (TextureWrapMode)1, hideFlags = (HideFlags)61 }; val.SetPixels32(array); val.Apply(); return val; } private void Rebuild(int side, int infoW) { foreach (Texture2D item in ((IEnumerable<Texture2D>)(object)new Texture2D[3] { bg, halo, info }).Concat((IEnumerable<Texture2D>)(((object)rings) ?? ((object)new Texture2D[0]))).Concat((IEnumerable<Texture2D>)(((object)planets) ?? ((object)new Texture2D[0])))) { if ((Object)(object)item != (Object)null) { Object.Destroy((Object)(object)item); } } frame = map.Render(side, palette); bg = Tex(frame.Bg); halo = Tex(frame.Halo); info = Tex(MapCore.InfoPanel(infoW, side, palette, frame.S)); rings = frame.Rings.Select((Sprite r) => Tex(r.C)).ToArray(); planets = frame.Planets.Select((Sprite p) => Tex(p.C)).ToArray(); texSide = side; } private void OnGUI() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Invalid comparison between Unknown and I4 //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: 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_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_03c3: Unknown result type (might be due to invalid IL or missing references) if (!open || (int)Event.current.type != 7) { return; } GUI.depth = -1000; var (num, num2, num3, num4, num5) = MapCore.Layout(Screen.width, Screen.height); if (frame == null || num != texSide) { Rebuild(num, num5); } float realtimeSinceStartup = Time.realtimeSinceStartup; float s = frame.S; GUI.color = new Color(0f, 0f, 0f, 0.6f); GUI.DrawTexture(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), (Texture)(object)Texture2D.whiteTexture); GUI.color = Color.white; GUI.DrawTexture(new Rect(num2, num3, (float)num, (float)num), (Texture)(object)bg); Vector2 val = default(Vector2); for (int i = 0; i < rings.Length; i++) { Sprite sprite = frame.Rings[i]; ((Vector2)(ref val))..ctor(num2 + sprite.X, num3 + sprite.Y); Matrix4x4 matrix = GUI.matrix; GUIUtility.RotateAroundPivot(MapCore.RingAngle(i, realtimeSinceStartup), val); GUI.DrawTexture(new Rect(val.x - (float)sprite.C.W / 2f, val.y - (float)sprite.C.H / 2f, (float)sprite.C.W, (float)sprite.C.H), (Texture)(object)rings[i]); GUI.matrix = matrix; } Vector2 mousePosition = Event.current.mousePosition; int num6 = map.HitTest((mousePosition.x - num2) / s, (mousePosition.y - num3) / s, realtimeSinceStartup); for (int j = 0; j < planets.Length; j++) { Sprite sprite2 = frame.Planets[j]; (float, float) tuple2 = map.Wobble(j, realtimeSinceStartup); float num7 = num2 + sprite2.X + tuple2.Item1 * s; float num8 = num3 + sprite2.Y + tuple2.Item2 * s; GUI.DrawTexture(new Rect(num7 - (float)sprite2.C.W / 2f, num8 - (float)sprite2.C.H / 2f, (float)sprite2.C.W, (float)sprite2.C.H), (Texture)(object)planets[j]); if (j == num6) { float num9 = (map.Planets[j].R + 5f) * s / (34f * s) * (float)((Texture)halo).width / 2f; GUI.DrawTexture(new Rect(num7 - num9, num8 - num9, 2f * num9, 2f * num9), (Texture)(object)halo); } foreach (Label label in sprite2.Labels) { Label(label, num7, num8, (j == num6) ? new Rgba?(palette.Accent) : ((Rgba?)null)); } } foreach (Label label2 in frame.Labels) { Label(label2, num2, num3); } GUI.DrawTexture(new Rect(num4, num3, (float)num5, (float)num), (Texture)(object)info); foreach (Label item in MapCore.Info((num6 >= 0) ? map.Planets[num6] : null, num5, s, palette)) { Label(item, num4, num3); } } private void Label(Label l, float ox, float oy, Rgba? color = null) { //IL_006d: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Expected O, but got Unknown //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) int num = Mathf.Max(8, Mathf.RoundToInt(l.Size)); string key = $"{num}{l.Bold}{l.Align}{l.W > 0f}"; if (!styles.TryGetValue(key, out var value)) { value = new GUIStyle { font = font, fontSize = num, fontStyle = (FontStyle)(l.Bold ? 1 : 0), wordWrap = (l.W > 0f), richText = false, alignment = (TextAnchor)((l.Align >= 0) ? ((l.Align <= 0) ? 1 : 2) : 0) }; styles[key] = value; } float num2 = ((l.W > 0f) ? l.W : 600f); float num3 = ((l.W > 0f) ? Screen.height : (num * 2)); float num4 = ox + l.X - ((l.Align < 0) ? 0f : ((l.Align > 0) ? num2 : (num2 / 2f))); float num5 = oy + l.Y; Rgba rgba = color ?? l.Color; value.normal.textColor = Color32.op_Implicit(new Color32(palette.Dark.R, palette.Dark.G, palette.Dark.B, (byte)220)); GUI.Label(new Rect(num4 + 1f, num5 + 1f, num2, num3), l.Text, value); value.normal.textColor = Color32.op_Implicit(new Color32(rgba.R, rgba.G, rgba.B, byte.MaxValue)); GUI.Label(new Rect(num4, num5, num2, num3), l.Text, value); } } [BepInPlugin("wesleysjourneymap", "WesleysJourneyMap", "0.5.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { internal static ManualLogSource Log; internal static Key ToggleKey = (Key)27; internal static readonly List<ConfigEntry<string>> Rings = new List<ConfigEntry<string>>(); internal static readonly List<ConfigEntry<string>> Planets = new List<ConfigEntry<string>>(); private void Awake() { //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) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Expected O, but got Unknown //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; ToggleKey = ((BaseUnityPlugin)this).Config.Bind<Key>("General", "Key", (Key)27, "Opens and closes the map (ignored while typing in chat or using the terminal).").Value; using (StreamReader streamReader = new StreamReader(typeof(Plugin).Assembly.GetManifestResourceStream("preset.txt"))) { string text = null; string text2; while ((text2 = streamReader.ReadLine()) != null) { if (text2.StartsWith("[")) { text = text2.Trim('[', ']'); continue; } string[] array = text2.Split(new char[1] { '=' }, 2); if (array.Length >= 2) { ((text == "Rings") ? Rings : Planets).Add(((BaseUnityPlugin)this).Config.Bind<string>(text, array[0].Trim(), array[1].Trim(), (ConfigDescription)null)); } } } GameObject val = new GameObject("WesleysJourneyMap"); Object.DontDestroyOnLoad((Object)val); ((Object)val).hideFlags = (HideFlags)61; val.AddComponent<MapOverlay>(); new Harmony("wesleysjourneymap").PatchAll(typeof(MenuPatch)); } } [HarmonyPatch(typeof(QuickMenuManager))] internal static class MenuPatch { [HarmonyPostfix] [HarmonyPatch("Start")] private static void Start(QuickMenuManager __instance) { ((MonoBehaviour)__instance).StartCoroutine(AddButton(__instance)); } [HarmonyPostfix] [HarmonyPatch("CloseQuickMenu")] private static void Close() { MapOverlay.Hide(); } private static IEnumerator AddButton(QuickMenuManager menu) { yield return null; GameObject panel = menu.mainButtonsPanel; if ((Object)(object)panel == (Object)null || (Object)(object)panel.transform.Find("JourneyMapButton") != (Object)null) { yield break; } List<Button> list = (from b in panel.GetComponentsInChildren<Button>(true) where (Object)(object)((Component)b).transform.parent == (Object)(object)panel.transform orderby Y(((Component)b).transform) descending select b).ToList(); if (list.Count == 0) { Plugin.Log.LogWarning((object)"No pause menu buttons found; use the key."); yield break; } Button val = ((IEnumerable<Button>)list).FirstOrDefault((Func<Button, bool>)((Button b) => ((Component)b).GetComponentsInChildren<TMP_Text>(true).Any((TMP_Text t) => t.text.ToLowerInvariant().Contains("quit")))) ?? list.Last(); int num = list.IndexOf(val); float num2 = ((num > 0) ? (Y(((Component)list[num - 1]).transform) - Y(((Component)val).transform)) : 40f); GameObject val2 = Object.Instantiate<GameObject>(((Component)val).gameObject, panel.transform); ((Object)val2).name = "JourneyMapButton"; val2.transform.SetSiblingIndex(((Component)val).transform.GetSiblingIndex()); ((RectTransform)val2.transform).anchoredPosition = ((RectTransform)((Component)val).transform).anchoredPosition; foreach (Button item in list.Skip(num)) { RectTransform val3 = (RectTransform)((Component)item).transform; val3.anchoredPosition -= new Vector2(0f, num2); } TMP_Text[] componentsInChildren = val2.GetComponentsInChildren<TMP_Text>(true); for (int num3 = 0; num3 < componentsInChildren.Length; num3++) { componentsInChildren[num3].text = "> Journey map"; } Button component = val2.GetComponent<Button>(); component.onClick = new ButtonClickedEvent(); ((UnityEvent)component.onClick).AddListener((UnityAction)delegate { MapOverlay.Toggle(menu); }); } private static float Y(Transform t) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) return ((RectTransform)t).anchoredPosition.y; } } }