// Function from file: gas_mixture.dm public GasMixture remove(double amount = 0) { double sum = 0; ByTable cached_gases = null; GasMixture removed = null; ByTable removed_gases = null; dynamic id = null; sum = this.total_moles(); amount = Num13.MinInt(((int)(amount)), ((int)(sum))); if (amount <= 0) { return(null); } cached_gases = this.gases; removed = new GasMixture(); removed_gases = removed.gases; removed.temperature = this.temperature; foreach (dynamic _a in Lang13.Enumerate(cached_gases)) { id = _a; removed.add_gas(id); removed_gases[id][1] = Num13.Round(Convert.ToDouble(cached_gases[id][1] / sum * amount), 1.0000000116860974e-7); cached_gases[id][1] -= removed_gases[id][1]; } this.garbage_collect(); return(removed); }
// Function from file: gas_mixture.dm public GasMixture remove_ratio(double?ratio = null) { ByTable cached_gases = null; GasMixture removed = null; ByTable removed_gases = null; dynamic id = null; if ((ratio ?? 0) <= 0) { return(null); } ratio = Num13.MinInt(((int)(ratio ?? 0)), 1); cached_gases = this.gases; removed = new GasMixture(); removed_gases = removed.gases; removed.temperature = this.temperature; foreach (dynamic _a in Lang13.Enumerate(cached_gases)) { id = _a; removed.add_gas(id); removed_gases[id][1] = Num13.Round(Convert.ToDouble(cached_gases[id][1] * ratio), 1.0000000116860974e-7); cached_gases[id][1] -= removed_gases[id][1]; } this.garbage_collect(); return(removed); }
// 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: 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); }