Exemple #1
0
        public void EqualiseWithMultiple(List <PipeData> others, bool EqualiseGas, bool EqualiseLiquid)
        {
            if (EqualiseGas)
            {
                gasMix.MergeGasMixes(others);
            }

            if (EqualiseLiquid)
            {
                float TotalVolume = Volume;
                foreach (var Pipe in others)
                {
                    TotalVolume += PipeFunctions.PipeOrNet(Pipe).Volume;
                }

                float TotalReagents = Mix.Total;
                foreach (var Pipe in others)
                {
                    TotalReagents += PipeFunctions.PipeOrNet(Pipe).Mix.Total;
                }

                if (TotalVolume == 0)
                {
                    Logger.LogError(" divide by 0 in EqualiseWithMultiple TotalVolume ");
                }

                float TargetDensity = TotalReagents / TotalVolume;


                foreach (var Pipe in others)
                {
                    PipeFunctions.PipeOrNet(Pipe).Mix.TransferTo(Mix, PipeFunctions.PipeOrNet(Pipe).Mix.Total);
                }

                foreach (var Pipe in others)
                {
                    Mix.TransferTo(PipeFunctions.PipeOrNet(Pipe).Mix,
                                   TargetDensity * PipeFunctions.PipeOrNet(Pipe).Volume);
                }
            }
        }
Exemple #2
0
        public void EqualiseWithMultiple(List <PipeData> others, bool EqualiseGas, bool EqualiseLiquid)
        {
            if (EqualiseGas)
            {
                gasMix.MergeGasMixes(others);
                if (gasMix.Gases.Any(x => x < 0))
                {
                    Logger.Log("0!!!");
                }
            }

            if (EqualiseLiquid)
            {
                float TotalVolume = Volume;
                foreach (var Pipe in others)
                {
                    TotalVolume += PipeFunctions.PipeOrNet(Pipe).Volume;
                }

                float TotalReagents = Mix.Total;
                foreach (var Pipe in others)
                {
                    TotalReagents += PipeFunctions.PipeOrNet(Pipe).Mix.Total;
                }

                float TargetDensity = TotalReagents / TotalVolume;


                foreach (var Pipe in others)
                {
                    PipeFunctions.PipeOrNet(Pipe).Mix.TransferTo(Mix, PipeFunctions.PipeOrNet(Pipe).Mix.Total);
                }

                foreach (var Pipe in others)
                {
                    Mix.TransferTo(PipeFunctions.PipeOrNet(Pipe).Mix, TargetDensity * PipeFunctions.PipeOrNet(Pipe).Volume);
                }
            }
        }