Example #1
0
    public List<AtmospherePacket> Process(AtmospherePacket input)
    {
        List<AtmospherePacket> outputs = new List<AtmospherePacket>(); //the output channels

        int destination; //the destination channel of the processing
        float[] x; //the gas fractions
        float gasHeat; //gas heat
        foreach (string gas in input.Keys) {
            destination = channels.IndexOf(gas);
            if (destination == -1) destination = channels.Count;
            x = RandomArray(destination, error);

            gasHeat = input.percent[gas]*input.heat;
            input.heat -= gasHeat;

            for (int i = 0; i < channels.Count+1; i++) {
                if (outputs[i] == null) outputs.Add(new AtmospherePacket());

                outputs[i][gas] += input[gas]*x[i];
                outputs[i].heat += gasHeat*x[i];
            }
        }

        return outputs;
    }
Example #2
0
    //get a specific mass
    public AtmospherePacket GetMass(float ma = -1f)
    {
        AtmospherePacket Ap = new AtmospherePacket();
        float ratio;

        if (ma >= mass || ma == -1f)
            ratio = 1f;
        else
            ratio = ma/mass;

        foreach (KeyValuePair<string, float> pair in gases)
            Ap[pair.Key] = pair.Value*ratio;
        Ap.heat = heat*ratio;
        Ap.volume = volume*ratio;

        return Ap;
    }
Example #3
0
    //push a specified atmosphere into this one
    public void Push(AtmospherePacket atmos)
    {
        foreach (string type in atmos.Keys) {
            gases[type] += atmos[type];
        }
        mass += atmos.mass;
        heat += atmos.heat;

        Recalculate();
    }
Example #4
0
    //get a specific volume
    public AtmospherePacket GetVolume(float vol = -1f)
    {
        AtmospherePacket Ap = new AtmospherePacket();
        float ratio;

        if (vol >= volume || vol == -1f)
            ratio = 1f;
        else
            ratio = vol/volume;

        foreach (KeyValuePair<string, float> pair in gases)
            Ap[pair.Key] = pair.Value*ratio;
        Ap.heat = heat*ratio;
        Ap.volume = volume;

        return Ap;
    }
Example #5
0
 //process the gas input, modifying it to match the desired amount
 public void ProcessGas(AtmospherePacket input, float amount, string channel)
 {
 }
Example #6
0
 public static AtmospherePacket operator /(AtmospherePacket A, float c)
 {
     AtmospherePacket Ar = new AtmospherePacket();
     foreach (KeyValuePair<string, float> pair in A.gases)
         Ar.gases.Add(pair.Key, pair.Value/c);
     Ar.mass = A.mass/c;
     Ar.heat = A.heat/c;
     Ar.volume = A.volume/c;
     Ar.Recalculate();
     return Ar;
 }
Example #7
0
 public static AtmospherePacket operator -(AtmospherePacket A1, AtmospherePacket A2)
 {
     AtmospherePacket Ar = new AtmospherePacket();
     foreach (KeyValuePair<string, float> pair in A1.gases)
         Ar.gases.Add(pair.Key, pair.Value);
     foreach (KeyValuePair<string, float> pair in A2.gases) {
         Ar.gases[pair.Key] -= pair.Value;
     }
     Ar.mass = A1.mass-A2.mass;
     Ar.heat = A1.heat-A2.heat;
     Ar.volume = A1.volume-A2.volume;
     Ar.Recalculate();
     return Ar;
 }
Example #8
0
 //push some gas into the tank, up to maxpressure.
 public void Push(AtmospherePacket atmos)
 {
     //AtmospherePacket combined = atmos+atmosphere;
 }
Example #9
0
 void Awake()
 {
     atmosphere = GetComponent<Atmosphere>();
     iAtmosphere = new AtmospherePacket();
     Refresh();
 }