Beispiel #1
0
        // Function from file: scrubber.dm
        public void scrub(GasMixture mixture = null)
        {
            double     transfer_moles = 0;
            GasMixture filtering      = null;
            GasMixture filtered       = null;
            dynamic    gas            = null;

            transfer_moles = Num13.MinInt(1, ((int)(this.volume_rate / (mixture.volume ?? 0)))) * mixture.total_moles();
            filtering      = mixture.remove(transfer_moles);
            filtered       = new GasMixture();

            if (!(filtering != null))
            {
                return;
            }
            filtered.temperature = filtering.temperature;

            foreach (dynamic _a in Lang13.Enumerate(filtering.gases & this.scrubbing))
            {
                gas = _a;

                filtered.add_gas(gas);
                filtered.gases[gas][1]  = filtering.gases[gas][1];
                filtering.gases[gas][1] = 0;
            }
            filtering.garbage_collect();
            this.air_contents.merge(filtered);
            mixture.merge(filtering);

            if (!Lang13.Bool(this.holding))
            {
                this.air_update_turf();
            }
            return;
        }
        // Function from file: spacevine.dm
        public override void process_mutation(Obj_Effect_Spacevine holder = null)
        {
            Ent_Static T  = null;
            GasMixture GM = null;

            T = holder.loc;

            if (T is Tile_Simulated_Floor)
            {
                GM = ((dynamic)T).air;

                if (!Lang13.Bool(GM.gases["o2"]))
                {
                    return;
                }
                GM.gases["o2"][1] -= (this.severity ?? 0) * holder.energy;
                GM.garbage_collect();
            }
            return;
        }
Beispiel #3
0
        // Function from file: airalarm.dm
        public override int?process(dynamic seconds = null)
        {
            dynamic    location                = null;
            Tlv        cur_tlv                 = null;
            GasMixture environment             = null;
            ByTable    env_gases               = null;
            dynamic    partial_pressure        = null;
            double     environment_pressure    = 0;
            int        pressure_dangerlevel    = 0;
            int        temperature_dangerlevel = 0;
            int        gas_dangerlevel         = 0;
            dynamic    gas_id           = null;
            int        old_danger_level = 0;


            if ((this.stat & 3) != 0 || Lang13.Bool(this.shorted))
            {
                return(null);
            }
            location = GlobalFuncs.get_turf(this);

            if (!Lang13.Bool(location))
            {
                return(null);
            }
            environment             = ((Ent_Static)location).return_air();
            env_gases               = environment.gases;
            partial_pressure        = environment.temperature * 8.31 / environment.volume;
            cur_tlv                 = this.TLV["pressure"];
            environment_pressure    = environment.return_pressure();
            pressure_dangerlevel    = cur_tlv.get_danger_level(environment_pressure);
            cur_tlv                 = this.TLV["temperature"];
            temperature_dangerlevel = cur_tlv.get_danger_level(environment.temperature);
            gas_dangerlevel         = 0;

            foreach (dynamic _a in Lang13.Enumerate(env_gases))
            {
                gas_id = _a;


                if (!this.TLV.Contains(gas_id))
                {
                    continue;
                }
                cur_tlv         = this.TLV[gas_id];
                gas_dangerlevel = Num13.MaxInt(gas_dangerlevel, cur_tlv.get_danger_level(env_gases[gas_id][1] * partial_pressure));
            }
            environment.garbage_collect();
            old_danger_level  = this.danger_level;
            this.danger_level = Num13.MaxInt(pressure_dangerlevel, temperature_dangerlevel, gas_dangerlevel);

            if (old_danger_level != this.danger_level)
            {
                this.apply_danger_level();
            }

            if (this.mode == 4 && environment_pressure < 5.066249847412109)
            {
                this.mode = 1;
                this.apply_mode();
            }
            return(null);
        }
Beispiel #4
0
        // Function from file: gas_mixture.dm
        public dynamic share(GasMixture sharer = null, int?atmos_adjacent_turfs = null)
        {
            atmos_adjacent_turfs = atmos_adjacent_turfs ?? 4;

            ByTable cached_gases                 = null;
            ByTable sharer_gases                 = null;
            dynamic temperature_delta            = null;
            double  abs_temperature_delta        = 0;
            double  old_self_heat_capacity       = 0;
            double  old_sharer_heat_capacity     = 0;
            double  heat_capacity_self_to_sharer = 0;
            double  heat_capacity_sharer_to_self = 0;
            double  moved_moles     = 0;
            double  abs_moved_moles = 0;
            dynamic id                       = null;
            dynamic id2                      = null;
            dynamic gas                      = null;
            dynamic sharergas                = null;
            double  delta                    = 0;
            double  gas_heat_capacity        = 0;
            double  new_self_heat_capacity   = 0;
            double  new_sharer_heat_capacity = 0;
            ByTable unique_gases             = null;
            dynamic delta_pressure           = null;


            if (!(sharer != null))
            {
                return(0);
            }
            cached_gases             = this.gases;
            sharer_gases             = sharer.gases;
            temperature_delta        = this.temperature_archived - sharer.temperature_archived;
            abs_temperature_delta    = Math.Abs(Convert.ToDouble(temperature_delta));
            old_self_heat_capacity   = 0;
            old_sharer_heat_capacity = 0;

            if (abs_temperature_delta > 0.5)
            {
                old_self_heat_capacity   = this.heat_capacity();
                old_sharer_heat_capacity = sharer.heat_capacity();
            }
            heat_capacity_self_to_sharer = 0;
            heat_capacity_sharer_to_self = 0;
            moved_moles     = 0;
            abs_moved_moles = 0;

            foreach (dynamic _a in Lang13.Enumerate(sharer_gases - cached_gases))
            {
                id = _a;

                this.add_gas(id);
            }

            foreach (dynamic _b in Lang13.Enumerate(cached_gases))
            {
                id2 = _b;


                if (!Lang13.Bool(sharer_gases[id2]))
                {
                    sharer.add_gas(id2);
                }
                gas       = cached_gases[id2];
                sharergas = sharer_gases[id2];
                delta     = Num13.Round(Convert.ToDouble(gas[2] - sharergas[2]), 1.0000000116860974e-7) / ((atmos_adjacent_turfs ?? 0) + 1);

                if (delta != 0 && abs_temperature_delta > 0.5)
                {
                    gas_heat_capacity = delta * Convert.ToDouble(gas[3][1]);

                    if (delta > 0)
                    {
                        heat_capacity_self_to_sharer += gas_heat_capacity;
                    }
                    else
                    {
                        heat_capacity_sharer_to_self -= gas_heat_capacity;
                    }
                }
                gas[1]          -= delta;
                sharergas[1]    += delta;
                moved_moles     += delta;
                abs_moved_moles += Math.Abs(delta);
            }
            this.last_share = abs_moved_moles;

            if (abs_temperature_delta > 0.5)
            {
                new_self_heat_capacity   = old_self_heat_capacity + heat_capacity_sharer_to_self - heat_capacity_self_to_sharer;
                new_sharer_heat_capacity = old_sharer_heat_capacity + heat_capacity_self_to_sharer - heat_capacity_sharer_to_self;

                if (new_self_heat_capacity > 0.0003)
                {
                    this.temperature = (old_self_heat_capacity * Convert.ToDouble(this.temperature) - heat_capacity_self_to_sharer * Convert.ToDouble(this.temperature_archived) + heat_capacity_sharer_to_self * Convert.ToDouble(sharer.temperature_archived)) / new_self_heat_capacity;
                }

                if (new_sharer_heat_capacity > 0.0003)
                {
                    sharer.temperature = (old_sharer_heat_capacity * Convert.ToDouble(sharer.temperature) - heat_capacity_sharer_to_self * Convert.ToDouble(sharer.temperature_archived) + heat_capacity_self_to_sharer * Convert.ToDouble(this.temperature_archived)) / new_sharer_heat_capacity;

                    if (Math.Abs(old_sharer_heat_capacity) > 0.0003)
                    {
                        if (Math.Abs(new_sharer_heat_capacity / old_sharer_heat_capacity - 1) < 0.1)
                        {
                            this.temperature_share(sharer, 0.4);
                        }
                    }
                }
            }
            unique_gases = cached_gases ^ sharer_gases;

            if (unique_gases.len != 0)
            {
                this.garbage_collect(cached_gases - sharer_gases);
                sharer.garbage_collect(sharer_gases - cached_gases);
            }

            if (Convert.ToDouble(temperature_delta) > 393.41 || Math.Abs(moved_moles) > 0.5199189782142639)
            {
                delta_pressure = this.temperature_archived * (this.total_moles() + moved_moles) - sharer.temperature_archived * (sharer.total_moles() - moved_moles);
                return(delta_pressure * 8.31 / this.volume);
            }
            return(null);
        }
Beispiel #5
0
        // Function from file: effects_smoke.dm
        public void Chilled(dynamic A = null)
        {
            dynamic            T       = null;
            GasMixture         G       = null;
            Obj_Effect_Hotspot H       = null;
            ByTable            G_gases = null;
            Obj_Machinery_Atmospherics_Components_Unary U = null;
            Mob_Living L    = null;
            Obj_Item   Item = null;


            if (A is Tile_Simulated)
            {
                T = A;

                if (Lang13.Bool(T.air))
                {
                    G = T.air;

                    if (Map13.GetDistance(T, this.location) < 2)
                    {
                        G.temperature = 2;
                    }
                    ((Tile)T).air_update_turf();

                    foreach (dynamic _a in Lang13.Enumerate(T, typeof(Obj_Effect_Hotspot)))
                    {
                        H = _a;

                        GlobalFuncs.qdel(H);
                        G_gases = G.gases;

                        if (Lang13.Bool(G_gases["plasma"]))
                        {
                            G.assert_gas("n2");
                            G_gases["n2"][1]    += G_gases["plasma"][1];
                            G_gases["plasma"][1] = 0;
                            G.garbage_collect();
                        }
                    }
                }

                foreach (dynamic _b in Lang13.Enumerate(T, typeof(Obj_Machinery_Atmospherics_Components_Unary)))
                {
                    U = _b;


                    if (!(U.welded == null) && !(U.welded == true))
                    {
                        U.welded = true;
                        U.update_icon();
                        U.visible_message("<span class='danger'>" + U + " was frozen shut!</span>");
                    }
                }

                foreach (dynamic _c in Lang13.Enumerate(T, typeof(Mob_Living)))
                {
                    L = _c;

                    L.ExtinguishMob();
                }

                foreach (dynamic _d in Lang13.Enumerate(T, typeof(Obj_Item)))
                {
                    Item = _d;

                    Item.extinguish();
                }
            }
            return;
        }
        // Function from file: scanners.dm
        public override dynamic attack_self(dynamic user = null, dynamic flag = null, bool?emp = null)
        {
            Ent_Static location             = null;
            GasMixture environment          = null;
            double     pressure             = 0;
            double     total_moles          = 0;
            ByTable    env_gases            = null;
            dynamic    o2_concentration     = null;
            dynamic    n2_concentration     = null;
            double     co2_concentration    = 0;
            double     plasma_concentration = 0;
            dynamic    id = null;
            dynamic    gas_concentration = null;

            this.add_fingerprint(user);

            if (Lang13.Bool(user.stat) || user.eye_blind != 0)
            {
                return(null);
            }
            location = user.loc;

            if (!(location is Tile))
            {
                return(null);
            }
            environment = location.return_air();
            pressure    = environment.return_pressure();
            total_moles = environment.total_moles();
            user.WriteMsg("<span class='info'><B>Results:</B></span>");

            if (Math.Abs(pressure - 101.32499694824219) < 10)
            {
                user.WriteMsg("<span class='info'>Pressure: " + Num13.Round(pressure, 0.1) + " kPa</span>");
            }
            else
            {
                user.WriteMsg("<span class='alert'>Pressure: " + Num13.Round(pressure, 0.1) + " kPa</span>");
            }

            if (total_moles != 0)
            {
                env_gases = environment.gases;
                GlobalVars.hardcoded_gases.Apply(Lang13.BindFunc(environment, "assert_gases"));
                o2_concentration     = env_gases["o2"][1] / total_moles;
                n2_concentration     = env_gases["n2"][1] / total_moles;
                co2_concentration    = Convert.ToDouble(env_gases["co2"][1] / total_moles);
                plasma_concentration = Convert.ToDouble(env_gases["plasma"][1] / total_moles);
                environment.garbage_collect();

                if (Math.Abs(Convert.ToDouble(n2_concentration - 0.79)) < 20)
                {
                    user.WriteMsg("<span class='info'>Nitrogen: " + Num13.Floor(Convert.ToDouble(n2_concentration * 100)) + " %</span>");
                }
                else
                {
                    user.WriteMsg("<span class='alert'>Nitrogen: " + Num13.Floor(Convert.ToDouble(n2_concentration * 100)) + " %</span>");
                }

                if (Math.Abs(Convert.ToDouble(o2_concentration - 0.01)) < 2)
                {
                    user.WriteMsg("<span class='info'>Oxygen: " + Num13.Floor(Convert.ToDouble(o2_concentration * 100)) + " %</span>");
                }
                else
                {
                    user.WriteMsg("<span class='alert'>Oxygen: " + Num13.Floor(Convert.ToDouble(o2_concentration * 100)) + " %</span>");
                }

                if (co2_concentration > 0.01)
                {
                    user.WriteMsg("<span class='alert'>CO2: " + Num13.Floor(co2_concentration * 100) + " %</span>");
                }
                else
                {
                    user.WriteMsg("<span class='info'>CO2: " + Num13.Floor(co2_concentration * 100) + " %</span>");
                }

                if (plasma_concentration > 0.01)
                {
                    user.WriteMsg("<span class='info'>Plasma: " + Num13.Floor(plasma_concentration * 100) + " %</span>");
                }

                foreach (dynamic _a in Lang13.Enumerate(env_gases))
                {
                    id = _a;


                    if (GlobalVars.hardcoded_gases.Contains(id))
                    {
                        continue;
                    }
                    gas_concentration = env_gases[id][1] / total_moles;
                    user.WriteMsg("<span class='alert'>" + env_gases[id][3][2] + ": " + Num13.Floor(Convert.ToDouble(gas_concentration * 100)) + " %</span>");
                }
                user.WriteMsg("<span class='info'>Temperature: " + Num13.Floor(Convert.ToDouble(environment.temperature - 273.41)) + " &deg;C</span>");
            }
            return(null);
        }