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 Kvist v1.0.1
plugins/Kvist/GreydwarfSorter.dll
Decompiled a month ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GreydwarfSorter.Categories; using GreydwarfSorter.Chests; using GreydwarfSorter.Crafting; using GreydwarfSorter.Farming; using GreydwarfSorter.Mining; using GreydwarfSorter.Patches; using GreydwarfSorter.Pieces; using GreydwarfSorter.Smelting; using GreydwarfSorter.Tools; using GreydwarfSorter.Upkeep; using GreydwarfSorter.Worker; using HarmonyLib; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using Microsoft.CodeAnalysis; using Splatform; using TMPro; using UnityEngine; using UnityEngine.AI; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.Rendering; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("assembly_utils")] [assembly: IgnoresAccessChecksTo("assembly_valheim")] [assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] [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 GreydwarfSorter { internal static class Keys { public static readonly int RespawnAt = StringExtensionMethods.GetStableHashCode("gs_respawn_at"); public static readonly int Carry = StringExtensionMethods.GetStableHashCode("gs_carry"); public static readonly int State = StringExtensionMethods.GetStableHashCode("gs_state"); public static readonly int Label = StringExtensionMethods.GetStableHashCode("gs_label"); public static readonly int Mode = StringExtensionMethods.GetStableHashCode("gs_mode"); public static readonly int Butcher = StringExtensionMethods.GetStableHashCode("gs_butcher"); public static readonly int ButcherKinds = StringExtensionMethods.GetStableHashCode("gs_butcher_kinds"); public static readonly int WorkerName = StringExtensionMethods.GetStableHashCode("gs_worker_name"); public static readonly int Problem = StringExtensionMethods.GetStableHashCode("gs_problem"); public static readonly int ProblemAt = StringExtensionMethods.GetStableHashCode("gs_problem_at"); public static readonly int Doing = StringExtensionMethods.GetStableHashCode("gs_doing"); public static readonly int ClaimAt = StringExtensionMethods.GetStableHashCode("gs_claim_at"); public static readonly int ClaimUntil = StringExtensionMethods.GetStableHashCode("gs_claim_until"); public static readonly int StatDay = StringExtensionMethods.GetStableHashCode("gs_stat_day"); public static readonly int[] Stats = new int[5] { StringExtensionMethods.GetStableHashCode("gs_stat_sorted"), StringExtensionMethods.GetStableHashCode("gs_stat_fed"), StringExtensionMethods.GetStableHashCode("gs_stat_harvested"), StringExtensionMethods.GetStableHashCode("gs_stat_planted"), StringExtensionMethods.GetStableHashCode("gs_stat_butchered") }; public static readonly int NestId = StringExtensionMethods.GetStableHashCode("gs_nest_id"); public static ZDOID GetLink(ZDO zdo) { //IL_000b: 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) if (zdo != null) { return zdo.GetConnectionZDOID((ConnectionType)3); } return ZDOID.None; } public static void SetLink(ZDO zdo, ZDOID target) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) zdo.SetConnection((ConnectionType)3, target); } } internal static class ModConfig { public static ConfigEntry<float> WorkRadius; public static ConfigEntry<float> MaxWorkRadius; public static ConfigEntry<int> CarryStacks; public static ConfigEntry<bool> DetailedLog; public static ConfigEntry<float> RespawnSeconds; public static ConfigEntry<float> HealSeconds; public static ConfigEntry<float> HealPercent; public static ConfigEntry<float> HealRange; public static readonly Dictionary<SorterStation.Mode, ConfigEntry<bool>> ModeEnabled = new Dictionary<SorterStation.Mode, ConfigEntry<bool>>(); public static ConfigEntry<bool> Scavenging; public static ConfigEntry<bool> BringMe; public static ConfigEntry<bool> FollowBackpack; public static ConfigEntry<bool> FollowHeal; public static ConfigEntry<bool> Flatten; public static ConfigEntry<float> AITickSeconds; public static ConfigEntry<float> IdleSeconds; public static ConfigEntry<float> DepositSeconds; public static ConfigEntry<float> StuckSeconds; public static ConfigEntry<float> ArriveDistance; public static ConfigEntry<KeyCode> LabelKey; public static ConfigEntry<bool> AreaFallback; public static ConfigEntry<int> CollectBatch; public static ConfigEntry<bool> Run; public static ConfigEntry<bool> NestSound; public static ConfigEntry<bool> Butchering; public static ConfigEntry<int> Breeders; public static ConfigEntry<int> ChickenFlock; public static ConfigEntry<int> ChickenCullAbove; public static ConfigEntry<int> SeedReserve; public static ConfigEntry<int> ForageLimit; public static ConfigEntry<float> TreeRadius; public static ConfigEntry<int> WoodLimit; public static ConfigEntry<float> MineRadius; public static ConfigEntry<int> MineLimit; public static ConfigEntry<int> FishLimit; public static ConfigEntry<int> CropLimit; public static ConfigEntry<int> CoalStock; public static ConfigEntry<int> KilnWoodReserve; public static ConfigEntry<int> TreeSeedReserve; public static ConfigEntry<int> SaplingsPerTree; public static ConfigEntry<bool> SmartPriorities; public static ConfigEntry<bool> TeleportWhenStuck; public static ConfigEntry<bool> BusyTeleport; public static ConfigEntry<bool> IdleSorting; public static ConfigEntry<float> ScavengeTime; public static ConfigEntry<float> ScavengeHaul; public static ConfigEntry<bool> ScavengeNeedsBosses; public static ConfigEntry<bool> StrictStacking; public static ConfigEntry<int> BusyTasks; public static ConfigEntry<bool> ReachWhenBlocked; public static ConfigEntry<float> ReachDistance; public static ConfigEntry<bool> ShowOnMap; public static ConfigEntry<bool> ShowLabelInTooltip; public static ConfigEntry<KeyCode> TasksKey; public static ConfigEntry<KeyCode> PauseKey; public static bool ModeAllowed(SorterStation.Mode m) { if (ModeEnabled.TryGetValue(m, out var value)) { return value.Value; } return true; } public static void Bind(ConfigFile cfg) { //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_000d: Expected O, but got Unknown //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Expected O, but got Unknown //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Expected O, but got Unknown //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Expected O, but got Unknown //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Expected O, but got Unknown //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Expected O, but got Unknown //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Expected O, but got Unknown //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Expected O, but got Unknown //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Expected O, but got Unknown //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Expected O, but got Unknown //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Expected O, but got Unknown //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Expected O, but got Unknown //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Expected O, but got Unknown //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Expected O, but got Unknown //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Expected O, but got Unknown //IL_030a: Unknown result type (might be due to invalid IL or missing references) //IL_0314: Expected O, but got Unknown //IL_0347: Unknown result type (might be due to invalid IL or missing references) //IL_0351: Expected O, but got Unknown //IL_0372: Unknown result type (might be due to invalid IL or missing references) //IL_037c: Expected O, but got Unknown //IL_039d: Unknown result type (might be due to invalid IL or missing references) //IL_03a7: Expected O, but got Unknown //IL_03cf: Unknown result type (might be due to invalid IL or missing references) //IL_03d9: Expected O, but got Unknown //IL_03fa: Unknown result type (might be due to invalid IL or missing references) //IL_0404: Expected O, but got Unknown //IL_0437: Unknown result type (might be due to invalid IL or missing references) //IL_0441: Expected O, but got Unknown //IL_0463: Unknown result type (might be due to invalid IL or missing references) //IL_046d: Expected O, but got Unknown //IL_048e: Unknown result type (might be due to invalid IL or missing references) //IL_0498: Expected O, but got Unknown //IL_04b9: Unknown result type (might be due to invalid IL or missing references) //IL_04c3: Expected O, but got Unknown //IL_04e4: Unknown result type (might be due to invalid IL or missing references) //IL_04ee: Expected O, but got Unknown //IL_050f: Unknown result type (might be due to invalid IL or missing references) //IL_0519: Expected O, but got Unknown //IL_0547: Unknown result type (might be due to invalid IL or missing references) //IL_0551: Expected O, but got Unknown //IL_057b: Unknown result type (might be due to invalid IL or missing references) //IL_0585: Expected O, but got Unknown //IL_05b3: Unknown result type (might be due to invalid IL or missing references) //IL_05bd: Expected O, but got Unknown //IL_05e7: Unknown result type (might be due to invalid IL or missing references) //IL_05f1: Expected O, but got Unknown //IL_061b: Unknown result type (might be due to invalid IL or missing references) //IL_0625: Expected O, but got Unknown //IL_064f: Unknown result type (might be due to invalid IL or missing references) //IL_0659: Expected O, but got Unknown //IL_0680: Unknown result type (might be due to invalid IL or missing references) //IL_068a: Expected O, but got Unknown //IL_06ad: Unknown result type (might be due to invalid IL or missing references) //IL_06b7: Expected O, but got Unknown //IL_06e1: Unknown result type (might be due to invalid IL or missing references) //IL_06eb: Expected O, but got Unknown //IL_0712: Unknown result type (might be due to invalid IL or missing references) //IL_071c: Expected O, but got Unknown //IL_0743: Unknown result type (might be due to invalid IL or missing references) //IL_074d: Expected O, but got Unknown //IL_076f: Unknown result type (might be due to invalid IL or missing references) //IL_0779: Expected O, but got Unknown //IL_07ac: Unknown result type (might be due to invalid IL or missing references) //IL_07b6: Expected O, but got Unknown //IL_07e9: Unknown result type (might be due to invalid IL or missing references) //IL_07f3: Expected O, but got Unknown //IL_0826: Unknown result type (might be due to invalid IL or missing references) //IL_0830: Expected O, but got Unknown //IL_089d: Unknown result type (might be due to invalid IL or missing references) //IL_08a7: Expected O, but got Unknown //IL_08e3: Unknown result type (might be due to invalid IL or missing references) //IL_08ed: Expected O, but got Unknown //IL_090e: Unknown result type (might be due to invalid IL or missing references) //IL_0918: Expected O, but got Unknown //IL_0939: Unknown result type (might be due to invalid IL or missing references) //IL_0943: Expected O, but got Unknown //IL_0964: Unknown result type (might be due to invalid IL or missing references) //IL_096e: Expected O, but got Unknown //IL_098f: Unknown result type (might be due to invalid IL or missing references) //IL_0999: Expected O, but got Unknown ConfigurationManagerAttributes val = new ConfigurationManagerAttributes { IsAdminOnly = true }; WorkRadius = cfg.Bind<float>("Worker", "WorkRadius", 50f, new ConfigDescription("How far from his nest Kvist works, in metres, for nests whose range hasn't been set in the K window.", (AcceptableValueBase)null, new object[1] { val })); MaxWorkRadius = cfg.Bind<float>("Worker", "MaxWorkRadius", 100f, new ConfigDescription("The largest range a nest can be set to in the K window, in metres. A bigger range means longer walks and more for him to check.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(10f, 200f), new object[1] { val })); CarryStacks = cfg.Bind<int>("Worker", "CarrySlots", 10, new ConfigDescription("Stacks the dwarf carries per trip.", (AcceptableValueBase)null, new object[1] { val })); DetailedLog = cfg.Bind<bool>("Worker", "DetailedLog", false, "Write each step Kvist takes to the BepInEx log (LogOutput.log), for reporting problems. Off keeps the log short; the nest log in the K window is kept either way."); RespawnSeconds = cfg.Bind<float>("Worker", "RespawnSeconds", 30f, new ConfigDescription("Seconds after death before the station spawns a new dwarf.", (AcceptableValueBase)null, new object[1] { val })); AITickSeconds = cfg.Bind<float>("Worker", "AITickSeconds", 0.5f, new ConfigDescription("Seconds between AI decisions.", (AcceptableValueBase)null, new object[1] { val })); IdleSeconds = cfg.Bind<float>("Worker", "IdleSeconds", 1f, new ConfigDescription("Seconds the dwarf waits when there is nothing to do.", (AcceptableValueBase)null, new object[1] { val })); DepositSeconds = cfg.Bind<float>("Worker", "DepositSeconds", 1f, new ConfigDescription("Pause after each deposit.", (AcceptableValueBase)null, new object[1] { val })); StuckSeconds = cfg.Bind<float>("Worker", "StuckSeconds", 8f, new ConfigDescription("Seconds without progress before a target is given up.", (AcceptableValueBase)null, new object[1] { val })); ArriveDistance = cfg.Bind<float>("Worker", "ArriveDistance", 2f, new ConfigDescription("Metres from a target that counts as arrived.", (AcceptableValueBase)null, new object[1] { val })); AreaFallback = cfg.Bind<bool>("Worker", "UseAreaFallback", false, new ConfigDescription("When no chest of an item's category has room, use another chest in the same Area (Forge, Kitchen...). Off: the item waits in the nest and the nest says which chest is missing.", (AcceptableValueBase)null, new object[1] { val })); Run = cfg.Bind<bool>("Worker", "Run", true, new ConfigDescription("Kvist runs everywhere, idle wandering included, instead of walking.", (AcceptableValueBase)null, new object[1] { val })); SmartPriorities = cfg.Bind<bool>("Worker", "SmartPriorities", true, new ConfigDescription("Kvist picks the job worth most for the walk (big jobs and near jobs first, deliveries when his hands are full). Off: the fixed priority order from 0.2.", (AcceptableValueBase)null, new object[1] { val })); TeleportWhenStuck = cfg.Bind<bool>("Worker", "TeleportWhenStuck", true, new ConfigDescription("When Kvist can't get to something (no path, no door that leads there, too far to reach over), he teleports beside it in a puff, and home the same way if he's trapped. Off: he skips it and tries again later, and jumps to get out of traps.", (AcceptableValueBase)null, new object[1] { val })); StrictStacking = cfg.Bind<bool>("Sorting", "StrictStacking", false, new ConfigDescription("Strict stacking: Kvist only puts an item in a chest that already holds it, or else in an empty chest of its label; never in one holding other things. With none, it stays in the nest. The default for every nest; switch it per nest in the K window.", (AcceptableValueBase)null, new object[1] { val })); IdleSorting = cfg.Bind<bool>("Worker", "IdleSorting", true, new ConfigDescription("When Kvist has nothing to do in his job, he tidies up loose items, sorts the nest and re-sorts chests until there is work again. The default for every nest; switch it per nest in the K window.", (AcceptableValueBase)null, new object[1] { val })); ScavengeTime = cfg.Bind<float>("Scavenging", "ScavengeTime", 1f, new ConfigDescription("Scavenging trips: how long he's away, times this (1 = 30 minutes).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 10f), new object[1] { val })); ScavengeHaul = cfg.Bind<float>("Scavenging", "ScavengeHaul", 1f, new ConfigDescription("Scavenging trips: how much he brings back, times this.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 10f), new object[1] { val })); ScavengeNeedsBosses = cfg.Bind<bool>("Scavenging", "ScavengeNeedsBosses", true, new ConfigDescription("Scavenging trips: a biome opens once its own boss is beaten (the Black Forest after the Elder, the Swamp after Bonemass, and so on; the Meadows from the start). Off: every biome from the start.", (AcceptableValueBase)null, new object[1] { val })); BusyTeleport = cfg.Bind<bool>("Worker", "BusyTeleport", true, new ConfigDescription("When Kvist is swamped (BusyTasks different tasks waiting at once, for a while), he teleports to jobs more than 15 m away instead of walking, until he catches up.", (AcceptableValueBase)null, new object[1] { val })); BusyTasks = cfg.Bind<int>("Worker", "BusyTasks", 6, new ConfigDescription("How many different tasks must be waiting at once for Kvist to count as swamped and hurry (BusyTeleport).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(2, 30), new object[1] { val })); ReachWhenBlocked = cfg.Bind<bool>("Worker", "ReachWhenBlocked", true, new ConfigDescription("The last resort when Kvist can't get to something (after doors, gates and teleporting): if it's within ReachDistance, he does the job from where he stands.", (AcceptableValueBase)null, new object[1] { val })); ReachDistance = cfg.Bind<float>("Worker", "ReachDistance", 8f, new ConfigDescription("Metres Kvist can reach from where he stands when blocked (ReachWhenBlocked).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 20f), new object[1] { val })); CollectBatch = cfg.Bind<int>("Smelting", "CollectBatch", 20, new ConfigDescription("Smelting mode: wait for a pile of charcoal or bars this big before fetching it, unless the kiln or furnace has finished or a furnace is out of coal.", (AcceptableValueBase)null, new object[1] { val })); Butchering = cfg.Bind<bool>("Animals", "Butchering", true, new ConfigDescription("Animal Husbandry mode: master switch for butchering. Each species also has to be chosen: look at one of your animals and press Shift+L (nothing is butchered until you do). Off: Kvist only feeds animals. Named animals and saddled mounts are never butchered.", (AcceptableValueBase)null, new object[1] { val })); Breeders = cfg.Bind<int>("Animals", "Breeders", 2, new ConfigDescription("Animal Husbandry mode: adults of each kind kept as breeders (the highest-starred). Other adults are butchered. Not used for chickens.", (AcceptableValueBase)null, new object[1] { val })); ChickenFlock = cfg.Bind<int>("Animals", "ChickenFlock", 4, new ConfigDescription("Hens + chicks to keep. Below this, Kvist leaves all eggs alone so they can hatch (vanilla: by a fire, under a roof); at or above it, he collects them in Upkeep mode.", (AcceptableValueBase)null, new object[1] { val })); ChickenCullAbove = cfg.Bind<int>("Animals", "ChickenCullAbove", 4, new ConfigDescription("Animal Husbandry mode: when adult hens exceed this, Kvist butchers down to ChickenFlock, keeping the highest-starred.", (AcceptableValueBase)null, new object[1] { val })); TreeRadius = cfg.Bind<float>("Farming", "TreeRadius", 100f, new ConfigDescription("Tree farming: how far from his nest Kvist plants and fells trees, on ground 10 m clear of anything players built.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(20f, 200f), Array.Empty<object>())); WoodLimit = cfg.Bind<int>("Farming", "WoodLimit", 500, new ConfigDescription("Tree farming: he stops felling trees that give a kind of wood once your chests and nest hold this much of it.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 10000), Array.Empty<object>())); MineRadius = cfg.Bind<float>("Mining", "MineRadius", 100f, new ConfigDescription("Mining: how far from his nest Kvist mines rocks and ore veins.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(20f, 200f), Array.Empty<object>())); MineLimit = cfg.Bind<int>("Mining", "MineLimit", 500, new ConfigDescription("Mining: he stops mining for a material (stone, an ore...) once your chests and nest hold this much of it. The default for every nest; set each material per nest in the K window (Mining).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 10000), Array.Empty<object>())); FishLimit = cfg.Bind<int>("Fishing", "FishLimit", 200, new ConfigDescription("Fishing: he stops fishing once your chests and nest hold this many fish, of all kinds together. The default for every nest; set it per nest in the K window (Fishing).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 10000), Array.Empty<object>())); CropLimit = cfg.Bind<int>("Farming", "CropLimit", 1000, new ConfigDescription("Farming: he stops planting a crop once your chests and nest hold this much of what it grows; the soil goes to the other crops. The default for every nest; set each crop per nest in the K window (Farming). He still harvests whatever is ripe.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 10000), Array.Empty<object>())); TreeSeedReserve = cfg.Bind<int>("Farming", "TreeSeedReserve", 10, new ConfigDescription("Tree farming: seeds and cones kept back, never planted.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 1000), Array.Empty<object>())); SaplingsPerTree = cfg.Bind<int>("Farming", "SaplingsPerTree", 3, new ConfigDescription("Tree farming: saplings he plants for each tree he fells, while felling is on. 0 = he plants wherever there is room.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 20), Array.Empty<object>())); ForageLimit = cfg.Bind<int>("Farming", "ForageLimit", 500, new ConfigDescription("Foraging: Kvist stops picking a wild food (mushrooms, berries, smoke puffs, dandelions, thistles, fiddleheads) once your chests and nest hold this many of it. The default for every nest; set each food per nest in the K window (Farming).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 10000), Array.Empty<object>())); CoalStock = cfg.Bind<int>("Smelting", "CoalStock", 100, new ConfigDescription("Smelting: Kvist keeps the charcoal kilns going until your chests and nest hold this much coal, whether a furnace needs it or not. 0 = coal only when a furnace needs it. The default for every nest; set it per nest in the K window (Smelting).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 10000), Array.Empty<object>())); KilnWoodReserve = cfg.Bind<int>("Smelting", "KilnWoodReserve", 100, new ConfigDescription("Smelting: plain Wood kept back when making coal for the stockpile; only wood above this goes in the kilns. Coal a furnace needs uses any wood.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 10000), Array.Empty<object>())); SeedReserve = cfg.Bind<int>("Animals", "SeedReserve", 20, new ConfigDescription("Of anything Kvist plants with (seeds, barley, flax...), keep at least this many in the nest and chests for planting. Animals are only fed what's above it.", (AcceptableValueBase)null, new object[1] { val })); HealSeconds = cfg.Bind<float>("Follow", "HealSeconds", 8f, new ConfigDescription("Follow: seconds between his heals.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 120f), new object[1] { val })); HealPercent = cfg.Bind<float>("Follow", "HealPercent", 10f, new ConfigDescription("Follow: each heal gives a hurt player this share of their maximum health, in percent (at least 5 health).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 100f), new object[1] { val })); HealRange = cfg.Bind<float>("Follow", "HealRange", 15f, new ConfigDescription("Follow: how near him, in metres, a player must be to be healed.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(2f, 50f), new object[1] { val })); foreach (SorterStation.Mode value in Enum.GetValues(typeof(SorterStation.Mode))) { if (value != SorterStation.Mode.Sorting) { ModeEnabled[value] = cfg.Bind<bool>("Server: modes", SorterStation.ModeName(value).Replace(" ", ""), true, new ConfigDescription("Allow the " + SorterStation.ModeName(value) + " mode. Off: it's gone from the K window and the L key, and a nest on it works as Sorting until changed.", (AcceptableValueBase)null, new object[1] { val })); } } Scavenging = cfg.Bind<bool>("Server: features", "Scavenging", true, new ConfigDescription("Allow sending Kvist scavenging (the K window's Scavenge button).", (AcceptableValueBase)null, new object[1] { val })); BringMe = cfg.Bind<bool>("Server: features", "BringMe", true, new ConfigDescription("Allow Bring me (the K window's button: he fetches items to you).", (AcceptableValueBase)null, new object[1] { val })); FollowBackpack = cfg.Bind<bool>("Server: features", "FollowBackpack", true, new ConfigDescription("Follow: allow opening a following Kvist's backpack (E).", (AcceptableValueBase)null, new object[1] { val })); FollowHeal = cfg.Bind<bool>("Server: features", "FollowHeal", true, new ConfigDescription("Follow: allow the Heal switch. Off: he never heals. How much and how often are in [Follow].", (AcceptableValueBase)null, new object[1] { val })); Flatten = cfg.Bind<bool>("Server: features", "Flatten", true, new ConfigDescription("Landscaping: allow the Flatten task.", (AcceptableValueBase)null, new object[1] { val })); ShowOnMap = cfg.Bind<bool>("Map", "ShowOnMap", true, "Show a pin for every Kvist on the map and minimap, named after his job."); ShowLabelInTooltip = cfg.Bind<bool>("Labels", "ShowLabelInTooltip", true, "Item tooltips say which chest label Kvist puts the item under."); NestSound = cfg.Bind<bool>("Nest", "NestSound", false, "Play the nest's ambient sound (the greydwarf nest loop). Takes effect immediately."); LabelKey = cfg.Bind<KeyCode>("Input", "LabelKey", (KeyCode)108, "Hover a chest and press to cycle its label. Hold Shift to cycle backwards."); PauseKey = cfg.Bind<KeyCode>("Input", "PauseKey", (KeyCode)112, "Look at a nest or its Kvist and press this to pause him where he stands; again to carry on. His job and settings are kept."); TasksKey = cfg.Bind<KeyCode>("Input", "TasksKey", (KeyCode)107, "Look at a nest and press to set its Kvist's task priorities."); } } [BepInPlugin("com.ryan.greydwarfsorter", "Kvist", "1.0.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string ModGuid = "com.ryan.greydwarfsorter"; public const string ModName = "Kvist"; public const string ModVersion = "1.0.1"; internal static ManualLogSource Log; private readonly Harmony _harmony = new Harmony("com.ryan.greydwarfsorter"); private void Awake() { Log = ((BaseUnityPlugin)this).Logger; ModConfig.Bind(((BaseUnityPlugin)this).Config); CategoryRegistry.Load(); PrefabManager.OnVanillaPrefabsAvailable += OnVanillaPrefabsAvailable; CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new DumpItemsCommand()); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new BreedCommand()); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new DropsCommand()); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new FillCarryCommand()); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new KillKvistCommand()); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new ClassifyCommand()); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new ClassifyAllCommand()); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new DebugCommand()); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new StressCommand()); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new FiresCommand()); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new UnusedItemsCommand()); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new SoilCommand()); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new RocksCommand()); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new RecipeCommand()); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new TidyCommand()); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new GroundCommand()); ((Component)this).gameObject.AddComponent<LabelInput>(); ((Component)this).gameObject.AddComponent<LabelPicker>(); ((Component)this).gameObject.AddComponent<DebugOverlay>(); ((Component)this).gameObject.AddComponent<MapPins>(); ((Component)this).gameObject.AddComponent<TaskWindow>(); _harmony.PatchAll(); Log.LogInfo((object)"Kvist 1.0.1 loaded"); } private void OnVanillaPrefabsAvailable() { PrefabManager.OnVanillaPrefabsAvailable -= OnVanillaPrefabsAvailable; StationRegistration.Register(); WorkerRegistration.Register(); HealEffect.Register(); LevelOp.Register(); } } } namespace GreydwarfSorter.Tools { internal class BreedCommand : ConsoleCommand { public override string Name => "gs_breed"; public override string Help => "Why the tames around you aren't breeding"; public override void Run(string[] args) { //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0355: Unknown result type (might be due to invalid IL or missing references) //IL_0362: Unknown result type (might be due to invalid IL or missing references) Player player = Player.m_localPlayer; if (!Object.op_Implicit((Object)(object)player) || !Object.op_Implicit((Object)(object)ZNetScene.instance)) { return; } List<Procreation> list = (from p in Object.FindObjectsOfType<Procreation>() where Object.op_Implicit((Object)(object)p) && Vector3.Distance(((Component)p).transform.position, ((Component)player).transform.position) <= 20f orderby Vector3.Distance(((Component)p).transform.position, ((Component)player).transform.position) select p).ToList(); if (list.Count == 0) { Say("gs_breed: no animals that breed within 20 m"); return; } foreach (Procreation item in list) { ZNetView component = ((Component)item).GetComponent<ZNetView>(); ZDO val = (Object.op_Implicit((Object)(object)component) ? component.GetZDO() : null); if (val != null) { Tameable component2 = ((Component)item).GetComponent<Tameable>(); BaseAI component3 = ((Component)item).GetComponent<BaseAI>(); Character component4 = ((Component)item).GetComponent<Character>(); GameObject prefab = ZNetScene.instance.GetPrefab(val.GetPrefab()); GameObject val2 = (Object.op_Implicit((Object)(object)item.m_offspring) ? ZNetScene.instance.GetPrefab(Utils.GetPrefabName(item.m_offspring)) : null); Vector3 position = ((Component)item).transform.position; int num = (Object.op_Implicit((Object)(object)prefab) ? SpawnSystem.GetNrOfInstances(prefab, position, item.m_totalCheckRange, false, false) : 0); int num2 = (Object.op_Implicit((Object)(object)val2) ? SpawnSystem.GetNrOfInstances(val2, position, item.m_totalCheckRange, false, false) : 0); GameObject val3 = (Object.op_Implicit((Object)(object)item.m_seperatePartner) ? item.m_seperatePartner : prefab); int num3 = (Object.op_Implicit((Object)(object)val3) ? SpawnSystem.GetNrOfInstances(val3, position, item.m_partnerCheckRange, false, true) : 0); bool flag = !Object.op_Implicit((Object)(object)item.m_seperatePartner); long num4 = val.GetLong(ZDOVars.s_pregnant, 0L); int num5 = val.GetInt(ZDOVars.s_lovePoints, 0); string text = (Object.op_Implicit((Object)(object)component4) ? component4.GetHoverName() : ((Object)item).name); string text2; if (Object.op_Implicit((Object)(object)component2) && !component2.IsTamed()) { text2 = "not tamed"; } else if (num4 == 0L) { text2 = ((Object.op_Implicit((Object)(object)component2) && component2.IsHungry()) ? "hungry (fed animals only)" : ((Object.op_Implicit((Object)(object)component3) && component3.IsAlerted()) ? "alerted (something scared it)" : ((num + num2 >= item.m_maxCreatures) ? $"too crowded: {num} adults + {num2} young within {item.m_totalCheckRange:0} m, max {item.m_maxCreatures}" : ((Object.op_Implicit((Object)(object)item.m_noPartnerOffspring) || num3 >= ((!flag) ? 1 : 2)) ? $"all good: love {num5}/{item.m_requiredLovePoints}, a {1f - item.m_pregnancyChance:P0} chance of a point every {item.m_updateInterval:0} s" : $"no partner within {item.m_partnerCheckRange:0} m")))); } else { double num6 = (double)item.m_pregnancyDuration - (ZNet.instance.GetTime() - new DateTime(num4)).TotalSeconds; text2 = ((num6 > 0.0) ? $"pregnant: due in {num6:0} s" : "pregnant: due now"); } Say($"gs_breed: {text} at {Vector3.Distance(position, ((Component)player).transform.position):0} m (level {((!Object.op_Implicit((Object)(object)component4)) ? 1 : component4.GetLevel())}): {text2}"); } } } private static void Say(string line) { Console.instance.Print(line); Plugin.Log.LogInfo((object)line); } } internal class ClassifyCommand : ConsoleCommand { public override string Name => "gs_classify"; public override string Help => "gs_classify <prefab> - show the category an item sorts into"; public override void Run(string[] args) { if (args.Length == 0) { Console.instance.Print("usage: gs_classify <prefab>"); return; } GameObject val = (Object.op_Implicit((Object)(object)ObjectDB.instance) ? ObjectDB.instance.GetItemPrefab(args[0]) : null); ItemDrop val2 = (Object.op_Implicit((Object)(object)val) ? val.GetComponent<ItemDrop>() : null); if (!Object.op_Implicit((Object)(object)val2)) { Console.instance.Print("gs_classify: no item prefab '" + args[0] + "'"); return; } ItemData obj = val2.m_itemData.Clone(); obj.m_dropPrefab = val; string via; Category category = ItemClassifier.Classify(obj, out via); Console.instance.Print(((Object)val).name + " -> " + category.Name + " (" + category.Id + ", " + via + ")"); } } internal class ClassifyAllCommand : ConsoleCommand { public override string Name => "gs_classify_all"; public override string Help => "Reload categories.yaml and write every item's category to classified.csv"; public override void Run(string[] args) { //IL_0133: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)ObjectDB.instance) || ObjectDB.instance.m_items.Count == 0) { Console.instance.Print("gs_classify_all: ObjectDB not loaded, run this in a world"); return; } CategoryRegistry.Load(); List<GameObject> list = (from go in ObjectDB.instance.m_items where Object.op_Implicit((Object)(object)go) && Object.op_Implicit((Object)(object)go.GetComponent<ItemDrop>()) orderby ((Object)go).name select go).ToList(); StringBuilder stringBuilder = new StringBuilder("prefab,name,itemType,category,via\n"); int num = 0; foreach (GameObject item in list) { ItemData val = item.GetComponent<ItemDrop>().m_itemData.Clone(); val.m_dropPrefab = item; string via; Category category = ItemClassifier.Classify(val, out via); if (category.Id == "incoming_loot") { num++; } stringBuilder.Append(((Object)item).name).Append(',').Append(Csv(Localization.instance.Localize(val.m_shared.m_name))) .Append(',') .Append(val.m_shared.m_itemType) .Append(',') .Append(category.Id) .Append(',') .Append(via) .Append('\n'); } List<string> names = list.Select((GameObject p) => ((Object)p).name).ToList(); var list2 = (from x in CategoryRegistry.All.SelectMany((Category c) => c.Items.Select((string i) => new { Id = c.Id, Entry = i })) where !names.Any((string n) => new Category("", "", "") { Items = { x.Entry } }.ListMatches(n)) select x).ToList(); stringBuilder.Append("\n# yaml entries matching no item\n"); foreach (var item2 in list2) { stringBuilder.Append("# ").Append(item2.Id).Append(": ") .Append(item2.Entry) .Append('\n'); } string text = Path.Combine(Path.Combine(Paths.ConfigPath, "GreydwarfSorter"), "classified.csv"); File.WriteAllText(text, stringBuilder.ToString()); Console.instance.Print($"gs_classify_all: {list.Count} items, {num} to Incoming Loot, " + $"{list2.Count} yaml names match nothing -> {text}"); } private static string Csv(string v) { if (v.IndexOfAny(new char[3] { ',', '"', '\n' }) >= 0) { return "\"" + v.Replace("\"", "\"\"") + "\""; } return v; } } public class DebugOverlay : MonoBehaviour { public static bool Enabled; private const float Range = 40f; private SorterAI[] _workers = new SorterAI[0]; private float _nextScan; private GUIStyle _style; private void Update() { if (Enabled && !(Time.time < _nextScan)) { _nextScan = Time.time + 1f; _workers = Object.FindObjectsByType<SorterAI>((FindObjectsSortMode)0); } } private void OnGUI() { //IL_0033: 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_003f: 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_0053: Expected O, but got Unknown //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: 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_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Expected O, but got Unknown //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) if (!Enabled || !Object.op_Implicit((Object)(object)Player.m_localPlayer) || !Object.op_Implicit((Object)(object)Camera.main)) { return; } if (_style == null) { _style = new GUIStyle(GUI.skin.box) { alignment = (TextAnchor)0, fontSize = 13, richText = true }; } SorterAI[] workers = _workers; foreach (SorterAI sorterAI in workers) { if (!Object.op_Implicit((Object)(object)sorterAI) || !Object.op_Implicit((Object)(object)((BaseAI)sorterAI).m_nview) || !((BaseAI)sorterAI).m_nview.IsValid()) { continue; } Vector3 val = ((Component)sorterAI).transform.position + Vector3.up * 2.4f; if (!(Vector3.Distance(val, ((Component)Player.m_localPlayer).transform.position) > 40f)) { Vector3 val2 = Camera.main.WorldToScreenPoint(val); if (!(val2.z <= 0f)) { string text = Describe(sorterAI); Vector2 val3 = _style.CalcSize(new GUIContent(text)); GUI.Box(new Rect(val2.x - val3.x / 2f, (float)Screen.height - val2.y - val3.y, val3.x, val3.y), text, _style); } } } } private static string Describe(SorterAI ai) { //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Expected O, but got Unknown //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Expected O, but got Unknown ZDO zDO = ((BaseAI)ai).m_nview.GetZDO(); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("<b>Kvist</b> ").Append((SorterAI.State)zDO.GetInt(Keys.State, 0)); if (((BaseAI)ai).m_nview.IsOwner()) { if (Object.op_Implicit((Object)(object)ai.Target)) { stringBuilder.Append(" → ").Append(Localization.instance.Localize(ai.Target.m_name)).Append(" [") .Append(CategoryRegistry.DisplayName(ChestLabel.Get(ai.Target))) .Append(']'); } else if (Object.op_Implicit((Object)(object)ai.SmelterTarget)) { stringBuilder.Append(" → ").Append(Localization.instance.Localize(ai.SmelterTarget.m_name)); } else if (Object.op_Implicit((Object)(object)ai.UpkeepTarget)) { stringBuilder.Append(" → ").Append(Utils.GetPrefabName(ai.UpkeepTarget.gameObject)); } else if (Object.op_Implicit((Object)(object)ai.CropTarget)) { stringBuilder.Append(" → ").Append(Utils.GetPrefabName(((Component)ai.CropTarget).gameObject)); } else if (Object.op_Implicit((Object)(object)ai.AnimalTarget)) { stringBuilder.Append(" → ").Append(Utils.GetPrefabName(((Component)ai.AnimalTarget).gameObject)); } } else { stringBuilder.Append(" (owned by another player)"); } GameObject val = ZNetScene.instance.FindInstance(ai.StationId); SorterStation sorterStation = (Object.op_Implicit((Object)(object)val) ? val.GetComponent<SorterStation>() : null); if (Object.op_Implicit((Object)(object)sorterStation)) { stringBuilder.Append("\nMode: ").Append(SorterStation.ModeName(sorterStation.CurrentMode)); } Inventory val2 = new Inventory("debug", (Sprite)null, Mathf.Max(1, ModConfig.CarryStacks.Value), 1); string text = zDO.GetString(Keys.Carry, ""); if (!string.IsNullOrEmpty(text)) { val2.Load(new ZPackage(text)); } List<ItemData> allItems = val2.GetAllItems(); stringBuilder.Append("\nCarry: ").Append((allItems.Count == 0) ? "empty" : string.Join(", ", allItems.Select((ItemData i) => $"{i.m_stack} {Localization.instance.Localize(i.m_shared.m_name)}"))); return stringBuilder.ToString(); } } internal class DebugCommand : ConsoleCommand { public override string Name => "gs_debug"; public override string Help => "Toggle the Kvist overlay (state, target, mode, carry)"; public override void Run(string[] args) { DebugOverlay.Enabled = !DebugOverlay.Enabled; Console.instance.Print("gs_debug: overlay " + (DebugOverlay.Enabled ? "on" : "off")); } } internal class DropsCommand : ConsoleCommand { public override string Name => "gs_drops"; public override string Help => "gs_drops <creature>: its drops, chances by stars, and this game's rare-drop countdown"; public override void Run(string[] args) { if (args.Length == 0 || !Object.op_Implicit((Object)(object)ZNetScene.instance)) { Say("gs_drops: name a creature, e.g. gs_drops Moose"); return; } string want = string.Join(" ", args); GameObject val = ZNetScene.instance.GetPrefab(want) ?? ((IEnumerable<GameObject>)ZNetScene.instance.m_prefabs).FirstOrDefault((Func<GameObject, bool>)((GameObject p) => Object.op_Implicit((Object)(object)p) && Object.op_Implicit((Object)(object)p.GetComponent<CharacterDrop>()) && string.Equals(((Object)p).name, want, StringComparison.OrdinalIgnoreCase))) ?? ((IEnumerable<GameObject>)ZNetScene.instance.m_prefabs).FirstOrDefault((Func<GameObject, bool>)((GameObject p) => Object.op_Implicit((Object)(object)p) && Object.op_Implicit((Object)(object)p.GetComponent<CharacterDrop>()) && ((Object)p).name.IndexOf(want, StringComparison.OrdinalIgnoreCase) >= 0)); CharacterDrop val2 = (Object.op_Implicit((Object)(object)val) ? val.GetComponent<CharacterDrop>() : null); if (!Object.op_Implicit((Object)(object)val2)) { Say("gs_drops: no creature called " + want); return; } bool flag = Object.op_Implicit((Object)(object)ZoneSystem.instance) && ZoneSystem.instance.GetGlobalKey((GlobalKeys)36); Say("gs_drops: " + ((Object)val).name + (flag ? " (this world has rare-drop countdowns off)" : "")); foreach (Drop item in val2.m_drops.Where((Drop d) => d != null && Object.op_Implicit((Object)(object)d.m_prefab))) { string[] array = new string[3]; for (int num = 0; num < 3; num++) { float num2 = item.m_chance * (item.m_levelMultiplier ? Mathf.Pow(2f, (float)num) : 1f); bool flag2 = num2 <= 0.3f && !flag; array[num] = string.Format("{0}* {1:P0}{2}", num, Mathf.Min(1f, num2), flag2 ? $" (countdown, sure within {(int)(2f / num2) + 1} kills)" : ""); } string text = ""; Say(string.Format(" {0} x{1}-{2}: {3}{4}", ((Object)item.m_prefab).name, item.m_amountMin, item.m_amountMax, string.Join(", ", array), text)); } } private static void Say(string line) { Console.instance.Print(line); Plugin.Log.LogInfo((object)line); } } internal class DumpItemsCommand : ConsoleCommand { public override string Name => "gs_dumpitems"; public override string Help => "Write every item prefab to BepInEx/config/GreydwarfSorter/items.csv"; public override void Run(string[] args) { //IL_00ef: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)ObjectDB.instance) || ObjectDB.instance.m_items.Count == 0) { Console.instance.Print("gs_dumpitems: ObjectDB not loaded, run this in a world"); return; } StringBuilder stringBuilder = new StringBuilder("prefab,name,itemType,food,stamina,eitr,hasStatusEffect\n"); IOrderedEnumerable<GameObject> orderedEnumerable = from go in ObjectDB.instance.m_items where Object.op_Implicit((Object)(object)go) && Object.op_Implicit((Object)(object)go.GetComponent<ItemDrop>()) orderby ((Object)go).name select go; int num = 0; foreach (GameObject item in orderedEnumerable) { SharedData shared = item.GetComponent<ItemDrop>().m_itemData.m_shared; stringBuilder.Append(Csv(((Object)item).name)).Append(',').Append(Csv(Localization.instance.Localize(shared.m_name))) .Append(',') .Append(shared.m_itemType) .Append(',') .Append(shared.m_food.ToString(CultureInfo.InvariantCulture)) .Append(',') .Append(shared.m_foodStamina.ToString(CultureInfo.InvariantCulture)) .Append(',') .Append(shared.m_foodEitr.ToString(CultureInfo.InvariantCulture)) .Append(',') .Append((Object)(object)shared.m_consumeStatusEffect != (Object)null) .Append('\n'); num++; } string text = Path.Combine(Paths.ConfigPath, "GreydwarfSorter"); Directory.CreateDirectory(text); string text2 = Path.Combine(text, "items.csv"); File.WriteAllText(text2, stringBuilder.ToString()); Console.instance.Print($"gs_dumpitems: {num} items -> {text2}"); } private static string Csv(string v) { if (v.IndexOfAny(new char[3] { ',', '"', '\n' }) >= 0) { return "\"" + v.Replace("\"", "\"\"") + "\""; } return v; } } internal class FillCarryCommand : ConsoleCommand { private static readonly string[] Prefabs = new string[5] { "Wood", "Stone", "Resin", "Flint", "RawMeat" }; public override string Name => "gs_fillcarry"; public override string Help => "Fill the nearest Kvist's carry with test stacks"; public override bool IsCheat => true; public override void Run(string[] args) { //IL_004a: 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) Player player = Player.m_localPlayer; if (!Object.op_Implicit((Object)(object)player)) { return; } WorkerCarry workerCarry = (from c in Object.FindObjectsByType<WorkerCarry>((FindObjectsSortMode)0) orderby Vector3.Distance(((Component)c).transform.position, ((Component)player).transform.position) select c).FirstOrDefault(); if (!Object.op_Implicit((Object)(object)workerCarry) || Vector3.Distance(((Component)workerCarry).transform.position, ((Component)player).transform.position) > 30f) { Console.instance.Print("gs_fillcarry: no Kvist within 30 m"); return; } if (!((Component)workerCarry).GetComponent<ZNetView>().IsOwner()) { Console.instance.Print("gs_fillcarry: another client owns this Kvist"); return; } foreach (string item in Prefabs.Take(workerCarry.Inventory.GetWidth())) { GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(item); if (Object.op_Implicit((Object)(object)itemPrefab)) { ItemData val = itemPrefab.GetComponent<ItemDrop>().m_itemData.Clone(); val.m_dropPrefab = itemPrefab; val.m_stack = val.m_shared.m_maxStackSize; workerCarry.Inventory.AddItem(val); } } workerCarry.Save(); Console.instance.Print($"gs_fillcarry: Kvist carries {workerCarry.Inventory.NrOfItems()} stacks"); } } internal class FiresCommand : ConsoleCommand { public override string Name => "gs_fires"; public override string Help => "List fires within 30 m and whether Kvist (Upkeep) fuels them"; public override void Run(string[] args) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if (!Object.op_Implicit((Object)(object)localPlayer)) { return; } Vector3 at = ((Component)localPlayer).transform.position; List<Fireplace> list = (from val in Object.FindObjectsByType<Fireplace>((FindObjectsSortMode)0) where Vector3.Distance(((Component)val).transform.position, at) <= 30f orderby Vector3.Distance(((Component)val).transform.position, at) select val).ToList(); if (list.Count == 0) { Console.instance.Print("gs_fires: no fires within 30 m"); return; } foreach (Fireplace f in list) { Piece componentInParent = ((Component)f).GetComponentInParent<Piece>(); string text = (Object.op_Implicit((Object)(object)componentInParent) ? Utils.GetPrefabName(((Component)componentInParent).gameObject) : Utils.GetPrefabName(((Component)f).gameObject)); SorterStation sorterStation = (from s in SorterStation.All where Object.op_Implicit((Object)(object)s) && s.CurrentMode == SorterStation.Mode.Upkeep orderby Vector3.Distance(((Component)s).transform.position, ((Component)f).transform.position) select s).FirstOrDefault(); string text2 = UpkeepIndex.WhyNot(f, Object.op_Implicit((Object)(object)sorterStation) ? new Vector3?(((Component)sorterStation).transform.position) : ((Vector3?)null)); Console.instance.Print(text + ": " + ((text2 == null) ? $"fuelled ({UpkeepIndex.FuelPrefab(f)}, room {UpkeepIndex.FuelRoom(f)})" : ("not fuelled: " + text2))); } } } internal class GroundCommand : ConsoleCommand { public override string Name => "gs_ground"; public override string Help => "Ground heights round you against the nearest nest's flatten height"; public override void Run(string[] args) { //IL_008d: 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_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0128: 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_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) Player me = Player.m_localPlayer; if (!Object.op_Implicit((Object)(object)me)) { return; } SorterStation sorterStation = (from s in SorterStation.All where Object.op_Implicit((Object)(object)s) orderby Vector3.Distance(((Component)s).transform.position, ((Component)me).transform.position) select s).FirstOrDefault(); float num = (Object.op_Implicit((Object)(object)sorterStation) ? sorterStation.FlattenHeight : float.NaN); object[] obj = new object[6] { ((Component)me).transform.position, Object.op_Implicit((Object)(object)sorterStation) ? sorterStation.WorkerName : "none", null, null, null, null }; object obj2; if (!Object.op_Implicit((Object)(object)sorterStation)) { obj2 = "-"; } else { Vector3 position = ((Component)sorterStation).transform.position; obj2 = ((Vector3)(ref position)).ToString("F1"); } obj[2] = obj2; obj[3] = num; obj[4] = (Object.op_Implicit((Object)(object)sorterStation) ? sorterStation.FlattenRadius : 0f); obj[5] = (Object.op_Implicit((Object)(object)sorterStation) ? Vector3.Distance(((Component)sorterStation).transform.position, ((Component)me).transform.position) : 0f); Say(string.Format("you at {0:F1}; nest {1} at {2}, flatten height {3:0.00}, radius {4:0}, {5:0} m from it", obj)); int mask = LayerMask.GetMask(new string[6] { "Default", "static_solid", "Default_small", "piece", "terrain", "vehicle" }); Vector3 val = default(Vector3); float num4 = default(float); RaycastHit val2 = default(RaycastHit); for (int num2 = 4; num2 >= -4; num2 -= 2) { StringBuilder stringBuilder = new StringBuilder(); for (int num3 = -4; num3 <= 4; num3 += 2) { ((Vector3)(ref val))..ctor(Mathf.Round(((Component)me).transform.position.x) + (float)num3, 0f, Mathf.Round(((Component)me).transform.position.z) + (float)num2); string text = (Heightmap.GetHeight(val, ref num4) ? num4.ToString("0.0") : "-"); float groundHeight = ZoneSystem.instance.GetGroundHeight(val); string text2 = (Physics.Raycast(val + Vector3.up * 200f, Vector3.down, ref val2, 400f, mask, (QueryTriggerInteraction)1) ? string.Format("{0:0.0}({1})", ((RaycastHit)(ref val2)).point.y, Object.op_Implicit((Object)(object)((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent<Heightmap>()) ? "terrain" : Utils.GetPrefabName(((Component)((Component)((RaycastHit)(ref val2)).collider).transform.root).gameObject)) : "-"); float liquidLevel = Floating.GetLiquidLevel(val, 1f, (LiquidType)10); stringBuilder.Append(string.Format("[{0:+0;-0;0},{1:+0;-0;0}] map {2} zone {3:0.0} ray {4}{5} ", num3, num2, text, groundHeight, text2, (liquidLevel > groundHeight + 0.3f) ? $" liquid {liquidLevel:0.0}" : "")); } Say(stringBuilder.ToString()); } } private static void Say(string line) { Plugin.Log.LogInfo((object)("gs_ground: " + line)); Console instance = Console.instance; if (instance != null) { instance.Print(line); } } } internal class KillKvistCommand : ConsoleCommand { public override string Name => "gs_killkvist"; public override string Help => "Kill the nearest Kvist (tests death drop and respawn)"; public override bool IsCheat => true; public override void Run(string[] args) { //IL_004a: 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_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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Expected O, but got Unknown Player player = Player.m_localPlayer; if (Object.op_Implicit((Object)(object)player)) { SorterAI sorterAI = (from a in Object.FindObjectsByType<SorterAI>((FindObjectsSortMode)0) orderby Vector3.Distance(((Component)a).transform.position, ((Component)player).transform.position) select a).FirstOrDefault(); if (!Object.op_Implicit((Object)(object)sorterAI) || Vector3.Distance(((Component)sorterAI).transform.position, ((Component)player).transform.position) > 30f) { Console.instance.Print("gs_killkvist: no Kvist within 30 m"); return; } Character component = ((Component)sorterAI).GetComponent<Character>(); HitData val = new HitData { m_point = component.GetCenterPoint() }; val.m_damage.m_damage = 1000000f; component.Damage(val); Console.instance.Print("gs_killkvist: done"); } } } internal class RecipeCommand : ConsoleCommand { public override string Name => "gs_recipe"; public override string Help => "How an item is made, and why work orders can't make it: gs_recipe fish soup"; public override void Run(string[] args) { if (!Object.op_Implicit((Object)(object)ObjectDB.instance) || !Object.op_Implicit((Object)(object)ZNetScene.instance)) { Say("Load a world first."); return; } string[] words = args.Select((string a) => a.ToLowerInvariant()).ToArray(); if (words.Length == 0) { Say("gs_recipe <words of the item's name>"); return; } List<GameObject> list = ObjectDB.instance.m_items.Where((GameObject val2) => Object.op_Implicit((Object)(object)val2) && Object.op_Implicit((Object)(object)val2.GetComponent<ItemDrop>())).Where(delegate(GameObject val2) { string text = (((Object)val2).name + " " + Localization.instance.Localize(val2.GetComponent<ItemDrop>().m_itemData.m_shared.m_name)).ToLowerInvariant(); return words.All(text.Contains); }).Take(8) .ToList(); if (list.Count == 0) { Say("No item named like '" + string.Join(" ", args) + "'."); return; } foreach (GameObject go in list) { string name = ((Object)go).name; Say("== " + name + " (" + OrderBook.DisplayName(name) + ")"); Step step = OrderBook.HowToMake(name); Say((step == null) ? " work orders: no way to make it known" : ((step.Kind == StepKind.Craft) ? string.Format(" work orders: craft at '{0}' level {1} from {2}", (step.Station == "") ? "hand" : step.Station, step.StationLevel, string.Join(", ", step.Inputs.Select((KeyValuePair<string, int> i) => i.Value + " " + i.Key).ToArray())) : $" work orders: {step.Kind} from {step.From}")); foreach (Recipe item in ObjectDB.instance.m_recipes.Where((Recipe r) => Object.op_Implicit((Object)(object)r) && Object.op_Implicit((Object)(object)r.m_item) && (Object)(object)((Component)r.m_item).gameObject == (Object)(object)go)) { Say(string.Format(" recipe {0}: enabled {1}, station {2} lvl {3}, only-upgrade {4}, one-of-ingredients {5}, ", ((Object)item).name, item.m_enabled, Object.op_Implicit((Object)(object)item.m_craftingStation) ? item.m_craftingStation.m_name : "none", item.m_minStationLevel, item.m_noCraftOnlyUpgrade, item.m_requireOnlyOneIngredient) + "needs " + string.Join(", ", item.m_resources.Select((Requirement q) => string.Format("{0} {1}{2}", q.GetAmount(1), Object.op_Implicit((Object)(object)q.m_resItem) ? ((Object)((Component)q.m_resItem).gameObject).name : "?", q.m_upgraderResource ? " (upgrade)" : "")).ToArray())); } foreach (GameObject prefab in ZNetScene.instance.m_prefabs) { if (!Object.op_Implicit((Object)(object)prefab)) { continue; } MonoBehaviour[] componentsInChildren = prefab.GetComponentsInChildren<MonoBehaviour>(true); foreach (MonoBehaviour val in componentsInChildren) { if (!Object.op_Implicit((Object)(object)val)) { continue; } foreach (string item2 in Produces(val, go)) { Say(" machine " + ((Object)prefab).name + " (" + ((object)val).GetType().Name + "." + item2 + ")"); } } } } } private static IEnumerable<string> Produces(MonoBehaviour c, GameObject item) { FieldInfo[] fields = ((object)c).GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (FieldInfo f in fields) { if (!typeof(IList).IsAssignableFrom(f.FieldType) || !(f.GetValue(c) is IList list)) { continue; } foreach (object e in list) { if (e == null || e is Object) { continue; } FieldInfo[] fields2 = e.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (FieldInfo fieldInfo in fields2) { object value = fieldInfo.GetValue(e); Component val = (Component)((value is Component) ? value : null); if ((Object)((val != null && Object.op_Implicit((Object)(object)val)) ? val.gameObject : ((value is GameObject) ? value : null)) != (Object)(object)item) { continue; } string text = ""; FieldInfo[] fields3 = e.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (FieldInfo fieldInfo2 in fields3) { object value2 = fieldInfo2.GetValue(e); Component val2 = (Component)((value2 is Component) ? value2 : null); GameObject val3 = (GameObject)((val2 != null && Object.op_Implicit((Object)(object)val2)) ? val2.gameObject : ((value2 is GameObject) ? value2 : null)); if (Object.op_Implicit((Object)(object)val3) && (Object)(object)val3 != (Object)(object)item) { text = text + " " + fieldInfo2.Name + "=" + ((Object)val3).name; } } yield return f.Name + "." + fieldInfo.Name + text; } } } } private static void Say(string line) { Plugin.Log.LogInfo((object)("gs_recipe: " + line)); Console instance = Console.instance; if (instance != null) { instance.Print(line); } } } internal class RocksCommand : ConsoleCommand { public override string Name => "gs_rocks"; public override string Help => "What Kvist makes of the rocks and ore veins around you"; public override void Run(string[] args) { //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: 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_006a: 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_0289: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_0376: Unknown result type (might be due to invalid IL or missing references) //IL_0397: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if (!Object.op_Implicit((Object)(object)localPlayer)) { return; } GameObject hoverObject = ((Humanoid)localPlayer).GetHoverObject(); if (Object.op_Implicit((Object)(object)hoverObject)) { Transform root = hoverObject.transform.root; Console.instance.Print($"gs_rocks: looking at {((Object)hoverObject).name} (root {((Object)root).name} at {root.position}, {Vector3.Distance(root.position, ((Component)localPlayer).transform.position):0} m)"); Transform val = hoverObject.transform; while (Object.op_Implicit((Object)(object)val)) { Console.instance.Print(" " + ((Object)val).name + ": " + string.Join(", ", (from c in ((Component)val).GetComponents<Component>() select ((object)c).GetType().Name).ToArray())); val = val.parent; } } Vector3 at = ((Component)localPlayer).transform.position; List<Component> list = new List<Component>(); list.AddRange((IEnumerable<Component>)(object)Object.FindObjectsByType<MineRock5>((FindObjectsSortMode)0)); list.AddRange((IEnumerable<Component>)(object)Object.FindObjectsByType<MineRock>((FindObjectsSortMode)0)); list.AddRange((IEnumerable<Component>)(from d in Object.FindObjectsByType<Destructible>((FindObjectsSortMode)0) where RockIndex.MaterialsOf((Component)(object)d).Count > 0 select d)); list = list.Where((Component val3) => Object.op_Implicit((Object)(object)val3) && Vector3.Distance(val3.transform.position, at) <= 30f).ToList(); Console.instance.Print($"gs_rocks: {list.Count} rocks and veins within 30 m"); SorterStation[] source = Object.FindObjectsByType<SorterStation>((FindObjectsSortMode)0); foreach (Component r in list) { int num = 0; int num2 = 0; Component obj = r; MineRock5 val2 = (MineRock5)(object)((obj is MineRock5) ? obj : null); if (val2 != null && val2.m_hitAreas != null) { foreach (HitArea item in val2.m_hitAreas.Where((HitArea a) => a != null && a.m_health > 0f && Object.op_Implicit((Object)(object)a.m_collider))) { if (RockIndex.Buried(item.m_collider)) { num2++; } else { num++; } } } SorterStation sorterStation = source.OrderBy((SorterStation n) => Vector3.Distance(((Component)n).transform.position, r.transform.position)).FirstOrDefault(); string text = (Object.op_Implicit((Object)(object)sorterStation) ? $"{Vector3.Distance(((Component)sorterStation).transform.position, r.transform.position):0} m from the nearest nest ({SorterStation.ModeName(sorterStation.CurrentMode)})" : "no nest loaded"); Console.instance.Print(string.Format(" {0} ({1}) at {2}: known {3}, gives {4}, ", ((Object)r.gameObject).name, ((object)r).GetType().Name, r.transform.position, RockIndex.Known(r), string.Join(", ", RockIndex.MaterialsOf(r).ToArray())) + $"pieces {num} showing / {num2} buried, {text}, clear of buildings {TreeIndex.ClearOfPlayerBuilds(r.transform.position, Object.op_Implicit((Object)(object)sorterStation) ? new Vector3?(((Component)sorterStation).transform.position) : ((Vector3?)null))}"); } } } internal class SoilCommand : ConsoleCommand { public override string Name => "gs_soil"; public override string Help => "Why crops can't be planted in the tilled soil around you"; public override void Run(string[] args) { //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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0087: 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_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0147: 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) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_019e: 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_01c1: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if (!Object.op_Implicit((Object)(object)localPlayer)) { return; } Sapling sapling = CropBook.All.FirstOrDefault((Sapling s) => s.Name == "sapling_carrot") ?? CropBook.All.FirstOrDefault(); if (sapling == null) { Console.instance.Print("gs_soil: no crops known"); return; } Vector3 position = ((Component)localPlayer).transform.position; Heightmap val = Heightmap.FindHeightmap(position); if (Object.op_Implicit((Object)(object)val)) { Color paintMask = val.GetPaintMask(position); TerrainComp val2 = TerrainComp.FindTerrainCompiler(((Component)val).transform.position); int num = default(int); int num2 = default(int); val.WorldToVertexMask(position, ref num, ref num2); int num3 = num2 * (val.m_width + 1) + num; bool flag = Object.op_Implicit((Object)(object)val2) && val2.m_modifiedPaint != null && num3 >= 0 && num3 < val2.m_modifiedPaint.Length && val2.m_modifiedPaint[num3]; Console.instance.Print($"gs_soil: ground here r {paintMask.r:0.00} g {paintMask.g:0.00} b {paintMask.b:0.00} a {paintMask.a:0.00}, painted {flag}, biome {Heightmap.FindBiome(position)}, counts as tilled {FarmIndex.Cultivated(position)}"); } Dictionary<string, int> dictionary = new Dictionary<string, int>(); int num4 = 0; int num5 = 0; Vector3 val3 = default(Vector3); for (float num6 = -4f; num6 <= 4f; num6 += 0.5f) { for (float num7 = -4f; num7 <= 4f; num7 += 0.5f) { ((Vector3)(ref val3))..ctor(position.x + num6, position.y, position.z + num7); if (FarmIndex.Cultivated(val3)) { val3.y = ZoneSystem.instance.GetGroundHeight(val3); num4++; string text = FarmIndex.WhyNotHere(sapling, val3); if (text == null) { num5++; } else { dictionary[text] = (dictionary.TryGetValue(text, out var value) ? value : 0) + 1; } } } } Console.instance.Print($"gs_soil: {num4} tilled spots within 4 m, {num5} free for {sapling.Name} (grow radius {sapling.GrowRadius:0.00})"); foreach (KeyValuePair<string, int> item in dictionary.OrderByDescending((KeyValuePair<string, int> kv) => kv.Value).Take(8)) { Console.instance.Print($" {item.Value}: {item.Key}"); } } } internal class StressCommand : ConsoleCommand { public override string Name => "gs_stress"; public override string Help => "Fill the nearest station with 50 mixed stacks and time Kvist emptying it"; public override bool IsCheat => true; public override void Run(string[] args) { //IL_004a: 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_01d1: Unknown result type (might be due to invalid IL or missing references) Player player = Player.m_localPlayer; if (!Object.op_Implicit((Object)(object)player)) { return; } SorterStation sorterStation = (from s in Object.FindObjectsByType<SorterStation>((FindObjectsSortMode)0) orderby Vector3.Distance(((Component)s).transform.position, ((Component)player).transform.position) select s).FirstOrDefault(); if (!Object.op_Implicit((Object)(object)sorterStation) || Vector3.Distance(((Component)sorterStation).transform.position, ((Component)player).transform.position) > 30f) { Console.instance.Print("gs_stress: no station within 30 m"); return; } ZNetView component = ((Component)sorterStation).GetComponent<ZNetView>(); if (!component.IsOwner()) { Console.instance.Print("gs_stress: another client owns this station"); return; } List<GameObject> list = (from n in CategoryRegistry.All.SelectMany((Category c) => c.Items) where !n.Contains("*") select ObjectDB.instance.GetItemPrefab(n) into p where Object.op_Implicit((Object)(object)p) select p).ToList(); if (list.Count == 0) { Console.instance.Print("gs_stress: no items found"); return; } Inventory inventory = sorterStation.Container.GetInventory(); int num = 0; for (int num2 = 0; num2 < 50; num2++) { if (!inventory.HaveEmptySlot()) { break; } GameObject val = list[Random.Range(0, list.Count)]; ItemData val2 = val.GetComponent<ItemDrop>().m_itemData.Clone(); val2.m_dropPrefab = val; val2.m_stack = val2.m_shared.m_maxStackSize; if (inventory.AddItem(val2)) { num++; } } StressRun.Start(component.GetZDO().m_uid, inventory.NrOfItems()); Console.instance.Print($"gs_stress: added {num} stacks; station holds {inventory.NrOfItems()}. Timing started."); } } public static class StressRun { private class Run { public float Start; public int Stacks; public int LastCount; public float LastChange; } private static readonly Dictionary<ZDOID, Run> _runs = new Dictionary<ZDOID, Run>(); public static void Start(ZDOID station, int stacks) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) _runs[station] = new Run { Start = Time.time, Stacks = stacks, LastCount = stacks, LastChange = Time.time }; } public static void Check(ZDOID station, Inventory inv) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) if (!_runs.TryGetValue(station, out var value)) { return; } int num = inv.NrOfItems(); if (num != value.LastCount) { value.LastCount = num; value.LastChange = Time.time; } bool flag = num == 0; bool flag2 = Time.time - value.LastChange > 60f; if (flag || flag2) { float num2 = (flag ? Time.time : value.LastChange) - value.Start; string text = (flag ? $"gs_stress: station emptied, {value.Stacks} stacks in {num2:F0}s" : $"gs_stress: stalled with {num} stacks left after {num2:F0}s ({value.Stacks - num} moved)"); Plugin.Log.LogInfo((object)text); if (Object.op_Implicit((Object)(object)Player.m_localPlayer)) { ((Character)Player.m_localPlayer).Message((MessageType)2, text, 0, (Sprite)null, false); } _runs.Remove(station); } } } internal class TidyCommand : ConsoleCommand { public override string Name => "gs_tidy"; public override string Help => "Why each Kvist leaves the items on the ground near you"; public override void Run(string[] args) { Player me = Player.m_localPlayer; if (!Object.op_Implicit((Object)(object)me)) { return; } List<SorterAI> list = (from a in Object.FindObjectsByType<SorterAI>((FindObjectsSortMode)0) where Object.op_Implicit((Object)(object)a.Station) select a).ToList(); if (list.Count == 0) { Say("No Kvist loaded."); return; } List<ItemDrop> list2 = ItemDrop.s_instances.Where((ItemDrop d) => Object.op_Implicit((Object)(object)d) && Vector3.Distance(((Component)d).transform.position, ((Component)me).transform.position) <= 6f).Take(10).ToList(); if (list2.Count == 0) { Say("Nothing on the ground within 6 m of you."); return; } foreach (ItemDrop item in list2) { foreach (SorterAI item2 in list) { Say($"{Utils.GetPrefabName(((Component)item).gameObject)} x{item.m_itemData.m_stack}, {item2.Station.WorkerName} ({SorterStation.ModeName(item2.Station.CurrentMode)}): {item2.TidyWhyNot(item)}"); } } } private static void Say(string line) { Plugin.Log.LogInfo((object)("gs_tidy: " + line)); Console instance = Console.instance; if (instance != null) { instance.Print(line); } } } internal class UnusedItemsCommand : ConsoleCommand { private readonly HashSet<string> _used = new HashSet<string>(); private readonly Dictionary<string, HashSet<string>> _sources = new Dictionary<string, HashSet<string>>(); public override string Name => "gs_unused"; public override string Help => "List items nothing uses or nothing gives (to BepInEx/config/GreydwarfSorter/unused.txt)"; private void Use(GameObject go) { if (Object.op_Implicit((Object)(object)go)) { _used.Add(Utils.GetPrefabName(go)); } } private void Use(Component c) { if (Object.op_Implicit((Object)(object)c)) { Use(c.gameObject); } } private void Give(GameObject go, string how) { if (Object.op_Implicit((Object)(object)go)) { string prefabName = Utils.GetPrefabName(go); if (!_sources.TryGetValue(prefabName, out var value)) { value = (_sources[prefabName] = new HashSet<string>()); } value.Add(how); } } private void Give(Component c, string how) { if (Object.op_Implicit((Object)(object)c)) { Give(c.gameObject, how); } } private void Give(DropTable t, string how) { //IL_001e: 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_0025: Unknown result type (might be due to invalid IL or missing references) if (t?.m_drops == null) { return; } foreach (DropData drop in t.m_drops) { Give(drop.m_item, how); } } public override void Run(string[] args) { //IL_0a64: Unknown result type (might be due to invalid IL or missing references) //IL_0a6b: Invalid comparison between Unknown and I4 //IL_053b: Unknown result type (might be due to invalid IL or missing references) //IL_0540: Unknown result type (might be due to invalid IL or missing references) //IL_0543: Unknown result type (might be due to invalid IL or missing references) //IL_06de: Unknown result type (might be due to invalid IL or missing references) //IL_06e3: Unknown result type (might be due to invalid IL or missing references) //IL_06e6: Unknown result type (might be due to invalid IL or missing references) ObjectDB instance = ObjectDB.instance; ZNetScene instance2 = ZNetScene.instance; if (!Object.op_Implicit((Object)(object)instance) || instance.m_items.Count == 0 || !Object.op_Implicit((Object)(object)instance2)) { Console.instance.Print("gs_unused: run this in a world"); return; } _used.Clear(); _sources.Clear(); foreach (Recipe recipe in instance.m_recipes) { if (!Object.op_Implicit((Object)(object)recipe) || !Object.op_Implicit((Object)(object)recipe.m_item)) { continue; } Give((Component)(object)recipe.m_item, "crafted"); if (recipe.m_resources != null) { Requirement[] resources = recipe.m_resources; foreach (Requirement val in resources) { Use((Component)(object)val.m_resItem); } } } foreach (GameObject item2 in instance.m_items) { PieceTable val2 = ((!Object.op_Implicit((Object)(object)item2)) ? null : item2.GetComponent<ItemDrop>()?.m_itemData.m_shared.m_buildPieces); if (!Object.op_Implicit((Object)(object)val2)) { continue; } foreach (GameObject piece in val2.m_pieces) { Piece val3 = (Object.op_Implicit((Object)(object)piece) ? piece.GetComponent<Piece>() : null); if (val3?.m_resources != null) { Requirement[] resources = val3.m_resources; foreach (Requirement val4 in resources) { Use((Component)(object)val4.m_resItem); } } } } foreach (GameObject prefab in instance2.m_prefabs) { if (!Object.op_Implicit((Object)(object)prefab)) { continue; } Smelter[] componentsInChildren = prefab.GetComponentsInChildren<Smelter>(true); foreach (Smelter val5 in componentsInChildren) { Use((Component)(object)val5.m_fuelItem); foreach (ItemConversion item3 in val5.m_conversion) { Use((Component)(object)item3.m_from); Give((Component)(object)item3.m_to, "smelted"); } } CookingStation[] componentsInChildren2 = prefab.GetComponentsInChildren<CookingStation>(true); foreach (CookingStation val6 in componentsInChildren2) { Use((Component)(object)val6.m_fuelItem); foreach (ItemConversion item4 in val6.m_conversion) { Use((Component)(object)item4.m_from); Give((Component)(object)item4.m_to, "cooked"); } } Fermenter[] componentsInChildren3 = prefab.GetComponentsInChildren<Fermenter>(true); for (int i = 0; i < componentsInChildren3.Length; i++) { foreach (ItemConversion item5 in componentsInChildren3[i].m_conversion) { Use((Component)(object)item5.m_from); Give((Component)(object)item5.m_to, "fermented"); } } Fireplace[] componentsInChildren4 = prefab.GetComponentsInChildren<Fireplace>(true); foreach (Fireplace val7 in componentsInChildren4) { Use((Component)(object)val7.m_fuelItem); } ShieldGenerator[] componentsInChildren5 = prefab.GetComponentsInChildren<ShieldGenerator>(true); foreach (ShieldGenerator val8 in componentsInChildren5) { if (val8.m_fuelItems == null) { continue; } foreach (ItemDrop fuelItem in val8.m_fuelItems) { Use((Component)(object)fuelItem); } } OfferingBowl[] componentsInChildren6 = prefab.GetComponentsInChildren<OfferingBowl>(true); foreach (OfferingBowl val9 in componentsInChildren6) { Use((Component)(object)val9.m_bossItem); } ItemStand[] componentsInChildren7 = prefab.GetComponentsInChildren<ItemStand>(true); foreach (ItemStand val10 in componentsInChildren7) { if (val10.m_supportedItems == null) { continue; } foreach (ItemDrop supportedItem in val10.m_supportedItems) { Use((Component)(object)supportedItem); } } MonsterAI[] componentsInChildren8 = prefab.GetComponentsInChildren<MonsterAI>(true); foreach (MonsterAI val11 in componentsInChildren8) { if (val11.m_consumeItems == null) { continue; } foreach (ItemDrop consumeItem in val11.m_consumeItems) { Use((Component)(object)consumeItem); } } Turret[] componentsInChildren9 = prefab.GetComponentsInChildren<Turret>(true); foreach (Turret val12 in componentsInChildren9) { if (val12.m_allowedAmmo == null) { continue; } foreach (AmmoType item6 in val12.m_allowedAmmo) { Use((Component)(object)item6.m_ammo); } } Trader[] componentsInChildren10 = prefab.GetComponentsInChildren<Trader>(true); foreach (Trader val13 in componentsInChildren10) { if (val13.m_items == null) { continue; } foreach (TradeItem item7 in val13.m_items) { Give((Component)(object)item7.m_prefab, "sold by a trader"); } } Beehive[] componentsInChildren11 = prefab.GetComponentsInChildren<Beehive>(true); foreach (Beehive val14 in componentsInChildren11) { Give((Component)(object)val14.m_honeyItem, "beehive"); } SapCollector[] componentsInChildren12 = prefab.GetComponentsInChildren<SapCollector>(true); foreach (SapCollector val15 in componentsInChildren12) { Give((Component)(object)val15.m_spawnItem, "sap collector"); } Pickable[] componentsInChildren13 = prefab.GetComponentsInChildren<Pickable>(true); foreach (Pickable val16 in componentsInChildren13) { Give(val16.m_itemPrefab, "plant"); Give(val16.m_extraDrops, "plant"); } PickableItem[] componentsInChildren14 = prefab.GetComponentsInChildren<PickableItem>(true); foreach (PickableItem val17 in componentsInChildren14) { Give((Component)(object)val17.m_itemPrefab, "lying about"); if (val17.m_randomItemPrefabs != null) { RandomItem[] randomItemPrefabs = val17.m_randomItemPrefabs; foreach (RandomItem val18 in randomItemPrefabs) { Give((Component)(object)val18.m_itemPrefab, "lying about"); } } } CharacterDrop[] componentsInChildren15 = prefab.GetComponentsInChildren<CharacterDrop>(true); foreach (CharacterDrop val19 in componentsInChildren15) { if (val19.m_drops == null) { continue; } foreach (Drop drop in val19.m_drops) { Give(drop.m_prefab, "creature"); } } MineRock[] componentsInChildren16 = prefab.GetComponentsInChildren<MineRock>(true); foreach (MineRock val20 in componentsInChildren16) { Give(val20.m_dropItems, "mined"); } MineRock5[] componentsInChildren17 = prefab.GetComponentsInChildren<MineRock5>(true); foreach (MineRock5 val21 in componentsInChildren17) { Give(val21.m_dropItems, "mined"); } TreeBase[] componentsInChildren18 = prefab.GetComponentsInChildren<TreeBase>(true); foreach (TreeBase val22 in componentsInChildren18) { Give(val22.m_dropWhenDestroyed, "tree"); } TreeLog[] componentsInChildren19 = prefab.GetComponentsInChildren<TreeLog>(true); foreach (TreeLog val23 in componentsInChildren19) { Give(val23.m_dropWhenDestroyed, "tree"); } DropOnDestroyed[] componentsInChildren20 = prefab.GetComponentsInChildren<DropOnDestroyed>(true); foreach (DropOnDestroyed val24 in componentsInChildren20) { Give(val24.m_dropWhenDestroyed, "broken"); } Container[] componentsInChildren21 = prefab.GetComponentsInChildren<Container>(true); foreach (Container val25 in componentsInChildren21) { Give(val25.m_defaultItems, "chest"); } LootSpawner[] componentsInChildren22 = prefab.GetComponentsInChildren<LootSpawner>(true); foreach (LootSpawner val26 in componentsInChildren22) { Give(val26.m_items, "loot"); } Fish[] componentsInChildren23 = prefab.GetComponentsInChildren<Fish>(true); foreach (Fish val27 in componentsInChildren23) { Give(((Component)val27).gameObject, "fished"); } } HashSet<string> hashSet = new HashSet<string>(from l in Scavenging.Biomes.SelectMany((Scavenging.Biome b) => b.Loot) select l.Item); List<string> list = new List<string>(); List<string> list2 = new List<string>(); List<string> list3 = new List<string>(); foreach (GameObject item8 in from g in instance.m_items where Object.op_Implicit((Object)(object)g) && Object.op_Implicit((Object)(object)g.GetComponent<ItemDrop>()) orderby ((Object)g).name select g) { string name = ((Object)item8).name; ItemDrop component = item8.GetComponent<ItemDrop>(); SharedData shared = component.m_itemData.m_shared; if (shared.m_icons != null && shared.m_icons.Length != 0 && Object.op_Implicit((Object)(object)shared.m_icons[0]) && (int)shared.m_itemType != 10) { string item = name + " (" + Localization.instance.Localize(component.m_itemData.m_shared.m_name) + ")" + (hashSet.Contains(name) ? " [SCAVENGED]" : ""); bool flag = _used.Contains(name) || UsefulInItself(component); HashSet<string> value; bool num = _sources.TryGetValue(name, out value) && value.Count > 0; if (!flag) { list.Add(item); } if (!num) { list2.Add(item); } else if (value.All((string h) => h == "plant")) { list3.Add(item); } } } StringBuilder sb = new StringBuilder(); Section("Nothing uses it", list); Section("Nothing gives it (only spawned, or not in the game)", list2); Section("Only from plants (check the plant grows somewhere)", list3); string text = Path.Combine(Paths.ConfigPath, "GreydwarfSorter"); Directory.CreateDirectory(text); string text2 = Path.Combine(text, "unused.txt"); File.WriteAllText(text2, sb.ToString()); int num2 = list.Concat(list2).Concat(list3).Count((string l) => l.Contains("[SCAVENGED]")); Console.instance.Print($"gs_unused: {list.Count} with no use, {list2.Count} with no source, {list3.Count} only from plants ({num2} of them scavenged) -> {text2}"); Plugin.Log.LogInfo((object)("gs_unused: written to " + text2)); void Section(string title, List<string> list4) { sb.Append($"== {title}: {list4.Count} ==\n"); foreach (string item9 in list4.OrderByDescending((string x) => x.Contains("[SCAVENGED]"))) { sb.Append(item9).Append('\n'); } sb.Append('\n'); } static bool UsefulInItself(ItemDrop d) { //IL_004e: 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_0056: Invalid comparison between Unknown and I4 //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Invalid comparison between Unknown and I4 SharedData shared2 = d.m_itemData.m_shared; if (shared2.m_food > 0f || shared2.m_foodStamina > 0f || shared2.m_foodEitr > 0f || Object.op_Implicit((Object)(object)shared2.m_consumeStatusEffect)) { return true; } if (shared2.m_value > 0) { return true; } ItemType itemType = shared2.m_itemType; if ((int)itemType <= 2 || (int)itemType == 16) { return false; } return true; } } } } namespace GreydwarfSorter.Worker { internal static class DropScan { private static readonly List<ItemDrop> _live = new List<ItemDrop>(); private static readonly Dictionary<int, string> _names = new Dictionary<int, string>(); private static int _frame = -1; public static List<ItemDrop> Live { get { if (_frame == Time.frameCount) { return _live; } _frame = Time.frameCount; _live.Clear(); foreach (ItemDrop s_instance in ItemDrop.s_instances) { if (Object.op_Implicit((Object)(object)s_instance) && Object.op_Implicit((Object)(object)s_instance.m_nview) && s_instance.m_nview.IsValid()) { _live.Add(s_instance); } } if (_names.Count > 4 * _live.Count + 256) { _names.Clear(); } return _live; } } public static bool Pickable(ItemDrop d) { if (d.m_autoPickup) { return true; } GameObject val = (Object.op_Implicit((Object)(object)ObjectDB.instance) ? ObjectDB.instance.GetItemPrefab(Name(d)) : null); ItemDrop val2 = (Object.op_Implicit((Object)(object)val) ? val.GetComponent<ItemDrop>() : null); if (Object.op_Implicit((Object)(object)val2)) { return val2.m_autoPickup; } return false; } public static string Name(ItemDrop d) { int instanceID = ((Object)d).GetInstanceID(); if (!_names.TryGetValue(instanceID, out var value)) { value = (_names[instanceID] = Utils.GetPrefabName(((Component)d).gameObject)); } return value; } } internal static class HealEffect { public const string Name = "SE_KvistHeal"; public static readonly int Hash = StringExtensionMethods.GetStableHashCode("SE_KvistHeal"); public static void Register() { //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown StatusEffect val = ScriptableObject.CreateInstance<StatusEffect>(); ((Object)val).name = "SE_KvistHeal"; val.m_name = "Kvist's care"; val.m_tooltip = "A Kvist following you heals you every few seconds while you're near him."; val.m_ttl = ModConfig.HealSeconds.Value + 2f; GameObject prefab = PrefabManager.Instance.GetPrefab("TrophyGreydwarfShaman"); Sprite[] array = ((!Object.op_Implicit((Object)(object)prefab)) ? null : prefab.GetComponent<ItemDrop>()?.m_itemData.m_shared.m_icons); if (array != null && array.Length != 0) { val.m_icon = array[0]; } ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(val, false)); Plugin.Log.LogInfo((object)("Registered SE_KvistHeal (icon " + (Object.op_Implicit((Object)(object)val.m_icon) ? ((Object)val.m_icon).name : "none") + ")")); } } public class KvistHide : MonoBehaviour { private ZNetView _nview; private bool _hidden; private float _next; private Container _pack; private Character _character; private void Awake() { _nview = ((Component)this).GetComponent<ZNetView>(); } private void Update() { //IL_00bb: Unknown result type (might be due to invalid IL or missing references) if (!(Time.time < _next) && Object.op_Implicit((Object)(object)_nview) && _nview.IsValid()) { _next = Time.time + 0.25f; bool flag = _nview.GetZDO().GetBool(SorterAI.HiddenKey, false); if (flag != _hidden) { Apply(flag); } bool flag2 = _nview.GetZDO().GetLong(SorterAI.FollowKeyHash, 0L) != 0; if (!Object.op_Implicit((Object)(object)_pack)) { _pack = ((Component)this).GetComponent<Container>(); } if (Object.op_Implicit((Object)(object)_pack)) { _pack.m_privacy = (PrivacySetting)((!flag2 || !ModConfig.FollowBackpack.Value) ? 1 : 2); } if (!Object.op_Implicit((Object)(object)_character)) { _character = ((Component)this).GetComponent<Character>(); } if (Object.op_Implicit((Object)(object)_character)) { _character.m_aiSkipTarget = flag2; } } } public void Apply(bool hidden) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) _hidden = hidden; Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<Renderer>(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].enabled = !hidden; } Collider[] componentsInChildren2 = ((Component)this).GetComponentsInChildren<Collider>(true); for (int i = 0; i < componentsInChildren2.Length; i++) { componentsInChildren2[i].enabled = !hidden; } Rigidbody component = ((Component)this).GetComponent<Rigidbody>(); if (Object.op_Implicit((Object)(object)component)) { component.isKinematic = hidden; if (!hidden) { component.linearVelocity = Vector3.zero; } } Character component2 = ((Component)this).GetComponent<Character>(); if (Object.op_Implicit((Object)(object)component2)) { component2.m_hideHud = hidden; } } } public class KvistPassThrough : MonoBehaviour { private const float CheckSeconds = 1f; private const float Range = 12f; private Collider[] _mine; private readonly HashSet<int> _done = new HashSet<int>(); private float _next; private void Update() { //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) if (Time.time < _next) { return; } _next = Time.time + 1f; if (_mine == null || _mine.Length == 0) { _mine = ((Component)this).GetComponentsInChildren<Collider>(); } foreach (Character allCharacter in Character.GetAllCharacters()) { if (!Object.op_Implicit((Object)(object)allCharacter) || (Object)(object)((Component)allCharacter).gameObject == (Object)(object)((Component)this).gameObject || (!allCharacter.IsPlayer() && !allCharacter.IsTamed()) || _done.Contains(((Object)allCharacter).GetInstanceID()) || Vector3.Distance(((Component)allCharacter).transform.position, ((Component)this).transform.position) > 12f) { continue; } Collider[] componentsInChildren = ((Component)allCharacter).GetComponentsInChildren<Collider>(); foreach (Collider val in componentsInChildren) { Collider[] mine = _mine; foreach (Collider val2 in mine) { if (Object.op_Implicit((Object)(object)val2) && Object.op_Implicit((Object)(object)val) && !val.isTrigger && !val2.isTrigger) { Physics.IgnoreCollision(val2, val, true); } } } _done.Add(((Object)allCharacter).GetInstanceID()); } } } public class KvistPet : MonoBehaviour, Interactable { public class NameInput : TextReceiver { private readonly SorterStation _station; public NameInput(SorterStation station) { _station = station; } public string GetText() { if (!Object.op_Implicit((Object)(object)_station)) { return ""; } return _station.WorkerName; } public void SetText(string text) { if (Object.op_Implicit((Object)(object)_station)) { _station.RequestSetName(text); } } } public EffectList m_petEffect = new EffectList(); private float _lastPet = -10f; public bool Interact(Humanoid user, bool hold, bool alt) { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) if (hold || !Object.op_Implicit((Object)(object)user)) { return false; } SorterAI component = ((Component)this).GetComponent<SorterAI>(); if (Object.op_Implicit((Object)(object)component) && component.Following && !alt && ModConfig.FollowBackpack.Value) { return component.OpenBackpack(user); } if (Time.time - _lastPet < 1f) { return true; } _lastPet = Time.time; m_petEffect.Create(((Component)this).transform.position, ((Component)this).transform.rotation, (Transform)null, 1f, -1, default(ZDOID)); Character component2 = ((Component)this).GetComponent<Character>(); string text = (Object.op_Implicit((Object)(object)component2) ? component2.GetHoverName() : "Kvist"); ((Character)user).Message((MessageType)2, text + " loves you", 0, (Sprite)null, false); return true; } public bool UseItem(Humanoid user, ItemData item) { return false; } } internal static class LevelOp { public const string Name = "kvist_level"; public const float Reach = 1f; public const float Influence = 2f; public const string PointName = "kvist_level_point"; public static GameObject Prefab { get; private set; } public static GameObject PointPrefab { get; private set; } public static void Register() { //IL_0021: Unknown result type (might be due to invalid IL or miss