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 HearthAndVillage v0.9.2
TXC.Village.dll
Decompiled 3 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; 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.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using Microsoft.CodeAnalysis; using Splatform; using TXC.Village.Commands; using TXC.Village.Core; using TXC.Village.Expeditions; using TXC.Village.Farming; using TXC.Village.Fishing; using TXC.Village.Food; using TXC.Village.Forestry; using TXC.Village.Gui; using TXC.Village.Jobs; using TXC.Village.Ranching; using TXC.Village.Village; using TXC.Village.Villagers; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyVersion("0.0.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 TXC.Village { [BepInPlugin("txc.village", "Hearth and Village", "0.9.2")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public class VillagePlugin : BaseUnityPlugin { public const string ModGuid = "txc.village"; public const string ModName = "Hearth and Village"; public const string ModVersion = "0.9.2"; private Harmony _harmony; private bool _consoleEnabled; private bool _tickErrorLogged; private bool _guiErrorLogged; internal static VillagePlugin Instance { get; private set; } internal static ManualLogSource Log { get; private set; } private void Awake() { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; VillageConfig.Bind(((BaseUnityPlugin)this).Config); BannerPrefab.Hook(); VillageCamp.Hook(); VillagerPrefab.Hook(); ContractItem.Hook(); ExpeditionBoardPrefab.Hook(); FieldMarkerPrefab.Hook(); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new VillageCommand()); _harmony = new Harmony("txc.village"); int num = 0; int num2 = 0; Type[] typesFromAssembly = AccessTools.GetTypesFromAssembly(typeof(VillagePlugin).Assembly); foreach (Type type in typesFromAssembly) { if (type.GetCustomAttributes(typeof(HarmonyPatch), inherit: false).Length != 0) { try { _harmony.CreateClassProcessor(type).Patch(); num++; } catch (Exception ex) { num2++; Log.LogError((object)("Patch " + type.FullName + " failed: " + ex.GetBaseException().Message)); } } } Log.LogInfo((object)$"Patches: {num} applied, {num2} failed."); Log.LogInfo((object)"Hearth and Village 0.9.2 loaded."); } private void Update() { try { Perf.Frame(Time.unscaledDeltaTime); long now = Perf.Now; VillageNet.Tick(Time.deltaTime); Perf.Add("tick VillageNet.Tick", now); now = Perf.Now; VillageMap.Tick(); Perf.Add("tick VillageMap.Tick", now); now = Perf.Now; VillagePanel.Tick(); Perf.Add("tick VillagePanel.Tick", now); now = Perf.Now; Book.Tick(); Perf.Add("tick Gui.Book.Tick", now); now = Perf.Now; ExpeditionPanel.Tick(); Perf.Add("tick Expeditions.ExpeditionPanel.Tick", now); now = Perf.Now; VillagerPanel.Tick(); Perf.Add("tick Villagers.VillagerPanel.Tick", now); now = Perf.Now; StationPanel.Tick(); Perf.Add("tick Jobs.StationPanel.Tick", now); now = Perf.Now; PantryPanel.Tick(); Perf.Add("tick Food.PantryPanel.Tick", now); now = Perf.Now; SoldierFormation.Tick(); Perf.Add("tick Villagers.SoldierFormation.Tick", now); now = Perf.Now; FormationWheel.Tick(); Perf.Add("tick Gui.FormationWheel.Tick", now); now = Perf.Now; ForestPanel.Tick(); Perf.Add("tick Forestry.ForestPanel.Tick", now); now = Perf.Now; PasturePanel.Tick(); Perf.Add("tick Ranching.PasturePanel.Tick", now); } catch (Exception ex) { if (!_tickErrorLogged) { _tickErrorLogged = true; Log.LogError((object)("Village tick failed: " + ex)); } } if (!_consoleEnabled && VillageConfig.EnableConsole.Value && (Object)(object)Console.instance != (Object)null) { Console.SetConsoleEnabledForThisSession(); _consoleEnabled = true; } } private void OnGUI() { try { VillagePanel.Draw(); } catch (Exception ex) { if (!_guiErrorLogged) { _guiErrorLogged = true; Log.LogError((object)("Village panel failed: " + ex)); } } } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } internal static void Debug(string msg) { if (VillageConfig.DebugLogging != null && VillageConfig.DebugLogging.Value) { Log.LogInfo((object)msg); } } } internal static class Perf { private class Acc { public double Ms; public double Max; public long N; } private static readonly Dictionary<string, Acc> Accs = new Dictionary<string, Acc>(); private static readonly double TickMs = 1000.0 / (double)Stopwatch.Frequency; private static Stopwatch _clock = Stopwatch.StartNew(); private static long _frames; private static double _frameMs; private static double _frameMax; public static long Now => Stopwatch.GetTimestamp(); public static void Add(string key, long start) { double num = (double)(Stopwatch.GetTimestamp() - start) * TickMs; if (!Accs.TryGetValue(key, out var value)) { value = (Accs[key] = new Acc()); } value.Ms += num; value.N++; if (num > value.Max) { value.Max = num; } } public static void Frame(float dt) { _frames++; double num = (double)dt * 1000.0; _frameMs += num; if (num > _frameMax) { _frameMax = num; } } public static void Reset() { Accs.Clear(); _frames = 0L; _frameMs = 0.0; _frameMax = 0.0; _clock = Stopwatch.StartNew(); } public static List<string> Report() { double num = Math.Max(0.001, _clock.Elapsed.TotalSeconds); List<string> list = new List<string>(); double num2 = Accs.Where((KeyValuePair<string, Acc> kv) => !kv.Key.Contains("/")).Sum((KeyValuePair<string, Acc> kv) => kv.Value.Ms); list.Add($"Over {num:0} s, {_frames} frames: average frame {((_frames > 0) ? (_frameMs / (double)_frames) : 0.0):0.0} ms ({((_frameMs > 0.0) ? ((double)_frames * 1000.0 / _frameMs) : 0.0):0} fps), worst {_frameMax:0} ms."); list.Add($"The mod: {num2 / num:0.00} ms per second ({num2 / Math.Max(1.0, _frameMs) * 100.0:0.0}% of frame time)."); foreach (KeyValuePair<string, Acc> item in Accs.OrderByDescending((KeyValuePair<string, Acc> k) => k.Value.Ms)) { list.Add($" {item.Key}: {item.Value.Ms / num:0.000} ms/s, {(double)item.Value.N / num:0.0} calls/s, avg {item.Value.Ms / (double)Math.Max(1L, item.Value.N):0.000} ms, worst {item.Value.Max:0.00} ms"); } return list; } } internal static class VillageConfig { public static ConfigEntry<float> VillageRadius; public static ConfigEntry<float> MinDistanceBetweenVillages; public static ConfigEntry<bool> BedsNeedFire; public static ConfigEntry<bool> DebugLogging; public static ConfigEntry<string> HealingStaffs; public static ConfigEntry<KeyboardShortcut> FormationKey; public static ConfigEntry<KeyboardShortcut> HoldKey; public static ConfigEntry<int> RecruitBaseCost; public static ConfigEntry<float> WandererDays; public static ConfigEntry<int> WanderersAtStart; public static ConfigEntry<int> WanderersPerBoss; public static ConfigEntry<bool> Permadeath; public static ConfigEntry<float> InjuryDaysMultiplier; public static ConfigEntry<int> ContractPrice; public static ConfigEntry<bool> ShowMapPins; public static ConfigEntry<bool> ShowAreaWithHammer; public static ConfigEntry<bool> EnableConsole; private static int _order; public static void Bind(ConfigFile config) { //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Expected O, but got Unknown //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Expected O, but got Unknown VillageRadius = Entry(config, "1 - Village", "Village base radius", 40f, "How far (metres, measured flat from the Village Banner) a hamlet reaches; a village adds 15 m, a town 35 m (40 / 55 / 75 by default). Only beds inside count as villager beds. Banners already built show the new size after the area is reloaded.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(10f, 100f)); MinDistanceBetweenVillages = Entry(config, "1 - Village", "Minimum distance between village banners", 100f, "A new Village Banner can't be placed closer than this to another one (metres), so villages never overlap.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(20f, 1000f)); BedsNeedFire = Entry(config, "1 - Village", "Villager beds need a fire", value: false, "If on, a villager bed must also be warmed by a fire (like sleeping in a player bed). The roof rule always applies."); RecruitBaseCost = Entry(config, "2 - Villagers", "Recruit base cost", 10, "Coins for the first recruit at the banner. Later ones cost more: x1, x3, x6, x10, x15, x21, x28, x36, then +10 each.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 1000)); WandererDays = Entry(config, "2 - Villagers", "Wanderer every N days", 1.5f, "In-game days between wanderers who come by themselves to a village with a free villager bed. 0 = no wanderers.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 30f)); WanderersAtStart = Entry(config, "2 - Villagers", "Wanderers before any boss", 0, "How many wanderers come by themselves to each village before any boss is defeated. Recruiting, contracts and expedition finds don't count.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 20)); WanderersPerBoss = Entry(config, "2 - Villagers", "Extra wanderers per boss", 1, "Each boss defeated in the world lets this many more wanderers come to each village (Eikthyr, the Elder, Bonemass, Moder, Yagluth, the Queen, Fader).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 20)); Permadeath = Entry(config, "2 - Villagers", "Permadeath", value: false, "Off: a villager who falls is badly hurt and recovers in bed for 1-3 in-game days. On: a villager who falls is dead for good."); InjuryDaysMultiplier = Entry(config, "2 - Villagers", "Injury time multiplier", 1f, "Scales how long injured villagers stay in bed (1 = 1-3 in-game days).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.05f, 10f)); ContractPrice = Entry(config, "2 - Villagers", "Recruitment contract price", 150, "Coins for a recruitment contract at Haldor and Hildir (used on a Village Banner it brings a villager for free). 0 = not sold. Needs a restart.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 10000)); HealingStaffs = Entry(config, "4 - Jobs", "Healing staffs", "BDS_DvergerStaffHeal", "Item names (comma separated) of staves that make a soldier a healer, besides any staff with \"Heal\" in its name (e.g. other mods' healing staves)."); FormationKey = Local<KeyboardShortcut>(config, "3 - This PC", "Soldier formation key", new KeyboardShortcut((KeyCode)107, Array.Empty<KeyCode>()), "Hold it to open the formation wheel (Free, Column, Shield wall, Ring, Hold / Follow me): point at one and let go, or click it."); HoldKey = Local<KeyboardShortcut>(config, "3 - This PC", "Soldier hold key", new KeyboardShortcut((KeyCode)108, Array.Empty<KeyCode>()), "Soldiers out with you hold their position here (in their formation, facing your way) or follow you again."); ShowMapPins = Local(config, "3 - This PC", "Show villages on the map", value: true, "Shows every village as a pin with its name on the map and minimap."); ShowAreaWithHammer = Local(config, "3 - This PC", "Show village area with the hammer", value: true, "Draws the village circle on the ground while you hold the hammer near a Village Banner (and while placing one)."); DebugLogging = Entry(config, "9 - Debug", "Debug logging", value: false, "Writes extra lines about villages and beds to the BepInEx log."); EnableConsole = config.Bind<bool>("9 - Debug", "Enable console (this PC only)", false, new ConfigDescription("Turns on the F5 console without the -console launch option. For testing; not synced.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { Order = (_order -= 1) } })); } private static ConfigEntry<T> Local<T>(ConfigFile config, string section, string key, T value, string description) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown return config.Bind<T>(section, key, value, new ConfigDescription(description, (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { Order = (_order -= 1) } })); } private static ConfigEntry<T> Entry<T>(ConfigFile config, string section, string key, T value, string description, AcceptableValueBase acceptable = null) { //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_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown ConfigurationManagerAttributes val = new ConfigurationManagerAttributes { IsAdminOnly = true, Order = (_order -= 1) }; return config.Bind<T>(section, key, value, new ConfigDescription(description, acceptable, new object[1] { val })); } } } namespace TXC.Village.Gui { internal static class Icons { private static readonly Dictionary<string, string[]> Bitmaps = new Dictionary<string, string[]> { ["ash"] = new string[12] { ".....#......", "....##......", "....###.....", "...####..#..", "...#####.#..", "..########..", "..###.####..", ".###...###..", ".##.....##..", ".##.....##..", "..##...##...", "...#####...." }, ["axe"] = new string[12] { "......####..", ".....######.", "....#######.", ".....######.", "......####..", ".....##.....", "....##......", "...##.......", "..##........", ".##.........", "##..........", "............" }, ["axe_expeditions"] = new string[12] { "............", "............", "......###...", ".....#####..", "....##.####.", "...##...###.", "..##.....#..", ".##.........", "##..........", "#...........", "............", "............" }, ["bait"] = new string[12] { "............", "............", "..##........", ".#..#.......", ".#...#..##..", "......##..#.", "..........#.", ".......##.#.", "......#..#..", ".....#......", "............", "............" }, ["berries"] = new string[12] { "......#.....", ".....#......", "....##......", "..##..##....", ".####.####..", ".####.####..", "..##..##....", "....##......", "...####.....", "...####.....", "....##......", "............" }, ["boar"] = new string[12] { "............", "...#....#...", "..########..", ".##########.", "###.####.###", "############", ".####..####.", "..########..", "..##....##..", "..##....##..", "............", "............" }, ["bone"] = new string[12] { ".##.........", "####........", ".####.......", "..###.......", "...###......", "....###.....", ".....###....", "......###...", ".......###..", "........####", ".........###", "..........##" }, ["bottle"] = new string[12] { ".....##.....", ".....##.....", "....####....", ".....##.....", "....####....", "...######...", "..########..", "..########..", "..########..", "..########..", "...######...", "............" }, ["bowl"] = new string[12] { "............", "...#..#..#..", "....#..#..#.", "............", "############", ".##########.", ".##########.", "..########..", "...######...", "....####....", "..########..", "............" }, ["bread"] = new string[12] { "............", "............", "...######...", ".##########.", "##.##.##.###", "############", "############", ".##########.", "............", "............", "............", "............" }, ["carrot"] = new string[12] { "......#.#...", ".......#....", "......###...", ".....####...", ".....###....", "....####....", "....###.....", "...###......", "...##.......", "..##........", "..#.........", "............" }, ["cart"] = new string[12] { "............", "............", "############", "#..........#", "#..........#", ".##########.", "..#......#..", ".###....###.", "#.#.#..#.#.#", ".###....###.", "............", "............" }, ["chest"] = new string[12] { "............", "............", ".##########.", "#..........#", "############", "#....##....#", "#...#..#...#", "#....##....#", "#..........#", "############", "............", "............" }, ["coin"] = new string[12] { "............", "...######...", "..#......#..", ".#..####..#.", ".#.#....#.#.", ".#.#....#.#.", ".#.#....#.#.", ".#..####..#.", "..#......#..", "...######...", "............", "............" }, ["coins"] = new string[12] { "............", "...######...", "..#......#..", ".#..####..#.", ".#.#....#.#.", ".#.#....#.#.", ".#..####..#.", "..#......#..", "...######...", "............", "............", "............" }, ["cone"] = new string[12] { ".....##.....", "....####....", "...#.##.#...", "...######...", "..#.####.#..", "..########..", "..#.####.#..", "...######...", "...#.##.#...", "....####....", ".....##.....", "............" }, ["cook"] = new string[12] { "....#..#....", "...#..#.....", "....#..#....", "............", "############", ".##########.", ".##########.", ".##########.", "..########..", "...######...", "..#......#..", ".##......##." }, ["cultivator"] = new string[12] { "..........##", ".........##.", "........##..", ".......##...", "......##....", ".....##.....", "....##......", ".#####......", "#.#.#.......", "#.#.#.......", "#.#.#.......", "............" }, ["deer"] = new string[12] { "#.#......#.#", ".#........#.", ".##......##.", "..##....##..", "...######...", "...######...", "....####....", "....####....", ".....##.....", "............", "............", "............" }, ["egg"] = new string[12] { "............", "....####....", "...######...", "..########..", "..########..", ".##########.", ".##########.", ".##########.", "..########..", "...######...", "............", "............" }, ["eye"] = new string[12] { "............", "............", "....####....", "..##....##..", ".#...##...#.", "#...####...#", "#...####...#", ".#...##...#.", "..##....##..", "....####....", "............", "............" }, ["eye_expeditions"] = new string[12] { "............", "............", "...######...", ".##......##.", "#...####...#", "#..##..##..#", "#..##..##..#", "#...####...#", ".##......##.", "...######...", "............", "............" }, ["farmer"] = new string[12] { ".#...#...#..", "#.#.#.#.#.#.", ".#...#...#..", "#.#.#.#.#.#.", ".#...#...#..", "..#..#..#...", "...#.#.#....", "....###.....", ".....#......", ".....#......", ".....#......", ".....#......" }, ["feather"] = new string[12] { "..........#.", ".........##.", "........###.", ".......###..", "......###...", ".....###....", "....###.....", "...###......", "..##........", ".#..........", "#...........", "............" }, ["fish"] = new string[12] { "............", "............", "............", "...#####...#", ".#########.#", "##.#########", "###########.", ".#########.#", "...#####...#", "............", "............", "............" }, ["flower"] = new string[12] { "....#..#....", "..#.####.#..", "...######...", "..########..", "...######...", "..#.####.#..", "....#..#....", ".....##.....", ".....##.....", "...#.##.....", "....###.....", ".....##....." }, ["forest"] = new string[12] { ".....##.....", "....####....", "...######...", ".....##.....", "...######...", "..########..", ".....##.....", "..########..", ".##########.", ".....##.....", ".....##.....", "....####...." }, ["hammer"] = new string[12] { "............", ".######.....", ".#######....", ".######.....", "...##.......", "....##......", ".....##.....", "......##....", ".......##...", "........##..", ".........##.", "............" }, ["healer"] = new string[12] { "............", "....####....", "....#..#....", "....#..#....", ".####..####.", ".#........#.", ".#........#.", ".####..####.", "....#..#....", "....#..#....", "....####....", "............" }, ["hen"] = new string[12] { "....##......", "...####.....", "..##.###....", ".###.####..#", "....########", "....#######.", ".....######.", "......####..", ".......#....", "......#.#...", ".....#...#..", "............" }, ["hide"] = new string[12] { "............", "..#......#..", ".##########.", ".##########.", "..########..", "..########..", "..########..", ".##########.", ".##########.", "..#......#..", "............", "............" }, ["hide_expeditions"] = new string[12] { "............", ".##......##.", "..########..", "..########..", "...######...", "...######...", "...######...", "..########..", ".##########.", ".##......##.", "............", "............" }, ["hive"] = new string[12] { "............", "....####....", "...#....#...", "..########..", "..#......#..", ".##########.", ".#...##...#.", "############", "#..........#", "############", "............", "............" }, ["hoe"] = new string[12] { "........####", "........####", ".........##.", "........##..", ".......##...", "......##....", ".....##.....", "....##......", "...##.......", "..##........", ".##.........", "##.........." }, ["ingot"] = new string[12] { "............", "............", "............", "...######...", "..########..", ".##########.", "############", "############", "............", "............", "............", "............" }, ["keeper"] = new string[12] { "............", "...#....#...", "..########..", ".##########.", "###.####.###", "############", ".####..####.", "..########..", "..##....##..", "..##....##..", "............", "............" }, ["kiln"] = new string[12] { "....#..#....", ".....#..#...", "....#..#....", "............", "....####....", "..########..", ".##########.", ".####..####.", "####....####", "####....####", "############", "............" }, ["knife"] = new string[12] { "..........#.", ".........##.", "........###.", ".......###..", "......###...", ".....###....", "....###.....", "...#........", "..###.......", ".###........", "###.........", "##.........." }, ["lizard"] = new string[12] { "............", "........###.", ".......#####", "......##....", "#....###....", ".#..######..", "..#########.", "...########.", "....#.#..#..", "...#..#..#..", "............", "............" }, ["log"] = new string[12] { "............", "............", "...#######..", "..#.......#.", ".#..##.....#", ".#.#..#....#", ".#.#..#....#", ".#..##.....#", "..#.......#.", "...#######..", "............", "............" }, ["lox"] = new string[12] { "............", "#.........#.", ".#.......#..", "..#######...", ".#########..", "###########.", "###########.", "###########.", ".##.##.##.#.", ".##.##.##.#.", ".##.##.##.#.", "............" }, ["lumber"] = new string[12] { "....####....", "..########..", ".##########.", "############", "############", ".##########.", "..########..", "....####....", ".....##.....", ".....##.....", ".....##.....", "...######..." }, ["meadows"] = new string[12] { "............", "....##......", "...#..#.....", "....##......", ".....#......", ".....#...#..", "..#..#..#...", "...#.#.#....", "#...###...#.", ".#..###..#..", "..#.###.#...", "############" }, ["meat"] = new string[12] { "............", "......####..", ".....######.", "....#######.", "....#######.", ".....#####..", "....##......", "...##.......", "..##........", ".#.#........", "#...........", "............" }, ["mist"] = new string[12] { "............", "............", "....###.....", "...#####.##.", ".##########.", "############", "############", "............", "..########..", "............", ".########...", "............" }, ["mountains"] = new string[12] { "............", "............", "....##......", "...####.....", "..##..##....", "..######.#..", ".########.#.", ".#########.#", "############", "############", "............", "............" }, ["mushroom"] = new string[12] { "............", "...######...", ".##########.", "############", "#..######..#", "....####....", "....####....", "....####....", "...######...", "............", "............", "............" }, ["ocean"] = new string[12] { "............", "............", "..##....##..", ".#..#..#..#.", "#....##....#", "............", "..##....##..", ".#..#..#..#.", "#....##....#", "............", "............", "............" }, ["ore"] = new string[12] { "............", "....###.....", "...#####....", "..###.###...", ".#########..", ".####.####..", "###########.", "####.######.", ".#########..", "..#######...", "............", "............" }, ["pantry"] = new string[12] { "............", "...######...", "....####....", "...######...", "..#......#..", "..#.####.#..", "..#......#..", "..#.####.#..", "..#......#..", "..########..", "............", "............" }, ["pants"] = new string[12] { "............", "..########..", "..########..", "..########..", "..###..###..", "..###..###..", "..###..###..", "..###..###..", "..###..###..", "..###..###..", "..###..###..", "............" }, ["pick"] = new string[12] { "............", "..########..", ".#...##...#.", "#....##....#", ".....##.....", ".....##.....", ".....##.....", ".....##.....", ".....##.....", ".....##.....", ".....##.....", "............" }, ["pie"] = new string[12] { "............", "............", "....#..#....", "..########..", ".#.#.#.#.#..", "############", "#..........#", "############", ".##########.", "............", "............", "............" }, ["plains"] = new string[12] { "............", "............", "....####....", "..########..", ".##########.", "############", "............", "############", "............", "..########..", "............", "....####...." }, ["resin"] = new string[12] { ".....#......", ".....#......", "....###.....", "....###.....", "...#####....", "..#######...", "..#######...", "..#######...", "...#####....", "....###.....", "............", "............" }, ["rod"] = new string[12] { "..........#.", ".........#.#", "........#..#", ".......#...#", "......#....#", ".....#.....#", "....#......#", "...#......##", "..##......#.", ".###........", "###.........", "##.........." }, ["sausage"] = new string[12] { "............", ".........##.", "........####", "......#####.", "....#####...", "..#####.....", ".####.......", "####........", ".##.........", "............", "............", "............" }, ["search"] = new string[12] { "............", "...####.....", "..#....#....", ".#......#...", ".#......#...", ".#......#...", "..#....#....", "...####.#...", "........#...", ".........#..", "..........#.", "............" }, ["seed"] = new string[12] { "............", "............", "....##......", "...####.....", "..######....", "..######....", "...####.....", "....##..##..", ".......####.", "......######", ".......####.", "........##.." }, ["shield"] = new string[12] { "............", "..########..", ".##########.", ".####..####.", ".###.##.###.", ".###.##.###.", ".####..####.", ".##########.", "..########..", "...######...", ".....##.....", "............" }, ["shore"] = new string[12] { "............", "............", "..##....##..", ".#..#..#..#.", "#....##....#", "............", "..##....##..", ".#..#..#..#.", "#....##....#", "............", "............", "............" }, ["smelter"] = new string[12] { "....##......", "....##......", "...####.....", "..######....", ".########...", ".##....##...", ".#......#...", ".#..##..#...", ".#.####.#...", ".########...", "##########..", "............" }, ["spear"] = new string[12] { "..........##", ".........###", "........###.", ".......##...", "......##....", ".....##.....", "....##......", "...##.......", "..##........", ".##.........", "##..........", "............" }, ["swamp"] = new string[12] { "..#.......#.", ".###.....###", "..#...#...#.", "..#..###..#.", "..#...#...#.", "..#...#...#.", "..#...#...#.", "............", "##..##..##..", "..##..##..##", "............", "##..##..##.." }, ["tank"] = new string[12] { "....####....", "..########..", ".##########.", ".####..####.", "####....####", "###..##..###", "###..##..###", "####....####", ".####..####.", ".##########.", "..########..", "....####...." }, ["tree"] = new string[12] { "....####....", "..########..", ".##########.", "############", "############", ".##########.", "..########..", "....####....", ".....##.....", ".....##.....", ".....##.....", "...######..." }, ["tunic"] = new string[12] { "............", "..###..###..", ".##########.", "############", "############", "#.########.#", "..########..", "..########..", "..########..", "..########..", "..########..", "............" }, ["tunic_village"] = new string[12] { "............", "..###..###..", ".####..####.", "############", "##.######.##", "#..######..#", "...######...", "...######...", "...######...", "...######...", "...######...", "............" }, ["wheel"] = new string[12] { "...######...", "..#..#...#..", ".#...#....#.", "#....#.....#", "#....#.....#", "######.....#", "#....#.....#", "#....#.....#", ".#...#....#.", "..#..#...#..", "...######...", "....#..#...." }, ["windmill"] = new string[12] { "#..........#", ".#........#.", "..#......#..", "...#....#...", "....#..#....", ".....##.....", ".....##.....", "....#..#....", "...#.##.#...", "..#..##..#..", ".#..####..#.", "#..######..#" }, ["wolf"] = new string[12] { "............", "..#.......#.", "..##.....##.", "..#########.", ".##.#####.##", "############", ".##########.", "...######...", "...##..##...", "...##..##...", "..##....##..", "............" }, ["wood"] = new string[12] { "............", "............", "..##...##...", ".#..#.#..#..", ".#..#.#..#..", "..##...##...", "....##......", "...#..#.....", "...#..#.....", "....##......", "............", "............" }, ["worm"] = new string[12] { "............", "............", "..###.......", ".#...#......", ".#...#..###.", "..#...##...#", "...#.......#", "....###...#.", ".......###..", "............", "............", "............" } }; private const int Cell = 8; private static readonly Dictionary<string, Sprite> Cache = new Dictionary<string, Sprite>(); public static bool Has(string key) { if (key != null) { return Bitmaps.ContainsKey(key); } return false; } public static Sprite Get(string key) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: 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_0040: Expected O, but got Unknown //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_0266: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: 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_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) if (key == null || !Bitmaps.TryGetValue(key, out var value)) { return null; } if (Cache.TryGetValue(key, out var value2)) { return value2; } int num = 96; Texture2D val = new Texture2D(num, num, (TextureFormat)4, false) { filterMode = (FilterMode)1, wrapMode = (TextureWrapMode)1 }; Color[] array = (Color[])(object)new Color[num * num]; for (int i = 0; i < array.Length; i++) { array[i] = new Color(1f, 1f, 1f, 0f); } float num2 = 1.2f; Vector2 a = default(Vector2); Vector2 b = default(Vector2); Vector2 a2 = default(Vector2); Vector2 b2 = default(Vector2); Vector2 p = default(Vector2); for (int j = 0; j < 12; j++) { for (int k = 0; k < 12; k++) { if (j >= value.Length || k >= value[j].Length || value[j][k] != '#') { continue; } ((Vector2)(ref a))..ctor(((float)k + 0.18f) * 8f, ((float)j + 0.18f) * 8f); ((Vector2)(ref b))..ctor(((float)k + 0.82f) * 8f, ((float)j + 0.82f) * 8f); ((Vector2)(ref a2))..ctor(((float)k + 0.82f) * 8f, ((float)j + 0.18f) * 8f); ((Vector2)(ref b2))..ctor(((float)k + 0.18f) * 8f, ((float)j + 0.82f) * 8f); for (int l = j * 8 - 2; l < (j + 1) * 8 + 2; l++) { for (int m = k * 8 - 2; m < (k + 1) * 8 + 2; m++) { if (m >= 0 && l >= 0 && m < num && l < num) { ((Vector2)(ref p))..ctor((float)m + 0.5f, (float)l + 0.5f); float num3 = Mathf.Min(Seg(p, a, b), Seg(p, a2, b2)); float num4 = Mathf.Clamp01(num2 - num3 + 0.5f); int num5 = (num - 1 - l) * num + m; if (num4 > array[num5].a) { array[num5].a = num4; } } } } } } val.SetPixels(array); val.Apply(); value2 = Sprite.Create(val, new Rect(0f, 0f, (float)num, (float)num), new Vector2(0.5f, 0.5f), 100f); Cache[key] = value2; return value2; } private static float Seg(Vector2 p, Vector2 a, Vector2 b) { //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_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: 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_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_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_0025: 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) Vector2 val = b - a; float num = Mathf.Clamp01(Vector2.Dot(p - a, val) / ((Vector2)(ref val)).sqrMagnitude); return Vector2.Distance(p, a + val * num); } public static Image Draw(Transform parent, string key, float x, float y, float size, Color color) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) Sprite val = Get(key); Image val2 = Kit.Img(parent, "ic_" + key, x, y, size, size, val, color); val2.preserveAspect = true; if ((Object)(object)val == (Object)null) { ((Graphic)val2).color = Kit.Clear; } return val2; } public static string ForJob(string job) { return job switch { "tender" => "hammer", "farmer" => "farmer", "lumberjack" => "lumber", "fisher" => "rod", "keeper" => "keeper", "cook" => "cook", "alchemist" => "bottle", "soldier" => "shield", _ => "chest", }; } } internal abstract class BookPage { public abstract string Key { get; } public abstract string Title { get; } public virtual bool Live => true; public abstract void Build(RectTransform content, Book book); public virtual void OnShow(object select) { } public virtual void BuildOverlay(RectTransform book, Book b) { } } internal class Book { [HarmonyPatch(typeof(Player), "Message")] private static class CentreMessages { private static void Postfix(Player __instance, MessageType type, string msg) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Invalid comparison between Unknown and I4 if (IsOpen && (int)type == 2 && (Object)(object)__instance == (Object)(object)Player.m_localPlayer) { Flash((Localization.instance != null) ? Localization.instance.Localize(msg) : msg); } } } [HarmonyPatch(typeof(Menu), "Update")] private static class NoMenuWhileBook { private static bool Prefix() { if (!IsOpen) { return Time.frameCount - ClosedFrame > 1; } return false; } } public const float W = 1284f; public const float H = 752f; public const float ContentW = 1012f; public const float ContentH = 620f; private const float VX = 168f; private const float VY = 16f; private const float VW = 1100f; private const float VH = 720f; private GameObject _root; private RectTransform _book; private RectTransform _content; private RectTransform _overlay; private RectTransform _popup; private RectTransform _tips; private Action<RectTransform> _popupBuild; private RectTransform _tabs; private readonly List<BookPage> _pages = new List<BookPage>(); private BookPage _page; private float _next; private bool _dirty; public Func<bool> OnEscape; public static int ClosedFrame = -10; private Image _flash; private Text _flashText; private float _flashUntil; private static readonly Dictionary<Color, Sprite> TabSprites = new Dictionary<Color, Sprite>(); public static Book Instance { get; private set; } public static bool IsOpen { get { if (Instance != null && (Object)(object)Instance._root != (Object)null) { return Instance._root.activeSelf; } return false; } } public VillageBanner Banner { get; private set; } public Vector3 OpenedAt { get; private set; } public RectTransform TipLayer => _tips; public static void Register(BookPage page) { if (Instance == null) { Instance = new Book(); } if (!Instance._pages.Exists((BookPage p) => p.Key == page.Key)) { Instance._pages.Add(page); } } public static void Open(VillageBanner banner, string tab = null, object select = null) { if (!((Object)(object)banner == (Object)null) && banner.IsValid) { if (Instance == null) { Instance = new Book(); } Instance.DoOpen(banner, tab, select); } } public static void Close() { Instance?.DoClose(); } public static void Dirty() { if (Instance != null) { Instance._dirty = true; } } public static void Tick() { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) Book instance = Instance; if (instance == null || (Object)(object)instance._root == (Object)null || !instance._root.activeSelf) { return; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)instance.Banner == (Object)null || !instance.Banner.IsValid || (Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsDead() || Menu.IsVisible() || Vector3.Distance(((Component)localPlayer).transform.position, instance.OpenedAt) > 12f || (ZInput.GetKeyDown((KeyCode)27, false) && !instance.EscapeTaken())) { instance.DoClose(); return; } if ((Object)(object)instance._flash != (Object)null && ((Component)instance._flash).gameObject.activeSelf && Time.unscaledTime > instance._flashUntil) { ((Component)instance._flash).gameObject.SetActive(false); } instance._next -= Time.unscaledDeltaTime; if (instance._dirty || (instance._next <= 0f && instance._page != null && instance._page.Live && !instance.Typing() && !Input.GetMouseButton(0))) { instance.Redraw(); } } private bool EscapeTaken() { if (_popupBuild != null) { ClosePopup(); return true; } if (OnEscape != null) { return OnEscape(); } return false; } private bool Typing() { GameObject val = (((Object)(object)EventSystem.current != (Object)null) ? EventSystem.current.currentSelectedGameObject : null); InputField val2 = (((Object)(object)val != (Object)null) ? val.GetComponent<InputField>() : null); if ((Object)(object)val2 != (Object)null) { return val2.isFocused; } return false; } private void DoOpen(VillageBanner banner, string tab, object select) { //IL_0056: 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) Kit.LoadFonts(); if ((Object)(object)_root == (Object)null) { BuildFrame(); } bool activeSelf = _root.activeSelf; Banner = banner; Player localPlayer = Player.m_localPlayer; OpenedAt = (((Object)(object)localPlayer != (Object)null) ? ((Component)localPlayer).transform.position : banner.Position); BookPage page = _pages.Find((BookPage x) => x.Key == tab) ?? _page ?? ((_pages.Count > 0) ? _pages[0] : null); _root.SetActive(true); if (!activeSelf) { GUIManager.BlockInput(true); } Show(page, select); } private void DoClose() { if (!((Object)(object)_root == (Object)null) && _root.activeSelf) { _root.SetActive(false); OnEscape = null; GUIManager.BlockInput(false); ClosedFrame = Time.frameCount; } } public static void Flash(string text) { Book instance = Instance; if (instance != null && !((Object)(object)instance._flash == (Object)null) && IsOpen && !string.IsNullOrEmpty(text)) { instance._flashText.text = text; ((Component)instance._flash).gameObject.SetActive(true); ((Component)instance._flash).transform.SetAsLastSibling(); instance._flashUntil = Time.unscaledTime + 4f; } } public void Popup(Action<RectTransform> build) { _popupBuild = build; Clear(_popup); if (build != null) { BuildPopup(); } } public void ClosePopup() { _popupBuild = null; Clear(_popup); } private void BuildPopup() { //IL_0021: 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_005c: Unknown result type (might be due to invalid IL or missing references) Image val = ((Component)Kit.Fill((Transform)(object)_popup, "catch")).gameObject.AddComponent<Image>(); ((Graphic)val).color = Kit.Clear; ((Graphic)val).raycastTarget = true; ((Graphic)val).rectTransform.offsetMin = new Vector2(-2000f, -2000f); ((Graphic)val).rectTransform.offsetMax = new Vector2(2000f, 2000f); Kit.Clickable(((Component)val).gameObject, ClosePopup, (Graphic)(object)val); RectTransform obj = Kit.Rect((Transform)(object)_popup, "host", 0f, 0f, 1284f, 752f); try { _popupBuild(obj); } catch (Exception ex) { VillagePlugin.Log.LogError((object)("[ui] popup: " + ex)); } } public static Vector2 ContentToBook(float x, float y) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) return new Vector2(214f + x, 66f + y); } public Vector2 BookPos(RectTransform rt, bool bottom = true) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0019: 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) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) Vector3[] array = (Vector3[])(object)new Vector3[4]; rt.GetWorldCorners(array); Vector3 val = ((Transform)_book).InverseTransformPoint(bottom ? array[0] : array[1]); return new Vector2(val.x + 642f, 376f - val.y); } public void Show(BookPage page, object select = null) { _page = page; OnEscape = null; _popupBuild = null; page?.OnShow(select); Redraw(); } public void Redraw() { //IL_00f0: Unknown result type (might be due to invalid IL or missing references) _dirty = false; _next = 2f; if ((Object)(object)_root == (Object)null) { return; } bool showing = Tip.Showing; FitScale(); DrawTabs(); Clear(_content); Clear(_overlay); Clear(_popup); Clear(_tips); if (_page == null) { return; } try { _page.Build(_content, this); _page.BuildOverlay(_overlay, this); if (_popupBuild != null) { BuildPopup(); } Tip.Carry(showing, (Transform)(object)_book); } catch (Exception arg) { VillagePlugin.Log.LogError((object)$"[ui] page {_page.Key}: {arg}"); Kit.Text((Transform)(object)_content, "err", "Something went wrong drawing this page (see the log).", 0f, 0f, 1012f, 30f, 18, Kit.Red, null, (TextAnchor)3); } } private static void Clear(RectTransform rt) { for (int num = ((Transform)rt).childCount - 1; num >= 0; num--) { GameObject gameObject = ((Component)((Transform)rt).GetChild(num)).gameObject; gameObject.SetActive(false); Object.Destroy((Object)(object)gameObject); } } private void BuildFrame() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //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_0059: 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_0064: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007c: 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_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Expected O, but got Unknown //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Expected O, but got Unknown //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: 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_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_028d: 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_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_0305: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_0365: Unknown result type (might be due to invalid IL or missing references) //IL_0374: Unknown result type (might be due to invalid IL or missing references) //IL_0383: Unknown result type (might be due to invalid IL or missing references) //IL_03d1: Unknown result type (might be due to invalid IL or missing references) //IL_03e6: Unknown result type (might be due to invalid IL or missing references) //IL_04f6: Unknown result type (might be due to invalid IL or missing references) //IL_0500: Unknown result type (might be due to invalid IL or missing references) //IL_0505: Unknown result type (might be due to invalid IL or missing references) //IL_0519: Unknown result type (might be due to invalid IL or missing references) //IL_0555: Unknown result type (might be due to invalid IL or missing references) //IL_0405: Unknown result type (might be due to invalid IL or missing references) //IL_0424: Unknown result type (might be due to invalid IL or missing references) _root = new GameObject("TXCV_Book", new Type[1] { typeof(RectTransform) }); _root.layer = GUIManager.CustomGUIFront.layer; RectTransform val = (RectTransform)_root.transform; ((Transform)val).SetParent(GUIManager.CustomGUIFront.transform, false); val.anchorMin = Vector2.zero; val.anchorMax = Vector2.one; Vector2 val2 = (val.offsetMin = (val.offsetMax = Vector2.zero)); Canvas obj = _root.AddComponent<Canvas>(); obj.overrideSorting = true; obj.sortingOrder = 30000; _root.AddComponent<GraphicRaycaster>(); Image obj2 = ((Component)Kit.Fill(_root.transform, "dim")).gameObject.AddComponent<Image>(); ((Graphic)obj2).color = new Color(0.03f, 0.024f, 0.016f, 0.38f); ((Graphic)obj2).raycastTarget = true; GameObject val4 = new GameObject("book", new Type[1] { typeof(RectTransform) }); val4.layer = _root.layer; _book = (RectTransform)val4.transform; ((Transform)_book).SetParent(_root.transform, false); RectTransform book = _book; RectTransform book2 = _book; ((Vector2)(ref val2))..ctor(0.5f, 0.5f); book2.anchorMax = val2; book.anchorMin = val2; _book.pivot = new Vector2(0.5f, 0.5f); _book.sizeDelta = new Vector2(1284f, 752f); FitScale(); Kit.Img((Transform)(object)_book, "shadow", 158f, 24f, 1120f, 750f, Kit.Box(new Color(0f, 0f, 0f, 0.35f), Kit.Clear, 0f, 30f), Color.white); _tabs = Kit.Rect((Transform)(object)_book, "tabs", 0f, 100f, 170f, 400f); Kit.Img((Transform)(object)_book, "vellum", 168f, 16f, 1100f, 720f, Kit.HGradient(Kit.Vellum, Kit.VellumEdge, 0.8f), Color.white, raycast: true); Kit.Img((Transform)(object)_book, "vellumEdge", 168f, 16f, 1100f, 720f, Kit.Box(Kit.Clear, Kit.Brown, 2f, 0f), Color.white); _content = Kit.Rect((Transform)(object)_book, "content", 214f, 66f, 1012f, 620f); Kit.Img((Transform)(object)_book, "rodTop", 152f, 0f, 1132f, 32f, Kit.Rod(32f), Color.white); Kit.Img((Transform)(object)_book, "rodBottom", 152f, 720f, 1132f, 32f, Kit.Rod(32f), Color.white); Image val5 = Kit.Img((Transform)(object)_book, "TXCV_close", 1296f, 36f, 52f, 52f, Kit.Seal(Kit.RedBright, Kit.Hex("7a1a10"), 52f), Color.white, raycast: true); for (int i = 0; i < 2; i++) { RectTransform obj3 = Kit.Rect(((Component)val5).transform, "x" + i, 16f, 25f, 20f, 2f); obj3.pivot = new Vector2(0.5f, 0.5f); obj3.anchoredPosition = new Vector2(26f, -26f); ((Transform)obj3).localRotation = Quaternion.Euler(0f, 0f, (float)((i == 0) ? 45 : (-45))); Image obj4 = ((Component)obj3).gameObject.AddComponent<Image>(); ((Graphic)obj4).color = Kit.Hex("f6e6c8"); ((Graphic)obj4).raycastTarget = false; } Kit.Clickable(((Component)val5).gameObject, DoClose, (Graphic)(object)val5); _overlay = Kit.Rect((Transform)(object)_book, "overlay", 0f, 0f, 1284f, 752f); _popup = Kit.Rect((Transform)(object)_book, "popup", 0f, 0f, 1284f, 752f); _tips = Kit.Rect((Transform)(object)_book, "tips", 0f, 0f, 1284f, 752f); _flash = Kit.Img((Transform)(object)_book, "flash", 418f, 660f, 600f, 44f, Kit.Box(Kit.A(Color.black, 0.78f), Kit.GoldBorder, 1.5f, 8f), Color.white); _flashText = Kit.Text(((Component)_flash).transform, "t", "", 12f, 0f, 576f, 44f, 17, Kit.Cream, Kit.Bold, (TextAnchor)4); ((Component)_flash).gameObject.SetActive(false); _root.SetActive(false); } private void FitScale() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) RectTransform val = (RectTransform)_root.transform; Rect rect = val.rect; float height = ((Rect)(ref rect)).height; rect = val.rect; float width = ((Rect)(ref rect)).width; if (!(height <= 0f) && !(width <= 0f)) { float num = Mathf.Min(height / 1080f, width / 1920f * 1.2f); ((Transform)_book).localScale = new Vector3(num, num, 1f); } } private void DrawTabs() { //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) Clear(_tabs); float num = 0f; foreach (BookPage page in _pages) { bool flag = page == _page; float num2 = (flag ? 170 : 150); float num3 = (flag ? 66 : 58); float x = ((!flag) ? 18 : 0); Image val = Kit.Img((Transform)(object)_tabs, "TXCV_tab_" + page.Key, x, num, num2, num3, TabSprite(flag ? Kit.Vellum : Kit.Tab), Color.white, raycast: true); Kit.Text(((Component)val).transform, "label", Kit.Spaced(page.Title.ToUpperInvariant()), flag ? 18 : 16, 0f, num2 - 20f, num3, 15, flag ? Kit.Red : Kit.Ink, Kit.Bold, (TextAnchor)3); if (!flag) { BookPage target = page; Kit.Clickable(((Component)val).gameObject, delegate { Show(target); }, (Graphic)(object)val); } num += num3 + 12f; } } private static Sprite TabSprite(Color fill) { //IL_0005: 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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown //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_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) if (TabSprites.TryGetValue(fill, out var value)) { return value; } Texture2D val = new Texture2D(80, 132, (TextureFormat)4, false) { filterMode = (FilterMode)1, wrapMode = (TextureWrapMode)1 }; Color brown = Kit.Brown; for (int i = 0; i < 132; i++) { for (int j = 0; j < 80; j++) { float num = (float)j + 0.5f; float num2 = (float)i + 0.5f; float num3 = Mathf.Max(20f - num, 0f); float num4 = Mathf.Max(new float[3] { 20f - num2, num2 - 112f, 0f }); float num5 = ((num3 > 0f && num4 > 0f) ? (20f - Mathf.Sqrt(num3 * num3 + num4 * num4)) : Mathf.Min(num, Mathf.Min(num2, 132f - num2))); Color val2 = Color.Lerp(brown, fill, Mathf.Clamp01(num5 - 4f + 0.5f)); val2.a = Mathf.Clamp01(num5 + 0.5f); val.SetPixel(j, i, val2); } } val.Apply(); value = Sprite.Create(val, new Rect(0f, 0f, 80f, 132f), new Vector2(0.5f, 0.5f), 200f, 0u, (SpriteMeshType)0, new Vector4(22f, 22f, 4f, 22f)); TabSprites[fill] = value; return value; } } internal static class Kit { public static readonly Color Ink = Hex("2a1d14"); public static readonly Color Brown = Hex("5a4128"); public static readonly Color BrownMid = Hex("5a3a22"); public static readonly Color Muted = Hex("8a7356"); public static readonly Color Faint = Hex("b59a6c"); public static readonly Color Line = Hex("c9b08a"); public static readonly Color Vellum = Hex("ece0c0"); public static readonly Color VellumEdge = Hex("e2d1aa"); public static readonly Color Paper = Hex("f6eed8"); public static readonly Color PaperLight = Hex("fbf5e4"); public static readonly Color Cream = Hex("fbf1dc"); public static readonly Color Red = Hex("8e2418"); public static readonly Color RedHover = Hex("a32b1d"); public static readonly Color RedDark = Hex("5e150c"); public static readonly Color RedBright = Hex("c23a26"); public static readonly Color Green = Hex("4a5e2a"); public static readonly Color Blue = Hex("2f4f6a"); public static readonly Color Navy = Hex("3d4a7a"); public static readonly Color Orange = Hex("b0581f"); public static readonly Color Tab = Hex("cdb68a"); public static readonly Color GoldBorder = Hex("b9791f"); public static readonly Color GoldFill = Hex("f3dca0"); public static readonly Color GoldText = Hex("5a3a0a"); public static readonly Color Clear = new Color(0f, 0f, 0f, 0f); public static Font Regular; public static Font Medium; public static Font Bold; public static Font Uncial; private static bool _fontsTried; private static readonly Dictionary<string, Sprite> Sprites = new Dictionary<string, Sprite>(); private const int S = 2; public static Color Hex(string h, float a = 1f) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) int num = Convert.ToInt32(h, 16); return new Color((float)((num >> 16) & 0xFF) / 255f, (float)((num >> 8) & 0xFF) / 255f, (float)(num & 0xFF) / 255f, a); } public static Color A(Color c, float a) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) c.a = a; return c; } public static string F(double x, string fmt) { return x.ToString(fmt, CultureInfo.InvariantCulture); } public static string Rich(Color c) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return "#" + ColorUtility.ToHtmlStringRGB(c); } public static void LoadFonts() { if (!_fontsTried || !((Object)(object)Regular != (Object)null)) { _fontsTried = true; GUIManager instance = GUIManager.Instance; if (instance != null) { Regular = instance.AveriaSerif ?? instance.AveriaSerifBold; Medium = Regular; Bold = instance.AveriaSerifBold ?? Regular; Uncial = instance.NorseBold ?? instance.Norse ?? Bold; } } } public static Sprite Box(Color fill, Color border, float bw, float radius) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_015e: 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_015a: 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_0181: Unknown result type (might be due to invalid IL or missing references) string key = $"box{fill}{border}{bw}{radius}"; if (Sprites.TryGetValue(key, out var value)) { return value; } float num = Mathf.Max(radius, bw) * 2f; float num2 = bw * 2f; int num3 = Mathf.CeilToInt(num) + 2; int num4 = num3 * 2 + 2; Texture2D val = NewTex(num4, num4); Color[] array = (Color[])(object)new Color[num4 * num4]; for (int i = 0; i < num4; i++) { for (int j = 0; j < num4; j++) { float num5 = (float)j + 0.5f; float num6 = (float)i + 0.5f; float num7 = Mathf.Max(new float[3] { num - num5, num5 - ((float)num4 - num), 0f }); float num8 = Mathf.Max(new float[3] { num - num6, num6 - ((float)num4 - num), 0f }); float num9 = ((!(num7 > 0f) || !(num8 > 0f)) ? Mathf.Min(Mathf.Min(num5, (float)num4 - num5), Mathf.Min(num6, (float)num4 - num6)) : (num - Mathf.Sqrt(num7 * num7 + num8 * num8))); float num10 = Mathf.Clamp01(num9 + 0.5f); float num11 = Mathf.Clamp01(num9 - num2 + 0.5f); Color val2 = ((num2 > 0f) ? Color.Lerp(border, fill, num11) : fill); val2.a *= num10; array[i * num4 + j] = val2; } } val.SetPixels(array); val.Apply(); value = Sprite.Create(val, new Rect(0f, 0f, (float)num4, (float)num4), new Vector2(0.5f, 0.5f), 200f, 0u, (SpriteMeshType)0, new Vector4((float)num3, (float)num3, (float)num3, (float)num3)); Sprites[key] = value; return value; } public static Sprite Rod(float h) { //IL_004f: 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_0060: 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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0082: 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_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: 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_00c9: 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_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: 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_0134: 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_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: 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) string key = "rod" + h; if (Sprites.TryGetValue(key, out var value)) { return value; } int num = Mathf.RoundToInt(h * 2f); int num2 = num / 2; int num3 = num * 2 + 2; Texture2D val = NewTex(num3, num); Color val2 = Hex("8a6040"); Color val3 = Hex("4a2f1b"); Color val4 = Hex("2e1c10"); Color val5 = Hex("1e120a"); for (int i = 0; i < num; i++) { float num4 = 1f - ((float)i + 0.5f) / (float)num; Color val6 = ((num4 < 0.6f) ? Color.Lerp(val2, val3, num4 / 0.6f) : Color.Lerp(val3, val4, (num4 - 0.6f) / 0.4f)); for (int j = 0; j < num3; j++) { float num5 = (float)j + 0.5f; float num6 = (float)i + 0.5f; float num7 = Mathf.Max(new float[3] { (float)num2 - num5, num5 - (float)(num3 - num2), 0f }); float num8 = num6 - (float)num2; float num9 = (float)num2 - Mathf.Sqrt(num7 * num7 + num8 * num8); Color val7 = Color.Lerp(val5, val6, Mathf.Clamp01(num9 - 2f + 0.5f)); val7.a = Mathf.Clamp01(num9 + 0.5f); val.SetPixel(j, i, val7); } } val.Apply(); value = Sprite.Create(val, new Rect(0f, 0f, (float)num3, (float)num), new Vector2(0.5f, 0.5f), 200f, 0u, (SpriteMeshType)0, new Vector4((float)(num2 + 1), 0f, (float)(num2 + 1), 0f)); Sprites[key] = value; return value; } public static Sprite HGradient(Color a, Color b, float startAt) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0053: 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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) string key = $"hg{a}{b}{startAt}"; if (Sprites.TryGetValue(key, out var value)) { return value; } Texture2D val = NewTex(256, 2); for (int i = 0; i < 256; i++) { float num = ((float)i + 0.5f) / 256f; Color val2 = ((num <= startAt) ? a : Color.Lerp(a, b, (num - startAt) / (1f - startAt))); val.SetPixel(i, 0, val2); val.SetPixel(i, 1, val2); } val.Apply(); value = Sprite.Create(val, new Rect(0f, 0f, 256f, 2f), new Vector2(0.5f, 0.5f), 100f); Sprites[key] = value; return value; } public static Sprite Seal(Color light, Color dark, float d) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: 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_00d0: 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_0171: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) string key = $"seal{light}{dark}{d}"; if (Sprites.TryGetValue(key, out var value)) { return value; } int num = Mathf.RoundToInt(d * 2f); Texture2D val = NewTex(num, num); float num2 = (float)num / 2f; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor((float)num * 0.38f, (float)num * 0.65f); Color val3 = A(Cream, 0.55f); Vector2 val4 = default(Vector2); for (int i = 0; i < num; i++) { for (int j = 0; j < num; j++) { ((Vector2)(ref val4))..ctor((float)j + 0.5f, (float)i + 0.5f); float num3 = Vector2.Distance(val4, new Vector2(num2, num2)); float num4 = Mathf.Clamp01(Vector2.Distance(val4, val2) / ((float)num * 0.75f) / 0.75f); Color val5 = Color.Lerp(light, dark, num4); float num5 = num2 - 12f - 1f; if (Mathf.Abs(num3 - num5) < 1.5f && (int)((Mathf.Atan2(val4.y - num2, val4.x - num2) * 57.29578f + 180f) / 9f) % 2 == 0) { val5 = Color.Lerp(val5, new Color(val3.r, val3.g, val3.b), val3.a); } val5.a = Mathf.Clamp01(num2 - num3 + 0.5f); val.SetPixel(j, i, val5); } } val.Apply(); value = Sprite.Create(val, new Rect(0f, 0f, (float)num, (float)num), new Vector2(0.5f, 0.5f), 200f); Sprites[key] = value; return value; } public static Sprite Dot(float d) { //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) string key = "dot" + d; if (Sprites.TryGetValue(key, out var value)) { return value; } int num = Mathf.Max(4, Mathf.RoundToInt(d * 2f * 2f)); Texture2D val = NewTex(num, num); float num2 = (float)num / 2f; for (int i = 0; i < num; i++) { for (int j = 0; j < num; j++) { float num3 = Vector2.Distance(new Vector2((float)j + 0.5f, (float)i + 0.5f), new Vector2(num2, num2)); val.SetPixel(j, i, new Color(1f, 1f, 1f, Mathf.Clamp01(num2 - num3 + 0.5f))); } } val.Apply(); value = Sprite.Create(val, new Rect(0f, 0f, (float)num, (float)num), new Vector2(0.5f, 0.5f), 400f); Sprites[key] = value; return value; } private static Texture2D NewTex(int w, int h) { //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_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown return new Texture2D(w, h, (TextureFormat)4, false) { filterMode = (FilterMode)1, wrapMode = (TextureWrapMode)1 }; } public static RectTransform Rect(Transform parent, string name, float x, float y, float w, float h) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: 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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007e: 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_008e: Expected O, but got Unknown RectTransform val = (RectTransform)new GameObject(name, new Type[1] { typeof(RectTransform) }) { layer = ((Component)parent).gameObject.layer }.transform; ((Transform)val).SetParent(parent, false); Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(0f, 1f); val.anchorMax = val2; val.anchorMin = val2; val.pivot = new Vector2(0f, 1f); val.anchoredPosition = new Vector2(x, 0f - y); val.sizeDelta = new Vector2(w, h); return val; } public static RectTransform Fill(Transform parent, string name, float inset = 0f) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_0048: 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_0055: 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_006f: Expected O, but got Unknown RectTransform val = (RectTransform)new GameObject(name, new Type[1] { typeof(RectTransform) }) { layer = ((Component)parent).gameObject.layer }.transform; ((Transform)val).SetParent(parent, false); val.anchorMin = Vector2.zero; val.anchorMax = Vector2.one; val.offsetMin = new Vector2(inset, inset); val.offsetMax = new Vector2(0f - inset, 0f - inset); return val; } public static Image Img(Transform parent, string name, float x, float y, float w, float h, Sprite sprite, Color color, bool raycast = false) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) Image val = ((Component)Rect(parent, name, x, y, w, h)).gameObject.AddComponent<Image>(); val.sprite = sprite; ((Graphic)val).color = color; ((Graphic)val).raycastTarget = raycast; if ((Object)(object)sprite != (Object)null && sprite.border != Vector4.zero) { val.type = (Type)1; } return val; } public static Image Panel(Transform parent, string name, float x, float y, float w, float h, Color fill, Color border, float bw = 1.5f, float radius = 3f, bool raycast = false) { //IL_0008: 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_0015: Unknown result type (might be due to invalid IL or missing references) return Img(parent, name, x, y, w, h, Box(fill, border, bw, radius), Color.white, raycast); } public static Text Text(Transform parent, string name, string text, float x, float y, float w, float h, int size, Color color, Font font = null, TextAnchor anchor = (TextAnchor)3, bool wrap = false) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) Text obj = ((Component)Rect(parent, name, x, y, w, h)).gameObject.AddComponent<Text>(); obj.font = font ?? Regular; obj.fontSize = size; ((Graphic)obj).color = color; obj.alignment = anchor; obj.supportRichText = true; obj.horizontalOverflow = (HorizontalWrapMode)(!wrap); obj.verticalOverflow = (VerticalWrapMode)1; ((Graphic)obj).raycastTarget = false; obj.lineSpacing = 1f; obj.text = text; return obj; } public static float Measure(string text, Font font, int size) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004d: 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_0063: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0084: 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_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(text) || (Object)(object)font == (Object)null) { return 0f; } TextGenerationSettings val = new TextGenerationSettings { font = font, fontSize = size, scaleFactor = 1f, richText = true, textAnchor = (TextAnchor)0, color = Color.white, generationExtents = new Vector2(4000f, 200f), pivot = Vector2.zero, horizontalOverflow = (HorizontalWrapMode)1, verticalOverflow = (VerticalWrapMode)1, lineSpacing = 1f, generateOutOfBounds = true, updateBounds = true }; return new TextGenerator().GetPreferredWidth(text, val); } public static float Heading(Transform parent, string text, float x, float y, float w, Color? color = null, string right = null) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0094: 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) string text2 = Spaced(text.ToUpperInvariant()); Text(parent, "H_" + text, text2, x, y, w, 18f, 12, (Color)(((??)color) ?? Ink), Bold, (TextAnchor)3); if (right != null) { Text(parent, "HR", Spaced(right.ToUpperInvariant()), x, y, w, 18f, 11, Muted, Bold, (TextAnchor)5); } Img(parent, "rule", x, y + 21f, w, 2f, null, Brown); return y + 30f; } public static string Spaced(string s) { StringBuilder stringBuilder = new StringBuilder(s.Length * 2); for (int i = 0; i < s.Length; i++) { stringBuilder.Append(s[i]); if (i < s.Length - 1 && s[i] != ' ' && s[i + 1] != ' ') { stringBuilder.Append('\u200a'); } } return stringBuilder.ToString(); } public static Button Clickable(GameObject go, Action onClick, Graphic target = null) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Expected O, but got Unknown Button val = go.GetComponent<Button>() ?? go.AddComponent<Button>(); ((Selectable)val).transition = (Transition)0; Navigation navigation = default(Navigation); ((Navigation)(ref navigation)).mode = (Mode)0; ((Selectable)val).navigation = navigation; if ((Object)(object)target != (Object)null) { ((Selectable)val).targetGraphic = target; target.raycastTarget = true; } ((UnityEvent)val.onClick).AddListener((UnityAction)delegate { try { onClick(); } catch (Exception ex) { VillagePlugin.Log.LogError((object)("[ui] click: " + ex)); } }); return val; } public static void Hover(Graphic g, Color normal, Color hover) { //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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) HoverTint obj = ((Component)g).gameObject.GetComponent<HoverTint>() ?? ((Component)g).gameObject.AddComponent<HoverTint>(); obj.Target = g; obj.Normal = normal; obj.Over = hover; g.color = normal; } } internal class HoverTint : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler { public Graphic Target; public Color Normal; public Color Over; public void OnPointerEnter(PointerEventData e) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Target != (Object)null) { Target.color = Over; } } public void OnPointerExit(PointerEventData e) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Target != (Object)null) { Target.color = Normal; } } } internal static class Pages { private static bool _done; public static bool Open(VillageBanner v, string tab, object select = null) { if ((Object)(object)v == (Object)null || !v.IsValid) { return false; } RegisterAll(); Book.Open(v, tab, select); return true; } public static void RegisterAll() { if (!_done) { _done = true; Book.Register(new VillagePage()); Book.Register(new ExpeditionsPage()); Book.Register(new WorkPage()); Book.Register(new StoragePage()); } } } internal class StoragePage : BookPage { private class Entry { public string Prefab; public string Name; public string Group; public int Count; public Sprite Icon; } private string _search = ""; private string _sel = ""; private float _scroll; private int _amount = 5; private int _bringMode = 1; private static readonly string[] Groups = new string[7] { "Materials", "Ores & metals", "Food", "Potions & meads", "Seeds", "Gear", "Other" }; public override string Key => "storage"; public override string Title => "Storage"; private static string GroupOf(ItemData d, string prefab) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Invalid comparison between Unknown and I4 //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Invalid comparison between Unknown and I4 //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Invalid comparison between Unknown and I4 //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Invalid comparison between Unknown and I4 ItemType itemType = d.m_shared.m_itemType; string text = prefab.ToLowerInvariant(); if (Foods.IsFood(d)) { return "Food"; } if ((int)itemType == 2) { return "Potions & meads"; } if (text.Contains("seed") || text.EndsWith("cone") || Crops.All.Any((Crops.Info c) => c.Plan.Seed == prefab && c.Plan.Seed != c.Plan.Product)) { return "Seeds"; } if (!text.EndsWith("ore") && !text.Contains("scrap")) { switch (text) { default: if (!text.StartsWith("flametal") && !text.Contains("nails")) { if ((int)itemType == 1) { return "Materials"; } if ((int)itemType == 13 || (int)itemType == 16) { return "Other"; } return "Gear"; } break; case "copper": case "tin": case "bronze": case "iron": case "silver": case "blackmetal": break; } } return "Ores & metals"; } public override void Build(RectTransform c, Book book) { //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_048a: Unknown result type (might be due to invalid IL or missing references) //IL_04ce: Unknown result type (might be due to invalid IL or missing references) //IL_0504: Unknown result type (might be due to invalid IL or missing references) //IL_053f: Unknown result type (might be due to invalid IL or missing references) //IL_0573: Unknown result type (might be due to invalid IL or missing references) //IL_05a5: Unknown result type (might be due to invalid IL or missing references) //IL_05d6: Unknown result type (might be due to invalid IL or missing references) //IL_0602: Unknown result type (might be due to invalid IL or missing references) //IL_0449: Unknown result type (might be due to invalid IL or missing references) //IL_06c5: Unknown result type (might be due to invalid IL or missing references) //IL_06ec: Unknown result type (might be due to invalid IL or missing references) //IL_0723: Unknown result type (might be due to invalid IL or missing references) //IL_0769: Unknown result type (might be due to invalid IL or missing references) //IL_085f: Unknown result type (might be due to invalid IL or missing references) //IL_0891: Unknown result type (might be due to invalid IL or missing references) //IL_08d0: Unknown result type (might be due to invalid IL or missing references) //IL_08c9: Unknown result type (might be due to invalid IL or missing references) //IL_08d5: Unknown result type (might be due to invalid IL or missing references) //IL_08e9: Unknown result type (might be due to invalid IL or missing references) //IL_092c: Unknown result type (might be due to invalid IL or missing references) //IL_0925: Unknown result type (might be due to invalid IL or missing references) //IL_09ae: Unknown result type (might be due to invalid IL or missing references) //IL_09b3: Unknown result type (might be due to invalid IL or missing references) //IL_09f3: Unknown result type (might be due to invalid IL or missing references) //IL_09ec: Unknown result type (might be due to invalid IL or missing references) //IL_09f8: Unknown result type (might be due to invalid IL or missing references) //IL_0a0c: Unknown result type (might be due to invalid IL or missing references) //IL_0a50: Unknown result type (might be due to invalid IL or missing references) //IL_0a49: Unknown result type (might be due to invalid IL or missing references) //IL_0b5e: Unknown result type (might be due to invalid IL or missing references) //IL_0b68: Unknown result type (might be due to invalid IL or missing references) //IL_0b6d: Unknown result type (might be due to invalid IL or missing references) //IL_0b77: Unknown result type (might be due to invalid IL or missing references) //IL_0b9e: Unknown result type (might be due to invalid IL or missing references) //IL_0bd9: Unknown result type (might be due to invalid IL or missing references) //IL_0c75: Unknown result type (might be due to invalid IL or missing references) //IL_0c17: Unknown result type (might be due to invalid IL or missing references) VillageBanner v = book.Banner; List<Container> list = Stations.Chests(v); Dictionary<string, Entry> dictionary = new Dictionary<string, Entry>(); foreach (Container item in list) { foreach (ItemData allItem in item.GetInventory().GetAllItems()) { string text = Stations.PrefabOf(allItem); if (text.Length != 0) { if (!dictionary.TryGetValue(text, out var value)) { Entry obj = new Entry { Prefab = text, Name = Localization.instance.Localize(allItem.m_shared.m_name), Group = GroupOf(allItem, text), Icon = allItem.GetIcon() }; value = obj; dictionary[text] = obj; } value.Count += allItem.m_stack; } } } List<Entry> list2 = dictionary.Values.Where((Entry e) => _search.Length == 0 || e.Name.IndexOf(_search, StringComparison.OrdinalIgnoreCase) >= 0).ToList(); if (_sel.Length == 0 || !dictionary.ContainsKey(_sel)) { _sel = list2.OrderByDescending((Entry e) => e.Count).FirstOrDefault()?.Prefab ?? ""; } W.Input((Transform)(object)c, "search", _search, 0f, 0f, 560f, 40f, 16, Kit.Medium, delegate(string s) { _search = s.Trim(); _scroll = 0f; Book.Dirty(); }, null, 0, numbers: false, (TextAnchor)3); if (_search.Length == 0) { Kit.Text((Transform)(object)c, "ph", "Search the chests", 40f, 0f, 300f, 40f, 16, Kit.Muted, Kit.Medium, (TextAnchor)3); } Icons.Draw((Transform)(object)c, "search", 12f, 10f, 20f, Kit.Brown); float cw = 67.75f; List<Action<RectTransform, float>> list3 = new List<Action<RectTransform, float>>(); List<float> list4 = new List<float>(); string[] groups = Groups; foreach (string g in groups) { List<Entry> list5 = (from e in list2 where e.Group == g orderby e.Name select e).ToList(); if (list5.Count == 0) { continue; } string label = g; list3.Add(delegate(RectTransform r, float y) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) string text2 = Kit.Spaced(label.ToUpperInvariant()); float num9 = Kit.Measure(text2, Kit.Bold, 12); Kit.Text((Transform)(object)r, "g", text2, 2f, y + 2f, num9 + 4f, 18f, 12, Kit.Red, Kit.Bold, (TextAnchor)3); Kit.Img((Transform)(object)r, "gl", num9 + 14f, y + 13f, 542f - num9 - 16f, 1f, null, Kit.Line); }); list4.Add(26f); for (int num2 = 0; num2 < list5.Count; num2 += 8) { List<Entry> chunk = list5.Skip(num2).Take(8).ToList(); list3.Add(delegate(RectTransform r, float y) { //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_00be: 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_0099: 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_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < chunk.Count; i++) { Entry entry = chunk[i]; bool flag = entry.Prefab == _sel; Image val3 = Kit.Img((Transform)(object)r, "TXCV_item_" + entry.Prefab, (float)i * cw, y, cw - 4f, 70f, flag ? Kit.Box(Kit.A(Kit.Red, 0.1f), Kit.Red, 2f, 3f) : Kit.Box(Kit.Clear, Kit.Clear, 0f, 3f), Color.white, raycast: true); W.Slot(((Component)val3).transform, "s", (cw - 4f - 44f) / 2f, 4f, 44f, entry.Icon, null, Kit.Ink); Kit.Text(((Component)val3).transform, "n", entry.Count.ToString(), 0f, 50f, cw - 4f, 18f, 14, Kit.Ink, Kit.Bold, (TextAnchor)4); string pp = entry.Prefab; string nm = entry.Name; Kit.Clickable(((Component)val3).gameObject, delegate { _sel = pp; Book.Dirty(); }, (Graphic)(object)val3); Tip.On(((Component)val3).gameObject, delegate(RectTransform h) { //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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) float num9 = Kit.Measure(nm, Kit.Bold, 14) + 20f; RectTransform parent = Kit.Rect((Transform)(object)h, "nt", (cw - 4f) / 2f - num9 / 2f, 2f, num9, 28f); Kit.Img((Transform)(object)parent, "bg", 0f, 0f, num9, 28f, Kit.Box(Kit.Ink, Kit.Ink, 0f, 3f), Color.white); Kit.Text((Transform)(object)parent, "t", nm, 0f, 0f, num9, 28f, 14, Kit.Cream, Kit.Bold, (TextAnchor)4); }); } }); list4.Add(76f); } } float contentHeight = list4.Sum(); ScrollArea scrollArea = ScrollArea.Make((Transform)(object)c, "grid", 0f, 52f, 542f, 568f, contentHeight, () => _scroll, delegate(float s) { _scroll = s; }); float num3 = 0f; for (int num4 = 0; num4 < list3.Count; num4++) { list3[num4](scrollArea.Content, num3); num3 += list4[num4]; } scrollArea.Apply(); if (list2.Count == 0) { Kit.Text((Transform)(object)c, "none", (dictionary.Count == 0) ? "The village chests are empty." : "Nothing matches.", 0f, 70f, 560f, 30f, 16, Kit.Muted, Kit.Medium, (TextAnchor)3); } float num5 = 588f; float num6 = 1012f - num5; Kit.Img((Transform)(object)c, "div", num5 - 14f, 0f, 1f, 620f, null, Kit.Faint); if (_sel.Length == 0 || !dictionary.TryGetValue(_sel, out var value2)) { return; } W.Slot((Transform)(object)c, "big", num5, 0f, 92f, value2.Icon, null, Kit.Ink); Kit.Text((Transform)(object)c, "nm", value2.Name, num5 + 106f, 10f, num6 - 180f, 36f, 28, Kit.Ink, Kit.Bold, (TextAnchor)3); Kit.Text((Transform)(object)c, "gr", value2.Group, num5 + 106f, 48f, num6 - 180f, 22f, 15, Kit.BrownMid, Kit.Medium, (TextAnchor)3); Kit.Text((Transform)(object)c, "tot", value2.Count.ToString(), num5, 4f, num6, 44f, 32, Kit.Red, Kit.Bold, (TextAnchor)5); Kit.Text((Transform)(object)c, "totl", Kit.Spaced("TOTAL"), num5, 46f, num6, 18f, 12, Kit.BrownMid, Kit.Bold, (TextAnchor)5); float num7 = 112f; Kit.Img((Transform)(object)c, "r1", num5, num7 - 8f, num6, 2f, null, Kit.Brown); Kit.Text((Transform)(object)c, "ih", Kit.Spaced("IN THESE CHESTS"), num5, num7, 200f, 24f, 13, Kit.BrownMid, Kit.Bold, (TextAnchor)3); List<Container> holders = (from ch in list where Stations.Count(ch.GetInventory(), _sel) > 0 orderby Stations.Count(ch.GetInventory(), _sel) descending select ch).Take(6).ToList(); W.Button((Transform)(object)c, "hall", "Highlight all", num5 + num6 - 120f, num7, 120f, 24f, W.Style.Paper, delegate { foreach (Container item2 in holders) { Glow.Show(item2, 30f); } Book.Dirty(); }, 13, upper: false); num7 += 32f; foreach (Container item3 in holders) { Kit.Img((Transform)(object)c, "cr", num5, num7 + 35f, num6, 1f, null, Kit.Faint); Icons.Draw((Transform)(object)c, "chest", num5 + 4f, num7 + 6f, 24f, Kit.Brown); Kit.Text((Transform)(object)c, "cn", ChestName(v, item3), num5 + 38f, num7, num6 - 220f, 36f, 15, Kit.Ink, Kit.Medium, (TextAnchor)3); Kit.Text((Transform)(object)c, "cc", Stations.Count(item3.GetInventory(), _sel).ToString(), num5, num7, num6 - 160f, 36f, 15, Kit.Ink, Kit.Bold, (TextAnchor)5); Container target = item3; float num8 = Glow.Left(item3); if (num8 > 0f) { W.Button((Transform)(object)c, "glow", $"Glowing · {Mathf.CeilToInt(num8)} s", num5 + num6 - 150f, num7 + 3f, 150f, 30f, W.Style.Gold, null, 13, upper: false); } else { W.Button((Transform)(object)c, "hl", "Highlight", num5 + num6 - 150f, num7 + 3f, 150f, 30f, W.Style.Paper, delegate { Glow.Show(target, 30f); Book.Dirty(); }, 13, upper: false); } num7 += 38f; } num7 += 14f; Kit.Img((Transform)(object)c, "r2", num5, num7, num6, 2f, null, Kit.Brown); Kit.Text((Transform)(object)c, "bh", Kit.Spaced("BRING TO ME"), num5, num7 + 8f, 200f, 24f, 13, Kit.BrownMid, Kit.Bold, (TextAnchor)3); num7 += 42f; Image val = Kit.Img((Transform)(object)c, "TXCV_bring_one", num5, num7, 40f, 40f, Kit.Box((_bringMode == 0) ? Kit.Red : Kit.Paper, Kit.Brown, 1.5f, 3f), Color.white, raycast: true); Kit.Text(((Component)val).transform, "t", "1", 0f, 0f, 40f, 40f, 16, (_bringMode == 0) ? Kit.Cream : Kit.Ink, Kit.Bold, (TextAnchor)4); Kit.Clickable(((Component)val).gameObject, delegate { _bringMode = 0; Book.Dirty(); }, (Graphic)(object)val); W.Amount((Transform)(object)c, "bring_n", num5 + 44f, num7, _amount, delegate(int n) { _amount = n; _bringMode = 1; Book.Dirty(); }); if (_bringMode == 1) { Kit.Panel((Transform)(object)c, "bsel", num5 + 43f, num7 - 1f, 134f, 42f, Kit.Clear, Kit.Red, 2f); } Image val2 = Kit.Img((Transform)(object)c, "TXCV_bring_all", num5 + 180f, num7, 50f, 40f, Kit.Box((_bringMode == 2) ? Kit.Red : Kit.Paper, Kit.Brown, 1.5f, 3f), Color.white, raycast: true); Kit.Text(((Component)val2).transform, "t", "All", 0f, 0f, 50f, 40f, 15, (_bringMode == 2) ? Kit.Cream : Kit.Ink, Kit.Bold, (TextAnchor)4); Kit.Clickable(((Component)val2).gameObject, delegate { _bringMode = 2; Book.Dirty(); }, (Graphic)(object)val2);