Ejemplo n.º 1
0
 private void OnOperationalChanged(object data)
 {
     operational = (bool)data;
     if (operational)
     {
         foreach (GameObject item in storage.items)
         {
             if ((UnityEngine.Object)item != (UnityEngine.Object)null)
             {
                 SimTemperatureTransfer component = item.GetComponent <SimTemperatureTransfer>();
                 OnItemSimRegistered(component);
             }
         }
     }
     else
     {
         foreach (GameObject item2 in storage.items)
         {
             if ((UnityEngine.Object)item2 != (UnityEngine.Object)null)
             {
                 SimTemperatureTransfer component2 = item2.GetComponent <SimTemperatureTransfer>();
                 Unregister(component2);
             }
         }
     }
 }
Ejemplo n.º 2
0
 private void Unregister(SimTemperatureTransfer stt)
 {
     stt.onSimRegistered = (Action <SimTemperatureTransfer>)Delegate.Remove(stt.onSimRegistered, new Action <SimTemperatureTransfer>(OnItemSimRegistered));
     if (Sim.IsValidHandle(stt.SimHandle))
     {
         SimMessages.ModifyElementChunkTemperatureAdjuster(stt.SimHandle, 0f, 0f, 0f);
     }
 }
Ejemplo n.º 3
0
 public Context(KMonoBehaviour cmp)
 {
     cell                  = Grid.PosToCell(cmp);
     navigator             = cmp.GetComponent <Navigator>();
     oxygenBreather        = cmp.GetComponent <OxygenBreather>();
     minionBrain           = cmp.GetComponent <MinionBrain>();
     temperatureTransferer = cmp.GetComponent <SimTemperatureTransfer>();
     primaryElement        = cmp.GetComponent <PrimaryElement>();
 }
Ejemplo n.º 4
0
 private void Register(SimTemperatureTransfer stt)
 {
     stt.onSimRegistered = (Action <SimTemperatureTransfer>)Delegate.Remove(stt.onSimRegistered, new Action <SimTemperatureTransfer>(OnItemSimRegistered));
     stt.onSimRegistered = (Action <SimTemperatureTransfer>)Delegate.Combine(stt.onSimRegistered, new Action <SimTemperatureTransfer>(OnItemSimRegistered));
     if (Sim.IsValidHandle(stt.SimHandle))
     {
         OnItemSimRegistered(stt);
     }
 }
Ejemplo n.º 5
0
 public void CleanUp()
 {
     storage.gameObject.Unsubscribe(-1697596308, OnStorageChanged);
     foreach (GameObject item in storage.items)
     {
         if ((UnityEngine.Object)item != (UnityEngine.Object)null)
         {
             SimTemperatureTransfer component = item.GetComponent <SimTemperatureTransfer>();
             Unregister(component);
         }
     }
 }
Ejemplo n.º 6
0
 private void OnItemSimRegistered(SimTemperatureTransfer stt)
 {
     if (!((UnityEngine.Object)stt == (UnityEngine.Object)null) && Sim.IsValidHandle(stt.SimHandle))
     {
         float num                  = temperature;
         float heat_capacity        = heatCapacity;
         float thermal_conductivity = thermalConductivity;
         if (!operational)
         {
             num                  = 0f;
             heat_capacity        = 0f;
             thermal_conductivity = 0f;
         }
         SimMessages.ModifyElementChunkTemperatureAdjuster(stt.SimHandle, num, heat_capacity, thermal_conductivity);
     }
 }
Ejemplo n.º 7
0
    private unsafe static float OnGetTemperature(PrimaryElement primary_element)
    {
        SimTemperatureTransfer component = primary_element.GetComponent <SimTemperatureTransfer>();
        float result;

        if (Sim.IsValidHandle(component.simHandle))
        {
            int handleIndex = Sim.GetHandleIndex(component.simHandle);
            result            = Game.Instance.simData.elementChunks[handleIndex].temperature;
            component.deltaKJ = Game.Instance.simData.elementChunks[handleIndex].deltaKJ;
        }
        else
        {
            result = primary_element.InternalTemperature;
        }
        return(result);
    }
Ejemplo n.º 8
0
    public static void DoStateTransition(int sim_handle)
    {
        SimTemperatureTransfer value = null;

        if (handleInstanceMap.TryGetValue(sim_handle, out value) && !((UnityEngine.Object)value == (UnityEngine.Object)null) && !value.HasTag(GameTags.Sealed))
        {
            PrimaryElement component = value.GetComponent <PrimaryElement>();
            Element        element   = component.Element;
            if (element.highTempTransitionTarget != SimHashes.Unobtanium)
            {
                if (component.Mass > 0f)
                {
                    int gameCell = Grid.PosToCell(value.transform.GetPosition());
                    SimMessages.AddRemoveSubstance(gameCell, element.highTempTransitionTarget, CellEventLogger.Instance.OreMelted, component.Mass, component.Temperature, component.DiseaseIdx, component.DiseaseCount, true, -1);
                }
                value.OnCleanUp();
                Util.KDestroyGameObject(value.gameObject);
            }
        }
    }
Ejemplo n.º 9
0
    private void OnStorageChanged(object data)
    {
        GameObject             gameObject = (GameObject)data;
        SimTemperatureTransfer component  = gameObject.GetComponent <SimTemperatureTransfer>();

        if (!((UnityEngine.Object)component == (UnityEngine.Object)null))
        {
            Pickupable component2 = gameObject.GetComponent <Pickupable>();
            if (!((UnityEngine.Object)component2 == (UnityEngine.Object)null))
            {
                if (operational && (UnityEngine.Object)component2.storage == (UnityEngine.Object)storage)
                {
                    Register(component);
                }
                else
                {
                    Unregister(component);
                }
            }
        }
    }
Ejemplo n.º 10
0
    private unsafe static void OnSetTemperature(PrimaryElement primary_element, float temperature)
    {
        if (temperature <= 0f)
        {
            KCrashReporter.Assert(false, "STT.OnSetTemperature - Tried to set <= 0 degree temperature");
            temperature = 293f;
        }
        SimTemperatureTransfer component = primary_element.GetComponent <SimTemperatureTransfer>();

        if (Sim.IsValidHandle(component.simHandle))
        {
            float mass          = primary_element.Mass;
            float heat_capacity = (!(mass >= 0.01f)) ? 0f : (mass * primary_element.Element.specificHeatCapacity);
            SimMessages.SetElementChunkData(component.simHandle, temperature, heat_capacity);
            int handleIndex = Sim.GetHandleIndex(component.simHandle);
            Game.Instance.simData.elementChunks[handleIndex].temperature = temperature;
        }
        else
        {
            primary_element.InternalTemperature = temperature;
        }
    }
 public static float PotentialEnergyFlowToCreature(int cell, PrimaryElement transfererPrimaryElement, SimTemperatureTransfer temperatureTransferer, float deltaTime = 1f)
 {
     return(SimUtil.CalculateEnergyFlowCreatures(cell, transfererPrimaryElement.Temperature, transfererPrimaryElement.Element.specificHeatCapacity, transfererPrimaryElement.Element.thermalConductivity, temperatureTransferer.SurfaceArea, temperatureTransferer.Thickness));
 }
    public GameObject CreatePrefab()
    {
        GameObject gameObject = EntityTemplates.CreatePlacedEntity("ColdBreather", STRINGS.CREATURES.SPECIES.COLDBREATHER.NAME, STRINGS.CREATURES.SPECIES.COLDBREATHER.DESC, 400f, Assets.GetAnim("coldbreather_kanim"), "grow_seed", Grid.SceneLayer.BuildingFront, 1, 2, DECOR.BONUS.TIER1, NOISE_POLLUTION.NOISY.TIER2, SimHashes.Creature, null, 293f);

        gameObject.AddOrGet <ReceptacleMonitor>();
        gameObject.AddOrGet <EntombVulnerable>();
        gameObject.AddOrGet <WiltCondition>();
        gameObject.AddOrGet <Prioritizable>();
        gameObject.AddOrGet <Uprootable>();
        gameObject.AddOrGet <UprootedMonitor>();
        gameObject.AddOrGet <DrowningMonitor>();
        EntityTemplates.ExtendPlantToFertilizable(gameObject, new PlantElementAbsorber.ConsumeInfo[1]
        {
            new PlantElementAbsorber.ConsumeInfo
            {
                tag = SimHashes.Phosphorite.CreateTag(),
                massConsumptionRate = 0.006666667f
            }
        });
        TemperatureVulnerable temperatureVulnerable = gameObject.AddOrGet <TemperatureVulnerable>();

        temperatureVulnerable.Configure(213.15f, 183.15f, 368.15f, 463.15f);
        gameObject.AddOrGet <OccupyArea>().objectLayers = new ObjectLayer[1]
        {
            ObjectLayer.Building
        };
        ColdBreather coldBreather = gameObject.AddOrGet <ColdBreather>();

        coldBreather.deltaEmitTemperature = -5f;
        coldBreather.emitOffsetCell       = new Vector3(0f, 1f);
        coldBreather.consumptionRate      = 1f;
        gameObject.AddOrGet <KBatchedAnimController>().randomiseLoopedOffset = true;
        Storage storage = BuildingTemplates.CreateDefaultStorage(gameObject, false);

        storage.showInUI = false;
        ElementConsumer elementConsumer = gameObject.AddOrGet <ElementConsumer>();

        elementConsumer.storeOnConsume    = true;
        elementConsumer.configuration     = ElementConsumer.Configuration.AllGas;
        elementConsumer.capacityKG        = 2f;
        elementConsumer.consumptionRate   = 0.25f;
        elementConsumer.consumptionRadius = 1;
        elementConsumer.sampleCellOffset  = new Vector3(0f, 0f);
        SimTemperatureTransfer component = gameObject.GetComponent <SimTemperatureTransfer>();

        component.SurfaceArea = 10f;
        component.Thickness   = 0.001f;
        GameObject plant = gameObject;

        SeedProducer.ProductionType productionType = SeedProducer.ProductionType.Hidden;
        string     id   = "ColdBreatherSeed";
        string     name = STRINGS.CREATURES.SPECIES.SEEDS.COLDBREATHER.NAME;
        string     desc = STRINGS.CREATURES.SPECIES.SEEDS.COLDBREATHER.DESC;
        KAnimFile  anim = Assets.GetAnim("seed_coldbreather_kanim");
        List <Tag> list = new List <Tag>();

        list.Add(GameTags.CropSeed);
        list = list;
        GameObject seed = EntityTemplates.CreateAndRegisterSeedForPlant(plant, productionType, id, name, desc, anim, "object", 1, list, SingleEntityReceptacle.ReceptacleDirection.Top, default(Tag), 2, STRINGS.CREATURES.SPECIES.COLDBREATHER.DOMESTICATEDDESC, EntityTemplates.CollisionShape.CIRCLE, 0.3f, 0.3f, null, string.Empty, false);

        EntityTemplates.CreateAndRegisterPreviewForPlant(seed, "ColdBreather_preview", Assets.GetAnim("coldbreather_kanim"), "place", 1, 2);
        SoundEventVolumeCache.instance.AddVolume("coldbreather_kanim", "ColdBreather_grow", NOISE_POLLUTION.CREATURES.TIER3);
        SoundEventVolumeCache.instance.AddVolume("coldbreather_kanim", "ColdBreather_intake", NOISE_POLLUTION.CREATURES.TIER3);
        return(gameObject);
    }