//public float HullHeatCapacity = 50000f; //public float HullKheat = 5f; //float HullHeat = 0; /* * struct InputConnection{ * public ChemConnection Connection; * public float balance = 0; * public InputConnection (ChemConnection connection, float balance) * { * this.Connection = connection; * this.balance = balance; * } * * }*/ void Awake() { Connections = new List <ChemConnection>(); plant = GetComponentInParent <Plant>(); Mix = new ChemMix(plant); Mix.Infinite = InfiniteMix; Mix.VolumeName = name; }
public void AddMix(ChemMix mix) { if (Infinite) { return; } foreach (ChemFraction f in mix.Fractions.Values) { if (f.Mass > 0) { AddFraction(f); } } Heat += mix.Heat; }
public void MoveMass(ChemVolume receiverVol, float mass) { ChemVolume sourceVol = GetSourceForReceiver(receiverVol); ChemMix mix = sourceVol.Mix.TakeMix(mass); receiverVol.Mix.AddMix(mix); if (receiverVol == VolumeOut) { Flow += mass; } else { Flow -= mass; } }
public ChemMix TakeMix(float mass) { ChemMix res = new ChemMix(plant); if (Mass == 0) { return(res); } float[] weights = new float[Fractions.Count]; int index = 0; foreach (ChemFraction f in Fractions.Values) { weights[index] = f.Mass / Mass; index++; } float deltaH = Heat * mass / massCache; plant.MaxDeltaH = Mathf.Max(plant.MaxDeltaH, deltaH); index = 0; List <string> toRemove = new List <string>(); foreach (ChemFraction f in Fractions.Values) { ChemFraction target = new ChemFraction(f.Element); TakeFraction(target, mass * weights[index], toRemove); index++; res.AddFraction(target); } foreach (string name in toRemove) { Fractions.Remove(name); } if (!Infinite) { Heat -= Mathf.Min(deltaH, Heat); } res.Heat += deltaH; return(res); }