Example #1
0
    //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;
    }
Example #2
0
 public void AddMix(ChemMix mix)
 {
     if (Infinite)
     {
         return;
     }
     foreach (ChemFraction f in mix.Fractions.Values)
     {
         if (f.Mass > 0)
         {
             AddFraction(f);
         }
     }
     Heat += mix.Heat;
 }
Example #3
0
    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;
        }
    }
Example #4
0
    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);
    }