Files
Delta-v/Content.Server/Atmos/EntitySystems/AutomaticAtmosSystem.cs
T
733d479425 Move a metric fuckton of AtmosphereSystem to Shared. (#42989)
* AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

* fix the tests I broke

* Remove methods that the client shouldn't be calling. Hamburger.

* light cleanup for now

* review

* whoop

* docs updates and misc changes

---------

Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com>
Co-authored-by: ArtisticRoomba <145879011+ArtisticRoomba@users.noreply.github.com>
2026-06-29 12:44:04 +02:00

40 lines
1.4 KiB
C#

using Content.Server.Shuttles.Systems;
using Content.Shared.Atmos.Components;
using Robust.Shared.Map.Components;
using Robust.Shared.Physics.Events;
namespace Content.Server.Atmos.EntitySystems;
/// <summary>
/// Handles automatically adding a grid atmosphere to grids that become large enough, allowing players to build shuttles
/// with a sealed atmosphere from scratch.
/// </summary>
public sealed class AutomaticAtmosSystem : EntitySystem
{
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<MapGridComponent, MassDataChangedEvent>(OnMassDataChanged);
}
private void OnMassDataChanged(Entity<MapGridComponent> ent, ref MassDataChangedEvent ev)
{
if (_atmosphereSystem.HasAtmosphere(ent))
return;
// We can't actually count how many tiles there are efficiently, so instead estimate with the mass.
if (ev.NewMass / ShuttleSystem.TileDensityMultiplier >= 7.0f)
{
AddComp<GridAtmosphereComponent>(ent);
Log.Info($"Giving grid {ent} GridAtmosphereComponent.");
}
// It's not super important to remove it should the grid become too small again.
// If explosions ever gain the ability to outright shatter grids, do rethink this.
return;
}
}