Example #1
0
 public void Add(MixAndVolume mixAndVolume)
 {
     Mix.Add(mixAndVolume.Mix);
     Volume = Volume + mixAndVolume.Volume;
     gasMix = gasMix + mixAndVolume.gasMix;
     gasMix.ChangeVolumeValue(mixAndVolume.gasMix.Volume);
 }
Example #2
0
        public Tuple <ReagentMix, GasMix> Take(MixAndVolume InmixAndVolume, bool removeVolume = true)
        {
            if (Volume == 0)
            {
                Logger.LogError(" divide by 0 in Take ");
            }

            float Percentage      = InmixAndVolume.Volume / Volume;
            float RemoveGasVolume = gasMix.Volume;
            float GasVolume       = gasMix.Volume;

            if (removeVolume)
            {
                RemoveGasVolume = RemoveGasVolume * Percentage;
                GasVolume       = GasVolume * (1 - Percentage);
            }

            var ReturnMix = Mix.Take(Mix.Total * Percentage);

            var Newone       = new float[gasMix.Gases.Length];
            var RemoveNewone = new float[gasMix.Gases.Length];

            for (int i = 0; i < gasMix.Gases.Length; i++)
            {
                RemoveNewone[i] = gasMix.Gases[i] * Percentage;
                Newone[i]       = gasMix.Gases[i] * (1 - Percentage);
            }

            gasMix = GasMix.FromTemperature(Newone, gasMix.Temperature, GasVolume);

            return(new Tuple <ReagentMix, GasMix>(ReturnMix,
                                                  GasMix.FromTemperature(RemoveNewone, gasMix.Temperature, RemoveGasVolume)));
        }
Example #3
0
        public void AddPipe(PipeData pipeData)
        {
            if (ISNewNet)
            {
                pipeData.OnNet    = this;
                this.mixAndVolume = pipeData.mixAndVolume.Clone();
                pipeData.mixAndVolume.Empty();
                this.Covering.Add(pipeData);
                this.NetUpdateProxy.OnNet = this;
                this.NetUpdateProxy.OnEnable();
                if (pipeData.CustomLogic == CustomLogic.CoolingPipe)
                {
                    this.pipeNetAction = new CoolingNet();
                    this.pipeNetAction.LiquidPipeNet = this;
                }

                ISNewNet = false;
            }
            else
            {
                if (pipeData.OnNet == null)
                {
                    pipeData.OnNet = this;
                    mixAndVolume.Add(pipeData.mixAndVolume);
                    Covering.Add(pipeData);
                }
                else
                {
                    if (this != pipeData.OnNet)
                    {
                        this.CombinePipeNets(pipeData.OnNet);
                    }
                }
            }
        }
Example #4
0
        public void MultiSplit(MixAndVolume InmixAndVolume, float TotalVolume)
        {
            float Multiplier = InmixAndVolume.Volume / TotalVolume;

            InmixAndVolume.gasMix = InmixAndVolume.gasMix + (gasMix * Multiplier);
            Mix.Clone().TransferTo(InmixAndVolume.Mix, Multiplier * Mix.Total);
        }
Example #5
0
        public MixAndVolume Clone()
        {
            var MiXV = new MixAndVolume();

            MiXV.gasMix = new GasMix(gasMix);
            MiXV.Mix    = Mix.Clone();
            return(MiXV);
        }
Example #6
0
        public void TransferTo(MixAndVolume toTransfer, Vector2 amount)
        {
            if (float.IsNaN(amount.x) == false)
            {
                Mix.TransferTo(toTransfer.Mix, amount.x);
            }

            if (float.IsNaN(amount.y) == false)
            {
                toTransfer.gasMix = toTransfer.gasMix + gasMix.RemoveMoles(amount.y);
            }
        }
Example #7
0
        public void MultiSplit(MixAndVolume InmixAndVolume, float TotalVolume)
        {
            if (TotalVolume == 0)
            {
                Logger.LogError(" divide by 0 in MultiSplit");
            }

            float Multiplier = InmixAndVolume.Volume / TotalVolume;

            InmixAndVolume.gasMix = InmixAndVolume.gasMix + (gasMix * Multiplier);
            Mix.Clone().TransferTo(InmixAndVolume.Mix, Multiplier * Mix.Total);
        }
Example #8
0
        public void Add(MixAndVolume mixAndVolume)
        {
            Mix.Add(mixAndVolume.Mix);
            Volume = Volume + mixAndVolume.Volume;
            gasMix = gasMix + mixAndVolume.gasMix;
            gasMix.ChangeVolumeValue(mixAndVolume.gasMix.Volume);

            if (gasMix.Gases.Any(x => x < 0))
            {
                Logger.Log("0!!!");
            }
        }
Example #9
0
        public void TransferTo(MixAndVolume toTransfer, Vector2 amount)
        {
            Mix.TransferTo(toTransfer.Mix, amount.x);
            if (float.IsNaN(amount.y) == false)
            {
                toTransfer.gasMix = toTransfer.gasMix + gasMix.RemoveMoles(amount.y);

                if (toTransfer.gasMix.Gases.Any(x => x < 0))
                {
                    Logger.Log("0!!!");
                }
            }
        }
Example #10
0
        public void TransferSpecifiedTo(MixAndVolume toTransfer, Gas?SpecifiedGas = null,
                                        Chemistry.Reagent Reagent = null, Vector2?amount = null)
        {
            if (SpecifiedGas != null)
            {
                float ToRemovegas = 0;
                var   Gas         = SpecifiedGas.GetValueOrDefault(Atmospherics.Gas.Oxygen);
                if (amount != null)
                {
                    ToRemovegas = amount.Value.y;
                }
                else
                {
                    ToRemovegas = gasMix.Gases[Gas];
                }

                float TransferredEnergy = ToRemovegas * Gas.MolarHeatCapacity * gasMix.Temperature;

                gasMix.RemoveGas(Gas, ToRemovegas);

                float CachedInternalEnergy = toTransfer.InternalEnergy + TransferredEnergy;                 //- TransferredEnergy;

                toTransfer.gasMix.AddGas(Gas, ToRemovegas);
                toTransfer.gasMix.InternalEnergy = CachedInternalEnergy;
            }

            if (Reagent != null)
            {
                float ToRemovegas = 0;

                if (amount != null)
                {
                    ToRemovegas = amount.Value.x;
                }
                else
                {
                    ToRemovegas = Mix[Reagent];
                }


                float TransferredEnergy    = ToRemovegas * Reagent.heatDensity * Mix.Temperature;
                float CachedInternalEnergy = Mix.InternalEnergy;
                Mix.Subtract(Reagent, ToRemovegas);
                Mix.InternalEnergy = CachedInternalEnergy - TransferredEnergy;

                CachedInternalEnergy = toTransfer.Mix.InternalEnergy;
                toTransfer.Mix.Add(Reagent, ToRemovegas);
                CachedInternalEnergy         += TransferredEnergy;
                toTransfer.Mix.InternalEnergy = CachedInternalEnergy;
            }
        }
Example #11
0
        public Tuple <ReagentMix, GasMix> Take(MixAndVolume InmixAndVolume, bool removeVolume = true)
        {
            if (InmixAndVolume.Volume == 0)
            {
                Logger.LogError(" divide by 0 in Take ");
            }

            float Percentage = Volume / InmixAndVolume.Volume;

            var ReturnMix = Mix.Take(Mix.Total * Percentage);

            if (removeVolume)
            {
                gasMix.ChangeVolumeValue(-InmixAndVolume.gasMix.Volume);
                Volume = Volume - InmixAndVolume.Volume;
            }

            var ReturnGasMix = gasMix.RemoveVolume(InmixAndVolume.gasMix.Volume);

            return(new Tuple <ReagentMix, GasMix>(ReturnMix, ReturnGasMix));
        }
Example #12
0
        public void Add(MixAndVolume mixAndVolume, bool ChangeVolume = true)
        {
            float internalEnergy = mixAndVolume.InternalEnergy + this.InternalEnergy;
            float GasVolume      = gasMix.Volume;

            if (ChangeVolume)
            {
                GasVolume = GasVolume + mixAndVolume.gasMix.Volume;
            }

            Mix.Add(mixAndVolume.Mix);
            var Newone = new float[gasMix.Gases.Length];

            for (int i = 0; i < gasMix.Gases.Length; i++)
            {
                Newone[i] = gasMix.Gases[i] + mixAndVolume.gasMix.Gases[i];
            }

            gasMix = GasMix.FromTemperature(Newone, gasMix.Temperature, GasVolume);
            this.InternalEnergy = internalEnergy;
        }
Example #13
0
        public Tuple <ReagentMix, GasMix> Take(MixAndVolume InmixAndVolume, bool removeVolume = true)
        {
            float Percentage = Volume / InmixAndVolume.Volume;

            var ReturnMix = Mix.Take(Mix.Total * Percentage);

            if (removeVolume)
            {
                gasMix.ChangeVolumeValue(-InmixAndVolume.gasMix.Volume);
                Volume = Volume - InmixAndVolume.Volume;
            }

            var ReturnGasMix = gasMix.RemoveVolume(InmixAndVolume.gasMix.Volume);

            if (gasMix.Gases.Any(x => x < 0))
            {
                Logger.Log("0!!!");
            }

            return(new Tuple <ReagentMix, GasMix>(ReturnMix, ReturnGasMix));
        }
Example #14
0
    public void CycleUpdate()
    {
        if (metaDataNode == null)
        {
            metaDataNode = MatrixManager.AtPoint(registerTile.WorldPositionServer, true).MetaDataLayer
                           .Get(registerTile.LocalPositionServer, false);
        }

        if (metaDataNode.PipeData.Count > 0)
        {
            MixAndVolume = metaDataNode.PipeData[0].pipeData.GetMixAndVolume;
            if (MixAndVolume.Density().y == 0)
            {
                spriteHandler.ChangeSprite(0);
            }
            else
            {
                int toSet = (int)Mathf.Floor(MixAndVolume.Density().y / (500f));                  //10000f/20f
                if (toSet == 0)
                {
                    toSet = 1;
                }

                if (toSet > 20)
                {
                    toSet = 20;
                }

                spriteHandler.ChangeSprite(toSet);
            }
        }
        else
        {
            spriteHandler.ChangeSprite(0);
        }
    }