Adds atmos (#1389)
* Add initial atmospherics framework * Make walls and airlocks airtight * Add the basic atmosphere gas system * Atmos: move CardinalToIntVec and Offset into extention methods in EntityNetworkUtils * Optimize vending machine code a bit. * Address feedback from Atmos PR, make code compile Fix use of OnMove -> SnapGridComponent.OnPositionChanged. Added pause checking to atmos simulations. * Improvements to the existing ZAS prototype (#996) * Rename Volume -> Quantity in GasProperty This makes the name consistent with the rest of the code, given that it's meant to be a mol value. * Replace Gas enum with GasPrototype Unused as of yet, but laying the groundwork for future changes. * Update AtmosphereMap, improving maths Adds a temporary default atmosphere, hardcoded in for testing. It will be replaced eventually. Fixed a maths mistake in the original code involving unit conversions. Added the Take() method to IAtmosphere, for taking some volume of mixture out of a gas mix. This will be pretty handy in the future, but for now it's used by walls to delete air where they are built. * Fix merging, splitting logic for zones Removing a cell from a zone now correctly reduces its volume. Adding a cell to a zone now correctly increases its volume. * Improvements to atmos code, reorganising of types Moved GasPrototype to shared, because it's going to be used by the client later. Split up the atmosphere code. Now zones are explicitly their own kind of atmosphere, which should speed up some loops and also solve inconsistencies in the volume calculation. GasMixtures are another type of atmosphere, for more general use. Try to fix the splitting/merging code, which was quite cryptic and not clear at all. It *should* work now. * Switch zones back to MapIndices Turns out I'm an idiot who misunderstood the code. MapIndices can be used as one-per-tile, which is what is needed for atmos. GridCoordinates are many-per-tile, and were causing lots of problems. * Add zone debugging overlay This is the first example of zone information being sent to a client. It adds the `togglezoneinfo` command, which overlays the tiles and gas information for the zone currently occupied by the user on the screen. This was helpful for debugging the GridCoordinates problem. * Fix position of atmos zone debug text * Make AirtightComponent only activate on MapInit This should stop it splitting atmospheres in mapping. * Doc comments improvements to AtmosphereMap Fix some malformed comments, inherit some useful docs, document some more functions. * Add zone logic for changing tiles to/from space Zones are now correctly created when all the tiles in a room are built, and destroyed when one of the tiles is destroyed. * update engine * right * Cleanup code * Port GasMixture, further cleanup * Fix windows not being airtight, some other stuff * Work on atmos * Difference between ZoneBlocked and AirBlocked * Big GridAtmosphereManager cleanup, zones are broken now oops * Remove zones, add excited group implementation * Further cleanup * Further work on atmos * Work on gas overlay. * PumpGasTo and ReleaseGasTo methods for GasMixture. * Adds Tile Overlay System. * More work on atmos * Gasses spread, equalize and all that * Fix a few crashes * Gas can actually spread from room to room after opening airlocks * Add explosive depressurization, tile prying on depressurization, gas spreading on wall break. Etc. * More work * Remove atmoschem, add "performant" gas overlays * what the fuck git * More work I guess? * Fix stuff, create a few (empty) components for future work * Fix temperature * Fix tile air sharing * Atmos optimizations * Further atmos optimizations * Even more optimizations! * Update Content.Client/GameObjects/EntitySystems/GasTileOverlaySystem.cs Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com> * Update Content.Client/GameObjects/EntitySystems/GasTileOverlaySystem.cs Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com> * Update Content.Client/GameObjects/EntitySystems/GasTileOverlaySystem.cs Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com> * Address a few reviews * Oops, forgot to remove this * Update Content.Server/Atmos/AtmosphereMap.cs Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com> * Fix compile * Improved client gas tile overlays * Less allocations * Even less allocations! * some stuff dunno * Big refactor time, oh yeah * it truly is 1 AM * bruh * No idea why now it doesn't work. Oh well! I'll fix this on thursday 😌 * Basic atmos serialization * Fix bugs, add VV attributes * Start adding stuff for gas reactions * Add a few atmos commands * Fill gas command * Changes to gas opacity * Fixes I guess * Fixes, add space wind sound * High pressure movement! * Better high pressure movements. * Fix direction, maybe? * And now it works great * Science! * and this is why you don't trust people * remove logging * Turns out I'm fucking dumb * Work on hotspots and reactions, add tritium gas * IGridAtmosphereComponent interface! For future unsimulated grids. * Makes atmos updates NoGC. * C E A S E * Add settemp atmos command * Important reminder. * Remove useless AtmosCooldown. * More work on hotspots * Overlays for hotspots. Fire works! * Turns out I suck at coding * Fire texture change * Yeah let's make that an absolute value, hmm? * Support for atmos after teleporting grid (more or less) * fix attempt (doesn't actually fix it) * Make static variable not static * Remove magic numbers * Stopwatch moment * Slight cleanup. * More cleanup. * Atmos optimizations * Fix build * Remove useless ghost atmos shit * Adds CanSeeGases component for gas overlay stuff * Component and prototype ignores * ExcitedGroups now dispose on being merged with others * Some tweaking. * Atmos now uses frame time for updates. * Nullable boogaloo * IExamine fix * Fix build * Fix restartround * Atmos tweaking, use invalid direction * Increase high pressure movement force * Better sort * Update submodule. * NULLABILITY AAAAH Special thanks to monster860 and all monstermos contributors! Co-authored-by: Campbell Suter <znix@znix.xyz> Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com> Co-authored-by: ComicIronic <comicironic@gmail.com> Co-authored-by: silicons <2003111+silicons@users.noreply.github.com> Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com>
This commit is contained in:
committed by
GitHub
parent
15f31b654e
commit
85df48a700
174
Content.Shared/Atmos/Atmospherics.cs
Normal file
174
Content.Shared/Atmos/Atmospherics.cs
Normal file
@@ -0,0 +1,174 @@
|
||||
using System.Collections.Generic;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Shared.Atmos
|
||||
{
|
||||
/// <summary>
|
||||
/// Class to store atmos constants.
|
||||
/// </summary>
|
||||
public static class Atmospherics
|
||||
{
|
||||
static Atmospherics()
|
||||
{
|
||||
var protoMan = IoCManager.Resolve<IPrototypeManager>();
|
||||
|
||||
GasPrototypes = new GasPrototype[TotalNumberOfGases];
|
||||
|
||||
for (var i = 0; i < TotalNumberOfGases; i++)
|
||||
{
|
||||
GasPrototypes[i] = protoMan.Index<GasPrototype>(i.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly GasPrototype[] GasPrototypes;
|
||||
|
||||
public static GasPrototype GetGas(int gasId) => GasPrototypes[gasId];
|
||||
public static GasPrototype GetGas(Gas gasId) => GasPrototypes[(int) gasId];
|
||||
public static IEnumerable<GasPrototype> Gases => GasPrototypes;
|
||||
|
||||
#region ATMOS
|
||||
/// <summary>
|
||||
/// The universal gas constant, in kPa*L/(K*mol)
|
||||
/// </summary>
|
||||
public const float R = 8.314462618f;
|
||||
|
||||
/// <summary>
|
||||
/// 1 ATM in kPA.
|
||||
/// </summary>
|
||||
public const float OneAtmosphere = 101.325f;
|
||||
|
||||
/// <summary>
|
||||
/// -270.3ºC in K. CMB stands for Cosmic Microwave Background.
|
||||
/// </summary>
|
||||
public const float TCMB = 2.7f;
|
||||
|
||||
/// <summary>
|
||||
/// 0ºC in K
|
||||
/// </summary>
|
||||
public const float T0C = 273.15f;
|
||||
|
||||
/// <summary>
|
||||
/// 20ºC in K
|
||||
/// </summary>
|
||||
public const float T20C = 293.15f;
|
||||
|
||||
/// <summary>
|
||||
/// Liters in a cell.
|
||||
/// </summary>
|
||||
public const float CellVolume = 2500f;
|
||||
|
||||
/// <summary>
|
||||
/// Moles in a 2.5 m^3 cell at 101.325 Pa and 20ºC
|
||||
/// </summary>
|
||||
public const float MolesCellStandard = (OneAtmosphere * CellVolume / (T20C * R));
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Visible moles multiplied by this factor to get moles at which gas is at max visibility.
|
||||
/// </summary>
|
||||
public const float FactorGasVisibleMax = 20f;
|
||||
|
||||
/// <summary>
|
||||
/// Minimum number of moles a gas can have.
|
||||
/// </summary>
|
||||
public const float GasMinMoles = 0.00000005f;
|
||||
|
||||
public const float OpenHeatTransferCoefficient = 0.4f;
|
||||
|
||||
/// <summary>
|
||||
/// Ratio of air that must move to/from a tile to reset group processing
|
||||
/// </summary>
|
||||
public const float MinimumAirRatioToSuspend = 0.1f;
|
||||
|
||||
/// <summary>
|
||||
/// Minimum ratio of air that must move to/from a tile
|
||||
/// </summary>
|
||||
public const float MinimumAirRatioToMove = 0.001f;
|
||||
|
||||
/// <summary>
|
||||
/// Minimum amount of air that has to move before a group processing can be suspended
|
||||
/// </summary>
|
||||
public const float MinimumAirToSuspend = (MolesCellStandard * MinimumAirRatioToSuspend);
|
||||
|
||||
public const float MinimumTemperatureToMove = (T20C + 100f);
|
||||
|
||||
public const float MinimumMolesDeltaToMove = (MolesCellStandard * MinimumAirRatioToMove);
|
||||
|
||||
/// <summary>
|
||||
/// Minimum temperature difference before group processing is suspended
|
||||
/// </summary>
|
||||
public const float MinimumTemperatureDeltaToSuspend = 4.0f;
|
||||
|
||||
/// <summary>
|
||||
/// Minimum temperature difference before the gas temperatures are just set to be equal.
|
||||
/// </summary>
|
||||
public const float MinimumTemperatureDeltaToConsider = 0.5f;
|
||||
|
||||
/// <summary>
|
||||
/// Minimum temperature for starting superconduction.
|
||||
/// </summary>
|
||||
public const float MinimumTemperatureStartSuperConduction = (T20C + 200f);
|
||||
|
||||
/// <summary>
|
||||
/// Minimum heat capacity.
|
||||
/// </summary>
|
||||
public const float MinimumHeatCapacity = 0.0003f;
|
||||
|
||||
#region Excited Groups
|
||||
|
||||
/// <summary>
|
||||
/// Number of full atmos updates ticks before an excited group breaks down (averages gas contents across turfs)
|
||||
/// </summary>
|
||||
public const int ExcitedGroupBreakdownCycles = 4;
|
||||
|
||||
/// <summary>
|
||||
/// Number of full atmos updates before an excited group dismantles and removes its turfs from active
|
||||
/// </summary>
|
||||
public const int ExcitedGroupsDismantleCycles = 16;
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Hard limit for tile equalization.
|
||||
/// </summary>
|
||||
public const int ZumosHardTileLimit = 2000;
|
||||
|
||||
/// <summary>
|
||||
/// Limit for zone-based tile equalization.
|
||||
/// </summary>
|
||||
public const int ZumosTileLimit = 200;
|
||||
|
||||
/// <summary>
|
||||
/// Total number of gases. Increase this if you want to add more!
|
||||
/// </summary>
|
||||
public const int TotalNumberOfGases = 5;
|
||||
|
||||
public const float FireMinimumTemperatureToExist = T0C + 100f;
|
||||
public const float FireMinimumTemperatureToSpread = T0C + 150f;
|
||||
public const float FireSpreadRadiosityScale = 0.85f;
|
||||
public const float FirePhoronEnergyReleased = 3000000f;
|
||||
public const float FireGrowthRate = 40000f;
|
||||
|
||||
public const float SuperSaturationThreshold = 96f;
|
||||
|
||||
public const float OxygenBurnRateBase = 1.4f;
|
||||
public const float PhoronMinimumBurnTemperature = (100f+T0C);
|
||||
public const float PhoronUpperTemperature = (1370f+T0C);
|
||||
public const float PhoronOxygenFullburn = 10f;
|
||||
public const float PhoronBurnRateDelta = 9f;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gases to Ids. Keep these updated with the prototypes!
|
||||
/// </summary>
|
||||
public enum Gas
|
||||
{
|
||||
Oxygen = 0,
|
||||
Nitrogen = 1,
|
||||
CarbonDioxide = 2,
|
||||
Phoron = 3,
|
||||
Tritium = 4,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user