internal static void PatchBatteries()
        {
            if (!TechTypeHandler.ModdedTechTypeExists("DeepPowerCell"))
            {
                var tabIcon = ImageUtils.LoadSpriteFromFile(@"./Qmods/" + Assets + @"/TabIcon.png");
                CraftTreeHandler.AddTabNode(CraftTree.Type.Fabricator, BatCraftTab, "Batteries and Power Cells", tabIcon, ResCraftTab, ElecCraftTab);
                SeraLogger.Message(Main.modName, "MidGameBatteries not installed, creating new crafting tab");

                CraftTreeHandler.RemoveNode(CraftTree.Type.Fabricator, ResCraftTab, ElecCraftTab, TechType.Battery.ToString());
                CraftTreeHandler.RemoveNode(CraftTree.Type.Fabricator, ResCraftTab, ElecCraftTab, TechType.PrecursorIonBattery.ToString());
                CraftTreeHandler.RemoveNode(CraftTree.Type.Fabricator, ResCraftTab, ElecCraftTab, TechType.PowerCell.ToString());
                CraftTreeHandler.RemoveNode(CraftTree.Type.Fabricator, ResCraftTab, ElecCraftTab, TechType.PrecursorIonPowerCell.ToString());

                CraftTreeHandler.AddCraftingNode(CraftTree.Type.Fabricator, TechType.Battery, CraftPath);
                CraftTreeHandler.AddCraftingNode(CraftTree.Type.Fabricator, TechType.PowerCell, CraftPath);
                CraftTreeHandler.AddCraftingNode(CraftTree.Type.Fabricator, TechType.PrecursorIonBattery, CraftPath);
                CraftTreeHandler.AddCraftingNode(CraftTree.Type.Fabricator, TechType.PrecursorIonPowerCell, CraftPath);
            }
            else
            {
                SeraLogger.Message(Main.modName, "MidGameBatteries installed, adding to crafting tab");
            }
            var enzBatt = new EnzymeBattery(1000f);

            enzBatt.Patch();
            var enzPowerCell = new EnzymePowerCell(enzBatt);

            enzPowerCell.Patch();
        }
示例#2
0
        /// <summary>
        /// Execute to start the creation process to load the items into the game
        /// </summary>

        public static void Patch()
        {
            //Set Rotation
            AISolutionsData.ChangeRotation();

            HarmonyInstance = HarmonyInstance.Create($"com.FCStudios.{Information.ModName}");
            HarmonyInstance.PatchAll(Assembly.GetExecutingAssembly());

            SolarPanel_Patcher.AddEventHandlerIfMissing(AlertSolorPanelAwake);
            //BuilderToolConstruct_Patcher.AddEventHandlerIfMissing(AlertedNewBuilderBuild);
            //PowerFXSetTarget_Patcher.AddEventHandlerIfMissing(AlertedSetTarget);

            //Load the language
            JetStreamT242ModStrings = LoadLanguage <JetStreamT242ModStrings>(Information.JetStreamTurbineName) as JetStreamT242ModStrings;
            MarineMonitorModStrings = LoadLanguage <MarineMonitorModStrings>(Information.MarineTurbinesMonitorName) as MarineMonitorModStrings;
            DeepDrillerModStrings   = LoadLanguage <DeepDrillerModStrings>(Information.DeepDrillerName) as DeepDrillerModStrings;

            bool FCSTechWorkBench = TechTypeHandler.ModdedTechTypeExists("FCSTechWorkBench");

            if (!FCSTechWorkBench)
            {
                Log.Error($"Mod FCS WorkBench is needed!");
                //throw new PatchTerminatedException("Error finding FCS Work Bench");
            }

            if (!FindAllowedModules())
            {
                Log.Error($"Allowed modules not found!");

                //throw new PatchTerminatedException("Error finding all allow modules in FCS Work Bench");
            }

            //Load Configuration
            bool loaded = LoadConfigs();

            if (!loaded)
            {
                throw new PatchTerminatedException("Error loading Configuration");
            }

            var item     = DeepDrillConfig.BiomeOres["safeshallows"];
            var techType = item[1].ToTechType();

            Log.Info($"Found TechType: {techType}");

            // == Get the Prefabs == //
            if (GetPrefabs())
            {
                // === Create the jetStream == //
                if (JetStreamT242ModStrings != null)
                {
                    var jetStream = new JetStreamT242(Information.JetStreamTurbineName, Information.JetStreamTurbineFriendly,
                                                      JetStreamT242ModStrings.Description);
                    jetStream.Register();
                    jetStream.Patch();
                    JETSTREAMT242_PREFAB_OBJECT = jetStream;
                }
                else
                {
                    throw new PatchTerminatedException("Error JetStreamT242ModStrings is null");
                }

                // === Create the MarineTurbinesMonitor == //
                if (MarineMonitorModStrings != null)
                {
                    var monitor = new MarineTurbinesMonitor(Information.MarineTurbinesMonitorName, Information.MarineTurbinesMonitorFriendly,
                                                            MarineMonitorModStrings.Description);
                    monitor.Register();
                    monitor.Patch();
                    MONITOR_PREFAB_OBJECT = monitor;
                }
                else
                {
                    throw new PatchTerminatedException("Error MarineMonitorModStrings is null");
                }

                // === Create the DeepDriller == //
                if (DeepDrillerModStrings != null)
                {
                    var driller = new DeepDriller(Information.DeepDrillerName, Information.DeepDrillerFriendly,
                                                  DeepDrillerModStrings.Description);
                    driller.Register();
                    driller.Patch();
                    DEEP_DRILLER_PREFAB_OBJECT = driller;
                }
                else
                {
                    throw new PatchTerminatedException("Error DeepDrillerModStrings is null");
                }

                //var file = Path.Combine(Information.LANGUAGEDIRECTORY, $"{Information.MarineTurbinesMonitorName}.json");
                //var file = Information.GetConfigFile(Information.DeepDrillerName);

                //var data = JsonConvert.SerializeObject(new DeepDrillerCfg(), Formatting.Indented);

                //File.WriteAllText(file, data);
            }
            else
            {
                throw new PatchTerminatedException("Error loading finding a prefab");
            }
        }