Пример #1
0
    private void OnAbsorb(object data)
    {
        Pickupable pickupable = (Pickupable)data;

        if ((UnityEngine.Object)pickupable != (UnityEngine.Object)null)
        {
            PrimaryElement component      = GetComponent <PrimaryElement>();
            PrimaryElement primaryElement = pickupable.PrimaryElement;
            if ((UnityEngine.Object)primaryElement != (UnityEngine.Object)null)
            {
                float temperature = 0f;
                float mass        = component.Mass;
                float mass2       = primaryElement.Mass;
                if (mass > 0f && mass2 > 0f)
                {
                    temperature = SimUtil.CalculateFinalTemperature(mass, component.Temperature, mass2, primaryElement.Temperature);
                }
                else if (primaryElement.Mass > 0f)
                {
                    temperature = primaryElement.Temperature;
                }
                component.SetMassTemperature(mass + mass2, temperature);
                if ((UnityEngine.Object)CameraController.Instance != (UnityEngine.Object)null)
                {
                    string sound = GlobalAssets.GetSound("Ore_absorb", false);
                    if (sound != null && CameraController.Instance.IsAudibleSound(pickupable.transform.GetPosition(), sound))
                    {
                        PlaySound3D(sound);
                    }
                }
            }
        }
    }
        private void SpawnGeneShuffler()
        {
            // sacrifice morb
            var morb = smi.GetMorb();

            if (morb != null)
            {
                storage.Drop(morb);
                morb.DeleteObject();
            }
            // спавним новый калибратор но без заряда и без лора
            var geneShuffler = GameUtil.KInstantiate(Assets.GetPrefab("GeneShuffler"), gameObject.transform.GetPosition(), Grid.SceneLayer.Building);

            geneShuffler.GetComponent <GeneShuffler>().IsConsumed = true;
            var loreBearer = geneShuffler.GetComponent <LoreBearer>();

            if (loreBearer != null)
            {
                BeenClicked.Set(loreBearer, true);
            }
            var builded = geneShuffler.GetComponent <BuildedGeneShuffler>();

            builded.isBuilded = true;
            // список конструкционных материалов
            var tag_list  = new List <Tag>();
            var mass_list = new List <float>();

            for (int i = 0; i < deconstructable.constructionElements.Length; i++)
            {
                tag_list.Add(deconstructable.constructionElements[i]);
                mass_list.Add(building.Def.Mass[i]);
            }
            // вычисляем конечную температуру и микробов, с учетом самой постройки и хранилищща
            var geneShufflerPE = geneShuffler.GetComponent <PrimaryElement>();
            var MyPE           = GetComponent <PrimaryElement>();

            geneShufflerPE.SetElement(MyPE.ElementID);
            geneShufflerPE.AddDisease(MyPE.DiseaseIdx, MyPE.DiseaseCount, "");
            float mass = MyPE.Mass;
            float temp = MyPE.Temperature;

            for (int i = 0; i < storage.Count; i++)
            {
                var itemPE = storage.items[i].GetComponent <PrimaryElement>();
                tag_list.Add(itemPE.Element.tag);
                mass_list.Add(itemPE.Mass);
                temp  = SimUtil.CalculateFinalTemperature(mass * MyPE.Element.specificHeatCapacity, temp, itemPE.Mass * itemPE.Element.specificHeatCapacity, itemPE.Temperature);
                mass += itemPE.Mass;
                geneShufflerPE.AddDisease(itemPE.DiseaseIdx, itemPE.DiseaseCount, "");
            }
            geneShufflerPE.Temperature = temp;
            geneShuffler.GetComponent <Deconstructable>().constructionElements = tag_list.ToArray();
            builded.constructionMass = mass_list.ToArray();
            storage.ConsumeAllIgnoringDisease();
            geneShuffler.SetActive(true);
            gameObject.DeleteObject();
        }
Пример #3
0
 private void OnSimConsume(Sim.MassConsumedCallback mass_cb_info)
 {
     if (mass_cb_info.mass > 0f)
     {
         this.storedTemperature = SimUtil.CalculateFinalTemperature(this.storedMass, this.storedTemperature, mass_cb_info.mass, mass_cb_info.temperature);
         this.storedMass       += mass_cb_info.mass;
         SimUtil.DiseaseInfo diseaseInfo = SimUtil.CalculateFinalDiseaseInfo(this.diseaseIdx, this.diseaseCount, mass_cb_info.diseaseIdx, mass_cb_info.diseaseCount);
         this.diseaseIdx   = diseaseInfo.idx;
         this.diseaseCount = diseaseInfo.count;
         if (this.storedMass > this.minConvertMass && this.simEmitCBHandle.IsValid())
         {
             Game.Instance.massEmitCallbackManager.GetItem(this.simEmitCBHandle);
             this.gasStorage.AddGasChunk(this.srcElem, this.storedMass, this.storedTemperature, this.diseaseIdx, this.diseaseCount, true, true);
             this.storedMass        = 0f;
             this.storedTemperature = 0f;
             this.diseaseIdx        = 255;
             this.diseaseCount      = 0;
         }
     }
 }
Пример #4
0
 private void OnSimEmitted(Sim.MassEmittedCallback info)
 {
     if (info.suceeded != 1)
     {
         this.storedTemperature = SimUtil.CalculateFinalTemperature(this.storedMass, this.storedTemperature, info.mass, info.temperature);
         this.storedMass       += info.mass;
         if (info.diseaseIdx != 255)
         {
             SimUtil.DiseaseInfo a = new SimUtil.DiseaseInfo
             {
                 idx   = this.diseaseIdx,
                 count = this.diseaseCount
             };
             SimUtil.DiseaseInfo b = new SimUtil.DiseaseInfo
             {
                 idx   = info.diseaseIdx,
                 count = info.diseaseCount
             };
             SimUtil.DiseaseInfo diseaseInfo = SimUtil.CalculateFinalDiseaseInfo(a, b);
             this.diseaseIdx   = diseaseInfo.idx;
             this.diseaseCount = diseaseInfo.count;
         }
     }
 }
Пример #5
0
    private GameObject CraftRecipe(Storage resource_storage, Ingredient[] ingredientTags)
    {
        SimUtil.DiseaseInfo a = SimUtil.DiseaseInfo.Invalid;
        float num             = 0f;
        float num2            = 0f;

        foreach (Ingredient ingredient in ingredientTags)
        {
            GameObject gameObject = resource_storage.FindFirst(ingredient.tag);
            if ((UnityEngine.Object)gameObject != (UnityEngine.Object)null)
            {
                Edible component = gameObject.GetComponent <Edible>();
                if ((bool)component)
                {
                    ReportManager.Instance.ReportValue(ReportManager.ReportType.CaloriesCreated, 0f - component.Calories, StringFormatter.Replace(UI.ENDOFDAYREPORT.NOTES.CRAFTED_USED, "{0}", component.GetProperName()), UI.ENDOFDAYREPORT.NOTES.CRAFTED_CONTEXT);
                }
            }
            resource_storage.ConsumeAndGetDisease(ingredient, out SimUtil.DiseaseInfo disease_info, out float temperature);
            a     = SimUtil.CalculateFinalDiseaseInfo(a, disease_info);
            num   = SimUtil.CalculateFinalTemperature(num2, num, ingredient.amount, temperature);
            num2 += ingredient.amount;
        }
        GameObject prefab      = Assets.GetPrefab(Result);
        GameObject gameObject2 = null;

        if ((UnityEngine.Object)prefab != (UnityEngine.Object)null)
        {
            gameObject2 = GameUtil.KInstantiate(prefab, Grid.SceneLayer.Ore, null, 0);
            PrimaryElement component2 = gameObject2.GetComponent <PrimaryElement>();
            gameObject2.GetComponent <KSelectable>().entityName = Name;
            if ((UnityEngine.Object)component2 != (UnityEngine.Object)null)
            {
                gameObject2.GetComponent <KPrefabID>().RemoveTag(TagManager.Create("Vacuum"));
                if (ResultElementOverride != 0)
                {
                    if ((UnityEngine.Object)component2.GetComponent <ElementChunk>() != (UnityEngine.Object)null)
                    {
                        component2.SetElement(ResultElementOverride);
                    }
                    else
                    {
                        component2.ElementID = ResultElementOverride;
                    }
                }
                component2.Temperature = num;
                component2.Units       = OutputUnits;
            }
            Edible component3 = gameObject2.GetComponent <Edible>();
            if ((bool)component3)
            {
                ReportManager.Instance.ReportValue(ReportManager.ReportType.CaloriesCreated, component3.Calories, StringFormatter.Replace(UI.ENDOFDAYREPORT.NOTES.CRAFTED, "{0}", component3.GetProperName()), UI.ENDOFDAYREPORT.NOTES.CRAFTED_CONTEXT);
            }
            gameObject2.SetActive(true);
            if ((UnityEngine.Object)component2 != (UnityEngine.Object)null)
            {
                component2.AddDisease(a.idx, a.count, "Recipe.CraftRecipe");
            }
            gameObject2.GetComponent <KMonoBehaviour>().Trigger(748399584, null);
        }
        return(gameObject2);
    }