예제 #1
0
        // Function from file: airalarm.dm
        public override ByTable ui_data(dynamic user = null)
        {
            ByTable    data             = null;
            dynamic    A                = null;
            dynamic    T                = null;
            GasMixture environment      = null;
            Tlv        cur_tlv          = null;
            double     pressure         = 0;
            dynamic    temperature      = null;
            double     total_moles      = 0;
            dynamic    partial_pressure = null;
            dynamic    gas_id           = null;
            dynamic    id_tag           = null;
            dynamic    long_name        = null;
            dynamic    info             = null;
            dynamic    id_tag2          = null;
            dynamic    long_name2       = null;
            dynamic    info2            = null;
            Tlv        selected         = null;
            ByTable    thresholds       = null;
            dynamic    gas_id2          = null;

            data = new ByTable().Set("locked", this.locked).Set("siliconUser", user.has_unlimited_silicon_privilege).Set("emagged", this.emagged).Set("danger_level", this.danger_level);
            A    = GlobalFuncs.get_area(this);
            data["atmos_alarm"] = A.atmosalm;
            data["fire_alarm"]  = A.fire;
            T           = GlobalFuncs.get_turf(this);
            environment = ((Ent_Static)T).return_air();
            data["environment_data"] = new ByTable();
            pressure = environment.return_pressure();
            cur_tlv  = this.TLV["pressure"];
            data["environment_data"] += new ByTable(new object [] { new ByTable().Set("name", "Pressure").Set("value", pressure).Set("unit", "kPa").Set("danger_level", cur_tlv.get_danger_level(pressure)) });
            temperature = environment.temperature;
            cur_tlv     = this.TLV["temperature"];
            data["environment_data"] += new ByTable(new object [] {
                new ByTable()
                .Set("name", "Temperature")
                .Set("value", temperature)
                .Set("unit", "K (" + Num13.Round(Convert.ToDouble(temperature - 273.41), 0.1) + "C)")
                .Set("danger_level", cur_tlv.get_danger_level(temperature))
            });
            total_moles      = environment.total_moles();
            partial_pressure = environment.temperature * 8.31 / environment.volume;

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


                if (!this.TLV.Contains(gas_id))
                {
                    continue;
                }
                cur_tlv = this.TLV[gas_id];
                data["environment_data"] += new ByTable(new object [] {
                    new ByTable()
                    .Set("name", environment.gases[gas_id][3][2])
                    .Set("value", environment.gases[gas_id][1] / total_moles * 100)
                    .Set("unit", "%")
                    .Set("danger_level", cur_tlv.get_danger_level(environment.gases[gas_id][1] * partial_pressure))
                });
            }

            if (!this.locked || user.has_unlimited_silicon_privilege)
            {
                data["vents"] = new ByTable();

                foreach (dynamic _b in Lang13.Enumerate(A.air_vent_names))
                {
                    id_tag = _b;

                    long_name = A.air_vent_names[id_tag];
                    info      = A.air_vent_info[id_tag];

                    if (!Lang13.Bool(info) || Convert.ToDouble(info["frequency"]) != this.frequency)
                    {
                        continue;
                    }
                    data["vents"] += new ByTable(new object [] {
                        new ByTable()
                        .Set("id_tag", id_tag)
                        .Set("long_name", GlobalFuncs.sanitize(long_name))
                        .Set("power", info["power"])
                        .Set("checks", info["checks"])
                        .Set("excheck", info["checks"] & 1)
                        .Set("incheck", info["checks"] & 2)
                        .Set("direction", info["direction"])
                        .Set("external", info["external"])
                        .Set("extdefault", Convert.ToDouble(info["external"]) == 101.32499694824219)
                    });
                }
                data["scrubbers"] = new ByTable();

                foreach (dynamic _c in Lang13.Enumerate(A.air_scrub_names))
                {
                    id_tag2 = _c;

                    long_name2 = A.air_scrub_names[id_tag2];
                    info2      = A.air_scrub_info[id_tag2];

                    if (!Lang13.Bool(info2) || Convert.ToDouble(info2["frequency"]) != this.frequency)
                    {
                        continue;
                    }
                    data["scrubbers"] += new ByTable(new object [] {
                        new ByTable()
                        .Set("id_tag", id_tag2)
                        .Set("long_name", GlobalFuncs.sanitize(long_name2))
                        .Set("power", info2["power"])
                        .Set("scrubbing", info2["scrubbing"])
                        .Set("widenet", info2["widenet"])
                        .Set("filter_co2", info2["filter_co2"])
                        .Set("filter_toxins", info2["filter_toxins"])
                        .Set("filter_n2o", info2["filter_n2o"])
                    });
                }
                data["mode"]   = this.mode;
                data["modes"]  = new ByTable();
                data["modes"] += new ByTable(new object [] { new ByTable().Set("name", "Filtering - Scrubs out contaminants").Set("mode", 1).Set("selected", this.mode == 1).Set("danger", 0) });
                data["modes"] += new ByTable(new object [] { new ByTable().Set("name", "Contaminated - Scrubs out ALL contaminants quickly").Set("mode", 8).Set("selected", this.mode == 8).Set("danger", 0) });
                data["modes"] += new ByTable(new object [] { new ByTable().Set("name", "Draught - Siphons out air while replacing").Set("mode", 2).Set("selected", this.mode == 2).Set("danger", 0) });
                data["modes"] += new ByTable(new object [] { new ByTable().Set("name", "Refill - Triple vent output").Set("mode", 9).Set("selected", this.mode == 9).Set("danger", 0) });
                data["modes"] += new ByTable(new object [] { new ByTable().Set("name", "Cycle - Siphons air before replacing").Set("mode", 4).Set("selected", this.mode == 4).Set("danger", 1) });
                data["modes"] += new ByTable(new object [] { new ByTable().Set("name", "Siphon - Siphons air out of the room").Set("mode", 7).Set("selected", this.mode == 7).Set("danger", 1) });
                data["modes"] += new ByTable(new object [] { new ByTable().Set("name", "Panic Siphon - Siphons air out of the room quickly").Set("mode", 3).Set("selected", this.mode == 3).Set("danger", 1) });
                data["modes"] += new ByTable(new object [] { new ByTable().Set("name", "Off - Shuts off vents and scrubbers").Set("mode", 5).Set("selected", this.mode == 5).Set("danger", 0) });

                if (Lang13.Bool(this.emagged))
                {
                    data["modes"] += new ByTable(new object [] { new ByTable().Set("name", "Flood - Shuts off scrubbers and opens vents").Set("mode", 6).Set("selected", this.mode == 6).Set("danger", 1) });
                }
                selected   = null;
                thresholds = new ByTable();
                selected   = this.TLV["pressure"];
                thresholds.Add(new ByTable(new object [] { new ByTable().Set("name", "Pressure").Set("settings", new ByTable()) }));
                thresholds[thresholds.len]["settings"] += new ByTable(new object [] { new ByTable().Set("env", "pressure").Set("val", "min2").Set("selected", selected.min2) });
                thresholds[thresholds.len]["settings"] += new ByTable(new object [] { new ByTable().Set("env", "pressure").Set("val", "min1").Set("selected", selected.min1) });
                thresholds[thresholds.len]["settings"] += new ByTable(new object [] { new ByTable().Set("env", "pressure").Set("val", "max1").Set("selected", selected.max1) });
                thresholds[thresholds.len]["settings"] += new ByTable(new object [] { new ByTable().Set("env", "pressure").Set("val", "max2").Set("selected", selected.max2) });
                selected = this.TLV["temperature"];
                thresholds.Add(new ByTable(new object [] { new ByTable().Set("name", "Temperature").Set("settings", new ByTable()) }));
                thresholds[thresholds.len]["settings"] += new ByTable(new object [] { new ByTable().Set("env", "temperature").Set("val", "min2").Set("selected", selected.min2) });
                thresholds[thresholds.len]["settings"] += new ByTable(new object [] { new ByTable().Set("env", "temperature").Set("val", "min1").Set("selected", selected.min1) });
                thresholds[thresholds.len]["settings"] += new ByTable(new object [] { new ByTable().Set("env", "temperature").Set("val", "max1").Set("selected", selected.max1) });
                thresholds[thresholds.len]["settings"] += new ByTable(new object [] { new ByTable().Set("env", "temperature").Set("val", "max2").Set("selected", selected.max2) });

                foreach (dynamic _d in Lang13.Enumerate(GlobalVars.meta_gas_info))
                {
                    gas_id2 = _d;


                    if (!this.TLV.Contains(gas_id2))
                    {
                        continue;
                    }
                    selected = this.TLV[gas_id2];
                    thresholds.Add(new ByTable(new object [] { new ByTable().Set("name", GlobalVars.meta_gas_info[gas_id2][2]).Set("settings", new ByTable()) }));
                    thresholds[thresholds.len]["settings"] += new ByTable(new object [] { new ByTable().Set("env", gas_id2).Set("val", "min2").Set("selected", selected.min2) });
                    thresholds[thresholds.len]["settings"] += new ByTable(new object [] { new ByTable().Set("env", gas_id2).Set("val", "min1").Set("selected", selected.min1) });
                    thresholds[thresholds.len]["settings"] += new ByTable(new object [] { new ByTable().Set("env", gas_id2).Set("val", "max1").Set("selected", selected.max1) });
                    thresholds[thresholds.len]["settings"] += new ByTable(new object [] { new ByTable().Set("env", gas_id2).Set("val", "max2").Set("selected", selected.max2) });
                }
                data["thresholds"] = thresholds;
            }
            return(data);
        }
예제 #2
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);
        }