using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using LazyBearTechnology; using Microsoft.CodeAnalysis; using Timbn.GraveyardKeeperTwo.Core.Framework; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Timbn.GraveyardKeeperTwo.InfusionRack")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.2.0.0")] [assembly: AssemblyInformationalVersion("1.2.0+779e224e9f8695c607b082ba08dcc45ab57305dd")] [assembly: AssemblyProduct("Timbn Infusion Rack")] [assembly: AssemblyTitle("Timbn.GraveyardKeeperTwo.InfusionRack")] [assembly: AssemblyVersion("1.2.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace Timbn.GraveyardKeeperTwo.InfusionRack { internal static class InfusionMachine { public const string StationId = "timbn_infusion_machine"; private const string _buildIcon = "infusion_machine_build"; private const string _skullTalent = "talent_blue"; private const string _template = "pocket_extract_item_craft"; private const int _ticks = 8; private const int _mastery = 4; public static void Register(TimbnFrameworkPlugin plugin) { TimbnModel model = plugin.Models.Build("InfusionMachine", (Action)delegate(TimbnModelFaces faces) { faces.Block("infusion_machine_table", 0, 0, 1, 24).Top("infusion_machine_basin", 5, 17, 5); }); plugin.Sprites.AddEmbedded("infusion_machine_build.png", (TimbnSpriteKind)2); TimbnStation machine = plugin.Stations.Add("timbn_infusion_machine", (Action)delegate(TimbnStationBuilder station) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) station.Model(model, new Vector3(0.64f, 0.5f, 0.6f)).Slot("timbn_infusion_slot", new Vector3(-0.64f, 0f, 0.15f), InfusionStand.Size).Slot("timbn_infusion_slot", new Vector3(0.64f, 0f, 0.15f), InfusionStand.Size) .Icon("infusion_machine_build") .BasedOn("kitchen_oven") .Talent("talent_blue") .NoFuel() .TakesZombie(false) .CraftSlots(50) .BuiltAt("builder_morgue", (string)null) .BuildTab("") .UnlockedBy("respec_potions") .Cost(new(string, int)[3] { ("stone_plate_1", 8), ("nails_iron", 6), ("detail_1_iron", 4) }) .Limit(1) .Extensions("timbn_infusion_stand", Array.Empty()); }); foreach (TechColor color in SpiritSolution.Colors) { string solution = SpiritSolution.ItemId(color); string text = color.ToString().ToLowerInvariant(); plugin.Crafts.Add("timbn_infusion_machine_" + text, (Action)delegate(TimbnCraftBuilder craft) { craft.In(machine).BasedOn("pocket_extract_item_craft").Needs(new(string, int)[2] { (solution, 1), ("crystal_goddess", 1) }) .Mastery(4) .Icon(solution) .DurationTicks(8) .AutoFinish() .Requires((Func)((WgoData machine2) => InfusionStand.OccupiedStands(machine2).Any())) .OnStarted((Action)delegate(TimbnCraftEvent infusion) { StartOnStands(plugin, infusion.Station); }) .OnFinished((Action)delegate(TimbnCraftEvent infusion) { Infuse(plugin, infusion.Station, color); }); }); } } private static void StartOnStands(TimbnFrameworkPlugin plugin, WgoData machine) { foreach (WgoData item in InfusionStand.IdleStands(machine)) { if (!plugin.Crafts.Start(item, "timbn_infusion_stand_infusion")) { TimbnFrameworkPlugin.Logger.LogWarning((object)("Could not start the stand infusion on " + ((ObjectLinkedToDefinition)(object)item).id + ".")); } } } private static void Infuse(TimbnFrameworkPlugin plugin, WgoData machine, TechColor color) { foreach (WgoData item in InfusionStand.InfusionStands(machine).ToList()) { ZombieWgoData val = TimbnZombies.AtStation(item); if (val != null) { SpiritSolution.GiveTo(val, machine, color); } plugin.Crafts.Finish(item); } } } internal static class InfusionStand { public const string StationId = "timbn_infusion_stand"; public const string InfusionId = "timbn_infusion_stand_infusion"; public const string SlotId = "timbn_infusion_slot"; public static readonly Vector3 Size = new Vector3(0.64f, 0.5f, 0.9f); private const string _buildIcon = "infusion_stand_build"; private const string _infusedFlag = "timbn_infusion_done"; private const string _buildingTalent = "talent_orange"; private const string _template = "pocket_extract_item_craft"; private const int _infusionTicks = 600; public static void Register(TimbnFrameworkPlugin plugin) { TimbnModel open = plugin.Models.Build("InfusionStandOpen", (Action)delegate(TimbnModelFaces faces) { faces.Block("infusion_stand_box", 0, 0, 1, 36).Top("infusion_stand_floor", 4, 6, 5).Front("infusion_stand_backwall", 4, 6, 33); }); TimbnModel lid = plugin.Models.Build("InfusionStandLid", (Action)delegate(TimbnModelFaces faces) { faces.Block("infusion_stand_lying_lid", 2, 16, 4, 30); }); TimbnModel glow = plugin.Models.Build("InfusionStandGlow", (Action)delegate(TimbnModelFaces faces) { faces.Front("infusion_stand_working_gemglow", 8, 7, 0).Top("infusion_stand_working_lidlines", 2, 20, 4).Front("infusion_stand_working_lidedge", 2, 17, 3); }); plugin.Sprites.AddEmbedded("infusion_stand_build.png", (TimbnSpriteKind)2); TimbnStation stand = plugin.Stations.Add("timbn_infusion_stand", (Action)delegate(TimbnStationBuilder station) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) station.Model(open, Size).Icon("infusion_stand_build").BasedOn("resurrection_table_1") .HoldsZombie() .Talent("talent_orange") .ShowWhen(TimbnLook.HoldsGroup("zombie", 1), lid, false) .ShowWhen(TimbnLook.Resource("timbn_infusion_done", (TimbnComparison)3, 1), glow, false) .Edit((Action)delegate(WGODef def) { def.customInteraction2.execution.Add(TimbnBalance.Expression("SetWGOPar(\"timbn_infusion_done\", 0)")); }) .BuildsInSlot("timbn_infusion_slot") .BuiltAt("builder_morgue", (string)null) .BuildTab("") .UnlockedBy("respec_potions") .Cost(new(string, int)[3] { ("stone_plate_1", 6), ("nails_iron", 4), ("detail_1_iron", 2) }); }); plugin.Events.SaveReady((Action)RepairEmptyStands); plugin.Crafts.Add("timbn_infusion_stand_infusion", (Action)delegate(TimbnCraftBuilder craft) { craft.In(stand).BasedOn("pocket_extract_item_craft").Mastery(1) .DurationTicks(600) .AutoFinish() .Hidden() .OnStarted((Action)delegate(TimbnCraftEvent infusion) { SetGlow(infusion.Station, 0); }) .OnFinished((Action)delegate(TimbnCraftEvent infusion) { SetGlow(infusion.Station, (TimbnZombies.AtStation(infusion.Station) != null) ? 1 : 0); }); }); } private static void SetGlow(WgoData stand, int value) { stand.SetGameRes("timbn_infusion_done", value); } private static void RepairEmptyStands() { foreach (WgoData item in TimbnWorld.FindAll("timbn_infusion_stand")) { if (TimbnZombies.AtStation(item) == null && !IsInfusing(item)) { SetGlow(item, 0); } } } public static IEnumerable StandsOf(WgoData machine) { return from stand in TimbnWorld.Extensions(machine) where ((ObjectLinkedToDefinition)(object)stand).id == "timbn_infusion_stand" select stand; } public static IEnumerable InfusionStands(WgoData machine) { return StandsOf(machine).Where(IsInfusing); } public static IEnumerable OccupiedStands(WgoData machine) { return from stand in StandsOf(machine) where TimbnZombies.AtStation(stand) != null && !IsInfusing(stand) select stand; } public static IEnumerable IdleStands(WgoData machine) { return from stand in StandsOf(machine) where !IsInfusing(stand) select stand; } private static bool IsInfusing(WgoData stand) { return TimbnWorld.RunningCraft(stand) == "timbn_infusion_stand_infusion"; } } internal static class InfusionTech { public const string Id = "respec_potions"; } [BepInPlugin("Timbn.GraveyardKeeperTwo.InfusionRack", "Timbn Infusion Rack", "1.2.0")] [BepInDependency("Timbn.GraveyardKeeperTwo.Core", "2.2.1")] public class Plugin : TimbnFrameworkPlugin { protected override TimbnModInfo ModInfo => new TimbnModInfo { ModGroupName = "Timbn Mods", ModGroupId = "338834e9-f5a5-4d7b-9773-17dfe3d5a954", Description = "Distill organs into Spirit Solutions and infuse your zombies with tech points.", Author = "Timbn", NexusLink = "https://www.nexusmods.com/graveyardkeeper2/mods/395", SteamWorkshopLink = "https://steamcommunity.com/sharedfiles/filedetails/?id=3821083540", ThunderstoreLink = "https://thunderstore.io/c/graveyard-keeper-2/p/Timbn/TimbnInfusionRack/" }; protected override void BindConfig(ConfigFile config) { PluginConfig.Bind(config); } protected override void OnAwake() { SpiritSolution.Register((TimbnFrameworkPlugin)(object)this); SpiritRecipes.Register((TimbnFrameworkPlugin)(object)this); InfusionStand.Register((TimbnFrameworkPlugin)(object)this); InfusionMachine.Register((TimbnFrameworkPlugin)(object)this); } } internal static class PluginConfig { public static ConfigEntry PointsPerSolution { get; private set; } public static void Bind(ConfigFile config) { PointsPerSolution = TimbnConfig.BindRange(config, "Infusion Rack", "PointsPerSolution", 50, "Tech points each zombie lying in a stand gets from one spirit solution. The distillation cube makes one solution for each white skull on the organ.", 1, 500); } } internal static class SpiritRecipes { private const int _firePerCraft = 20; private static readonly (string Organ, TechColor Color, int Skulls)[] _organs = new(string, TechColor, int)[14] { ("heart_0_1:1", TechColor.Red, 1), ("heart_1_1:1", TechColor.Red, 1), ("heart_3_1:3", TechColor.Red, 1), ("heart_1_2:2", TechColor.Red, 2), ("heart_2_2:2", TechColor.Red, 2), ("heart_0_3:3", TechColor.Red, 3), ("guts_2_1:2", TechColor.Green, 1), ("guts_2_2:2", TechColor.Green, 1), ("guts_1_3:3", TechColor.Green, 3), ("brain_0_1:1", TechColor.Blue, 1), ("brain_2_1:2", TechColor.Blue, 1), ("brain_3_1:3", TechColor.Blue, 1), ("brain_0_2:2", TechColor.Blue, 2), ("brain_0_3:3", TechColor.Blue, 3) }; public static void Register(TimbnFrameworkPlugin plugin) { (string, TechColor, int)[] organs = _organs; for (int i = 0; i < organs.Length; i++) { (string, TechColor, int) tuple = organs[i]; string organ = tuple.Item1; TechColor item = tuple.Item2; int skulls = tuple.Item3; string solution = SpiritSolution.ItemId(item); plugin.Crafts.Add("timbn_spirit_" + organ.Replace(':', '_'), (Action)delegate(TimbnCraftBuilder craft) { craft.In("distillation_cube").BasedOn("fragrance").Needs(new(string, int)[3] { (organ, 1), ("fire", 20), ("alchemy_bottle_1", 1) }) .Makes(solution, skulls) .Mastery(1) .Icon(solution) .UnlockedBy("respec_potions"); }); } } } internal enum TechColor { Red, Green, Blue } internal static class SpiritSolution { private const string _itemTemplate = "embalm_white:1"; public static IEnumerable Colors => Enum.GetValues(typeof(TechColor)).Cast(); public static string ItemId(TechColor color) { return "timbn_spirit_solution_" + color.ToString().ToLowerInvariant(); } public static void Register(TimbnFrameworkPlugin plugin) { foreach (TechColor color in Colors) { string text = ItemId(color); plugin.Sprites.AddEmbedded(text + ".png", (TimbnSpriteKind)1); plugin.Balance.AddItem("embalm_white:1", text, "", "", text, (Action)delegate(ItemDef item) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) item.type = (ItemType)0; item.whiteSkulls = 0; item.redSkulls = 0; item.quality = 0; item.qualityType = (QualityType)0; }); } } public static void GiveTo(ZombieWgoData zombie, WgoData table, TechColor color) { int value = PluginConfig.PointsPerSolution.Value; zombie.DoTechPointsReward(table, (color == TechColor.Red) ? value : 0, (color == TechColor.Green) ? value : 0, (color == TechColor.Blue) ? value : 0); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "Timbn.GraveyardKeeperTwo.InfusionRack"; public const string PLUGIN_NAME = "Timbn Infusion Rack"; public const string PLUGIN_VERSION = "1.2.0"; } }