private static void Postfix(ProcGen.MutatedWorldData __instance)
            {
                var densityModifier = SizeNotIncludedOptions.Instance.Density();

                foreach (KeyValuePair <string, ElementBandConfiguration> bandConfiguration in __instance.biomes.BiomeBackgroundElementBandConfigurations)
                {
                    foreach (ElementGradient elementGradient in bandConfiguration.Value)
                    {
                        ProcGen.WorldTrait.ElementBandModifier modifier = new ProcGen.WorldTrait.ElementBandModifier();
                        Traverse.Create(modifier).Property("element").SetValue(elementGradient.content);
                        var element = ElementLoader.FindElementByName(elementGradient.content);
                        if (element != null && element.id == SimHashes.Magma)
                        {
                            // no modifier for magma. breaks the bottom of the world
                            Traverse.Create(modifier).Property("massMultiplier").SetValue(1f);
                        }
                        else if (element != null && element.IsLiquid)
                        {
                            // give the player at most 2x liquids otherwise they really break out of the pockets they spawn in
                            Traverse.Create(modifier).Property("massMultiplier").SetValue((float)Math.Min(maxLiquidModifier, densityModifier));
                        }
                        else
                        {
                            // everything else - gasses and solid tiles should just use whatever density modifier the game has
                            Traverse.Create(modifier).Property("massMultiplier").SetValue((float)densityModifier);
                        }
                        elementGradient.Mod(modifier);
                    }
                }
            }
    private void ConfigurePollutedWaterOutput()
    {
        Storage storage = null;
        Tag     tag     = ElementLoader.FindElementByHash(SimHashes.DirtyWater).tag;

        Storage[] components = GetComponents <Storage>();
        foreach (Storage storage2 in components)
        {
            if (storage2.storageFilters.Contains(tag))
            {
                storage = storage2;
                break;
            }
        }
        ElementConverter[] components2 = GetComponents <ElementConverter>();
        foreach (ElementConverter elementConverter in components2)
        {
            ElementConverter.OutputElement[] outputElements = elementConverter.outputElements;
            for (int k = 0; k < outputElements.Length; k++)
            {
                ElementConverter.OutputElement outputElement = outputElements[k];
                if (outputElement.elementHash == SimHashes.DirtyWater)
                {
                    elementConverter.SetStorage(storage);
                    break;
                }
            }
        }
        pollutedWaterStorage = storage;
    }
Beispiel #3
0
        /// <summary>
        /// Reads a portion of a binary stream to populate this building config.
        /// </summary>
        /// <param name="binaryReader">The <see cref="BinaryReader"/> encapsulating the binary information to read</param>
        /// <returns>True if the read succeeded, false otherwise</returns>
        public bool ReadBinary(BinaryReader binaryReader)
        {
            try {
                Offset      = new Vector2I(binaryReader.ReadInt32(), binaryReader.ReadInt32());
                BuildingDef = Assets.GetBuildingDef(binaryReader.ReadString());

                int selectedElementCount = binaryReader.ReadInt32();
                for (int i = 0; i < selectedElementCount; ++i)
                {
                    Tag elementTag;

                    //Only add the tag to the list if it describes a valid element in game.
                    if (ElementLoader.GetElement(elementTag = new Tag(binaryReader.ReadInt32())) != null)
                    {
                        SelectedElements.Add(elementTag);
                    }
                }

                Orientation = (Orientation)binaryReader.ReadInt32();
                Flags       = binaryReader.ReadInt32();
                return(true);
            }

            catch (System.Exception) {
                return(false);
            }
        }
        // Big copy paste of the game code
        public override void ConfigureBuildingTemplate(GameObject go, Tag prefab_tag)
        {
            go.GetComponent <KPrefabID>().AddTag(RoomConstraints.ConstraintTags.IndustrialMachinery);
            Electrolyzer electrolyzer = go.AddOrGet <Electrolyzer>();

            electrolyzer.maxMass  = 1.8f;
            electrolyzer.hasMeter = true;
            ConduitConsumer conduitConsumer = go.AddOrGet <ConduitConsumer>();

            conduitConsumer.conduitType        = ConduitType.Liquid;
            conduitConsumer.consumptionRate    = 1f;
            conduitConsumer.capacityTag        = ElementLoader.FindElementByHash(SimHashes.DirtyWater).tag;
            conduitConsumer.wrongElementResult = ConduitConsumer.WrongElementResult.Dump;
            Storage storage = go.AddOrGet <Storage>();

            storage.capacityKg = 2f;
            storage.showInUI   = true;
            ElementConverter elementConverter = go.AddOrGet <ElementConverter>();

            elementConverter.consumedElements = new ElementConverter.ConsumedElement[]
            {
                new ElementConverter.ConsumedElement(new Tag("DirtyWater"), 1f)
            };
            elementConverter.outputElements = new ElementConverter.OutputElement[]
            {
                new ElementConverter.OutputElement(0.888f, SimHashes.ContaminatedOxygen, OXYGEN_TEMPERATURE, false, 0f, 1f, false, 1f, byte.MaxValue, 0),
                new ElementConverter.OutputElement(0.111999989f, SimHashes.Hydrogen, OXYGEN_TEMPERATURE, false, 0f, 1f, false, 1f, byte.MaxValue, 0)
            };
            Prioritizable.AddRef(go);
        }
Beispiel #5
0
        private void OnFilterChanged(Tag tag)
        {
            mySlider = (ISingleSliderControl)this;

            FilteredTag = tag;
            Element element = ElementLoader.GetElement(FilteredTag);

            if (element != null)
            {
                FilteredElement = element.id;
            }
            GetComponent <KSelectable>().ToggleStatusItem(Db.Get().BuildingStatusItems.NoFilterElementSelected, !IsValidFilter, null);
            Temp = Math.Max(Temp, element.lowTemp);
            Temp = Math.Min(Temp, element.highTemp);
            Temp = Math.Max(Temp, MinAllowedTemperature);
            Temp = Math.Min(Temp, MaxAllowedTemperature);
            mySlider.SetSliderValue(Temp, -1);
            if (DetailsScreen.Instance != null && !inUpdate)
            {
                inUpdate = true;
                try
                {
                    DetailsScreen.Instance.Refresh(gameObject);
                }
                catch (Exception) { }
                inUpdate = false;
            }
        }
        public override void ConfigureBuildingTemplate(GameObject go, Tag prefab_tag)
        {
            go.GetComponent <KPrefabID>().AddTag(RoomConstraints.ConstraintTags.IndustrialMachinery, false);
            Storage defaultStorage = BuildingTemplates.CreateDefaultStorage(go, false);

            defaultStorage.SetDefaultStoredItemModifiers(Storage.StandardSealedStorage);
            defaultStorage.storageFilters = new List <Tag>()
            {
                new Tag("BleachStone")
            };
            defaultStorage.capacityKg = 400f + 20f;
            go.AddOrGet <HexiLiquidGermScrubber>();
            Prioritizable.AddRef(go);
            GermScrubConverter elementConverter = go.AddOrGet <GermScrubConverter>();

            elementConverter.SetStorage(defaultStorage);
            ConduitConsumer conduitConsumer = go.AddOrGet <ConduitConsumer>();

            conduitConsumer.conduitType          = ConduitType.Liquid;
            conduitConsumer.consumptionRate      = 10f;
            conduitConsumer.capacityKG           = 20f;
            conduitConsumer.capacityTag          = GameTags.Liquid;
            conduitConsumer.forceAlwaysSatisfied = true;
            conduitConsumer.wrongElementResult   = ConduitConsumer.WrongElementResult.Dump;
            ManualDeliveryKG manualDeliveryKg = go.AddComponent <ManualDeliveryKG>();

            manualDeliveryKg.SetStorage(defaultStorage);
            manualDeliveryKg.requestedItemTag = ElementLoader.FindElementByHash(SimHashes.BleachStone).tag;
            manualDeliveryKg.capacity         = 400f;
            manualDeliveryKg.refillMass       = 100f;
            manualDeliveryKg.choreTypeIDHash  = Db.Get().ChoreTypes.FetchCritical.IdHash;
        }
        public List <Descriptor> EffectDescriptors(BuildingDef def)
        {
            List <Descriptor> list = new List <Descriptor>();
            List <Descriptor> result;

            if (this.formula.outputs == null || this.formula.outputs.Length == 0)
            {
                result = list;
            }
            else
            {
                for (int i = 0; i < this.formula.outputs.Length; i++)
                {
                    EnergyGenerator.OutputItem outputItem = this.formula.outputs[i];
                    Element    element = ElementLoader.FindElementByHash(outputItem.element);
                    string     arg     = element.tag.ProperName();
                    Descriptor item    = default(Descriptor);
                    if (outputItem.minTemperature > 0f)
                    {
                        item.SetupDescriptor(string.Format(UI.BUILDINGEFFECTS.ELEMENTEMITTED_MINORENTITYTEMP, arg, GameUtil.GetFormattedMass(outputItem.creationRate, GameUtil.TimeSlice.PerSecond, GameUtil.MetricMassFormat.UseThreshold, true, "{0:0.#}"), GameUtil.GetFormattedTemperature(outputItem.minTemperature, GameUtil.TimeSlice.None, GameUtil.TemperatureInterpretation.Absolute, true, false)), string.Format(UI.BUILDINGEFFECTS.TOOLTIPS.ELEMENTEMITTED_MINORENTITYTEMP, arg, GameUtil.GetFormattedMass(outputItem.creationRate, GameUtil.TimeSlice.PerSecond, GameUtil.MetricMassFormat.UseThreshold, true, "{0:0.#}"), GameUtil.GetFormattedTemperature(outputItem.minTemperature, GameUtil.TimeSlice.None, GameUtil.TemperatureInterpretation.Absolute, true, false)), Descriptor.DescriptorType.Effect);
                    }
                    else
                    {
                        item.SetupDescriptor(string.Format(UI.BUILDINGEFFECTS.ELEMENTEMITTED_ENTITYTEMP, arg, GameUtil.GetFormattedMass(outputItem.creationRate, GameUtil.TimeSlice.PerSecond, GameUtil.MetricMassFormat.UseThreshold, true, "{0:0.#}")), string.Format(UI.BUILDINGEFFECTS.TOOLTIPS.ELEMENTEMITTED_ENTITYTEMP, arg, GameUtil.GetFormattedMass(outputItem.creationRate, GameUtil.TimeSlice.PerSecond, GameUtil.MetricMassFormat.UseThreshold, true, "{0:0.#}")), Descriptor.DescriptorType.Effect);
                    }
                    list.Add(item);
                }
                result = list;
            }
            return(result);
        }
        public static void InitalizeDictionaries()
        {
            StoredGases   = new Dictionary <Tag, float>();
            StoredLiquids = new Dictionary <Tag, float>();

            if (!TechRequirements.Instance.GetGameTech("Plastics").IsComplete())
            {
                StoredLiquids.Add(ElementLoader.FindElementByHash(SimHashes.Petroleum).tag, 0);
            }
            if (!TechRequirements.Instance.GetGameTech("LiquidFiltering").IsComplete())
            {
                StoredLiquids.Add(ElementLoader.FindElementByHash(SimHashes.SaltWater).tag, 0);
            }
            if (!TechRequirements.Instance.GetGameTech("Distillation").IsComplete())
            {
                StoredLiquids.Add(ElementLoader.FindElementByHash(SimHashes.DirtyWater).tag, 0);
            }

            if (!TechRequirements.Instance.GetGameTech("Catalytics").IsComplete())
            {
                StoredGases.Add(ElementLoader.FindElementByHash(SimHashes.CarbonDioxide).tag, 0);
            }
            if (!TechRequirements.Instance.GetGameTech("RenewableEnergy").IsComplete())
            {
                StoredGases.Add(ElementLoader.FindElementByHash(SimHashes.Steam).tag, 0);
            }
        }
Beispiel #9
0
 public static void Postfix()
 {
     MakeRadioactive(ElementLoader.GetElement(SimHashes.Radium.ToString()));
     MakeRadioactive(ElementLoader.GetElement(SimHashes.UraniumOre.ToString()));
     MakeRadioactive(ElementLoader.GetElement(SimHashes.EnrichedUranium.ToString()));
     MakeRadioactive(ElementLoader.GetElement(SimHashes.DepletedUranium.ToString()));
 }
Beispiel #10
0
            public static void Postfix()
            {
                foreach (ElementEntry entry in elementEntries)
                {
                    var element = ElementLoader.FindElementByName(entry.elementId);
                    if (element == null)
                    {
                        Log.Error($"Element {entry.elementId} was never created");
                        continue;
                    }

                    if (entry.attributeModifiers != null)
                    {
                        foreach (AttributeModifierEntry attr in entry.attributeModifiers)
                        {
                            Log.Spam($"Adding attribute {attr.attributeId} to {entry.elementId}");

                            attr.description = attr.description ?? element.name;
                            element.attributeModifiers.Add(MakeAttributeModifier(attr));
                        }
                    }

                    var exists = ElementLoader.elements.Exists(x => x.id == (SimHashes)Hash.SDBMLower(entry.elementId));
                    if (!exists)
                    {
                        Log.Error($"Element {entry.elementId} was not added to list, only hashtable");
                        continue;
                    }

                    Traverse.Create(element.substance).Field("nameTag").SetValue(element.tag);

                    Log.Spam($"{entry.elementId}: {element.nameUpperCase}, {element.tag} | {Traverse.Create(element.substance).Field("nameTag").GetValue<Tag>()}");
                }
            }
        public static GasExposure GetElementExposition(int cell, int xWidth, int yHeight)
        {
            GasExposure exp;

            exp.OxygenMass = 0;
            exp.OtherMass  = 0;
            Element oxygen = ElementLoader.GetElement(GameTags.Oxygen);

            for (int x = 0; x < xWidth; x++)
            {
                for (int y = 0; y < yHeight; y++)
                {
                    int offsetCell = Grid.OffsetCell(cell, x, y);
                    if (Grid.Element[offsetCell] == oxygen)
                    {
                        exp.OxygenMass += Grid.Mass[offsetCell];
                    }
                    else if (Grid.Element[offsetCell].IsGas)
                    {
                        exp.OtherMass += Grid.Mass[offsetCell];
                    }
                }
            }

            return(exp);
        }
Beispiel #12
0
        public static void Postfix(ref GameObject go)
        {
            ComplexRecipe.RecipeElement[] ingredients = new ComplexRecipe.RecipeElement[1]
            {
                new ComplexRecipe.RecipeElement(ElementLoader.FindElementByHash(SimHashes.Katairite).tag, 100f)
            };

            ComplexRecipe.RecipeElement[] results = new ComplexRecipe.RecipeElement[2]
            {
                new ComplexRecipe.RecipeElement(ElementLoader.FindElementByHash(SimHashes.AluminumOre).tag, 50f),
                new ComplexRecipe.RecipeElement(ElementLoader.FindElementByHash(SimHashes.Sand).tag, 50f)
            };

            new ComplexRecipe(
                ComplexRecipeManager.MakeRecipeID(
                    "RockCrusher"
                    , (IList <ComplexRecipe.RecipeElement>)ingredients
                    , (IList <ComplexRecipe.RecipeElement>)results)
                , ingredients, results
                )
            {
                time        = 40f,
                description = string.Format((string)STRINGS.BUILDINGS.PREFABS.ROCKCRUSHER.LIME_FROM_LIMESTONE_RECIPE_DESCRIPTION, (object)SimHashes.Katairite.CreateTag().ProperName(), (object)SimHashes.Wolframite.CreateTag().ProperName(), (object)SimHashes.Sand.CreateTag().ProperName()),
                nameDisplay = ComplexRecipe.RecipeNameDisplay.IngredientToResult
            }.fabricators = new List <Tag>()
            {
                TagManager.Create("RockCrusher")
            };
        }
Beispiel #13
0
        public override BuildingDef CreateBuildingDef()
        {
            var def = BuildingTemplates.CreateBuildingDef(
                id: ID,
                width: 3,
                height: 2,
                anim: "storage_skip_kanim",
                hitpoints: BUILDINGS.HITPOINTS.TIER1,
                construction_time: BUILDINGS.CONSTRUCTION_TIME_SECONDS.TIER3,
                construction_mass: new float[] { BUILDINGS.CONSTRUCTION_MASS_KG.TIER3[0], BUILDINGS.CONSTRUCTION_MASS_KG.TIER2[0] },
                construction_materials: new string[] {
                GameTags.Metal.Name,
                ElementLoader.FindElementByHash(SimHashes.Ceramic).tag.Name
            },
                melting_point: BUILDINGS.MELTING_POINT_KELVIN.TIER0,
                build_location_rule: BuildLocationRule.OnFloorOrBuildingAttachPoint,
                decor: BUILDINGS.DECOR.PENALTY.TIER3,
                noise: NOISE_POLLUTION.NOISY.TIER1
                );

            def.AudioCategory = AUDIO.HOLLOW_METAL;
            def.EnergyConsumptionWhenActive = BUILDINGS.ENERGY_CONSUMPTION_WHEN_ACTIVE.TIER5;
            def.PermittedRotations          = PermittedRotations.FlipH;
            def.RequiresPowerInput          = true;
            def.ViewMode            = OverlayModes.Power.ID;
            def.OverheatTemperature = BUILDINGS.OVERHEAT_TEMPERATURES.HIGH_1;
            def.LogicOutputPorts    = OUTPUT_PORTS;
            return(def);
        }
Beispiel #14
0
        public override void DoPostConfigureComplete(GameObject go)
        {
            go.AddOrGet <Storage>().capacityKg = 0.09999999f;
            go.AddOrGet <MassiveHeatSink>();
            go.AddOrGet <MinimumOperatingTemperature>().minimumTemperature = 120f;
            PrimaryElement component = go.GetComponent <PrimaryElement>();

            component.SetElement(SimHashes.Iron);
            component.Temperature = 294.15f;
            ConduitConsumer conduitConsumer = go.AddOrGet <ConduitConsumer>();

            conduitConsumer.conduitType          = ConduitType.Gas;
            conduitConsumer.consumptionRate      = 1f;
            conduitConsumer.capacityTag          = GameTagExtensions.Create(SimHashes.Hydrogen);
            conduitConsumer.capacityKG           = 0.09999999f;
            conduitConsumer.forceAlwaysSatisfied = true;
            conduitConsumer.wrongElementResult   = ConduitConsumer.WrongElementResult.Dump;
            go.AddOrGet <ElementConverter>().consumedElements = new ElementConverter.ConsumedElement[1]
            {
                new ElementConverter.ConsumedElement(ElementLoader.FindElementByHash(SimHashes.Hydrogen).tag, 0.01f)
            };
            ElementConverter elementConverter = go.AddOrGet <ElementConverter>();

            elementConverter.outputElements = new ElementConverter.OutputElement[] { };
            GeneratedBuildings.RegisterLogicPorts(go, BriskArcticConfig.INPUT_PORTS);
            go.AddOrGet <LogicOperationalController>();
            go.AddOrGetDef <PoweredActiveController.Def>();
        }
Beispiel #15
0
        public static void Postfix()
        {
            ComplexRecipe.RecipeElement[] ingredients2 = new ComplexRecipe.RecipeElement[4]
            {
                new ComplexRecipe.RecipeElement(ElementLoader.FindElementByHash(SimHashes.Tungsten).tag, 50f),
                new ComplexRecipe.RecipeElement(ElementLoader.FindElementByHash(SimHashes.MaficRock).tag, 50f),
                new ComplexRecipe.RecipeElement(ElementLoader.FindElementByHash(SimHashes.Obsidian).tag, 100f),
                new ComplexRecipe.RecipeElement(ElementLoader.FindElementByHash(SimHashes.SuperCoolant).tag, 50f),
            };
            ComplexRecipe.RecipeElement[] results2 = new ComplexRecipe.RecipeElement[1]
            {
                new ComplexRecipe.RecipeElement(SimHashes.SolidMercury.CreateTag(), 100f)
            };
            ComplexRecipe complexRecipe3 = new ComplexRecipe(ComplexRecipeManager.MakeRecipeID("SupermaterialRefinery", (IList <ComplexRecipe.RecipeElement>)ingredients2, (IList <ComplexRecipe.RecipeElement>)results2), ingredients2, results2);

            complexRecipe3.time                   = 80f;
            complexRecipe3.description            = (string)STRINGS.BUILDINGS.PREFABS.SUPERMATERIALREFINERY.SUPERCOOLANT_RECIPE_DESCRIPTION;
            complexRecipe3.useResultAsDescription = true;
            ComplexRecipe complexRecipe4 = complexRecipe3;
            List <Tag>    tagList3       = new List <Tag>();

            tagList3.Add(TagManager.Create("SupermaterialRefinery"));
            List <Tag> tagList4 = tagList3;

            complexRecipe4.fabricators = tagList4;
        }
Beispiel #16
0
    public override void DoPostConfigureComplete(GameObject go)
    {
        SolidBooster solidBooster = go.AddOrGet <SolidBooster>();

        solidBooster.mainEngine = false;
        solidBooster.efficiency = ROCKETRY.ENGINE_EFFICIENCY.BOOSTER;
        solidBooster.fuelTag    = ElementLoader.FindElementByHash(SimHashes.Iron).tag;
        Storage storage = go.AddOrGet <Storage>();

        storage.SetDefaultStoredItemModifiers(Storage.StandardSealedStorage);
        storage.capacityKg       = 800f;
        solidBooster.fuelStorage = storage;
        ManualDeliveryKG manualDeliveryKG = go.AddComponent <ManualDeliveryKG>();

        manualDeliveryKG.SetStorage(storage);
        manualDeliveryKG.requestedItemTag = solidBooster.fuelTag;
        manualDeliveryKG.refillMass       = storage.capacityKg / 2f;
        manualDeliveryKG.capacity         = storage.capacityKg / 2f;
        manualDeliveryKG.choreTypeIDHash  = Db.Get().ChoreTypes.MachineFetch.IdHash;
        ManualDeliveryKG manualDeliveryKG2 = go.AddComponent <ManualDeliveryKG>();

        manualDeliveryKG2.SetStorage(storage);
        manualDeliveryKG2.requestedItemTag = ElementLoader.FindElementByHash(SimHashes.OxyRock).tag;
        manualDeliveryKG2.refillMass       = storage.capacityKg / 2f;
        manualDeliveryKG2.capacity         = storage.capacityKg / 2f;
        manualDeliveryKG2.choreTypeIDHash  = Db.Get().ChoreTypes.MachineFetch.IdHash;
        RocketModule rocketModule = go.AddOrGet <RocketModule>();

        rocketModule.SetBGKAnim(Assets.GetAnim("rocket_solid_booster_bg_kanim"));
        EntityTemplates.ExtendBuildingToRocketModule(go);
    }
 protected override void OnPrefabInit()
 {
     base.OnPrefabInit();
     this.machinerySpeedAttribute = this.gameObject.GetAttributes().Add(Db.Get().Attributes.MachinerySpeed);
     if (GermScrubConverterInput == null)
     {
         Tag inElem = ElementLoader.FindElementByHash(filterIn).tag;
         GermScrubConverterInput = new StatusItem("ElementConverterInput", "BUILDING", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, true, OverlayModes.None.ID, true, 129022).SetResolveStringCallback((Func <string, object, string>)((str, data) =>
         {
             str = str.Replace("{ElementTypes}", inElem.ProperName());
             str = str.Replace("{FlowRate}", GameUtil.GetFormattedByTag(inElem, Game.Instance.accumulators.GetAverageRate((HandleVector <int> .Handle)data), GameUtil.TimeSlice.PerSecond));
             return(str);
         }));
     }
     if (GermScrubConverterOutput == null && EMIT_CHLORINE)
     {
         Tag outElem = ElementLoader.FindElementByHash(filterOut).tag;
         GermScrubConverterOutput = new StatusItem("ElementConverterOutput", "BUILDING", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, true, OverlayModes.None.ID, true, 129022).SetResolveStringCallback((Func <string, object, string>)((str, data) =>
         {
             str = str.Replace("{ElementTypes}", outElem.ProperName());
             str = str.Replace("{FlowRate}", GameUtil.GetFormattedByTag(outElem, Game.Instance.accumulators.GetAverageRate((HandleVector <int> .Handle)data), GameUtil.TimeSlice.PerSecond));
             return(str);
         }));
     }
     if (GermScrubConverterMisc == null)
     {
         GermScrubConverterMisc = new StatusItem("PumpingLiquidOrGas", "BUILDING", string.Empty, StatusItem.IconType.Info, NotificationType.Neutral, true, OverlayModes.None.ID, true, 129022).SetResolveStringCallback((Func <string, object, string>)((str, data) =>
         {
             str = str.Replace("{FlowRate}", GameUtil.GetFormattedByTag(GameTags.Liquid, Game.Instance.accumulators.GetAverageRate((HandleVector <int> .Handle)data), GameUtil.TimeSlice.PerSecond));
             return(str);
         }));
     }
 }
            public static void Postfix()
            {
                var copper   = ElementLoader.FindElementByHash(SimHashes.Copper);
                var iron     = ElementLoader.FindElementByHash(SimHashes.Iron);
                var tungsten = ElementLoader.FindElementByHash(SimHashes.Tungsten);
                var gold     = ElementLoader.FindElementByHash(SimHashes.Gold);
                var lead     = ElementLoader.FindElementByHash(SimHashes.Lead);
                var aluminum = ElementLoader.FindElementByHash(SimHashes.Aluminum);


                var elements = new[] { copper, iron, gold, lead, aluminum, tungsten };

                if (DlcManager.IsExpansion1Active())
                {
                    var cobalt = ElementLoader.FindElementByHash(SimHashes.Cobalt);
                    elements.AddItem(cobalt);
                }

                foreach (var element in elements)
                {
                    var tags = new List <Tag>(element.oreTags)
                    {
                        GameTags.Metal
                    };
                    element.oreTags = tags.ToArray();

                    GameTags.SolidElements.Add(element.tag);
                }
            }
Beispiel #19
0
        protected override bool OnWorkTick(Worker worker, float dt)
        {
            base.OnWorkTick(worker, dt);
            OreScrubber    component     = GetComponent <OreScrubber>();
            Storage        component2    = GetComponent <Storage>();
            PrimaryElement firstInfected = GetFirstInfected(worker.GetComponent <Storage>());
            int            num           = 0;

            SimUtil.DiseaseInfo invalid = SimUtil.DiseaseInfo.Invalid;
            if ((UnityEngine.Object)firstInfected != (UnityEngine.Object)null)
            {
                num             = Math.Min((int)(dt / workTime * (float)component.diseaseRemovalCount), firstInfected.DiseaseCount);
                diseaseRemoved += num;
                invalid.idx     = firstInfected.DiseaseIdx;
                invalid.count   = num;
                firstInfected.ModifyDiseaseCount(-num, "OreScrubber.OnWorkTick");
            }
            component.maxPossiblyRemoved += num;
            float num2 = component.massConsumedPerUse * dt / workTime;

            SimUtil.DiseaseInfo disease_info = SimUtil.DiseaseInfo.Invalid;
            component2.ConsumeAndGetDisease(ElementLoader.FindElementByHash(component.consumedElement).tag, num2, out disease_info, out float aggregate_temperature);
            if (component.outputElement != SimHashes.Vacuum)
            {
                disease_info = SimUtil.CalculateFinalDiseaseInfo(invalid, disease_info);
                component2.AddLiquid(component.outputElement, num2, aggregate_temperature, disease_info.idx, disease_info.count, false, true);
            }
            return(diseaseRemoved > component.diseaseRemovalCount);
        }
Beispiel #20
0
        public override void ConfigureBuildingTemplate(GameObject go, Tag prefab_tag)
        {
            go.GetComponent <KPrefabID>().AddTag(RoomConstraints.ConstraintTags.RecBuilding, false);
            Storage storage = go.AddOrGet <Storage>();

            storage.SetDefaultStoredItemModifiers(Storage.StandardFabricatorStorage);
            ConduitConsumer conduitConsumer = go.AddOrGet <ConduitConsumer>();

            conduitConsumer.conduitType        = ConduitType.Liquid;
            conduitConsumer.capacityTag        = ElementLoader.FindElementByHash(SimHashes.Ethanol).tag;
            conduitConsumer.capacityKG         = 20f;
            conduitConsumer.wrongElementResult = ConduitConsumer.WrongElementResult.Dump;
            ManualDeliveryKG manualDeliveryKg = go.AddOrGet <ManualDeliveryKG>();

            manualDeliveryKg.SetStorage(storage);
            manualDeliveryKg.requestedItemTag = GrapeberryConfig.Id.ToTag();
            manualDeliveryKg.capacity         = 4f;
            manualDeliveryKg.refillMass       = 1f;
            manualDeliveryKg.minimumMass      = 0.5f;
            manualDeliveryKg.choreTypeIDHash  = Db.Get().ChoreTypes.MachineFetch.IdHash;
            go.AddOrGet <ChampagneFillerWorkable>().basePriority = RELAXATION.PRIORITY.TIER5;
            ChampagneFiller champagneFiller = go.AddOrGet <ChampagneFiller>();

            champagneFiller.specificEffect       = "SodaFountain";
            champagneFiller.trackingEffect       = "RecentlyRecDrink";
            champagneFiller.ingredientTag        = GrapeberryConfig.Id.ToTag();
            champagneFiller.ingredientMassPerUse = 1f;
            champagneFiller.ethanolMassPerUse    = 5f;
            RoomTracker roomTracker = go.AddOrGet <RoomTracker>();

            roomTracker.requiredRoomType = Db.Get().RoomTypes.RecRoom.Id;
            roomTracker.requirement      = RoomTracker.Requirement.Recommended;
        }
Beispiel #21
0
    public override void ConfigureBuildingTemplate(GameObject go, Tag prefab_tag)
    {
        go.GetComponent <KPrefabID>().AddTag(RoomConstraints.ConstraintTags.IndustrialMachinery, false);
        OreScrubber oreScrubber = go.AddOrGet <OreScrubber>();

        oreScrubber.massConsumedPerUse  = 0.07f;
        oreScrubber.consumedElement     = SimHashes.ChlorineGas;
        oreScrubber.diseaseRemovalCount = 480000;
        ConduitConsumer conduitConsumer = go.AddOrGet <ConduitConsumer>();

        conduitConsumer.conduitType        = ConduitType.Liquid;
        conduitConsumer.consumptionRate    = 1f;
        conduitConsumer.capacityKG         = 10f;
        conduitConsumer.wrongElementResult = ConduitConsumer.WrongElementResult.Dump;
        conduitConsumer.capacityTag        = ElementLoader.FindElementByHash(SimHashes.ChlorineGas).tag;
        go.AddOrGet <DirectionControl>();
        OreScrubber.Work work = go.AddOrGet <OreScrubber.Work>();
        work.overrideAnims = new KAnimFile[1]
        {
            Assets.GetAnim("anim_interacts_ore_scrubber_kanim")
        };
        work.workTime  = 10.2f;
        work.trackUses = true;
        work.workLayer = Grid.SceneLayer.BuildingUse;
        Storage storage = go.AddOrGet <Storage>();

        storage.SetDefaultStoredItemModifiers(Storage.StandardSealedStorage);
    }
Beispiel #22
0
    public List <Descriptor> GetResultDescriptions(ComplexRecipe recipe)
    {
        List <Descriptor> list = new List <Descriptor>();

        ComplexRecipe.RecipeElement[] results = recipe.results;
        foreach (ComplexRecipe.RecipeElement recipeElement in results)
        {
            GameObject prefab         = Assets.GetPrefab(recipeElement.material);
            string     formattedByTag = GameUtil.GetFormattedByTag(recipeElement.material, recipeElement.amount, GameUtil.TimeSlice.None);
            list.Add(new Descriptor(string.Format(UI.UISIDESCREENS.FABRICATORSIDESCREEN.RECIPEPRODUCT, prefab.GetProperName(), formattedByTag), string.Format(UI.UISIDESCREENS.FABRICATORSIDESCREEN.TOOLTIPS.RECIPEPRODUCT, prefab.GetProperName(), formattedByTag), Descriptor.DescriptorType.Requirement, false));
            Element element = ElementLoader.GetElement(recipeElement.material);
            if (element != null)
            {
                List <Descriptor> materialDescriptors = GameUtil.GetMaterialDescriptors(element);
                GameUtil.IndentListOfDescriptors(materialDescriptors, 1);
                list.AddRange(materialDescriptors);
            }
            else
            {
                List <Descriptor> effectDescriptors = GameUtil.GetEffectDescriptors(GameUtil.GetAllDescriptors(prefab, false));
                GameUtil.IndentListOfDescriptors(effectDescriptors, 1);
                list.AddRange(effectDescriptors);
            }
        }
        return(list);
    }
            public static void Postfix(ref GameObject prefab)
            {
                prefab.GetComponent <PressureVulnerable>()

                .safe_atmospheres
                .Add(ElementLoader.FindElementByHash(SimHashes.SourGas));
            }
Beispiel #24
0
        private void OnFilterChanged(Tag tag)
        {
            FilteredTag = tag;
            Element element = ElementLoader.GetElement(FilteredTag);

            if (element != null)
            {
                FilteredElement = element.id;
            }
            GetComponent <KSelectable>().ToggleStatusItem(Db.Get().BuildingStatusItems.NoFilterElementSelected, !IsValidFilter, null);
            GetComponent <Operational>().SetFlag(filterFlag, IsValidFilter);
            Temp = Math.Max(Temp, element.lowTemp);
            Temp = Math.Min(Temp, element.highTemp);
            Temp = Math.Max(Temp, MinAllowedTemperature);
            Temp = Math.Min(Temp, MaxAllowedTemperature);
            SetSliderValue(Temp, -1);

            /*if (DetailsScreen.Instance != null && !inUpdate)
             * {
             *  inUpdate = true;
             *  try
             *  {
             *      DetailsScreen.Instance.Refresh(gameObject);
             *  }
             *  catch (Exception) { }
             *  inUpdate = false;
             * }*/
        }
Beispiel #25
0
    public static void Postfix()
    {
        ComplexRecipe.RecipeElement[] ingredients = new ComplexRecipe.RecipeElement[3]
        {
            new ComplexRecipe.RecipeElement(ElementLoader.FindElementByHash(SimHashes.Steel).tag, 25f),
            new ComplexRecipe.RecipeElement(ElementLoader.FindElementByHash(SimHashes.Glass).tag, 25f),
            new ComplexRecipe.RecipeElement(ElementLoader.FindElementByHash(SimHashes.SolidNaphtha).tag, 100f)
        };
        ComplexRecipe.RecipeElement[] results = new ComplexRecipe.RecipeElement[1]
        {
            new ComplexRecipe.RecipeElement(ElementLoader.FindElementByHash(SimHashes.LiquidPropane).tag, 100f)
        };
        string obsolete_id = ComplexRecipeManager.MakeObsoleteRecipeID("GlassForge", ingredients[0].material);
        string str         = ComplexRecipeManager.MakeRecipeID("GlassForge", (IList <ComplexRecipe.RecipeElement>)ingredients, (IList <ComplexRecipe.RecipeElement>)results);

        new ComplexRecipe(str, ingredients, results)
        {
            time = 40f,
            useResultAsDescription = true,
            description            = string.Format((string)STRINGS.BUILDINGS.PREFABS.GLASSFORGE.RECIPE_DESCRIPTION, (object)ElementLoader.GetElement(results[0].material).name, (object)ElementLoader.GetElement(ingredients[0].material).name)
        }.fabricators = new List <Tag>()
        {
            TagManager.Create("GlassForge")
        };
        ComplexRecipeManager.Get().AddObsoleteIDMapping(obsolete_id, str);
    }
Beispiel #26
0
    public static void Postfix()
    {
        ElementLoader.FindElementByHash(SimHashes.SolidMercury).highTemp            = 1000f;
        ElementLoader.FindElementByHash(SimHashes.Mercury).lowTemp                  = 50f;
        ElementLoader.FindElementByHash(SimHashes.Mercury).highTemp                 = 1200f;
        ElementLoader.FindElementByHash(SimHashes.Granite).highTempTransitionTarget = SimHashes.Mercury;
        ComplexRecipe.RecipeElement[] ingredients = new ComplexRecipe.RecipeElement[3]
        {
            new ComplexRecipe.RecipeElement(ElementLoader.FindElementByHash(SimHashes.Tungsten).tag, 50f),
            new ComplexRecipe.RecipeElement(ElementLoader.FindElementByHash(SimHashes.MaficRock).tag, 50f),
            new ComplexRecipe.RecipeElement(ElementLoader.FindElementByHash(SimHashes.Obsidian).tag, 100f)
        };
        ComplexRecipe.RecipeElement[] results = new ComplexRecipe.RecipeElement[1]
        {
            new ComplexRecipe.RecipeElement(ElementLoader.FindElementByHash(SimHashes.Mercury).tag, 200f)
        };
        string obsolete_id = ComplexRecipeManager.MakeObsoleteRecipeID("GlassForge", ingredients[0].material);
        string str         = ComplexRecipeManager.MakeRecipeID("GlassForge", (IList <ComplexRecipe.RecipeElement>)ingredients, (IList <ComplexRecipe.RecipeElement>)results);

        new ComplexRecipe(str, ingredients, results)
        {
            time = 40f,
            useResultAsDescription = true,
            description            = string.Format((string)STRINGS.BUILDINGS.PREFABS.GLASSFORGE.RECIPE_DESCRIPTION, (object)ElementLoader.GetElement(results[0].material).name, (object)ElementLoader.GetElement(ingredients[0].material).name)
        }.fabricators = new List <Tag>()
        {
            TagManager.Create("GlassForge")
        };
        ComplexRecipeManager.Get().AddObsoleteIDMapping(obsolete_id, str);
    }
        // Accumulate how many germs remain
        public void SinkWorkTick(Workable work, float dt)
        {
            if (work == null)
            {
                throw new ArgumentNullException("work");
            }
            var obj = work.gameObject;

            if (germsConsumed.TryGetValue(work, out SimUtil.DiseaseInfo germs) && obj != null)
            {
                var sanitizer = obj.GetComponent <HandSanitizer>();
                var storage   = obj.GetComponent <Storage>();
                // Only if a hand sanitizer with available contents
                if (sanitizer != null && storage != null)
                {
                    float time = work.workTime, qty = sanitizer.massConsumedPerUse * dt /
                                                      time;
                    GetGermsInStorage(storage, ElementLoader.FindElementByHash(sanitizer.
                                                                               consumedElement).tag, qty, out SimUtil.DiseaseInfo itemGerm);
                    // Only transfer if disease matches and germ count is nonzero
                    if (itemGerm.count > 0 && (germs.count < 1 || germs.idx == itemGerm.idx))
                    {
                        germs.count += itemGerm.count;
                        germs.idx    = itemGerm.idx;
                        // It is a struct, must store it back
                        germsConsumed[work] = germs;
                    }
                }
            }
        }
Beispiel #28
0
        public override void DoPostConfigureComplete(GameObject go)
        {
            go.GetComponent <KPrefabID>().AddTag(RoomConstraints.ConstraintTags.IndustrialMachinery);
            go.AddOrGet <MassiveHeatSink>();
            go.AddOrGet <MinimumOperatingTemperature>().minimumTemperature = 1f;
            PrimaryElement component = go.GetComponent <PrimaryElement>();

            component.SetElement(SimHashes.Iron);
            component.Temperature = 294.15f;
            go.AddOrGet <LoopingSounds>();
            go.AddOrGet <Storage>().capacityKg = 9.99999999f;
            ConduitConsumer conduitConsumer = go.AddOrGet <ConduitConsumer>();

            conduitConsumer.conduitType          = ConduitType.Liquid;
            conduitConsumer.consumptionRate      = 10f;
            conduitConsumer.capacityTag          = GameTagExtensions.Create(SimHashes.Mercury);
            conduitConsumer.capacityKG           = 9.99999999f;
            conduitConsumer.forceAlwaysSatisfied = true;
            conduitConsumer.wrongElementResult   = ConduitConsumer.WrongElementResult.Dump;
            go.AddOrGet <ElementConverter>().consumedElements = new ElementConverter.ConsumedElement[1]
            {
                new ElementConverter.ConsumedElement(ElementLoader.FindElementByHash(SimHashes.Mercury).tag, 1.0f)
            };
            go.AddOrGetDef <PoweredActiveController.Def>();
        }
    private static void UpdateSolidDigAmount(TextureRegion region, int x0, int y0, int x1, int y1)
    {
        int elementIndex = ElementLoader.GetElementIndex(SimHashes.Void);

        for (int i = y0; i <= y1; i++)
        {
            int num  = Grid.XYToCell(x0, i);
            int num2 = Grid.XYToCell(x1, i);
            int num3 = num;
            int num4 = x0;
            while (num3 <= num2)
            {
                byte b  = 0;
                byte b2 = 0;
                byte b3 = 0;
                if (Grid.ElementIdx[num3] != elementIndex)
                {
                    b3 = byte.MaxValue;
                }
                if (Grid.Solid[num3])
                {
                    b  = byte.MaxValue;
                    b2 = (byte)(255f * Grid.Damage[num3]);
                }
                region.SetBytes(num4, i, b, b2, b3);
                num3++;
                num4++;
            }
        }
    }
Beispiel #30
0
        public override void PostInitialize()
        {
            ElementManager.AddBulkTags(new Dictionary <Element, Tag[]>()
            {
                {
                    // Sand is a powder
                    ElementLoader.FindElementByHash(SimHashes.Sand),
                    new Tag[] { Tags.Powder }
                },
                {
                    // Regolith is a silt
                    ElementLoader.FindElementByHash(SimHashes.Regolith),
                    new Tag[] { Tags.Silt }
                },
                {
                    // Steel is an alloy
                    ElementLoader.FindElementByHash(SimHashes.Steel),
                    new Tag[] { GameTags.Alloy }
                },
                {
                    // Thermium is an alloy
                    ElementLoader.FindElementByHash(SimHashes.TempConductorSolid),
                    new Tag[] { GameTags.Alloy }
                }
            });

            ElementLoader.FindElementByHash(SimHashes.Diamond).tag = Tags.Gem;
            ElementLoader.FindElementByHash(SimHashes.Salt).tag    = Tags.Silt;
        }