Example #1
0
 public override BuildingDef CreateBuildingDef()
 {
     // Believe it or not, stock game pumps make no noise pollution
     PGameUtils.CopySoundsToAnim(LiquidPumpFiltered.Animation, "pumpliquid_kanim");
     GeneratedBuildings.RegisterWithOverlay(OverlayScreen.LiquidVentIDs, ID);
     return(LiquidPumpFiltered?.CreateDef());
 }
 /// <summary>
 /// Creates this building.
 /// </summary>
 /// <returns>The building instance to be registered.</returns>
 internal static PBuilding CreateBuilding()
 {
     return(ThermalInterfacePlate = new PBuilding(ID, ThermalPlateStrings.BUILDINGS.
                                                  PREFABS.THERMALINTERFACEPLATE.NAME)
     {
         AddAfter = "ExteriorWall",
         AlwaysOperational = true,
         Animation = "thermalPlate_kanim",
         AudioCategory = "Metal",
         Category = "Utilities",
         ConstructionTime = 30.0f,
         Description = null,
         EffectText = null,
         Entombs = false,
         Floods = false,
         Height = 1,
         HP = 30,
         Ingredients =
         {
             new BuildIngredient(TUNING.MATERIALS.REFINED_METALS, tier: 3)
         },
         ObjectLayer = PGameUtils.GetObjectLayer(nameof(ObjectLayer.Backwall),
                                                 ObjectLayer.Backwall),
         Placement = BuildLocationRule.NotInTiles,
         SceneLayer = Grid.SceneLayer.Backwall,
         SubCategory = "temperature",
         Tech = "Suits",
         Width = 1
     });
 }
        /// <summary>
        /// Cycles through critters of this type.
        /// </summary>
        internal void OnCycleThrough()
        {
            int id       = ClusterManager.Instance.activeWorldId;
            var matching = ListPool <KPrefabID, PinnedCritterEntry> .Allocate();

            var type = CritterType;

            // Compile a list of critters matching this species
            CritterInventoryUtils.GetCritters(id, (kpid) => {
                if (kpid.GetCritterType() == type)
                {
                    matching.Add(kpid);
                }
            }, Species);
            int n = matching.Count;

            if (selectionIndex >= n)
            {
                selectionIndex = 0;
            }
            else
            {
                selectionIndex = (selectionIndex + 1) % n;
            }
            if (n > 0)
            {
                PGameUtils.CenterAndSelect(matching[selectionIndex]);
            }
            matching.Recycle();
        }
Example #4
0
 /// <summary>
 /// Creates a popup on the cell of all buildings where a tool is applied.
 /// </summary>
 /// <param name="enable">true if the "enable" tool was used, false for "disable".</param>
 /// <param name="enabled">The enable tool.</param>
 /// <param name="disabled">The disable tool.</param>
 /// <param name="cell">The cell where the change occurred.</param>
 private static void ShowPopup(bool enable, BulkToolMode enabled, BulkToolMode disabled,
                               int cell)
 {
     PGameUtils.CreatePopup(enable ? PopFXManager.Instance.sprite_Plus : PopFXManager.
                            Instance.sprite_Negative, enable ? enabled.PopupText : disabled.PopupText,
                            cell);
 }
Example #5
0
 public BulkChangeTool()
 {
     numObjectLayers = (int)PGameUtils.GetObjectLayer(nameof(ObjectLayer.NumLayers),
                                                      ObjectLayer.NumLayers);
     pickupableLayer = (int)PGameUtils.GetObjectLayer(nameof(ObjectLayer.Pickupables),
                                                      ObjectLayer.Pickupables);
 }
 private static void AfterDbInit()
 {
     Utils.AddBuildingToPlanScreen("Equipment", SuitRechargerConfig.ID, SuitFabricatorConfig.ID);
     Utils.AddBuildingToTechnology("ImprovedGasPiping", SuitRechargerConfig.ID);
     PGameUtils.CopySoundsToAnim("suitrecharger_kanim", "suit_maker_kanim");
     SuitRecharger.Init();
 }
 public ThermalInterfacePlate()
 {
     backwallLayer = (int)PGameUtils.GetObjectLayer(nameof(ObjectLayer.Backwall),
                                                    ObjectLayer.Backwall);
     numObjectLayers = (int)PGameUtils.GetObjectLayer(nameof(ObjectLayer.NumLayers),
                                                      ObjectLayer.NumLayers);
     transferCache = new List <GameObject>();
 }
 public override BuildingDef CreateBuildingDef()
 {
     PGameUtils.CopySoundsToAnim(GasPumpFiltered.Animation, "pumpgas_kanim");
     GeneratedBuildings.RegisterWithOverlay(OverlayScreen.GasVentIDs, ID);
     // Added before the others, because it was registered first
     LocString.CreateLocStringKeys(typeof(SmartPumpsStrings.BUILDINGS));
     return(GasPumpFiltered?.CreateDef());
 }
 public override void ConfigureBuildingTemplate(GameObject go, Tag prefabTag)
 {
     ThermalInterfacePlate?.ConfigureBuildingTemplate(go);
     go.AddOrGet <AnimTileable>().objectLayer = PGameUtils.GetObjectLayer(
         nameof(ObjectLayer.Backwall), ObjectLayer.Backwall);
     go.AddComponent <ZoneTile>();
     BuildingConfigManager.Instance.IgnoreDefaultKComponent(typeof(RequiresFoundation),
                                                            prefabTag);
 }
Example #10
0
 public Instance(AirlockDoor door) : base(door)
 {
     minionLayer = (int)PGameUtils.GetObjectLayer(nameof(ObjectLayer.Minion),
                                                  ObjectLayer.Minion);
     pickupableLayer = (int)PGameUtils.GetObjectLayer(nameof(ObjectLayer.
                                                             Pickupables), ObjectLayer.Pickupables);
     pressureSamples = 0;
     totalPressure   = 0.0f;
 }
Example #11
0
        /// <summary>
        /// Saves the mod enabled settings and restarts the game.
        /// </summary>
        private static void SaveAndRestart()
        {
#if OPTIONS_ONLY
            POptionsPatches.SaveMods();
#else
            PGameUtils.SaveMods();
#endif
            App.instance.Restart();
        }
Example #12
0
 public override void OnLoad(Harmony harmony)
 {
     base.OnLoad(harmony);
     BUILDING_LAYER = (int)PGameUtils.GetObjectLayer(nameof(ObjectLayer.Building),
                                                     ObjectLayer.Building);
     PUtil.InitLibrary();
     new PBuildingManager().Register(AirlockDoorConfig.CreateBuilding());
     new PLocalization().Register();
     new PVersionCheck().Register(this, new SteamVersionChecker());
 }
Example #13
0
 public override void OnLoad(Harmony harmony)
 {
     base.OnLoad(harmony);
     numObjectLayers = (int)PGameUtils.GetObjectLayer(nameof(ObjectLayer.NumLayers),
                                                      ObjectLayer.NumLayers);
     PUtil.InitLibrary();
     lastChecked.Reset();
     new PPatchManager(harmony).RegisterPatchClass(typeof(BuildStraightUpPatches));
     new PVersionCheck().Register(this, new SteamVersionChecker());
 }
Example #14
0
        /// <summary>
        /// Creates a new building. All buildings thus created must be registered using
        /// PBuilding.Register and have an appropriate IBuildingConfig class.
        ///
        /// Building should be created in OnLoad or a post-load patch (not in static
        /// initializers) to give the localization framework time to patch the LocString
        /// containing the building name and description.
        /// </summary>
        /// <param name="id">The building ID.</param>
        /// <param name="name">The building name.</param>
        public PBuilding(string id, string name)
        {
            if (string.IsNullOrEmpty(id))
            {
                throw new ArgumentNullException(nameof(id));
            }
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException(nameof(name));
            }
            AddAfter              = null;
            AlwaysOperational     = false;
            Animation             = "";
            AudioCategory         = "Metal";
            AudioSize             = "medium";
            Breaks                = true;
            Category              = DEFAULT_CATEGORY;
            ConstructionTime      = 10.0f;
            Decor                 = TUNING.BUILDINGS.DECOR.NONE;
            DefaultPriority       = null;
            Description           = "Default Building Description";
            EffectText            = "Default Building Effect";
            Entombs               = true;
            ExhaustHeatGeneration = 0.0f;
            Floods                = true;
            HeatGeneration        = 0.0f;
            Height                = 1;
            Ingredients           = new List <BuildIngredient>(4);
            IndustrialMachine     = false;
            InputConduits         = new List <ConduitConnection>(4);
            HP          = 100;
            ID          = id;
            LogicIO     = new List <LogicPorts.Port>(4);
            Name        = name;
            Noise       = TUNING.NOISE_POLLUTION.NONE;
            ObjectLayer = PGameUtils.GetObjectLayer(nameof(ObjectLayer.Building), ObjectLayer.
                                                    Building);
            OutputConduits      = new List <ConduitConnection>(4);
            OverheatTemperature = null;
            Placement           = BuildLocationRule.OnFloor;
            PowerInput          = null;
            PowerOutput         = null;
            RotateMode          = PermittedRotations.Unrotatable;
            SceneLayer          = Grid.SceneLayer.Building;
            // Hard coded strings in base game, no const to reference
            SubCategory = "default";
            Tech        = null;
            ViewMode    = OverlayModes.None.ID;
            Width       = 1;

            addedPlan    = false;
            addedStrings = false;
            addedTech    = false;
        }
#pragma warning restore IDE0044
#pragma warning restore CS0649

        /// <summary>
        /// Highlights all critters matching this critter type on the active world.
        /// </summary>
        /// <param name="color">The color to highlight the critters.</param>
        internal void HighlightAllMatching(Color color)
        {
            var type = CritterType;
            int id   = ClusterManager.Instance.activeWorldId;

            CritterInventoryUtils.GetCritters(id, (kpid) => {
                if (kpid.GetCritterType() == type)
                {
                    PGameUtils.HighlightEntity(kpid, color);
                }
            });
        }
Example #16
0
        /// <summary>
        /// Highlights all critters matching this critter type on the active world.
        /// </summary>
        /// <param name="color">The color to highlight the critters.</param>
        /// <param name="species">The species type to highlight.</param>
        internal void HighlightAllMatching(Color color)
        {
            var type = CritterType;
            int id   = ClusterManager.Instance.activeWorldId;

            CritterInventoryUtils.GetCritters(id, (creature) => {
                if (creature.GetCritterType() == type)
                {
                    PGameUtils.HighlightEntity(creature, color);
                }
            }, entry.Resource);
        }
Example #17
0
        public override BuildingDef CreateBuildingDef()
        {
            LocString.CreateLocStringKeys(typeof(AirlockDoorStrings.BUILDING));
            LocString.CreateLocStringKeys(typeof(AirlockDoorStrings.BUILDINGS));
            var def = AirlockDoorTemplate?.CreateDef();

            def.ForegroundLayer = Grid.SceneLayer.TileMain;
            def.IsFoundation    = true;
            def.PreventIdleTraversalPastBuilding = true;
            // /5 multiplier to thermal conductivity
            def.ThermalConductivity = 0.2f;
            def.TileLayer           = PGameUtils.GetObjectLayer(nameof(ObjectLayer.FoundationTile),
                                                                ObjectLayer.FoundationTile);
            return(def);
        }
Example #18
0
        private static void AddBuilding()
        {
            Utils.AddBuildingToPlanScreen("HEP", HEPBridgeInsulationTileConfig.ID, HEPBridgeTileConfig.ID);
            PGameUtils.CopySoundsToAnim("wallbridge_orb_transporter_kanim", "orb_transporter_kanim");
            // заменяем технологию для клеевской пластины
            var klei_tech_current = Db.Get().Techs.TryGetTechForTechItem(HEPBridgeTileConfig.ID);
            var klei_tech_new_id  = HEPBridgeInsulationTileOptions.Instance.research_klei.ToString();

            if (klei_tech_current != null && klei_tech_current.Id != klei_tech_new_id)
            {
                klei_tech_current.unlockedItemIDs.Remove(HEPBridgeTileConfig.ID);
                Utils.AddBuildingToTechnology(klei_tech_new_id, HEPBridgeTileConfig.ID);
            }
            var mod_tech_id = HEPBridgeInsulationTileOptions.Instance.research_mod.ToString();

            Utils.AddBuildingToTechnology(mod_tech_id, HEPBridgeInsulationTileConfig.ID);
        }
        internal FilteredDestroyTool()
        {
            Color color;

            modes = new List <DestroyFilter>(12)
            {
                new DestroyFilter("Elements", SandboxToolsStrings.DESTROY_ELEMENTS,
                                  DestroyElement),
                new DestroyFilter("Items", SandboxToolsStrings.DESTROY_ITEMS, DestroyItems),
                new DestroyFilter("Creatures", SandboxToolsStrings.DESTROY_CREATURES,
                                  DestroyCreatures),
                new DestroyFilter("Plants", SandboxToolsStrings.DESTROY_PLANTS,
                                  DestroyPlants),
                new DestroyFilter("Buildings", SandboxToolsStrings.DESTROY_BUILDINGS),
                new DestroyFilter("BackWall", SandboxToolsStrings.DESTROY_DRYWALL),
                new DestroyFilter("LiquidPipes", SandboxToolsStrings.DESTROY_LPIPES),
                new DestroyFilter("GasPipes", SandboxToolsStrings.DESTROY_GPIPES),
                new DestroyFilter("Wires", SandboxToolsStrings.DESTROY_POWER),
                new DestroyFilter("Logic", SandboxToolsStrings.DESTROY_AUTO),
                new DestroyFilter("SolidConduits", SandboxToolsStrings.DESTROY_SHIPPING)
            };
            // "All" checkbox to destroy everything
            if (!SandboxToolsPatches.AdvancedFilterEnabled)
            {
                modes.Insert(0, new DestroyFilter("All", SandboxToolsStrings.DESTROY_ALL,
                                                  DestroyAll));
            }
            pendingCells = new HashSet <int>();
            try {
                // Take from stock tool if possible
                color = RECENTLY_AFFECTED.Get(SandboxDestroyerTool.instance);
            } catch (System.Exception e) {
#if DEBUG
                PUtil.LogExcWarn(e);
#endif
                // Use default
                color = new Color(1f, 1f, 1f, 0.1f);
            }
            // Read value at runtime if possible
            numObjectLayers = (int)PGameUtils.GetObjectLayer(nameof(ObjectLayer.NumLayers),
                                                             ObjectLayer.NumLayers);
            pickupLayer = (int)PGameUtils.GetObjectLayer(nameof(ObjectLayer.Pickupables),
                                                         ObjectLayer.Pickupables);
            pendingHighlightColor = color;
        }
 /// <summary>
 /// Called when the object is selected.
 /// </summary>
 /// <param name="data">true if selected, or false if deselected.</param>
 private void OnSelect(object data)
 {
     if (data is bool selected)
     {
         var position = transform.position;
         // Play the appropriate sound and update the visualizers
         if (selected)
         {
             PGameUtils.PlaySound("RadialGrid_form", position);
             CreateVisualizers();
         }
         else
         {
             PGameUtils.PlaySound("RadialGrid_disappear", position);
             RemoveVisualizers();
         }
     }
 }
Example #21
0
        /// <summary>
        /// Called to select and center the mismatched wires.
        /// </summary>
        private void OnFindMismatched()
        {
            var enet = GetNetwork();

            if (wire != null && enet != null)
            {
                var wattageRating = wire.MaxWattageRating;
                // Just locate the first wire with a mismatched wattage that is less than
                // this wire and select it
                foreach (var badWire in enet.allWires)
                {
                    if (badWire.MaxWattageRating < wattageRating && badWire != wire)
                    {
                        PGameUtils.CenterAndSelect(badWire);
                        break;
                    }
                }
            }
        }
Example #22
0
        /// <summary>
        /// Called to select and center the mismatched pipes.
        /// </summary>
        private void OnFindMismatched()
        {
            var cnet = GetNetwork();

            if (pe != null && cnet != null)
            {
                var element = pe.ElementID;
                var type    = conduit.ConduitType;
                foreach (var conduit in cnet.conduits)
                {
                    var otherPE = conduit.GameObject.GetComponentSafe <PrimaryElement>();
                    if (((otherPE != null && otherPE.ElementID != element) || conduit.
                         ConduitType != type) && otherPE != pe)
                    {
                        PGameUtils.CenterAndSelect(otherPE);
                        break;
                    }
                }
            }
        }
Example #23
0
 /// <summary>
 /// Creates this building.
 /// </summary>
 /// <returns>The building instance to be registered.</returns>
 internal static PBuilding CreateBuilding()
 {
     return(TileTempSensor = new PBuilding(ID,
                                           TileTempSensorStrings.BUILDINGS.PREFABS.TILETEMPSENSOR.NAME)
     {
         AddAfter = LogicTemperatureSensorConfig.ID,
         Animation = "thermo_tile_kanim",
         AudioCategory = "Metal",
         AudioSize = "small",
         Category = "Automation",
         ConstructionTime = 30.0f,
         Decor = TUNING.BUILDINGS.DECOR.BONUS.TIER0,
         Description = null,
         EffectText = null,
         Entombs = false,
         Floods = false,
         Height = 1,
         HP = 100,
         Ingredients =
         {
             new BuildIngredient(TUNING.MATERIALS.REFINED_METALS, tier: 2)
         },
         IsSolidTile = true,
         LogicIO =
         {
             LogicPorts.Port.OutputPort(LogicSwitch.PORT_ID,                                                  new CellOffset(0, 0),
                                        STRINGS.BUILDINGS.PREFABS.LOGICTEMPERATURESENSOR.LOGIC_PORT,
                                        STRINGS.BUILDINGS.PREFABS.LOGICTEMPERATURESENSOR.LOGIC_PORT_ACTIVE,
                                        STRINGS.BUILDINGS.PREFABS.LOGICTEMPERATURESENSOR.LOGIC_PORT_INACTIVE, true)
         },
         ObjectLayer = PGameUtils.GetObjectLayer(nameof(ObjectLayer.Backwall),
                                                 ObjectLayer.Backwall),
         Placement = BuildLocationRule.Tile,
         SceneLayer = Grid.SceneLayer.TileMain,
         SubCategory = "sensors",
         Tech = "HVAC",
         ViewMode = OverlayModes.Logic.ID,
         Width = 1
     });
 }
Example #24
0
            /// <summary>
            /// Applied before OnClick runs.
            /// </summary>
            internal static bool Prefix(ResourceEntry __instance, ref int ___selectionIdx)
            {
                var  entry = __instance.gameObject.GetComponentSafe <CritterResourceEntry>();
                bool cont  = entry == null;

                if (!cont)
                {
                    var creaturesOfType = entry.CachedCritters;
                    // Build list if empty
                    entry.UpdateLastClick();
                    if (creaturesOfType == null)
                    {
                        creaturesOfType = entry.PopulateCache();
                        entry.StartCoroutine(entry.ClearCacheAfterThreshold());
                    }
                    int count = creaturesOfType.Count;
                    if (count > 0)
                    {
                        // Rotate through valid indexes
                        PGameUtils.CenterAndSelect(creaturesOfType[___selectionIdx++ % count]);
                    }
                }
                return(cont);
            }
 public AirlockDoorTransitionLayer(Navigator navigator) : base(navigator)
 {
     buildingLayer = (int)PGameUtils.GetObjectLayer(nameof(ObjectLayer.Building),
                                                    ObjectLayer.Building);
     doors = new Dictionary <AirlockDoor, DoorRequestType>(4);
 }
Example #26
0
 /// <summary>
 /// Saves the mod enabled settings and restarts the game.
 /// </summary>
 private static void SaveAndRestart()
 {
     PGameUtils.SaveMods();
     App.instance.Restart();
 }
Example #27
0
        /// <summary>
        /// Applies decor values from the database.
        /// </summary>
        internal static void ApplyDatabase(DecorReimaginedOptions options)
        {
            DecorDbEntry[] entries = null;
            try {
                // Read in database from the embedded config json
                using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(
                           "ReimaginationTeam.DecorRework.buildings.json")) {
                    var jr = new JsonTextReader(new StreamReader(stream));
                    entries = new JsonSerializer {
                        MaxDepth = 2
                    }.Deserialize <DecorDbEntry[]>(jr);
                    jr.Close();
                }
            } catch (JsonException e) {
                // Error when loading decor
                PUtil.LogExcWarn(e);
            } catch (IOException e) {
                // Error when loading decor
                PUtil.LogExcWarn(e);
            }
            if (entries != null)
            {
                var editDecor = DictionaryPool <string, DecorDbEntry, DecorDbEntry> .Allocate();

                var tileLayer = PGameUtils.GetObjectLayer(nameof(ObjectLayer.FoundationTile),
                                                          ObjectLayer.FoundationTile);
                string id;
                // Add to dictionary, way faster
                foreach (var entry in entries)
                {
                    if (!string.IsNullOrEmpty(id = entry.id) && !editDecor.ContainsKey(id))
                    {
                        editDecor.Add(id, entry);
                    }
                }
                foreach (var def in Assets.BuildingDefs)
                {
                    // If PreserveTileDecor is set to true, ignore foundation tile decor mods
                    if (editDecor.TryGetValue(id = def.PrefabID, out DecorDbEntry entry) &&
                        (def.TileLayer != tileLayer || !options.PreserveTileDecor))
                    {
                        float decor    = entry.decor;
                        int   radius   = entry.radius;
                        var   provider = def.BuildingComplete.GetComponent <DecorProvider>();
                        // For reference, these do not alter the BuildingComplete
                        def.BaseDecor       = decor;
                        def.BaseDecorRadius = radius;
                        // Actual decor provider
                        if (provider != null)
                        {
                            PUtil.LogDebug("Patched: {0} Decor: {1:F1} Radius: {2:D}".F(id,
                                                                                        decor, radius));
                            provider.baseDecor  = decor;
                            provider.baseRadius = radius;
                        }
                    }
                }
                editDecor.Recycle();
            }
            // Patch in the debris decor
            var baseOreTemplate = typeof(EntityTemplates).GetFieldSafe("baseOreTemplate",
                                                                       true)?.GetValue(null) as GameObject;
            DecorProvider component;

            if (baseOreTemplate != null && (component = baseOreTemplate.
                                                        GetComponent <DecorProvider>()) != null)
            {
                int radius = Math.Max(1, options.DebrisRadius);
                component.baseDecor  = options.DebrisDecor;
                component.baseRadius = radius;
                PUtil.LogDebug("Debris: {0:F1} radius {1:D}".F(options.DebrisDecor, radius));
            }
            // Patch the suits
            PUtil.LogDebug("Snazzy Suit: {0:D} Warm/Cool Vest: {1:D}".F(options.
                                                                        SnazzySuitDecor, options.VestDecor));
            ClothingWearer.ClothingInfo.FANCY_CLOTHING.decorMod = options.SnazzySuitDecor;
            ClothingWearer.ClothingInfo.COOL_CLOTHING.decorMod  = options.VestDecor;
            ClothingWearer.ClothingInfo.WARM_CLOTHING.decorMod  = options.VestDecor;
        }
Example #28
0
#pragma warning restore IDE0044
#pragma warning restore CS0649

        public SinkCheckpoint() : base()
        {
            buildingLayer = (int)PGameUtils.GetObjectLayer(nameof(ObjectLayer.Building),
                                                           ObjectLayer.Building);
        }
Example #29
0
 public override BuildingDef CreateBuildingDef()
 {
     PGameUtils.CopySoundsToAnim(VacuumPump.Animation, "pumpgas_kanim");
     GeneratedBuildings.RegisterWithOverlay(OverlayScreen.GasVentIDs, ID);
     return(VacuumPump?.CreateDef());
 }
Example #30
0
 private static void AddBuilding()
 {
     Utils.AddBuildingToPlanScreen("Medical", BuildableGeneShufflerConfig.ID);
     Utils.AddBuildingToTechnology("MedicineIV", BuildableGeneShufflerConfig.ID);
     PGameUtils.CopySoundsToAnim(BuildableGeneShufflerConfig.anim, "geneshuffler_kanim");
 }