// Decorations mod entry point public static void Patch() { // 1) INITIALIZE HARMONY if (!MyHarmony.Initialize()) { return; } // 2) LOAD CONFIGURATION ConfigSwitcher.LoadConfiguration(); // 3) REGISTER NEW ITEMS DecorationsMod.DecorationItems = RegisterNewItems(); // 4) REGISTER LANGUAGE STRINGS RegisterLanguageStrings(); // 5) MAKE SOME EXISTING ITEMS PICKUPABLE & PLACEABLE if (ConfigSwitcher.EnablePlaceItems) { PlaceToolItems.MakeItemsPlaceable(); } // 6) REGISTER DECORATIONS FABRICATOR Logger.Log("INFO: Registering decorations fabricator..."); Fabricator_Decorations decorationsFabricator = new Fabricator_Decorations(); decorationsFabricator.RegisterDecorationsFabricator(DecorationsMod.DecorationItems); // 7) REGISTER FLORA FABRICATOR if (ConfigSwitcher.EnableNewFlora) { Logger.Log("INFO: Registering seeds fabricator..."); Fabricator_Flora floraFabricator = new Fabricator_Flora(); floraFabricator.RegisterFloraFabricator(DecorationsMod.DecorationItems); } // 8) HARMONY PATCHING MyHarmony.PatchAll(); // Various enhancements. if (ConfigSwitcher.FixAquariumLighting) { PrefabsHelper.FixAquariumSkyApplier(); } MyHarmony.FixSignInput(); // Mods compatibility. MyHarmony.FixAutoLoadMod(); // 9) SETUP IN GAME OPTIONS MENU Logger.Log("INFO: Setting up in-game options menu..."); SMLHelper.V2.Handlers.OptionsPanelHandler.RegisterModOptions(new ConfigOptions("Decorations mod")); }
// Decorations mod entry point public static void Patch() { // 1) INITIALIZE HARMONY if ((HarmonyInstance = HarmonyInstance.Create("com.osubmarin.decorationsmod")) == null) { Logger.Log("ERROR: Unable to initialize Harmony!"); return; } // 2) LOAD CONFIGURATION ConfigSwitcher.LoadConfiguration(); // 3) REGISTER NEW ITEMS DecorationsMod.DecorationItems = RegisterNewItems(); // 4) REGISTER LANGUAGE STRINGS RegisterLanguageStrings(); // 5) MAKE SOME EXISTING ITEMS PICKUPABLE & PLACEABLE if (ConfigSwitcher.EnablePlaceItems) { PlaceToolItems.MakeItemsPlaceable(); } // 6) REGISTER DECORATIONS FABRICATOR Fabricator_Decorations decorationsFabricator = new Fabricator_Decorations(); decorationsFabricator.RegisterDecorationsFabricator(DecorationsMod.DecorationItems); // 7) REGISTER FLORA FABRICATOR if (ConfigSwitcher.EnableNewFlora) { Fabricator_Flora floraFabricator = new Fabricator_Flora(); floraFabricator.RegisterFloraFabricator(DecorationsMod.DecorationItems); } // 8) HARMONY PATCHING HarmonyPatchAll(); // 9) ENHANCEMENTS if (ConfigSwitcher.FixAquariumLighting) { PrefabsHelper.FixAquariumSkyApplier(); } // 10) SETUP IN GAME OPTIONS MENU Logger.Log("Setting up in-game options menu..."); SMLHelper.V2.Handlers.OptionsPanelHandler.RegisterModOptions(new ConfigOptions("Decorations mod")); }
public static void Patch() { // 1) INITIALIZE HARMONY HarmonyInstance = HarmonyInstance.Create("com.osubmarin.decorationsmod"); // 2) LOAD CONFIGURATION ConfigSwitcher.LoadConfiguration(); // 3) REGISTER DECORATION ITEMS List <IDecorationItem> decorationItems = RegisterDecorationItems(); // 4) MAKE SOME EXISTING ITEMS PICKUPABLE & POSITIONABLE if (ConfigSwitcher.EnablePlaceItems) { PlaceToolItems.MakeItemsPlaceable(); } // 5) REGISTER DECORATIONS FABRICATOR CustomFabricator.RegisterDecorationsFabricator(decorationItems); // 6) REGISTER FLORA FABRICATOR CustomFabricator.RegisterFloraFabricator(decorationItems); // 7) HARMONY PATCHING Logger.Log("Patching with Harmony..."); // Patch dictionaries Utility.PatchDictionary(typeof(CraftData), "backgroundTypes", CustomBackgroundTypes); Utility.PatchDictionary(typeof(CraftData), "harvestFinalCutBonusList", CustomFinalCutBonusList); Utility.PatchDictionary(typeof(BaseBioReactor), "charge", CustomCharges); // Give salt when purple pinecone is cut var giveResourceOnDamageMethod = typeof(Knife).GetMethod("GiveResourceOnDamage", BindingFlags.NonPublic | BindingFlags.Instance); var giveResourceOnDamagePostfix = typeof(KnifeFixer).GetMethod("GiveResourceOnDamage_Postfix", BindingFlags.Public | BindingFlags.Static); HarmonyInstance.Patch(giveResourceOnDamageMethod, null, new HarmonyMethod(giveResourceOnDamagePostfix)); // Make plants undropable var canDropItemHereMethod = typeof(Inventory).GetMethod("CanDropItemHere", BindingFlags.Public | BindingFlags.Static); var canDropItemHerePrefix = typeof(InventoryFixer).GetMethod("CanDropItemHere_Prefix", BindingFlags.Public | BindingFlags.Static); HarmonyInstance.Patch(canDropItemHereMethod, new HarmonyMethod(canDropItemHerePrefix), null); // Change custom plants tooltips var onHandHoverMethod = typeof(GrownPlant).GetMethod("OnHandHover", BindingFlags.Public | BindingFlags.Instance); var onHandHoverPostfix = typeof(GrownPlantFixer).GetMethod("OnHandHover_Postfix", BindingFlags.Public | BindingFlags.Static); HarmonyInstance.Patch(onHandHoverMethod, null, new HarmonyMethod(onHandHoverPostfix)); // Fix cargo crates items-containers var onProtoDeserializeObjectTreeMethod = typeof(StorageContainer).GetMethod("OnProtoDeserializeObjectTree", BindingFlags.Public | BindingFlags.Instance); var onProtoDeserializeObjectTreePostfix = typeof(StorageContainerFixer).GetMethod("OnProtoDeserializeObjectTree_Postfix", BindingFlags.Public | BindingFlags.Static); HarmonyInstance.Patch(onProtoDeserializeObjectTreeMethod, null, new HarmonyMethod(onProtoDeserializeObjectTreePostfix)); // Failsafe on lockers and cargo crates deconstruction var canDeconstructMethod = typeof(Constructable).GetMethod("CanDeconstruct", BindingFlags.Public | BindingFlags.Instance); var canDeconstructPrefix = typeof(ConstructableFixer).GetMethod("CanDeconstruct_Prefix", BindingFlags.Public | BindingFlags.Static); HarmonyInstance.Patch(canDeconstructMethod, new HarmonyMethod(canDeconstructPrefix), null); // Fix equipment types for batteries, power cells, and their ion versions if (ConfigSwitcher.EnablePlaceBatteries) { var allowedToAddMethod = typeof(Equipment).GetMethod("AllowedToAdd", BindingFlags.Public | BindingFlags.Instance); var allowedToAddPrefix = typeof(EquipmentFixer).GetMethod("AllowedToAdd_Prefix", BindingFlags.Public | BindingFlags.Static); HarmonyInstance.Patch(allowedToAddMethod, new HarmonyMethod(allowedToAddPrefix), null); var addOrSwapMethod = typeof(Inventory).GetMethod("AddOrSwap", new Type[] { typeof(InventoryItem), typeof(Equipment), typeof(string) }); //, BindingFlags.Public | BindingFlags.Static); var addOrSwapPrefix = typeof(InventoryFixer).GetMethod("AddOrSwap_Prefix", BindingFlags.Public | BindingFlags.Static); HarmonyInstance.Patch(addOrSwapMethod, new HarmonyMethod(addOrSwapPrefix), null); var canSwitchOrSwapMethod = typeof(uGUI_Equipment).GetMethod("CanSwitchOrSwap", BindingFlags.Public | BindingFlags.Instance); var canSwitchOrSwapPrefix = typeof(uGUI_EquipmentFixer).GetMethod("CanSwitchOrSwap_Prefix", BindingFlags.Public | BindingFlags.Static); HarmonyInstance.Patch(canSwitchOrSwapMethod, new HarmonyMethod(canSwitchOrSwapPrefix), null); } }