Example #1
0
        void Awake()
        {
            logger = Logger;

            string pluginfolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            resource = new ResourceData(MODNAME, "gigastations", pluginfolder);
            resource.LoadAssetBundle("gigastations");

            ProtoRegistry.AddResource(resource);


            //General
            gridXCount   = Config.Bind("-|0|- General", "-| 1 Grid X Max. Count", 1, new ConfigDescription("Amount of slots visible horizontally.\nIf this value is bigger than 1, layout will form a grid", new AcceptableValueRange <int>(1, 3))).Value;
            gridYCount   = Config.Bind("-|0|- General", "-| 2 Grid Y Max. Count", 5, new ConfigDescription("Amount of slots visible vertically", new AcceptableValueRange <int>(3, 12))).Value;
            stationColor = Config.Bind("-|0|- General", "-| 3 Station Color", new Color(0.3726f, 0.8f, 1f, 1f), "Color tint of giga stations").Value;

            //ILS
            ilsMaxSlots   = Config.Bind("-|1|- ILS", "-| 1 Max. Item Slots", 12, new ConfigDescription("The maximum Item Slots the Station can have.\nVanilla: 5", new AcceptableValueRange <int>(5, 12))).Value;
            ilsMaxStorage = Config.Bind("-|1|- ILS", "-| 2 Max. Storage", 30000, "The maximum Storage capacity per Item-Slot.\nVanilla: 10000").Value;
            ilsMaxVessels = Config.Bind("-|1|- ILS", "-| 3 Max. Vessels", 30, new ConfigDescription("The maximum Logistic Vessels amount.\nVanilla: 10", new AcceptableValueRange <int>(10, 30))).Value;
            ilsMaxDrones  = Config.Bind("-|1|- ILS", "-| 4 Max. Drones", 150, new ConfigDescription("The maximum Logistic Drones amount.\nVanilla: 50", new AcceptableValueRange <int>(50, 150))).Value;
            ilsMaxAcuGJ   = Config.Bind("-|1|- ILS", "-| 5 Max. Accu Capacity (GJ)", 50, "The Stations maximum Accumulator Capacity in GJ.\nVanilla: 12 GJ").Value;
            ilsMaxWarps   = Config.Bind("-|1|- ILS", "-| 6 Max. Warps", 150, "The maximum Warp Cells amount.\nVanilla: 50").Value;

            //PLS
            plsMaxSlots   = Config.Bind("-|2|- PLS", "-| 1 Max. Item Slots", 12, new ConfigDescription("The maximum Item Slots the Station can have.\nVanilla: 3", new AcceptableValueRange <int>(3, 12))).Value;
            plsMaxStorage = Config.Bind("-|2|- PLS", "-| 2 Max. Storage", 15000, "The maximum Storage capacity per Item-Slot.\nVanilla: 5000").Value;
            plsMaxDrones  = Config.Bind("-|2|- PLS", "-| 3 Max. Drones", 150, new ConfigDescription("The maximum Logistic Drones amount.\nVanilla: 50", new AcceptableValueRange <int>(50, 150))).Value;
            plsMaxAcuMJ   = Config.Bind("-|2|- PLS", "-| 4 Max. Accu Capacity (GJ)", 500, "The Stations maximum Accumulator Capacity in MJ.\nVanilla: 180 MJ").Value;

            //Collector
            colSpeedMultiplier = Config.Bind("-|3|- Collector", "-| 1 Collect Speed Multiplier", 3, "Multiplier for the Orbital Collectors Collection-Speed.\nVanilla: 1").Value;
            colMaxStorage      = Config.Bind("-|3|- Collector", "-| 2 Max. Storage", 15000, "The maximum Storage capacity per Item-Slot.\nVanilla: 5000").Value;


            //VesselCapacity
            vesselCapacityMultiplier = Config.Bind("-|4|- Vessel", "-| 1 Max. Capacity", 3, "Vessel Capacity Multiplier\n1 == 1000 Vessel Capacity at max Level").Value;

            //DroneCapacity
            droneCapacityMultiplier = Config.Bind("-|5|- Drone", "-| 1 Max. Capacity", 3, "Drone Capacity Multiplier\n1 == 100 Drone Capacity at max Level").Value;

            ProtoRegistry.RegisterString("PLS_Name", "Planetary Giga Station");
            ProtoRegistry.RegisterString("PLS_Desc", "Has more Slots, Capacity, etc. than a usual PLS.");
            ProtoRegistry.RegisterString("ILS_Name", "Interstellar Giga Station");
            ProtoRegistry.RegisterString("ILS_Desc", "Has more Slots, Capacity, etc. than a usual ILS.");
            ProtoRegistry.RegisterString("Collector_Name", "Orbital Giga Collector");
            ProtoRegistry.RegisterString("Collector_Desc", $"Has more Capacity and collects {colSpeedMultiplier}x faster than a usual Collector.");

            ProtoRegistry.RegisterString("ModificationWarn", "  - [GigaStationsUpdated] Replaced {0} buildings");

            ProtoRegistry.RegisterString("CantDowngradeWarn", "Downgrading logistic station is not possible!");


            pls                  = ProtoRegistry.RegisterItem(2110, "PLS_Name", "PLS_Desc", "assets/gigastations/texture2d/icon_pls", 2701);
            ils                  = ProtoRegistry.RegisterItem(2111, "ILS_Name", "ILS_Desc", "assets/gigastations/texture2d/icon_ils", 2702);
            collector            = ProtoRegistry.RegisterItem(2112, "Collector_Name", "Collector_Desc", "assets/gigastations/texture2d/icon_collector", 2703);
            collector.BuildInGas = true;

            ProtoRegistry.RegisterRecipe(410, ERecipeType.Assemble, 2400, new[] { 2103, 1103, 1106, 1303, 1206 }, new[] { 1, 40, 40, 40, 20 }, new[] { pls.ID },
                                         new[] { 1 }, "PGS_Desc", 1604);
            ProtoRegistry.RegisterRecipe(411, ERecipeType.Assemble, 3600, new[] { 2110, 1107, 1206 }, new[] { 1, 40, 20 }, new[] { ils.ID },
                                         new[] { 1 }, "ILS_Desc", 1605);
            ProtoRegistry.RegisterRecipe(412, ERecipeType.Assemble, 3600, new[] { 2111, 1205, 1406, 2207 }, new[] { 1, 50, 20, 20 }, new[] { collector.ID },
                                         new[] { 1 }, "Collector_Desc", 1606);


            plsModel       = ProtoRegistry.RegisterModel(300, pls, "Entities/Prefabs/logistic-station", null, new[] { 24, 38, 12, 10, 1 }, 605, 2, new [] { 2103, 0 });
            ilsModel       = ProtoRegistry.RegisterModel(301, ils, "Entities/Prefabs/interstellar-logistic-station", null, new[] { 24, 38, 12, 10, 1 }, 606, 2, new [] { 2104, 0 });
            collectorModel = ProtoRegistry.RegisterModel(302, collector, "Entities/Prefabs/orbital-collector", null, new[] { 18, 11, 32, 1 }, 607, 2, new [] { 2105, 0 });

            ProtoRegistry.onLoadingFinished += AddGigaPLS;
            ProtoRegistry.onLoadingFinished += AddGigaILS;
            ProtoRegistry.onLoadingFinished += AddGigaCollector;

            var harmony = new Harmony(MODGUID);

            harmony.PatchAll(typeof(StationEditPatch));
            harmony.PatchAll(typeof(SaveFixPatch));
            harmony.PatchAll(typeof(StationUpgradePatch));
            harmony.PatchAll(typeof(UIStationWindowPatch));
            harmony.PatchAll(typeof(BlueprintBuilding_Patch));
            harmony.PatchAll(typeof(UIEntityBriefInfo_Patch));

            foreach (var pluginInfo in BepInEx.Bootstrap.Chainloader.PluginInfos)
            {
                if (pluginInfo.Value.Metadata.GUID != WARPERS_MOD_GUID)
                {
                    continue;
                }

                ((ConfigEntry <bool>)pluginInfo.Value.Instance.Config["General", "ShowWarperSlot"]).Value = true;
                logger.LogInfo("Overriding Distribute Space Warpers config: ShowWarperSlot = true");
                break;
            }

            UtilSystem.AddLoadMessageHandler(SaveFixPatch.GetFixMessage);

            logger.LogInfo("GigaStations is initialized!");
        }
Example #2
0
        void Awake()
        {
            logger = Logger;

            mode = Config.Bind("General", "Mode", ModeType.SIMPLE,
                               "Which mode to use:\n" +
                               "Simple means only one model for substation, and fully safe to use(Removing this mod will not harm saves).\n" +
                               "Advanced means that all substation types will be available at once.\n" +
                               "Downside is that it is not save safe(Removing this mod will cause you to lose all built substations)\n" +
                               "Remove mode is intended to prepare your save to removal of this mod. In it all placed substations will revert back to original when save is LOADED");

            type = Config.Bind("General", "SubstationType", SubstaionType.GROUND, "Which model to use(Has no effect in advanced mode!)");

            string pluginfolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            resource = new ResourceData(ID, "custommachines", pluginfolder);
            resource.LoadAssetBundle("substationbundle");
            resource.ResolveVertaFolder();

            ProtoRegistry.AddResource(resource);


            Material mainMat = ProtoRegistry.CreateMaterial("VF Shaders/Forward/PBR Standard Substation", "ground-substation",
                                                            "#FF7070FF",
                                                            new[]
            {
                "assets/custommachines/texture2d/orbital-substation-a",
                "assets/custommachines/texture2d/orbital-substation-n",
                "assets/custommachines/texture2d/orbital-substation-s",
                "assets/custommachines/texture2d/orbital-substation-e"
            });

            //VF Shaders/Forward/Unlit Additive Substation
            Material effectMat = ProtoRegistry.CreateMaterial("VF Shaders/Forward/Unlit Additive Substation", "substation-effects",
                                                              "#00000000",
                                                              new[]
            {
                "assets/custommachines/texture2d/orbital-substation-effect",
                "assets/custommachines/texture2d/orbital-substation-effect-mask"
            }, null,
                                                              new[]
            {
                Shader.PropertyToID("_MainTex"),
                Shader.PropertyToID("_MaskTex")
            });

            effectMat.SetFloat(Multiplier, 20);
            effectMat.SetVector(UVSpeed, new Vector4(0, 1, 0, 0));
            effectMat.SetFloat(InvFade, 0.4f);

            ProtoRegistry.RegisterString("SubstationModificationWarn", "  - [GroundSubstation] Replaced {0} buildings");
            ProtoRegistry.RegisterString("SubstationRestoreWarn", "  - [GroundSubstation] Restored {0} buildings (Save the game! You can now remove this mod safely)");

            if (mode.Value == ModeType.SIMPLE)
            {
                Logger.LogInfo("Initialising in SIMPLE mode");
                switch (type.Value)
                {
                case SubstaionType.GROUND:
                    ProtoRegistry.AddLodMaterials("assets/custommachines/prefabs/ground-substation", 0, new [] { mainMat, effectMat });
                    break;

                case SubstaionType.SATELITE:
                    ProtoRegistry.AddLodMaterials("assets/custommachines/prefabs/orbital-substation", 0, new [] { mainMat, effectMat });
                    break;
                }
                Harmony.CreateAndPatchAll(typeof(VFPreloadPatch), "groundsubstation");
                Harmony.CreateAndPatchAll(typeof(BuildTool_ClickPatch), "groundsubstation");
            }
            else if (mode.Value == ModeType.ADVANCED)
            {
                Logger.LogInfo("Initialising in ADVANCED mode");
                ProtoRegistry.RegisterModel(firstSubstationId, "Entities/Prefabs/orbital-substation", new[] { mainMat, effectMat });
                ProtoRegistry.RegisterModel(firstSubstationId + 1, "assets/custommachines/prefabs/ground-substation", new[] { mainMat, effectMat });
                ProtoRegistry.RegisterModel(firstSubstationId + 2, "assets/custommachines/prefabs/orbital-substation", new[] { mainMat, effectMat });
                Harmony.CreateAndPatchAll(typeof(BuildTool_ClickPatch), "groundsubstation");

                Harmony.CreateAndPatchAll(typeof(GameDataPatch), "groundsubstation");
                Harmony.CreateAndPatchAll(typeof(EntityDataPatch), "groundsubstation");
                Harmony.CreateAndPatchAll(typeof(PlayerControlGizmoPatch), "groundsubstation");
            }
            else
            {
                Logger.LogInfo("Initialising in REMOVE mode");

                Harmony.CreateAndPatchAll(typeof(GameDataPatch), "groundsubstation");
                Harmony.CreateAndPatchAll(typeof(EntityDataPatch), "groundsubstation");
            }

            UtilSystem.AddLoadMessageHandler(GetReplaceMessage);


            Logger.LogInfo("Ground Substation mod is initialized!");

            ProtoRegistry.onLoadingFinished += AfterLoad;
        }