示例#1
0
            static void Postfix(MetalRefineryConfig __instance, ref GameObject go)
            {
                //bool MetalDupeWork = DynamicBuildingsState.StateManager.State.MetalDupe;
                LiquidCooledRefinery liquidCooledRefinery = go.AddOrGet <LiquidCooledRefinery>();

                liquidCooledRefinery.duplicantOperated = true;
            }
示例#2
0
 private static void Postfix(LiquidCooledRefinery __instance)
 {
     if (__instance is LiquidCooledFueledRefinery || SmelterOptions.Instance.MetalRefineryDropOverheatedCoolant)
     {
         __instance.DropOverheatedCoolant();
     }
 }
示例#3
0
        // формулы расчета тепла и прироста температуры для порции хладагента массой minCoolantMass
        // для правильности расчета должны быть аналогичны формулам внутри LiquidCooledRefinery.SpawnOrderProduct
        public static float CalculateEnergyDelta(this LiquidCooledRefinery @this, ComplexRecipe recipe)
        {
            var firstresult = recipe.results[0];
            var element     = ElementLoader.GetElement(firstresult.material);

            return(GameUtil.CalculateEnergyDeltaForElementChange(firstresult.amount, element.specificHeatCapacity, element.highTemp, @this.outputTemperature) * @this.thermalFudge);
        }
示例#4
0
            private static void Prefix(LiquidCooledRefinery __instance)
            {
                var  lcfr             = (__instance as LiquidCooledFueledRefinery);
                bool allowOverheating = lcfr?.AllowOverheating ?? false;

                if (lcfr != null || SmelterOptions.Instance.MetalRefineryReuseCoolant)
                {
                    __instance.ReuseCoolant(allowOverheating);
                }
            }
示例#5
0
            static void Postfix(MetalRefineryConfig __instance, ref GameObject go)
            {
                bool DoTheFudge = DynamicBuildingsState.StateManager.State.Fudge;
                LiquidCooledRefinery liquidCooledRefinery = go.AddOrGet <LiquidCooledRefinery>();

                if (DoTheFudge)
                {
                    liquidCooledRefinery.thermalFudge = 0.8f;
                }
                else
                {
                    liquidCooledRefinery.thermalFudge = 0f;
                }
            }
示例#6
0
        // переиспользование отработанного хладагента
        internal static void ReuseCoolant(this LiquidCooledRefinery @this, bool allowOverheating = false)
        {
            // высчитать бесопастное повышение температуры для текущего рецепта
            // брать из выходного хранилища, если температура бесопастна или разрешен перегрев. помещать в рабочее
            float energyDelta = @this.CalculateEnergyDelta(@this.CurrentWorkingOrder);

            var pooledList = ListPool <GameObject, LiquidCooledFueledRefinery> .Allocate();

            @this.outStorage.Find(@this.coolantTag, pooledList);

            float remaining_mass = @this.minCoolantMass;

            foreach (GameObject gameObject in pooledList)
            {
                var   pickupable       = gameObject.GetComponent <Pickupable>();
                var   primaryElement   = pickupable.PrimaryElement;
                float mass             = primaryElement.Mass;
                float temperatureDelta = @this.CalculateTemperatureDelta(primaryElement, energyDelta);

                if (mass > 0 && (allowOverheating || (primaryElement.Temperature + temperatureDelta < primaryElement.Element.highTemp)))
                {
                    if (mass <= remaining_mass)
                    {
                        @this.outStorage.Transfer(gameObject, @this.buildStorage, false, true);
                        remaining_mass -= mass;
                    }
                    else
                    {
                        var take = pickupable.Take(remaining_mass);
                        @this.buildStorage.Store(take.gameObject, true);
                        remaining_mass -= take.PrimaryElement.Mass;
                    }
                    if (remaining_mass <= 0)
                    {
                        break;
                    }
                }
            }
            pooledList.Recycle();

            // недостающую массу добрать из входного хранилища
            while (remaining_mass > 0f && @this.buildStorage.GetAmountAvailable(@this.coolantTag) < @this.minCoolantMass && @this.inStorage.GetAmountAvailable(@this.coolantTag) > 0f)
            {
                float mass = @this.inStorage.Transfer(@this.buildStorage, @this.coolantTag, remaining_mass, false, true);
                remaining_mass -= mass;
            }
        }
示例#7
0
        // сброс перегретого хладагента
        internal static void DropOverheatedCoolant(this LiquidCooledRefinery @this)
        {
            var pooledList = ListPool <GameObject, LiquidCooledRefinery> .Allocate();

            var position = @this.transform.GetPosition() + @this.outputOffset;

            @this.outStorage.Find(@this.coolantTag, pooledList);
            foreach (GameObject gameObject in pooledList)
            {
                var primaryElement = gameObject.GetComponent <PrimaryElement>();
                if (primaryElement.Temperature > primaryElement.Element.highTemp)
                {
                    @this.outStorage.Drop(gameObject)?.GetComponent <Dumpable>()?.Dump(position);
                }
            }
            pooledList.Recycle();
        }
    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);
    }
示例#9
0
 public static float CalculateTemperatureDelta(this LiquidCooledRefinery @this, PrimaryElement primaryElement, float energyDelta)
 {
     return(GameUtil.CalculateTemperatureChange(primaryElement.Element.specificHeatCapacity, @this.minCoolantMass, -energyDelta));
 }