Exemplo n.º 1
0
 private void InitializeStatusItems()
 {
     if (filterStatusItem != null)
     {
         return;
     }
     filterStatusItem = new StatusItem("Filter", "BUILDING", "", StatusItem.IconType.Info, NotificationType.Neutral, false, OverlayModes.LiquidConduits.ID, true, 129022);
     filterStatusItem.resolveStringCallback = (str, data) =>
     {
         InfiniteSource infiniteSource = (InfiniteSource)data;
         if (infiniteSource.FilteredElement == SimHashes.Void)
         {
             str = string.Format(BUILDINGS.PREFABS.GASFILTER.STATUS_ITEM, BUILDINGS.PREFABS.GASFILTER.ELEMENT_NOT_SPECIFIED);
         }
         else
         {
             Element elementByHash = ElementLoader.FindElementByHash(infiniteSource.FilteredElement);
             str = string.Format(BUILDINGS.PREFABS.GASFILTER.STATUS_ITEM, elementByHash.name);
         }
         return(str);
     };
     filterStatusItem.conditionalOverlayCallback = new Func <HashedString, object, bool>(ShowInUtilityOverlay);
 }
Exemplo n.º 2
0
 internal void OnDeserialized()
 {
     if (ids != null)
     {
         selectedElements = new Element[ids.Length];
         for (int i = 0; i < ids.Length; i++)
         {
             selectedElements[i] = ElementLoader.FindElementByHash((SimHashes)ids[i]);
         }
         if (selectedElementsTags == null)
         {
             selectedElementsTags = new Tag[ids.Length];
             for (int j = 0; j < ids.Length; j++)
             {
                 selectedElementsTags[j] = ElementLoader.FindElementByHash((SimHashes)ids[j]).tag;
             }
         }
         Debug.Assert(selectedElements.Length == selectedElementsTags.Length);
         for (int k = 0; k < selectedElements.Length; k++)
         {
             Debug.Assert(selectedElements[k].tag == SelectedElementsTags[k]);
         }
     }
 }
Exemplo n.º 3
0
 //Cancel the current activity
 private void OnCancel()
 {
     if (chore == null && fetchList == null)
     {
         return;
     }
     if (fetchList != null)
     {
         fetchList.Cancel("Cancelled by user");
         fetchList = null;
         DropStorage();
         MaterialNeeds.Instance.UpdateNeed(ElementLoader.FindElementByHash(SimHashes.SuperInsulator).tag, 0 - MassToInsulate);
     }
     if (chore != null)
     {
         this.chore.Cancel("Cancelled by user");
         this.chore = null;
         this.ShowProgressBar(false);
         this.workTimeRemaining = this.workTime;
         DropStorage();
     }
     Prioritizable.RemoveRef(gameObject);
     isMarkedForWork = false;
 }
        private static bool Prefix(GameObject go, Tag prefab_tag)
        {
            Storage storage1 = go.AddOrGet <Storage>();

            storage1.capacityKg = 50f;
            storage1.SetDefaultStoredItemModifiers(Storage.StandardInsulatedStorage);

            go.AddOrGet <MassiveHeatSink>();
            go.AddOrGetDef <PoweredActiveController.Def>();

            go.AddOrGet <MinimumOperatingTemperature>().minimumTemperature = 273.15f;
            go.AddOrGet <LoopingSounds>();
            Prioritizable.AddRef(go);
            ManualDeliveryKG manualDeliveryKg = go.AddComponent <ManualDeliveryKG>();

            manualDeliveryKg.SetStorage(storage1);
            manualDeliveryKg.requestedItemTag = GameTags.IceOre;
            manualDeliveryKg.capacity         = storage1.capacityKg;
            manualDeliveryKg.refillMass       = storage1.capacityKg * 0.2f;
            manualDeliveryKg.minimumMass      = 10f;
            manualDeliveryKg.choreTypeIDHash  = Db.Get().ChoreTypes.MachineFetch.IdHash;

            ElementConverter elementConverter = go.AddOrGet <ElementConverter>();

            elementConverter.consumedElements = new ElementConverter.ConsumedElement[]
            { new ElementConverter.ConsumedElement(ElementLoader.FindElementByHash(SimHashes.Ice).tag, 0.01f) };
            elementConverter.outputElements = new ElementConverter.OutputElement[]
            { new ElementConverter.OutputElement(0.01f, SimHashes.Water, 278.15f, false, true, 0.0f, 0.5f, 1f, byte.MaxValue, 0) };

            ElementDropper elementDropper = go.AddOrGet <ElementDropper>();

            elementDropper.emitMass   = 10f;
            elementDropper.emitTag    = new Tag("Water");
            elementDropper.emitOffset = new Vector3(0.0f, 1f, 0.0f);
            return(false);
        }
Exemplo n.º 5
0
        static void Prefix()
        {
            Element radium       = ElementLoader.FindElementByHash(SimHashes.Radium);
            Element radiumgas    = ElementLoader.FindElementByHash(SimHashes.Helium);
            Element radiumliquid = ElementLoader.FindElementByHash(SimHashes.LiquidHelium);
            Element naphta       = ElementLoader.FindElementByHash(SimHashes.SolidNaphtha);
            Element prop         = ElementLoader.FindElementByHash(SimHashes.LiquidPropane);

            radiumgas.name    = "Radium Gas";
            radiumliquid.name = "Liquid Radium";
            prop.name         = "Radium Precursor";
            radiumgas.lowTemp = 6500f;
            radiumgas.defaultValues.temperature    = 9000f;
            radiumliquid.defaultValues.temperature = 5000f;
            radiumliquid.lowTemp                 = 500f;
            radiumliquid.highTemp                = 8000f;
            naphta.highTemp                      = 1000f;
            radium.highTemp                      = 1200f;
            radium.highTempTransitionTarget      = radiumliquid.id;
            prop.lowTempTransitionTarget         = radium.id;
            radiumliquid.lowTempTransitionTarget = naphta.id;
            radiumliquid.attributeModifiers      = radium.attributeModifiers;
            radiumgas.attributeModifiers         = radium.attributeModifiers;
        }
Exemplo n.º 6
0
            public static void Postfix()
            {
                var copper   = ElementLoader.FindElementByHash(SimHashes.Copper);
                var iron     = ElementLoader.FindElementByHash(SimHashes.Iron);
                var tungsten = ElementLoader.FindElementByHash(SimHashes.Tungsten);
                var steel    = ElementLoader.FindElementByHash(SimHashes.Steel);
                var gold     = ElementLoader.FindElementByHash(SimHashes.Gold);

                var basic = new[] { copper, iron, gold };

                foreach (var element in basic)
                {
                    element.oreTags = CreateTags(element.materialCategory, new[] { "Burns", "BuildableAny", "RefinedMetal", "Metal" });
                    GameTags.SolidElements.Add(element.tag);
                }

                tungsten.oreTags =
                    CreateTags(tungsten.materialCategory, new[] { "Plumbable", "BuildableAny", "RefinedMetal", "Metal" });
                GameTags.SolidElements.Add(tungsten.tag);

                steel.oreTags =
                    CreateTags(steel.materialCategory, new[] { "RefinedMetal", "BuildableAny", "Metal" });
                GameTags.SolidElements.Add(steel.tag);
            }
Exemplo n.º 7
0
        private void OnOccupantChanged(object data)
        {
            var elementConsumers = GetComponents <PassiveElementConsumer>();

            foreach (PassiveElementConsumer elementConsumer in elementConsumers)
            {
                elementConsumer.EnableConsumption(false);
            }

            if (data != null)
            {
                var consumed_infos = ((GameObject)data)?.GetSMI <IrrigationMonitor.Instance>()?.def.consumedElements;
                if (consumed_infos != null)
                {
                    foreach (var consumeInfo in consumed_infos)
                    {
                        foreach (var elementConsumer in elementConsumers)
                        {
                            var element = ElementLoader.FindElementByHash(elementConsumer.elementToConsume);
                            if (element != null)
                            {
                                if (element.tag != consumeInfo.tag)
                                {
                                    var traverse = Traverse.Create(elementConsumer);
                                    traverse.Method("SimUnregister").GetValue();
                                    elementConsumer.elementToConsume = ElementLoader.GetElementID(consumeInfo.tag);
                                    traverse.Method("SimRegister").GetValue();
                                }
                                elementConsumer.consumptionRate = consumeInfo.massConsumptionRate * 1.5f;
                                elementConsumer.EnableConsumption(true);
                            }
                        }
                    }
                }
            }
        }
    public override void ConfigureBuildingTemplate(GameObject go, Tag prefab_tag)
    {
        go.AddOrGet <DropAllWorkable>();
        go.AddOrGet <BuildingComplete>().isManuallyOperated = true;
        LiquidCooledRefinery liquidCooledRefinery = go.AddOrGet <LiquidCooledRefinery>();

        liquidCooledRefinery.duplicantOperated = true;
        liquidCooledRefinery.sideScreenStyle   = ComplexFabricatorSideScreen.StyleSetting.ListQueueHybrid;
        liquidCooledRefinery.keepExcessLiquids = true;
        go.AddOrGet <FabricatorIngredientStatusManager>();
        go.AddOrGet <CopyBuildingSettings>();
        ComplexFabricatorWorkable complexFabricatorWorkable = go.AddOrGet <ComplexFabricatorWorkable>();

        BuildingTemplates.CreateComplexFabricatorStorage(go, liquidCooledRefinery);
        liquidCooledRefinery.coolantTag            = COOLANT_TAG;
        liquidCooledRefinery.minCoolantMass        = 400f;
        liquidCooledRefinery.outStorage.capacityKg = 2000f;
        liquidCooledRefinery.thermalFudge          = 0.8f;
        liquidCooledRefinery.inStorage.SetDefaultStoredItemModifiers(RefineryStoredItemModifiers);
        liquidCooledRefinery.buildStorage.SetDefaultStoredItemModifiers(RefineryStoredItemModifiers);
        liquidCooledRefinery.outStorage.SetDefaultStoredItemModifiers(RefineryStoredItemModifiers);
        liquidCooledRefinery.outputOffset       = new Vector3(1f, 0.5f);
        complexFabricatorWorkable.overrideAnims = new KAnimFile[1]
        {
            Assets.GetAnim("anim_interacts_metalrefinery_kanim")
        };
        RequireOutputs requireOutputs = go.AddOrGet <RequireOutputs>();

        requireOutputs.ignoreFullPipe = true;
        ConduitConsumer conduitConsumer = go.AddOrGet <ConduitConsumer>();

        conduitConsumer.capacityTag          = GameTags.Liquid;
        conduitConsumer.capacityKG           = 800f;
        conduitConsumer.storage              = liquidCooledRefinery.inStorage;
        conduitConsumer.alwaysConsume        = true;
        conduitConsumer.forceAlwaysSatisfied = true;
        ConduitDispenser conduitDispenser = go.AddOrGet <ConduitDispenser>();

        conduitDispenser.storage        = liquidCooledRefinery.outStorage;
        conduitDispenser.conduitType    = ConduitType.Liquid;
        conduitDispenser.elementFilter  = null;
        conduitDispenser.alwaysDispense = true;
        List <Element> list = ElementLoader.elements.FindAll((Element e) => e.IsSolid && e.HasTag(GameTags.Metal));
        ComplexRecipe  complexRecipe;

        foreach (Element item in list)
        {
            Element highTempTransition = item.highTempTransition;
            Element lowTempTransition  = highTempTransition.lowTempTransition;
            if (lowTempTransition != item)
            {
                ComplexRecipe.RecipeElement[] array = new ComplexRecipe.RecipeElement[1]
                {
                    new ComplexRecipe.RecipeElement(item.tag, 100f)
                };
                ComplexRecipe.RecipeElement[] array2 = new ComplexRecipe.RecipeElement[1]
                {
                    new ComplexRecipe.RecipeElement(lowTempTransition.tag, 100f)
                };
                string obsolete_id = ComplexRecipeManager.MakeObsoleteRecipeID("MetalRefinery", item.tag);
                string text        = ComplexRecipeManager.MakeRecipeID("MetalRefinery", array, array2);
                complexRecipe             = new ComplexRecipe(text, array, array2);
                complexRecipe.time        = 40f;
                complexRecipe.description = string.Format(STRINGS.BUILDINGS.PREFABS.METALREFINERY.RECIPE_DESCRIPTION, lowTempTransition.name, item.name);
                complexRecipe.nameDisplay = ComplexRecipe.RecipeNameDisplay.IngredientToResult;
                complexRecipe.fabricators = new List <Tag>
                {
                    TagManager.Create("MetalRefinery")
                };
                ComplexRecipeManager.Get().AddObsoleteIDMapping(obsolete_id, text);
            }
        }
        Element element = ElementLoader.FindElementByHash(SimHashes.Steel);

        ComplexRecipe.RecipeElement[] array3 = new ComplexRecipe.RecipeElement[3]
        {
            new ComplexRecipe.RecipeElement(ElementLoader.FindElementByHash(SimHashes.Iron).tag, 70f),
            new ComplexRecipe.RecipeElement(ElementLoader.FindElementByHash(SimHashes.RefinedCarbon).tag, 20f),
            new ComplexRecipe.RecipeElement(ElementLoader.FindElementByHash(SimHashes.Lime).tag, 10f)
        };
        ComplexRecipe.RecipeElement[] array4 = new ComplexRecipe.RecipeElement[1]
        {
            new ComplexRecipe.RecipeElement(ElementLoader.FindElementByHash(SimHashes.Steel).tag, 100f)
        };
        string obsolete_id2 = ComplexRecipeManager.MakeObsoleteRecipeID("MetalRefinery", element.tag);
        string text2        = ComplexRecipeManager.MakeRecipeID("MetalRefinery", array3, array4);

        complexRecipe             = new ComplexRecipe(text2, array3, array4);
        complexRecipe.time        = 40f;
        complexRecipe.nameDisplay = ComplexRecipe.RecipeNameDisplay.IngredientToResult;
        complexRecipe.description = string.Format(STRINGS.BUILDINGS.PREFABS.METALREFINERY.RECIPE_DESCRIPTION, ElementLoader.FindElementByHash(SimHashes.Steel).name, ElementLoader.FindElementByHash(SimHashes.Iron).name);
        complexRecipe.fabricators = new List <Tag>
        {
            TagManager.Create("MetalRefinery")
        };
        ComplexRecipeManager.Get().AddObsoleteIDMapping(obsolete_id2, text2);
        Prioritizable.AddRef(go);
    }
    private void Consume(float dt, ConduitFlow conduit_mgr)
    {
        this.IsSatisfied = false;
        if (this.building.Def.CanMove)
        {
            this.utilityCell = this.GetInputCell();
        }
        if (!this.IsConnected)
        {
            return;
        }
        ConduitFlow.ConduitContents contents = conduit_mgr.GetContents(this.utilityCell);
        if ((double)contents.mass <= 0.0)
        {
            return;
        }
        this.IsSatisfied = true;
        if (!this.alwaysConsume && !this.operational.IsOperational)
        {
            return;
        }
        float delta = Mathf.Min(this.ConsumptionRate * dt, this.space_remaining_kg);
        float mass  = 0.0f;

        if ((double)delta > 0.0)
        {
            ConduitFlow.ConduitContents conduitContents = conduit_mgr.RemoveElement(this.utilityCell, delta);
            mass = conduitContents.mass;
            this.lastConsumedElement = conduitContents.element;
        }
        bool flag = ElementLoader.FindElementByHash(contents.element).HasTag(this.capacityTag);

        if ((double)mass > 0.0 && this.capacityTag != GameTags.Any && !flag)
        {
            this.Trigger(-794517298, (object)new BuildingHP.DamageSourceInfo()
            {
                damage    = 1,
                source    = (string)BUILDINGS.DAMAGESOURCES.BAD_INPUT_ELEMENT,
                popString = (string)UI.GAMEOBJECTEFFECTS.DAMAGE_POPS.WRONG_ELEMENT
            });
        }
        if (flag || this.wrongElementResult == ConduitConsumer2.WrongElementResult.Store || (contents.element == SimHashes.Vacuum || this.capacityTag == GameTags.Any))
        {
            if ((double)mass <= 0.0)
            {
                return;
            }
            int     disease_count = (int)((double)contents.diseaseCount * ((double)mass / (double)contents.mass));
            Element elementByHash = ElementLoader.FindElementByHash(contents.element);
            switch (this.conduitType)
            {
            case ConduitType.Gas:
                if (elementByHash.IsGas)
                {
                    this.storage.AddGasChunk(contents.element, mass, contents.temperature, contents.diseaseIdx, disease_count, this.keepZeroMassObject, false);
                    break;
                }
                Debug.LogWarning((object)("Gas conduit consumer consuming non gas: " + elementByHash.id.ToString()));
                break;

            case ConduitType.Liquid:
                if (elementByHash.IsLiquid)
                {
                    this.storage.AddLiquid(contents.element, mass, contents.temperature, contents.diseaseIdx, disease_count, this.keepZeroMassObject, false);
                    break;
                }
                Debug.LogWarning((object)("Liquid conduit consumer consuming non liquid: " + elementByHash.id.ToString()));
                break;
            }
        }
        else
        {
            if ((double)mass <= 0.0 || this.wrongElementResult != ConduitConsumer2.WrongElementResult.Dump)
            {
                return;
            }
            int disease_count = (int)((double)contents.diseaseCount * ((double)mass / (double)contents.mass));
            SimMessages.AddRemoveSubstance(Grid.PosToCell(this.transform.GetPosition()), contents.element, CellEventLogger.Instance.ConduitConsumerWrongElement, mass, contents.temperature, contents.diseaseIdx, disease_count, true, -1);
        }
    }
Exemplo n.º 10
0
            public static void Postfix()
            {
                ComplexRecipe.RecipeElement[] ingredients1 = new ComplexRecipe.RecipeElement[1]
                {
                    new ComplexRecipe.RecipeElement(AquaBulbSackConfig.Id.ToTag(), 1f)
                };
                ComplexRecipe.RecipeElement[] results1 = new ComplexRecipe.RecipeElement[1]
                {
                    new ComplexRecipe.RecipeElement(GameTags.Water, 1000f)
                };
                string str1 = ComplexRecipeManager.MakeRecipeID(RockCrusherConfig.ID, ingredients1, results1);

                new ComplexRecipe(str1, ingredients1, results1)
                {
                    time        = 40f,
                    nameDisplay = ComplexRecipe.RecipeNameDisplay.IngredientToResult,
                    description = string.Format(STRINGS.BUILDINGS.PREFABS.ROCKCRUSHER.RECIPE_DESCRIPTION, AquaBulbSackConfig.Name, ElementLoader.FindElementByHash(SimHashes.Water).name)
                }.fabricators = new List <Tag>()
                {
                    RockCrusherConfig.ID.ToTag()
                };
            }
Exemplo n.º 11
0
        private static string ResolveWattageStatus(string str, object data)
        {
            SteamTurbine steamTurbine = (SteamTurbine)data;
            float        num          = Game.Instance.accumulators.GetAverageRate(steamTurbine.accumulator) / steamTurbine.maxWattage;

            return(str.Replace("{Wattage}", GameUtil.GetFormattedWattage(steamTurbine.CurrentWattage, GameUtil.WattageFormatterUnit.Automatic)).Replace("{Max_Wattage}", GameUtil.GetFormattedWattage(steamTurbine.maxWattage, GameUtil.WattageFormatterUnit.Automatic)).Replace("{Efficiency}", GameUtil.GetFormattedPercent(num * 100f, GameUtil.TimeSlice.None)).Replace("{Src_Element}", ElementLoader.FindElementByHash(steamTurbine.srcElem).name));
        }
Exemplo n.º 12
0
        public override void ConfigureBuildingTemplate(GameObject go, Tag prefab_tag)
        {
            Storage storage1 = go.AddOrGet <Storage>();

            storage1.showInUI = true;

            Storage storage2 = go.AddComponent <Storage>();

            storage2.capacityKg = 5f;
            storage2.showInUI   = true;
            storage2.SetDefaultStoredItemModifiers(PollutedWaterStorageModifiers);
            storage2.allowItemRemoval = false;
            storage2.storageFilters   = new List <Tag> {
                ElementLoader.FindElementByHash(SimHashes.DirtyWater).tag
            };

            ManualDeliveryKG manualDeliveryKg1 = go.AddOrGet <ManualDeliveryKG>();

            manualDeliveryKg1.SetStorage(storage1);
            manualDeliveryKg1.requestedItemTag = new Tag("Algae");
            manualDeliveryKg1.capacity         = 90f;
            manualDeliveryKg1.refillMass       = 18f;
            manualDeliveryKg1.choreTypeIDHash  = Db.Get().ChoreTypes.OperateFetch.IdHash;

            ManualDeliveryKG manualDeliveryKg2 = go.AddComponent <ManualDeliveryKG>();

            manualDeliveryKg2.SetStorage(storage1);
            manualDeliveryKg2.requestedItemTag = new Tag("Water");
            manualDeliveryKg2.capacity         = 360f;
            manualDeliveryKg2.refillMass       = 72f;
            manualDeliveryKg2.allowPause       = true;
            manualDeliveryKg2.choreTypeIDHash  = Db.Get().ChoreTypes.OperateFetch.IdHash;

            PipedAlgaeTerrarium algaeHabitat = go.AddOrGet <PipedAlgaeTerrarium>();

            algaeHabitat.lightBonusMultiplier = 1.1f;
            algaeHabitat.pressureSampleOffset = new CellOffset(0, 1);

            ElementConverter elementConverter = go.AddComponent <ElementConverter>();

            elementConverter.consumedElements = new ElementConverter.ConsumedElement[2]
            {
                new ElementConverter.ConsumedElement(new Tag("Algae"), 0.03f),
                new ElementConverter.ConsumedElement(new Tag("Water"), 0.3f)
            };
            elementConverter.outputElements = new ElementConverter.OutputElement[2]
            {
                new ElementConverter.OutputElement(0.04f, SimHashes.Oxygen, 303.15f, false, 0.0f, 1f, false, 1f, byte.MaxValue, 0),
                new ElementConverter.OutputElement(0.2903333f, SimHashes.DirtyWater, 303.15f, true, 0.0f, 1f, false, 1f, byte.MaxValue, 0)
            };

            ConduitDispenser conduitDispenser = go.AddOrGet <ConduitDispenser>();

            conduitDispenser.conduitType         = ConduitType.Liquid;
            conduitDispenser.invertElementFilter = true;
            conduitDispenser.elementFilter       = new SimHashes[1]
            {
                SimHashes.Water
            };

            ElementConsumer elementConsumer = go.AddOrGet <ElementConsumer>();

            elementConsumer.elementToConsume  = SimHashes.CarbonDioxide;
            elementConsumer.consumptionRate   = 0.0003333333f;
            elementConsumer.consumptionRadius = (byte)3;
            elementConsumer.showInStatusPanel = true;
            elementConsumer.sampleCellOffset  = new Vector3(0.0f, 1f, 0.0f);
            elementConsumer.isRequired        = false;

            PassiveElementConsumer passiveElementConsumer = go.AddComponent <PassiveElementConsumer>();

            passiveElementConsumer.elementToConsume  = SimHashes.Water;
            passiveElementConsumer.consumptionRate   = 1.2f;
            passiveElementConsumer.consumptionRadius = (byte)1;
            passiveElementConsumer.showDescriptor    = false;
            passiveElementConsumer.storeOnConsume    = true;
            passiveElementConsumer.capacityKG        = 360f;
            passiveElementConsumer.showInStatusPanel = false;

            go.AddOrGet <AnimTileable>();

            Prioritizable.AddRef(go);
        }
    private void OnSimConsume(Sim.MassConsumedCallback mass_cb_info)
    {
        float num = mass_cb_info.mass * base.smi.master.exchangeRatio;

        if (reportExchange && base.smi.master.emittedElement == SimHashes.Oxygen)
        {
            string            text      = base.gameObject.GetProperName();
            ReceptacleMonitor component = GetComponent <ReceptacleMonitor>();
            if ((UnityEngine.Object)component != (UnityEngine.Object)null && (UnityEngine.Object)component.GetReceptacle() != (UnityEngine.Object)null)
            {
                text = text + " (" + component.GetReceptacle().gameObject.GetProperName() + ")";
            }
            ReportManager.Instance.ReportValue(ReportManager.ReportType.OxygenCreated, num, text, null);
        }
        SimMessages.EmitMass(Grid.PosToCell(base.smi.master.transform.GetPosition() + outputOffset), ElementLoader.FindElementByHash(base.smi.master.emittedElement).idx, num, ElementLoader.FindElementByHash(base.smi.master.emittedElement).defaultValues.temperature, byte.MaxValue, 0, -1);
    }
Exemplo n.º 14
0
        internal static void ConfigureRecipes()
        {
            const float INPUT_KG = 100f;

            // добавляем переплавку абиссалития в электроплавильню
            if (SmelterOptions.Instance.RecipeKatairiteToTungsten)
            {
                const float PHOSPHORUS             = 10f;
                const float SALT                   = 20f;
                const float TUNGSTEN               = INPUT_KG - PHOSPHORUS - SALT;
                const float SALT_TO_CHLORINE_RATIO = 1f / 3f;
                const float CHLORINEGAS            = SALT * SALT_TO_CHLORINE_RATIO;
                const float MAGMA                  = INPUT_KG - TUNGSTEN - CHLORINEGAS;

                var ingredients = new ComplexRecipe.RecipeElement[]
                {
                    new ComplexRecipe.RecipeElement(SimHashes.Katairite.CreateTag(), TUNGSTEN),
                    new ComplexRecipe.RecipeElement(SimHashes.Salt.CreateTag(), SALT),
                    new ComplexRecipe.RecipeElement(SimHashes.Phosphorus.CreateTag(), PHOSPHORUS)
                };
                var results = new ComplexRecipe.RecipeElement[]
                {
                    new ComplexRecipe.RecipeElement(SimHashes.Tungsten.CreateTag(), TUNGSTEN),
                    new ComplexRecipe.RecipeElement(SimHashes.IgneousRock.CreateTag(), MAGMA),
                    new ComplexRecipe.RecipeElement(SimHashes.ChlorineGas.CreateTag(), CHLORINEGAS)
                };
                string obsolete_id = ComplexRecipeManager.MakeObsoleteRecipeID(MetalRefineryConfig.ID, SimHashes.Katairite.CreateTag());
                string id          = ComplexRecipeManager.MakeRecipeID(MetalRefineryConfig.ID, ingredients, results);
                new ComplexRecipe(id, ingredients, results)
                {
                    time        = BUILDINGS.FABRICATION_TIME_SECONDS.MODERATE,
                    description = string.Format(
                        global::STRINGS.BUILDINGS.PREFABS.METALREFINERY.RECIPE_DESCRIPTION,
                        ElementLoader.FindElementByHash(SimHashes.Tungsten).name,
                        ElementLoader.FindElementByHash(SimHashes.Katairite).name),
                    nameDisplay = ComplexRecipe.RecipeNameDisplay.IngredientToResult,
                    fabricators = new List <Tag> {
                        TagManager.Create(MetalRefineryConfig.ID)
                    }
                };
                ComplexRecipeManager.Get().AddObsoleteIDMapping(obsolete_id, id);
            }

            // добавляем переплавку фосфора в стеклоплавильню
            if (SmelterOptions.Instance.RecipePhosphoriteToPhosphorus)
            {
                var ingredients = new ComplexRecipe.RecipeElement[]
                {
                    new ComplexRecipe.RecipeElement(SimHashes.Phosphorite.CreateTag(), INPUT_KG)
                };
                var results = new ComplexRecipe.RecipeElement[]
                {
                    new ComplexRecipe.RecipeElement(SimHashes.LiquidPhosphorus.CreateTag(), INPUT_KG)
                };
                string obsolete_id = ComplexRecipeManager.MakeObsoleteRecipeID(GlassForgeConfig.ID, SimHashes.Phosphorite.CreateTag());
                string id          = ComplexRecipeManager.MakeRecipeID(GlassForgeConfig.ID, ingredients, results);
                new ComplexRecipe(id, ingredients, results)
                {
                    time        = BUILDINGS.FABRICATION_TIME_SECONDS.SHORT / 2,
                    description = string.Format(
                        global::STRINGS.BUILDINGS.PREFABS.GLASSFORGE.RECIPE_DESCRIPTION,
                        ElementLoader.FindElementByHash(SimHashes.LiquidPhosphorus).name,
                        ElementLoader.FindElementByHash(SimHashes.Phosphorite).name),
                    nameDisplay = ComplexRecipe.RecipeNameDisplay.Result,
                    fabricators = new List <Tag> {
                        TagManager.Create(GlassForgeConfig.ID)
                    }
                };
                ComplexRecipeManager.Get().AddObsoleteIDMapping(obsolete_id, id);
            }

            // добавляем копию рецептов из электроплавильни. кроме стали и наёбия
            var metalrefinery_recipes = ComplexRecipeManager.Get().recipes
                                        .Where((ComplexRecipe recipe) => recipe.fabricators.Contains(TagManager.Create(MetalRefineryConfig.ID)))
                                        .ToList();

            metalrefinery_recipes
            .DoIf(
                condition: (ComplexRecipe recipe) => !recipe.id.Contains(SimHashes.Steel.ToString()) &&
                !recipe.id.Contains(SimHashes.Niobium.ToString()),
                action: (ComplexRecipe recipe) => recipe.fabricators.Add(TagManager.Create(ID))
                );

            // добавляем сталь с увеличенным временем фабрикации
            const float fabricationTimeMultiplier = 1.3f;

            metalrefinery_recipes
            .Where((ComplexRecipe recipe) => recipe.id.Contains(SimHashes.Steel.ToString()))
            .ToList()
            .Do((ComplexRecipe recipe) =>
            {
                string obsolete_id = ComplexRecipeManager.MakeObsoleteRecipeID(ID, recipe.ingredients[0].material);
                string id          = ComplexRecipeManager.MakeRecipeID(ID, recipe.ingredients, recipe.results);
                new ComplexRecipe(id, recipe.ingredients, recipe.results)
                {
                    time        = recipe.time * fabricationTimeMultiplier,
                    description = recipe.description,
                    nameDisplay = recipe.nameDisplay,
                    fabricators = new List <Tag> {
                        TagManager.Create(ID)
                    }
                };
                ComplexRecipeManager.Get().AddObsoleteIDMapping(obsolete_id, id);
            });

            // добавляем копию рецептов из стеклоплавильни с увеличенным временем фабрикации
            var glassforge_recipes = ComplexRecipeManager.Get().recipes
                                     .Where((ComplexRecipe recipe) => recipe.fabricators.Contains(TagManager.Create(GlassForgeConfig.ID)))
                                     .ToList();

            glassforge_recipes
            .Do((ComplexRecipe recipe) =>
            {
                var results = new ComplexRecipe.RecipeElement[] {
                    new ComplexRecipe.RecipeElement(ElementLoader.GetElement(recipe.results[0].material).lowTempTransition.tag, recipe.results[0].amount)
                };
                string obsolete_id = ComplexRecipeManager.MakeObsoleteRecipeID(ID, recipe.ingredients[0].material);
                string id          = ComplexRecipeManager.MakeRecipeID(ID, recipe.ingredients, results);
                new ComplexRecipe(id, recipe.ingredients, results)
                {
                    time        = recipe.time * fabricationTimeMultiplier,
                    description = string.Format(global::STRINGS.BUILDINGS.PREFABS.GLASSFORGE.RECIPE_DESCRIPTION, ElementLoader.GetElement(results[0].material).name, ElementLoader.GetElement(recipe.ingredients[0].material).name),
                    nameDisplay = ComplexRecipe.RecipeNameDisplay.IngredientToResult,
                    fabricators = new List <Tag> {
                        TagManager.Create(ID)
                    }
                };
                ComplexRecipeManager.Get().AddObsoleteIDMapping(obsolete_id, id);
            });

            // добавляем переплавку  пластика
            if (SmelterOptions.Instance.RecipePlasticToNaphtha)
            {
                var ingredients = new ComplexRecipe.RecipeElement[]
                {
                    new ComplexRecipe.RecipeElement(SimHashes.Polypropylene.CreateTag(), INPUT_KG)
                };
                var results = new ComplexRecipe.RecipeElement[]
                {
                    new ComplexRecipe.RecipeElement(SimHashes.Naphtha.CreateTag(), INPUT_KG)
                };
                string obsolete_id = ComplexRecipeManager.MakeObsoleteRecipeID(ID, SimHashes.Polypropylene.CreateTag());
                string id          = ComplexRecipeManager.MakeRecipeID(ID, ingredients, results);
                new ComplexRecipe(id, ingredients, results)
                {
                    time        = BUILDINGS.FABRICATION_TIME_SECONDS.SHORT,
                    description = string.Format(
                        global::STRINGS.BUILDINGS.PREFABS.GLASSFORGE.RECIPE_DESCRIPTION,
                        ElementLoader.FindElementByHash(SimHashes.Naphtha).name,
                        ElementLoader.FindElementByHash(SimHashes.Polypropylene).name),
                    nameDisplay = ComplexRecipe.RecipeNameDisplay.IngredientToResult,
                    fabricators = new List <Tag> {
                        TagManager.Create(ID)
                    }
                };
                ComplexRecipeManager.Get().AddObsoleteIDMapping(obsolete_id, id);
            }

            // добавляем древесный уголь в печку
            if (SmelterOptions.Instance.RecipeWoodToCarbon)
            {
                const float WOOD   = 200f;
                const float CARBON = 100f;
                const float CO2    = 60f;

                var ingredients = new ComplexRecipe.RecipeElement[]
                {
                    new ComplexRecipe.RecipeElement(WoodLogConfig.TAG, WOOD)
                };
                var results = new ComplexRecipe.RecipeElement[]
                {
                    new ComplexRecipe.RecipeElement(SimHashes.RefinedCarbon.CreateTag(), CARBON),
                    new ComplexRecipe.RecipeElement(SimHashes.CarbonDioxide.CreateTag(), CO2)
                };
                string obsolete_id = ComplexRecipeManager.MakeObsoleteRecipeID(KilnConfig.ID, WoodLogConfig.TAG);
                string id          = ComplexRecipeManager.MakeRecipeID(KilnConfig.ID, ingredients, results);
                new ComplexRecipe(id, ingredients, results)
                {
                    time        = BUILDINGS.FABRICATION_TIME_SECONDS.SHORT,
                    description = string.Format(
                        global::STRINGS.BUILDINGS.PREFABS.EGGCRACKER.RECIPE_DESCRIPTION,
                        global::STRINGS.UI.FormatAsLink(global::STRINGS.ITEMS.INDUSTRIAL_PRODUCTS.WOOD.NAME, ForestTreeConfig.ID.ToUpperInvariant()),
                        ElementLoader.FindElementByHash(SimHashes.RefinedCarbon).name),
                    nameDisplay = ComplexRecipe.RecipeNameDisplay.IngredientToResult,
                    fabricators = new List <Tag> {
                        TagManager.Create(KilnConfig.ID)
                    }
                };
                ComplexRecipeManager.Get().AddObsoleteIDMapping(obsolete_id, id);
            }
        }
Exemplo n.º 15
0
        public GameObject CreatePrefab()
        {
            var placedEntity = EntityTemplates.CreatePlacedEntity(
                id: Id,
                name: Name,
                desc: Description,
                mass: 1f,
                anim: Assets.GetAnim("magmafern"),
                initialAnim: "idle_empty",
                sceneLayer: Grid.SceneLayer.BuildingFront,
                width: 1,
                height: 1,
                decor: TUNING.DECOR.BONUS.TIER2,
                defaultTemperature: DefaultTemperature);

            EntityTemplates.ExtendEntityToBasicPlant(
                template: placedEntity,
                temperature_lethal_low: TemperatureLethalLow,
                temperature_warning_low: TemperatureWarningLow,
                temperature_warning_high: TemperatureWarningHigh,
                temperature_lethal_high: TemperatureLethalHigh,
                safe_elements: new[] { SimHashes.Magma },
                pressure_sensitive: false,
                crop_id: SeedId);

            EntityTemplates.ExtendPlantToFertilizable(
                template: placedEntity,
                fertilizers: new[]
            {
                new PlantElementAbsorber.ConsumeInfo()
                {
                    tag = ElementLoader.FindElementByHash(SimHashes.Obsidian).tag,
                    massConsumptionRate = FertilizationRate
                }
            })
            ;
            EntityTemplates.ExtendPlantToIrrigated(
                template: placedEntity,
                info: new PlantElementAbsorber.ConsumeInfo()
            {
                tag = ElementLoader.FindElementByHash(SimHashes.Magma).tag,
                massConsumptionRate = IrrigationRate
            });

            placedEntity.AddOrGet <StandardCropPlant>();

            var seed = EntityTemplates.CreateAndRegisterSeedForPlant(
                plant: placedEntity,
                productionType: SeedProducer.ProductionType.DigOnly,
                id: SeedId,
                name: SeedName,
                desc: SeedDescription,
                anim: Assets.GetAnim("seed_magmafern"),
                initialAnim: "object",
                numberOfSeeds: 1,
                additionalTags: new List <Tag>()
            {
                GameTags.CropSeed
            },
                planterDirection: SingleEntityReceptacle.ReceptacleDirection.Top,
                replantGroundTag: new Tag(),
                sortOrder: 2,
                domesticatedDescription: DomesticatedDescription,
                collisionShape: EntityTemplates.CollisionShape.CIRCLE,
                width: 0.2f,
                height: 0.2f,
                ignoreDefaultSeedTag: true);

            var foodInfo = new EdiblesManager.FoodInfo(
                SeedId,
                caloriesPerUnit: 0.0f,
                quality: 0,
                preserveTemperatue: PreserveTemperature,
                rotTemperature: RotTemperature,
                spoilTime: TUNING.FOOD.SPOIL_TIME.SLOW,
                can_rot: true);

            EntityTemplates.ExtendEntityToFood(
                template: seed,
                foodInfo: foodInfo);

            EntityTemplates.CreateAndRegisterPreviewForPlant(
                seed: seed,
                id: "MagmaFern_preview",
                anim: Assets.GetAnim("magmafern"),
                initialAnim: "place",
                width: 1,
                height: 1);

            SoundEventVolumeCache.instance.AddVolume("magmafern", "MagmaFern_grow", TUNING.NOISE_POLLUTION.CREATURES.TIER3);
            SoundEventVolumeCache.instance.AddVolume("magmafern", "MagmaFern_harvest", TUNING.NOISE_POLLUTION.CREATURES.TIER3);
            return(placedEntity);
        }
        public void Run(RenderMeshContext context)
        {
            Element element = null;

            for (int i = start; i != end; i++)
            {
                ConduitFlow.Conduit         conduit         = context.outer.flowManager.soaInfo.GetConduit(context.visible_conduits[i]);
                ConduitFlow.ConduitFlowInfo lastFlowInfo    = conduit.GetLastFlowInfo(context.outer.flowManager);
                ConduitFlow.ConduitContents initialContents = conduit.GetInitialContents(context.outer.flowManager);
                if (lastFlowInfo.contents.mass > 0f)
                {
                    int      cell = conduit.GetCell(context.outer.flowManager);
                    int      cellFromDirection = ConduitFlow.GetCellFromDirection(cell, lastFlowInfo.direction);
                    Vector2I v               = Grid.CellToXY(cell);
                    Vector2I vector2I        = Grid.CellToXY(cellFromDirection);
                    Vector2  pos             = (cell != -1) ? Vector2.Lerp(new Vector2((float)v.x, (float)v.y), new Vector2((float)vector2I.x, (float)vector2I.y), context.lerp_percent) : ((Vector2)v);
                    Color32  cellTintColour  = context.outer.GetCellTintColour(cell);
                    Color32  cellTintColour2 = context.outer.GetCellTintColour(cellFromDirection);
                    Color32  color           = Color32.Lerp(cellTintColour, cellTintColour2, context.lerp_percent);
                    bool     highlight       = false;
                    if (context.outer.showContents)
                    {
                        if (lastFlowInfo.contents.mass >= initialContents.mass)
                        {
                            moving_balls.Add(new Ball(lastFlowInfo.direction, pos, color, context.outer.tuning.size, false, false));
                        }
                        if (element == null || lastFlowInfo.contents.element != element.id)
                        {
                            element = ElementLoader.FindElementByHash(lastFlowInfo.contents.element);
                        }
                    }
                    else
                    {
                        element = null;
                        int num = Grid.PosToCell(new Vector3(pos.x + GRID_OFFSET.x, pos.y + GRID_OFFSET.y, 0f));
                        highlight = (num == context.outer.highlightedCell);
                    }
                    Color32 contentsColor = context.outer.GetContentsColor(element, color);
                    float   num2          = 1f;
                    if (context.outer.showContents || lastFlowInfo.contents.mass < initialContents.mass)
                    {
                        num2 = context.outer.CalculateMassScale(lastFlowInfo.contents.mass);
                    }
                    moving_balls.Add(new Ball(lastFlowInfo.direction, pos, contentsColor, context.outer.tuning.size * num2, true, highlight));
                    moving_conduits.Add(conduit);
                }
                if (initialContents.mass > lastFlowInfo.contents.mass && initialContents.mass > 0f)
                {
                    int      cell2           = conduit.GetCell(context.outer.flowManager);
                    Vector2I v2              = Grid.CellToXY(cell2);
                    Vector2  pos2            = v2;
                    float    mass            = initialContents.mass - lastFlowInfo.contents.mass;
                    bool     highlight2      = false;
                    Color32  cellTintColour3 = context.outer.GetCellTintColour(cell2);
                    float    num3            = context.outer.CalculateMassScale(mass);
                    if (context.outer.showContents)
                    {
                        static_balls.Add(new Ball(ConduitFlow.FlowDirections.None, pos2, cellTintColour3, context.outer.tuning.size * num3, false, false));
                        if (element == null || initialContents.element != element.id)
                        {
                            element = ElementLoader.FindElementByHash(initialContents.element);
                        }
                    }
                    else
                    {
                        element    = null;
                        highlight2 = (cell2 == context.outer.highlightedCell);
                    }
                    Color32 contentsColor2 = context.outer.GetContentsColor(element, cellTintColour3);
                    static_balls.Add(new Ball(ConduitFlow.FlowDirections.None, pos2, contentsColor2, context.outer.tuning.size * num3, true, highlight2));
                }
            }
        }
        public static float Resources(SimHashes hash)
        {
            Tag tag = ElementLoader.FindElementByHash(hash).tag;

            return(WorldInventory.Instance.GetTotalAmount(tag));
        }
Exemplo n.º 18
0
        private static bool Prefix(Game __instance, GameObject go)
        {
            if (!(bool)EasierBuildingsState.StateManager.State.ExtraPipeOutputs)
            {
                return(true);
            }
            go.GetComponent <KPrefabID>().AddTag(RoomConstraints.ConstraintTags.IndustrialMachinery, false);
            Storage defaultStorage = BuildingTemplates.CreateDefaultStorage(go, false);

            defaultStorage.SetDefaultStoredItemModifiers(Storage.StandardSealedStorage);
            go.AddOrGet <WaterPurifier>();
            //ManualDeliveryKG manualDeliveryKg1 = go.AddComponent<ManualDeliveryKG>();
            //manualDeliveryKg1.SetStorage(defaultStorage);
            //manualDeliveryKg1.choreTypeIDHash = Db.Get().ChoreTypes.MachineFetch.IdHash;
            //manualDeliveryKg1.requestedItemTag = new Tag("Dirt");
            //manualDeliveryKg1.capacity = 136.5f;
            //manualDeliveryKg1.refillMass = 19.5f;
            ManualDeliveryKG manualDeliveryKg2 = go.AddComponent <ManualDeliveryKG>();

            manualDeliveryKg2.SetStorage(defaultStorage);
            manualDeliveryKg2.choreTypeIDHash  = Db.Get().ChoreTypes.MachineFetch.IdHash;
            manualDeliveryKg2.requestedItemTag = new Tag("Phosphorite");
            manualDeliveryKg2.capacity         = 6f * 54.6f;
            manualDeliveryKg2.refillMass       = 6f * 7.8f;
            ConduitConsumer conduitConsumer = go.AddOrGet <ConduitConsumer>();

            conduitConsumer.conduitType          = ConduitType.Liquid;
            conduitConsumer.consumptionRate      = 10f;
            conduitConsumer.capacityTag          = ElementLoader.FindElementByHash(SimHashes.DirtyWater).tag;
            conduitConsumer.capacityKG           = 3.12f;
            conduitConsumer.wrongElementResult   = ConduitConsumer.WrongElementResult.Dump;
            conduitConsumer.forceAlwaysSatisfied = true;
            ElementConverter elementConverter = go.AddOrGet <ElementConverter>();

            elementConverter.consumedElements = new ElementConverter.ConsumedElement[]
            {
                new ElementConverter.ConsumedElement(new Tag("DirtyWater"), 6f * (0.039f + 0.065f)),
                //new ElementConverter.ConsumedElement(new Tag("Dirt"), 0.065f),
                new ElementConverter.ConsumedElement(new Tag("Phosphorite"), 6f * 0.026f)
            };
            elementConverter.outputElements = new ElementConverter.OutputElement[]
            {
                new ElementConverter.OutputElement(6f * 0.12f, SimHashes.Fertilizer, 323.15f, false, true, 0.0f, 0.5f, 1f, byte.MaxValue, 0),
                new ElementConverter.OutputElement(6f * 0.01f, SimHashes.Methane, 323.15f, false, true, 0.0f, 0.5f, 1f, byte.MaxValue, 0)
            };
            //BuildingElementEmitter buildingElementEmitter = go.AddOrGet<BuildingElementEmitter>();
            //buildingElementEmitter.emitRate = 0.01f;
            //buildingElementEmitter.temperature = 349.15f;
            //buildingElementEmitter.element = SimHashes.Methane;
            //buildingElementEmitter.modifierOffset = new Vector2(2f, 2f);

            ConduitDispenser conduitDispenser = go.AddOrGet <ConduitDispenser>();

            conduitDispenser.conduitType         = ConduitType.Gas;
            conduitDispenser.invertElementFilter = true;
            conduitDispenser.elementFilter       = new SimHashes[]
            {
                SimHashes.Dirt,
                SimHashes.Phosphorite,
                SimHashes.DirtyWater
            };

            ElementDropper elementDropper = go.AddComponent <ElementDropper>();

            elementDropper.emitMass   = 6f * 10f;
            elementDropper.emitTag    = new Tag("Fertilizer");
            elementDropper.emitOffset = new Vector3(0.0f, 1f, 0.0f);
            Prioritizable.AddRef(go);

            return(false);
        }
Exemplo n.º 19
0
        private void ConfigureRecipes()
        {
            float inputAmount  = 200.0f;
            float outputAmount = 100.0f;

            ComplexRecipe.RecipeElement[] ingredients1 = new ComplexRecipe.RecipeElement[1]
            {
                new ComplexRecipe.RecipeElement(
                    ElementLoader.FindElementByHash(Elements.CorundumElement.SimHash).tag,
                    inputAmount)
            };
            ComplexRecipe.RecipeElement[] results1 = new ComplexRecipe.RecipeElement[1]
            {
                new ComplexRecipe.RecipeElement(
                    ElementLoader.FindElementByHash(Elements.PolishedCorundumElement.SimHash).tag,
                    outputAmount)
            };
            string str1 = ComplexRecipeManager.MakeRecipeID(Id,
                                                            ingredients1, results1);
            string desc1 = $"Polishes {STRINGS.UI.FormatAsLink(Elements.CorundumElement.Name, Elements.CorundumElement.Id)} into a shiny gemstone.";

            new ComplexRecipe(str1, ingredients1, results1)
            {
                time        = BUILDINGS.FABRICATION_TIME_SECONDS.SHORT,
                nameDisplay = ComplexRecipe.RecipeNameDisplay.Result,
                description = desc1
            }.fabricators = new List <Tag>()
            {
                TagManager.Create(Id)
            };
            ComplexRecipe.RecipeElement[] ingredients2 = new ComplexRecipe.RecipeElement[1]
            {
                new ComplexRecipe.RecipeElement(
                    ElementLoader.FindElementByHash(Elements.KyaniteElement.SimHash).tag,
                    inputAmount)
            };
            ComplexRecipe.RecipeElement[] results2 = new ComplexRecipe.RecipeElement[1]
            {
                new ComplexRecipe.RecipeElement(
                    ElementLoader.FindElementByHash(Elements.PolishedKyaniteElement.SimHash).tag,
                    outputAmount)
            };
            string str2 = ComplexRecipeManager.MakeRecipeID(Id,
                                                            ingredients2, results2);
            string desc2 = $"Polishes {STRINGS.UI.FormatAsLink(Elements.KyaniteElement.Name, Elements.KyaniteElement.Id)} into a shiny gemstone.";

            new ComplexRecipe(str2, ingredients2, results2)
            {
                time        = BUILDINGS.FABRICATION_TIME_SECONDS.SHORT,
                nameDisplay = ComplexRecipe.RecipeNameDisplay.Result,
                description = desc2
            }.fabricators = new List <Tag>()
            {
                TagManager.Create(Id)
            };
            ComplexRecipe.RecipeElement[] ingredients3 = new ComplexRecipe.RecipeElement[1]
            {
                new ComplexRecipe.RecipeElement(
                    ElementLoader.FindElementByHash(Elements.SodaliteElement.SimHash).tag,
                    inputAmount)
            };
            ComplexRecipe.RecipeElement[] results3 = new ComplexRecipe.RecipeElement[1]
            {
                new ComplexRecipe.RecipeElement(
                    ElementLoader.FindElementByHash(Elements.PolishedSodaliteElement.SimHash).tag,
                    outputAmount)
            };
            string str3 = ComplexRecipeManager.MakeRecipeID(Id,
                                                            ingredients3, results3);
            string desc3 = $"Polishes {STRINGS.UI.FormatAsLink(Elements.SodaliteElement.Name, Elements.SodaliteElement.Id)} into a shiny gemstone.";

            new ComplexRecipe(str3, ingredients3, results3)
            {
                time        = BUILDINGS.FABRICATION_TIME_SECONDS.SHORT,
                nameDisplay = ComplexRecipe.RecipeNameDisplay.Result,
                description = desc3
            }.fabricators = new List <Tag>()
            {
                TagManager.Create(Id)
            };
        }
Exemplo n.º 20
0
    public List <Descriptor> EffectDescriptors(BuildingDef def)
    {
        List <Descriptor> list = new List <Descriptor>();

        if (outputElement != SimHashes.Vacuum)
        {
            list.Add(new Descriptor(string.Format(UI.BUILDINGEFFECTS.ELEMENTEMITTEDPERUSE, ElementLoader.FindElementByHash(outputElement).name, GameUtil.GetFormattedMass(massConsumedPerUse, GameUtil.TimeSlice.None, GameUtil.MetricMassFormat.UseThreshold, true, "{0:0.#}")), string.Format(UI.BUILDINGEFFECTS.TOOLTIPS.ELEMENTEMITTEDPERUSE, ElementLoader.FindElementByHash(outputElement).name, GameUtil.GetFormattedMass(massConsumedPerUse, GameUtil.TimeSlice.None, GameUtil.MetricMassFormat.UseThreshold, true, "{0:0.#}")), Descriptor.DescriptorType.Effect, false));
        }
        list.Add(new Descriptor(string.Format(UI.BUILDINGEFFECTS.DISEASECONSUMEDPERUSE, GameUtil.GetFormattedDiseaseAmount(diseaseRemovalCount)), string.Format(UI.BUILDINGEFFECTS.TOOLTIPS.DISEASECONSUMEDPERUSE, GameUtil.GetFormattedDiseaseAmount(diseaseRemovalCount)), Descriptor.DescriptorType.Effect, false));
        return(list);
    }
Exemplo n.º 21
0
 /// <summary>
 /// Return true if a SimHashes is discovered. Should not be called until game loaded.
 /// </summary>
 /// <param name="hash"> SimHash of the element </param>
 /// <returns></returns>
 public static bool IsSimHashesDiscovered(SimHashes hash)
 {
     return(WorldInventory.Instance.IsDiscovered(ElementLoader.FindElementByHash(hash).tag));
 }
    public void UpdatePortrait(GameObject target)
    {
        KSelectable component = target.GetComponent <KSelectable>();

        if (!((UnityEngine.Object)component == (UnityEngine.Object)null))
        {
            TabTitle.portrait.ClearPortrait();
            Building component2 = component.GetComponent <Building>();
            if ((bool)component2)
            {
                Sprite sprite = null;
                sprite = component2.Def.GetUISprite("ui", false);
                if ((UnityEngine.Object)sprite != (UnityEngine.Object)null)
                {
                    TabTitle.portrait.SetPortrait(sprite);
                    return;
                }
            }
            MinionIdentity component3 = target.GetComponent <MinionIdentity>();
            if ((bool)component3)
            {
                TabTitle.SetPortrait(component.gameObject);
            }
            else
            {
                Edible component4 = target.GetComponent <Edible>();
                if ((UnityEngine.Object)component4 != (UnityEngine.Object)null)
                {
                    KBatchedAnimController component5  = component4.GetComponent <KBatchedAnimController>();
                    Sprite uISpriteFromMultiObjectAnim = Def.GetUISpriteFromMultiObjectAnim(component5.AnimFiles[0], "ui", false, string.Empty);
                    TabTitle.portrait.SetPortrait(uISpriteFromMultiObjectAnim);
                }
                else
                {
                    PrimaryElement component6 = target.GetComponent <PrimaryElement>();
                    if ((UnityEngine.Object)component6 != (UnityEngine.Object)null)
                    {
                        TabTitle.portrait.SetPortrait(Def.GetUISpriteFromMultiObjectAnim(ElementLoader.FindElementByHash(component6.ElementID).substance.anim, "ui", false, string.Empty));
                    }
                    else
                    {
                        CellSelectionObject component7 = target.GetComponent <CellSelectionObject>();
                        if ((UnityEngine.Object)component7 != (UnityEngine.Object)null)
                        {
                            string animName = (!component7.element.IsSolid) ? component7.element.substance.name : "ui";
                            Sprite uISpriteFromMultiObjectAnim2 = Def.GetUISpriteFromMultiObjectAnim(component7.element.substance.anim, animName, false, string.Empty);
                            TabTitle.portrait.SetPortrait(uISpriteFromMultiObjectAnim2);
                        }
                    }
                }
            }
        }
    }
Exemplo n.º 23
0
 public override string Name()
 {
     return(ElementLoader.FindElementByHash(element).name);
 }
Exemplo n.º 24
0
        /// <summary>
        /// Shows or hides panels depending on the active object.
        /// </summary>
        /// <param name="target">The selected target object.</param>
        private void SetPanels(GameObject target)
        {
            var    modifiers            = lastSelection.modifiers;
            var    descriptionContainer = sis.descriptionContainer;
            var    id = lastSelection.identity;
            var    attributeLabels = sis.attributeLabels;
            int    n = attributeLabels.Count;
            string descText = "", flavorText = "";
            var    effects = DescriptorAllocPatches.GetGameObjectEffects(target, true);

            Klei.AI.Amounts amounts;
            bool            hasAmounts = modifiers != null && (amounts = modifiers.amounts) != null &&
                                         amounts.Count > 0, hasProcess = lastSelection.conditions != null,
                            hasEffects = effects.Count > 0;

            for (int i = 0; i < n; i++)
            {
                Destroy(attributeLabels[i]);
            }
            attributeLabels.Clear();
            if (hasAmounts)
            {
                sis.vitalsContainer.selectedEntity = target;
                if (target.TryGetComponent(out Uprootable plant) && !target.TryGetComponent(
                        out WiltCondition _))
                {
                    hasAmounts = plant.GetPlanterStorage != null;
                }
            }
            vitalsActive = hasAmounts;
            sis.vitalsPanel.gameObject.SetActive(hasAmounts);
            sis.processConditionContainer.SetActive(hasProcess);
            if (hasProcess)
            {
                sis.RefreshProcessConditions();
            }
            if (id != null)
            {
                descText = "";
            }
            else if (target.TryGetComponent(out InfoDescription description))
            {
                descText = description.description;
            }
            else if (target.TryGetComponent(out Building building))
            {
                descText   = building.Def.Effect;
                flavorText = building.Def.Desc;
            }
            else if (target.TryGetComponent(out Edible edible))
            {
                descText = STRINGS.UI.GAMEOBJECTEFFECTS.CALORIES.Format(GameUtil.
                                                                        GetFormattedCalories(edible.FoodInfo.CaloriesPerUnit));
            }
            else if (target.TryGetComponent(out CellSelectionObject cso))
            {
                descText = cso.element.FullDescription(false);
            }
            else if (target.TryGetComponent(out PrimaryElement pe))
            {
                var element = ElementLoader.FindElementByHash(pe.ElementID);
                descText = (element != null) ? element.FullDescription(false) : "";
            }
            bool showInfo = id == null && (!descText.IsNullOrWhiteSpace() || !flavorText.
                                           IsNullOrWhiteSpace() || hasEffects);

            descriptionContainer.descriptors.gameObject.SetActive(hasEffects);
            if (hasEffects)
            {
                descriptionContainer.descriptors.SetDescriptors(effects);
            }
            descriptionContainer.gameObject.SetActive(showInfo);
            if (descText != null)
            {
                descriptionContainer.description.SetText(descText);
            }
            if (flavorText != null)
            {
                descriptionContainer.flavour.SetText(flavorText);
            }
            sis.infoPanel.gameObject.SetActive(showInfo);
            descriptionContainer.flavour.gameObject.SetActive(!string.IsNullOrWhiteSpace(
                                                                  flavorText));
            storageParent.HeaderLabel.SetText((id != null) ? DETAILTABS.DETAILS.
                                              GROUPNAME_MINION_CONTENTS : DETAILTABS.DETAILS.GROUPNAME_CONTENTS);
            if (lastSelection.fertility == null)
            {
                sis.fertilityPanel.gameObject.SetActive(false);
            }
            sis.rocketStatusContainer.gameObject.SetActive(lastSelection.
                                                           rocketInterface != null || lastSelection.rocketModule != null);
        }
Exemplo n.º 25
0
        protected override void ConduitTick(float delta)
        {
            if (!AlwaysConsume && !operational.IsOperational)
            {
                return;
            }
            IConduitFlow conduitFlow = GetConduitManager();

            if (ConduitType != ConduitType.Solid)
            {
                ConduitFlow mngr = conduitFlow as ConduitFlow;
                ConduitFlow.ConduitContents contents = mngr.GetContents(portCell);
                if (contents.mass <= 0)
                {
                    return;
                }
                Element element         = ElementLoader.FindElementByHash(contents.element);
                bool    matchesTag      = StoreTag == GameTags.Any || element.HasTag(StoreTag);
                float   rateAmount      = ConsumptionRate * delta;
                float   maxTake         = 0f;
                float   storageContains = storage.MassStored();
                float   storageLeft     = storage.capacityKg - storageContains;
                float   portContains    = StoreTag == GameTags.Any ? storageContains : storage.GetMassAvailable(StoreTag);
                float   portLeft        = MaximumStore - portContains;
                maxTake = Mathf.Min(storageLeft, portLeft);
                maxTake = Mathf.Min(rateAmount, maxTake);
                float removed = 0f;
                if (maxTake > 0f)
                {
                    ConduitFlow.ConduitContents removedContents = mngr.RemoveElement(portCell, maxTake);
                    removed             = removedContents.mass;
                    LastConsumedElement = removedContents.element;
                    float ratio = removed / contents.mass;
                    if (!matchesTag)
                    {
                        BuildingHP.DamageSourceInfo damage = new BuildingHP.DamageSourceInfo
                        {
                            damage    = 1,
                            source    = BUILDINGS.DAMAGESOURCES.BAD_INPUT_ELEMENT,
                            popString = UI.GAMEOBJECTEFFECTS.DAMAGE_POPS.WRONG_ELEMENT
                        };
                        Trigger((int)GameHashes.DoBuildingDamage, damage);
                        if (WrongElement == WrongElementResult.Dump)
                        {
                            int buildingCell = Grid.PosToCell(_parent.transform.GetPosition());
                            SimMessages.AddRemoveSubstance(buildingCell, contents.element, CellEventLogger.Instance.ConduitConsumerWrongElement, removed, contents.temperature, contents.diseaseIdx, contents.diseaseIdx);
                            return;
                        }
                    }
                    if (ConduitType == ConduitType.Gas)
                    {
                        if (!element.IsGas)
                        {
                            Debug.LogWarning($"[MultIO] Gas input port attempted to consume non gass: {element.id.ToString()}");
                        }
                        else
                        {
                            storage.AddGasChunk(element.id, removed, contents.temperature, contents.diseaseIdx, contents.diseaseCount, KeepZeroMassObject, false);
                        }
                    }
                    else if (ConduitType == ConduitType.Liquid)
                    {
                        if (!element.IsLiquid)
                        {
                            Debug.LogWarning($"[MultIO] Liquid input port attempted to consume non liquid: {element.id.ToString()}");
                        }
                        else
                        {
                            storage.AddLiquid(element.id, removed, contents.temperature, contents.diseaseIdx, contents.diseaseCount, KeepZeroMassObject, false);
                        }
                    }
                }
            }
            else
            {
                SolidConduitFlow mngr = conduitFlow as SolidConduitFlow;
                SolidConduitFlow.ConduitContents contents = mngr.GetContents(portCell);
                if (contents.pickupableHandle.IsValid() && (AlwaysConsume || operational.IsOperational))
                {
                    float stored           = StoreTag == GameTags.Any ? storage.MassStored() : storage.GetMassAvailable(StoreTag);
                    float maxStorage       = Mathf.Min(storage.capacityKg, MaximumStore);
                    float availableStorage = Mathf.Max(0f, maxStorage - stored);
                    if (availableStorage > 0f)
                    {
                        Pickupable tmp        = mngr.GetPickupable(contents.pickupableHandle);
                        bool       matchesTag = StoreTag == GameTags.Any || tmp.HasTag(StoreTag);
                        if (matchesTag)
                        {
                            if (tmp.PrimaryElement.Mass <= stored || tmp.PrimaryElement.Mass > maxStorage)
                            {
                                Pickupable take = mngr.RemovePickupable(portCell);
                                if (take != null)
                                {
                                    storage.Store(take.gameObject, true);
                                }
                            }
                        }
                        else
                        {
                            Pickupable take = mngr.RemovePickupable(portCell);
                            take.transform.SetPosition(Grid.CellToPos(portCell));
                            //TODO: Add a PopFX. Likely will not do damage.
                        }
                    }
                }
            }
        }
Exemplo n.º 26
0
    private void SetPanels(GameObject target)
    {
        MinionIdentity            component  = target.GetComponent <MinionIdentity>();
        Amounts                   amounts    = target.GetAmounts();
        PrimaryElement            component2 = target.GetComponent <PrimaryElement>();
        BuildingComplete          component3 = target.GetComponent <BuildingComplete>();
        BuildingUnderConstruction component4 = target.GetComponent <BuildingUnderConstruction>();
        CellSelectionObject       component5 = target.GetComponent <CellSelectionObject>();
        InfoDescription           component6 = target.GetComponent <InfoDescription>();
        Edible component7 = target.GetComponent <Edible>();

        attributeLabels.ForEach(delegate(LocText x)
        {
            UnityEngine.Object.Destroy(x.gameObject);
        });
        attributeLabels.Clear();
        vitalsPanel.gameObject.SetActive(amounts != null);
        string text  = string.Empty;
        string text2 = string.Empty;

        if (amounts != null)
        {
            vitalsContainer.selectedEntity = selectedTarget;
            Uprootable component8 = selectedTarget.gameObject.GetComponent <Uprootable>();
            if ((UnityEngine.Object)component8 != (UnityEngine.Object)null)
            {
                vitalsPanel.gameObject.SetActive((UnityEngine.Object)component8.GetPlanterStorage != (UnityEngine.Object)null);
            }
            WiltCondition component9 = selectedTarget.gameObject.GetComponent <WiltCondition>();
            if ((UnityEngine.Object)component9 != (UnityEngine.Object)null)
            {
                vitalsPanel.gameObject.SetActive(true);
            }
        }
        if ((bool)component)
        {
            text = string.Empty;
        }
        else if ((bool)component6)
        {
            text = component6.description;
        }
        else if ((UnityEngine.Object)component3 != (UnityEngine.Object)null)
        {
            text  = component3.Def.Effect;
            text2 = component3.Def.Desc;
        }
        else if ((UnityEngine.Object)component4 != (UnityEngine.Object)null)
        {
            text  = component4.Def.Effect;
            text2 = component4.Def.Desc;
        }
        else if ((UnityEngine.Object)component7 != (UnityEngine.Object)null)
        {
            EdiblesManager.FoodInfo foodInfo = component7.FoodInfo;
            text += string.Format(UI.GAMEOBJECTEFFECTS.CALORIES, GameUtil.GetFormattedCalories(foodInfo.CaloriesPerUnit, GameUtil.TimeSlice.None, true));
        }
        else if ((UnityEngine.Object)component5 != (UnityEngine.Object)null)
        {
            text = component5.element.FullDescription(false);
        }
        else if ((UnityEngine.Object)component2 != (UnityEngine.Object)null)
        {
            Element element = ElementLoader.FindElementByHash(component2.ElementID);
            text = ((element == null) ? string.Empty : element.FullDescription(false));
        }
        List <Descriptor> gameObjectEffects = GameUtil.GetGameObjectEffects(target, true);
        bool flag = gameObjectEffects.Count > 0;

        descriptionContainer.gameObject.SetActive(flag);
        descriptionContainer.descriptors.gameObject.SetActive(flag);
        if (flag)
        {
            descriptionContainer.descriptors.SetDescriptors(gameObjectEffects);
        }
        descriptionContainer.description.text = text;
        descriptionContainer.flavour.text     = text2;
        infoPanel.gameObject.SetActive((UnityEngine.Object)component == (UnityEngine.Object)null);
        descriptionContainer.gameObject.SetActive(infoPanel.activeSelf);
        descriptionContainer.flavour.gameObject.SetActive(text2 != string.Empty && text2 != "\n");
        if (vitalsPanel.gameObject.activeSelf && amounts.Count == 0)
        {
            vitalsPanel.gameObject.SetActive(false);
        }
    }
Exemplo n.º 27
0
    public override void ConfigureBuildingTemplate(GameObject go, Tag prefab_tag)
    {
        go.AddOrGet <DropAllWorkable>();
        go.AddOrGet <BuildingComplete>().isManuallyOperated = true;
        ComplexFabricator complexFabricator = go.AddOrGet <ComplexFabricator>();

        complexFabricator.sideScreenStyle   = ComplexFabricatorSideScreen.StyleSetting.ListQueueHybrid;
        complexFabricator.duplicantOperated = true;
        go.AddOrGet <FabricatorIngredientStatusManager>();
        go.AddOrGet <CopyBuildingSettings>();
        ComplexFabricatorWorkable complexFabricatorWorkable = go.AddOrGet <ComplexFabricatorWorkable>();

        BuildingTemplates.CreateComplexFabricatorStorage(go, complexFabricator);
        complexFabricatorWorkable.overrideAnims = new KAnimFile[1]
        {
            Assets.GetAnim("anim_interacts_rockrefinery_kanim")
        };
        complexFabricatorWorkable.workingPstComplete = "working_pst_complete";
        Tag            tag  = SimHashes.Sand.CreateTag();
        List <Element> list = ElementLoader.elements.FindAll((Element e) => e.HasTag(GameTags.Crushable));
        ComplexRecipe  complexRecipe;

        foreach (Element item in list)
        {
            ComplexRecipe.RecipeElement[] array = new ComplexRecipe.RecipeElement[1]
            {
                new ComplexRecipe.RecipeElement(item.tag, 100f)
            };
            ComplexRecipe.RecipeElement[] array2 = new ComplexRecipe.RecipeElement[1]
            {
                new ComplexRecipe.RecipeElement(tag, 100f)
            };
            string obsolete_id = ComplexRecipeManager.MakeObsoleteRecipeID("RockCrusher", item.tag);
            string text        = ComplexRecipeManager.MakeRecipeID("RockCrusher", array, array2);
            complexRecipe             = new ComplexRecipe(text, array, array2);
            complexRecipe.time        = 40f;
            complexRecipe.description = string.Format(STRINGS.BUILDINGS.PREFABS.ROCKCRUSHER.RECIPE_DESCRIPTION, item.name, tag.ProperName());
            complexRecipe.nameDisplay = ComplexRecipe.RecipeNameDisplay.IngredientToResult;
            complexRecipe.fabricators = new List <Tag>
            {
                TagManager.Create("RockCrusher")
            };
            ComplexRecipeManager.Get().AddObsoleteIDMapping(obsolete_id, text);
        }
        List <Element> list2 = ElementLoader.elements.FindAll((Element e) => e.IsSolid && e.HasTag(GameTags.Metal));

        foreach (Element item2 in list2)
        {
            Element highTempTransition = item2.highTempTransition;
            Element lowTempTransition  = highTempTransition.lowTempTransition;
            if (lowTempTransition != item2)
            {
                ComplexRecipe.RecipeElement[] array3 = new ComplexRecipe.RecipeElement[1]
                {
                    new ComplexRecipe.RecipeElement(item2.tag, 100f)
                };
                ComplexRecipe.RecipeElement[] array4 = new ComplexRecipe.RecipeElement[2]
                {
                    new ComplexRecipe.RecipeElement(lowTempTransition.tag, 50f),
                    new ComplexRecipe.RecipeElement(tag, 50f)
                };
                string obsolete_id2 = ComplexRecipeManager.MakeObsoleteRecipeID("RockCrusher", lowTempTransition.tag);
                string text2        = ComplexRecipeManager.MakeRecipeID("RockCrusher", array3, array4);
                complexRecipe             = new ComplexRecipe(text2, array3, array4);
                complexRecipe.time        = 40f;
                complexRecipe.description = string.Format(STRINGS.BUILDINGS.PREFABS.ROCKCRUSHER.METAL_RECIPE_DESCRIPTION, lowTempTransition.name, item2.name);
                complexRecipe.nameDisplay = ComplexRecipe.RecipeNameDisplay.IngredientToResult;
                complexRecipe.fabricators = new List <Tag>
                {
                    TagManager.Create("RockCrusher")
                };
                ComplexRecipeManager.Get().AddObsoleteIDMapping(obsolete_id2, text2);
            }
        }
        Element element = ElementLoader.FindElementByHash(SimHashes.Lime);

        ComplexRecipe.RecipeElement[] array5 = new ComplexRecipe.RecipeElement[1]
        {
            new ComplexRecipe.RecipeElement("EggShell", 5f)
        };
        ComplexRecipe.RecipeElement[] array6 = new ComplexRecipe.RecipeElement[1]
        {
            new ComplexRecipe.RecipeElement(ElementLoader.FindElementByHash(SimHashes.Lime).tag, 5f)
        };
        string obsolete_id3 = ComplexRecipeManager.MakeObsoleteRecipeID("RockCrusher", element.tag);
        string text3        = ComplexRecipeManager.MakeRecipeID("RockCrusher", array5, array6);

        complexRecipe             = new ComplexRecipe(text3, array5, array6);
        complexRecipe.time        = 40f;
        complexRecipe.description = string.Format(STRINGS.BUILDINGS.PREFABS.ROCKCRUSHER.LIME_RECIPE_DESCRIPTION, SimHashes.Lime.CreateTag().ProperName(), MISC.TAGS.EGGSHELL);
        complexRecipe.nameDisplay = ComplexRecipe.RecipeNameDisplay.IngredientToResult;
        complexRecipe.fabricators = new List <Tag>
        {
            TagManager.Create("RockCrusher")
        };
        ComplexRecipeManager.Get().AddObsoleteIDMapping(obsolete_id3, text3);
        Element element2 = ElementLoader.FindElementByHash(SimHashes.Lime);

        ComplexRecipe.RecipeElement[] array7 = new ComplexRecipe.RecipeElement[1]
        {
            new ComplexRecipe.RecipeElement("BabyCrabShell", 1f)
        };
        ComplexRecipe.RecipeElement[] array8 = new ComplexRecipe.RecipeElement[1]
        {
            new ComplexRecipe.RecipeElement(element2.tag, 5f)
        };
        string id = ComplexRecipeManager.MakeRecipeID("RockCrusher", array7, array8);

        complexRecipe             = new ComplexRecipe(id, array7, array8);
        complexRecipe.time        = 40f;
        complexRecipe.description = string.Format(STRINGS.BUILDINGS.PREFABS.ROCKCRUSHER.LIME_RECIPE_DESCRIPTION, SimHashes.Lime.CreateTag().ProperName(), ITEMS.INDUSTRIAL_PRODUCTS.CRAB_SHELL.NAME);
        complexRecipe.nameDisplay = ComplexRecipe.RecipeNameDisplay.IngredientToResult;
        complexRecipe.fabricators = new List <Tag>
        {
            TagManager.Create("RockCrusher")
        };
        Element element3 = ElementLoader.FindElementByHash(SimHashes.Lime);

        ComplexRecipe.RecipeElement[] array9 = new ComplexRecipe.RecipeElement[1]
        {
            new ComplexRecipe.RecipeElement("CrabShell", 1f)
        };
        ComplexRecipe.RecipeElement[] array10 = new ComplexRecipe.RecipeElement[1]
        {
            new ComplexRecipe.RecipeElement(element3.tag, 10f)
        };
        string id2 = ComplexRecipeManager.MakeRecipeID("RockCrusher", array9, array10);

        complexRecipe             = new ComplexRecipe(id2, array9, array10);
        complexRecipe.time        = 40f;
        complexRecipe.description = string.Format(STRINGS.BUILDINGS.PREFABS.ROCKCRUSHER.LIME_RECIPE_DESCRIPTION, SimHashes.Lime.CreateTag().ProperName(), ITEMS.INDUSTRIAL_PRODUCTS.CRAB_SHELL.NAME);
        complexRecipe.nameDisplay = ComplexRecipe.RecipeNameDisplay.IngredientToResult;
        complexRecipe.fabricators = new List <Tag>
        {
            TagManager.Create("RockCrusher")
        };
        ComplexRecipe.RecipeElement[] array11 = new ComplexRecipe.RecipeElement[1]
        {
            new ComplexRecipe.RecipeElement(ElementLoader.FindElementByHash(SimHashes.Fossil).tag, 100f)
        };
        ComplexRecipe.RecipeElement[] array12 = new ComplexRecipe.RecipeElement[2]
        {
            new ComplexRecipe.RecipeElement(ElementLoader.FindElementByHash(SimHashes.Lime).tag, 5f),
            new ComplexRecipe.RecipeElement(ElementLoader.FindElementByHash(SimHashes.SedimentaryRock).tag, 95f)
        };
        string id3 = ComplexRecipeManager.MakeRecipeID("RockCrusher", array11, array12);

        complexRecipe             = new ComplexRecipe(id3, array11, array12);
        complexRecipe.time        = 40f;
        complexRecipe.description = string.Format(STRINGS.BUILDINGS.PREFABS.ROCKCRUSHER.LIME_FROM_LIMESTONE_RECIPE_DESCRIPTION, SimHashes.Fossil.CreateTag().ProperName(), SimHashes.SedimentaryRock.CreateTag().ProperName(), SimHashes.Lime.CreateTag().ProperName());
        complexRecipe.nameDisplay = ComplexRecipe.RecipeNameDisplay.IngredientToResult;
        complexRecipe.fabricators = new List <Tag>
        {
            TagManager.Create("RockCrusher")
        };
        float num = 5E-05f;

        ComplexRecipe.RecipeElement[] array13 = new ComplexRecipe.RecipeElement[1]
        {
            new ComplexRecipe.RecipeElement(SimHashes.Salt.CreateTag(), 100f)
        };
        ComplexRecipe.RecipeElement[] array14 = new ComplexRecipe.RecipeElement[2]
        {
            new ComplexRecipe.RecipeElement(TableSaltConfig.ID.ToTag(), 100f * num),
            new ComplexRecipe.RecipeElement(SimHashes.Sand.CreateTag(), 100f * (1f - num))
        };
        string id4 = ComplexRecipeManager.MakeRecipeID("RockCrusher", array13, array14);

        complexRecipe             = new ComplexRecipe(id4, array13, array14);
        complexRecipe.time        = 40f;
        complexRecipe.description = string.Format(STRINGS.BUILDINGS.PREFABS.ROCKCRUSHER.RECIPE_DESCRIPTION, SimHashes.Salt.CreateTag().ProperName(), ITEMS.INDUSTRIAL_PRODUCTS.TABLE_SALT.NAME);
        complexRecipe.nameDisplay = ComplexRecipe.RecipeNameDisplay.IngredientToResult;
        complexRecipe.fabricators = new List <Tag>
        {
            TagManager.Create("RockCrusher")
        };
        Prioritizable.AddRef(go);
    }
        private void ConvertMass()
        {
            float             filterAmt = 0;
            List <GameObject> items     = this.storage.items;
            PrimaryElement    elem      = null;

            foreach (GameObject item in items)
            {
                elem = item.GetComponent <PrimaryElement>();
                if (elem.ElementID == SimHashes.BleachStone)
                {
                    filterAmt += elem.Mass;
                }
            }
            if (filterAmt <= 0)
            {
                return;
            }
            float       maxGerms      = Mathf.Min(GERMS_PER_KG * MAX_KG_PER_SEC, (int)(filterAmt * GERMS_PER_KG));
            float       removedAmount = 0;
            ConduitFlow flowManager   = Conduit.GetFlowManager(ConduitType.Liquid);

            if (!flowManager.HasConduit(inCell) || !flowManager.HasConduit(outCell))
            {
                return;
            }
            foreach (GameObject item in items)
            {
                elem = item.GetComponent <PrimaryElement>();
                if (elem.Element.IsLiquid)
                {
                    float mass    = Mathf.Min(10f, elem.Mass);
                    float disease = elem.DiseaseCount / elem.Mass * mass;
                    if (elem.DiseaseIdx == Byte.MaxValue)
                    {
                        disease = 0;
                    }
                    if (disease > maxGerms)
                    {
                        mass    = mass * maxGerms / disease;
                        disease = maxGerms;
                    }
                    float trueMass = flowManager.AddElement(outCell, elem.ElementID, mass, elem.Temperature, Byte.MaxValue, 0);
                    if (trueMass < mass)
                    {
                        disease = disease * trueMass / mass;
                        mass    = trueMass;
                    }
                    elem.Mass -= mass;
                    elem.ModifyDiseaseCount(-(int)disease, "");
                    removedAmount = disease;
                    Game.Instance.accumulators.Accumulate(fluidProcessedLastTick, mass);
                    if (mass > 0)
                    {
                        break;
                    }
                }
            }
            if (removedAmount > 0)
            {
                float removal = (float)removedAmount / GERMS_PER_KG;
                storage.ConsumeIgnoringDisease(ElementLoader.FindElementByHash(filterIn).tag, removal);
                Game.Instance.accumulators.Accumulate(filterConsumedLastTick, removal);
                if (EMIT_CHLORINE)
                {
                    float   addition      = (float)removedAmount / GERMS_PER_KG;
                    Element elementByHash = ElementLoader.FindElementByHash(filterOut);
                    Vector3 outVector3    = new Vector3(this.transform.GetPosition().x, this.transform.GetPosition().y, 0.0f);
                    int     outCell       = Grid.PosToCell(outVector3);
                    SimMessages.AddRemoveSubstance(outCell, filterOut, CellEventLogger.Instance.OxygenModifierSimUpdate, addition, 273.15f + 45f, Byte.MaxValue, 0);
                }
            }
            //TODO: find out what the nice name is
            this.storage.Trigger(-1697596308, (object)this.gameObject);
        }
Exemplo n.º 29
0
        private void ConduitUpdate(float dt)
        {
            //If the building is broken, nothing normally stops it from operating!
            if (gameObject.GetComponent <BuildingHP>().HitPoints == 0)
            {
                return;
            }
            ConduitFlow manager = Conduit.GetFlowManager(valveBase.conduitType);

            ConduitFlow.Conduit inputConduit  = manager.GetConduit(InputCell);
            ConduitFlow.Conduit outputConduit = manager.GetConduit(OutputCell);
            if (!manager.HasConduit(InputCell) || !manager.HasConduit(OutputCell))
            {
                valveBase.UpdateAnim();
            }
            else
            {
                ConduitFlow.ConduitContents inputContents = inputConduit.GetContents(manager);
                if (!bufferMode)
                {
                    float     valveFlow = valveBase.CurrentFlow * dt;
                    float     maxFlow;
                    float     temp;
                    SimHashes element;
                    byte      diseaseIdx;
                    float     ratio;
                    int       disease_count;
                    bool      fromStorage = false;
                    Tag       storedTag   = Tag.Invalid;

                    if (!storage.IsEmpty())
                    {
                        //If there is still mass within the storage but we are not in buffer mode, take nothing in until the storage is emptied! (while still following the limit mode settings)
                        fromStorage = true;
                        GameObject     item          = storage.items.FirstOrDefault();
                        PrimaryElement storedPrimary = item.GetComponent <PrimaryElement>();
                        maxFlow       = Mathf.Min(valveFlow, storedPrimary.Mass);
                        element       = storedPrimary.ElementID;
                        temp          = storedPrimary.Temperature;
                        diseaseIdx    = storedPrimary.DiseaseIdx;
                        ratio         = maxFlow / storedPrimary.Mass;
                        disease_count = (int)(ratio * (float)storedPrimary.DiseaseCount);
                        storedTag     = storedPrimary.Element.tag;
                    }
                    else
                    {
                        maxFlow       = Mathf.Min(inputContents.mass, valveBase.CurrentFlow * dt);
                        element       = inputContents.element;
                        temp          = inputContents.temperature;
                        diseaseIdx    = inputContents.diseaseIdx;
                        ratio         = maxFlow / inputContents.mass;
                        disease_count = (int)(ratio * (float)inputContents.diseaseCount);
                    }

                    if (maxFlow > 0f)
                    {
                        float movableMass = manager.AddElement(OutputCell, element, maxFlow, temp, diseaseIdx, disease_count);
                        Game.Instance.accumulators.Accumulate(flowAccumulator, movableMass);
                        if (movableMass > 0f)
                        {
                            //If we took the mass from storage, make sure we use the right function
                            if (!fromStorage)
                            {
                                manager.RemoveElement(InputCell, movableMass);
                            }
                            else
                            {
                                storage.ConsumeIgnoringDisease(storedTag, movableMass);
                            }
                        }
                    }
                }
                else
                {
                    float      availableInput = inputContents.mass;
                    GameObject storedItem     = storage.items.FirstOrDefault();
                    Element    storedElement  = storedItem?.GetComponent <PrimaryElement>().Element;
                    float      storedMass     = storedItem != null?storedItem.GetComponent <PrimaryElement>().Mass : 0f;

                    float maxOutputCapacity = Integration.GetMaxCapacityAt(OutputCell, valveBase.conduitType);

                    //Override the set current flow if the output pipe cannot support a flow that large. This prevents the valve from storing, for example, 3KG, when it can only output 1KG at a time.
                    float minimumOutput = Mathf.Min(maxOutputCapacity, valveBase.CurrentFlow);
                    storage.capacityKg = maxOutputCapacity;

                    float movableToStorage = Mathf.Min(availableInput, storage.RemainingCapacity());
                    if (movableToStorage > 0f)
                    {
                        Element inputElement       = ElementLoader.FindElementByHash(inputContents.element);
                        float   ratio              = movableToStorage / inputContents.mass;
                        int     transferredDisease = (int)((float)inputContents.diseaseCount * ratio);
                        if (inputElement == storedElement || storedItem == null)
                        {
                            if (valveBase.conduitType == ConduitType.Gas)
                            {
                                storage.AddGasChunk(inputContents.element, movableToStorage, inputContents.temperature, inputContents.diseaseIdx, transferredDisease, false);
                            }
                            else
                            {
                                storage.AddLiquid(inputContents.element, movableToStorage, inputContents.temperature, inputContents.diseaseIdx, transferredDisease, false);
                            }
                            storedMass += movableToStorage;
                            if (storedItem == null)
                            {
                                storedElement = inputElement;
                            }
                        }
                        else
                        {
                            //The input has a different element than what is in storage! Deal damage and remove however much mass attempted to flow into the valve.
                            Trigger(-794517298, new BuildingHP.DamageSourceInfo
                            {
                                damage    = 1,
                                source    = STRINGS.BUILDINGS.DAMAGESOURCES.BAD_INPUT_ELEMENT,
                                popString = STRINGS.UI.GAMEOBJECTEFFECTS.DAMAGE_POPS.WRONG_ELEMENT
                            });
                            SimMessages.AddRemoveSubstance(Grid.PosToCell(base.transform.GetPosition()), inputContents.element, CellEventLogger.Instance.ConduitConsumerWrongElement, movableToStorage, inputContents.temperature, inputContents.diseaseIdx, transferredDisease);
                        }
                        manager.RemoveElement(InputCell, movableToStorage);
                    }

                    ConduitFlow.ConduitContents outputContents = outputConduit.GetContents(manager);
                    float   initialOutputMass = outputContents.mass;
                    Element outputElement     = ElementLoader.FindElementByHash(outputContents.element);
                    //If we can create a packet of at least size CurrentFlow, including if we combined the valve's output into what is already in the output conduit
                    //Debug.Log($"[TogglableValve] InitialOut: {initialOutputMass}, StoredMass: {storedMass}, MinimumOutput: {minimumOutput}, MaxOutputCapacity: {maxOutputCapacity}, AvailableInput: {availableInput}, MovableToStorage: {movableToStorage}");
                    if (initialOutputMass + storedMass >= minimumOutput && (storedElement == outputElement || outputElement == null || outputElement.id == SimHashes.Vacuum))
                    {
                        float movableToOut = Mathf.Min(storedMass, maxOutputCapacity - initialOutputMass);
                        if (movableToOut > 0f)
                        {
                            PrimaryElement storedPrimary      = storage.items.FirstOrDefault()?.GetComponent <PrimaryElement>();
                            float          ratio              = movableToOut / storedMass;
                            int            transferredDisease = (int)((float)storedPrimary.DiseaseCount * ratio);
                            float          totalMovedOut      = manager.AddElement(OutputCell, storedPrimary.ElementID, storedMass, storedPrimary.Temperature, storedPrimary.DiseaseIdx, transferredDisease);
                            Game.Instance.accumulators.Accumulate(flowAccumulator, totalMovedOut);
                            if (totalMovedOut > 0f)
                            {
                                storage.ConsumeIgnoringDisease(storedPrimary.Element.tag, totalMovedOut);
                            }
                        }
                    }
                }
                valveBase.UpdateAnim();
            }
        }
Exemplo n.º 30
0
    private void ConfgiureRecipes()
    {
        Tag   tag       = SimHashes.Ceramic.CreateTag();
        Tag   material  = SimHashes.Clay.CreateTag();
        Tag   material2 = SimHashes.Carbon.CreateTag();
        float num       = 100f;
        float num2      = 25f;

        ComplexRecipe.RecipeElement[] array = new ComplexRecipe.RecipeElement[2]
        {
            new ComplexRecipe.RecipeElement(material, num),
            new ComplexRecipe.RecipeElement(material2, num2)
        };
        ComplexRecipe.RecipeElement[] array2 = new ComplexRecipe.RecipeElement[1]
        {
            new ComplexRecipe.RecipeElement(tag, num)
        };
        string        obsolete_id   = ComplexRecipeManager.MakeObsoleteRecipeID("Kiln", tag);
        string        text          = ComplexRecipeManager.MakeRecipeID("Kiln", array, array2);
        ComplexRecipe complexRecipe = new ComplexRecipe(text, array, array2);

        complexRecipe.time        = 40f;
        complexRecipe.description = string.Format(STRINGS.BUILDINGS.PREFABS.EGGCRACKER.RECIPE_DESCRIPTION, ElementLoader.FindElementByHash(SimHashes.Clay).name, ElementLoader.FindElementByHash(SimHashes.Ceramic).name);
        complexRecipe.fabricators = new List <Tag>
        {
            TagManager.Create("Kiln")
        };
        complexRecipe.nameDisplay = ComplexRecipe.RecipeNameDisplay.Result;
        ComplexRecipeManager.Get().AddObsoleteIDMapping(obsolete_id, text);
        Tag tag2 = SimHashes.RefinedCarbon.CreateTag();

        ComplexRecipe.RecipeElement[] array3 = new ComplexRecipe.RecipeElement[1]
        {
            new ComplexRecipe.RecipeElement(material2, num + num2)
        };
        ComplexRecipe.RecipeElement[] array4 = new ComplexRecipe.RecipeElement[1]
        {
            new ComplexRecipe.RecipeElement(tag2, num)
        };
        string obsolete_id2 = ComplexRecipeManager.MakeObsoleteRecipeID("Kiln", tag2);
        string text2        = ComplexRecipeManager.MakeRecipeID("Kiln", array3, array4);

        complexRecipe             = new ComplexRecipe(text2, array3, array4);
        complexRecipe.time        = 40f;
        complexRecipe.description = string.Format(STRINGS.BUILDINGS.PREFABS.EGGCRACKER.RECIPE_DESCRIPTION, ElementLoader.FindElementByHash(SimHashes.Carbon).name, ElementLoader.FindElementByHash(SimHashes.RefinedCarbon).name);
        complexRecipe.fabricators = new List <Tag>
        {
            TagManager.Create("Kiln")
        };
        complexRecipe.nameDisplay = ComplexRecipe.RecipeNameDisplay.Result;
        ComplexRecipeManager.Get().AddObsoleteIDMapping(obsolete_id2, text2);
    }