Add atmos grid impulses, disabled by default.

This commit is contained in:
Vera Aguilera Puerto
2021-07-23 17:27:16 +02:00
parent da25266dd5
commit 4ade87c040
3 changed files with 22 additions and 0 deletions

View File

@@ -13,6 +13,7 @@ namespace Content.Server.Atmos.EntitySystems
public bool MonstermosEqualization { get; private set; }
public bool MonstermosDepressurization { get; private set; }
public bool MonstermosRipTiles { get; private set; }
public bool GridImpulse { get; private set; }
public bool Superconduction { get; private set; }
public bool ExcitedGroupsSpaceIsAllConsuming { get; private set; }
public float AtmosMaxProcessTime { get; private set; }
@@ -26,6 +27,7 @@ namespace Content.Server.Atmos.EntitySystems
_cfg.OnValueChanged(CCVars.MonstermosEqualization, value => MonstermosEqualization = value, true);
_cfg.OnValueChanged(CCVars.MonstermosDepressurization, value => MonstermosDepressurization = value, true);
_cfg.OnValueChanged(CCVars.MonstermosRipTiles, value => MonstermosRipTiles = value, true);
_cfg.OnValueChanged(CCVars.AtmosGridImpulse, value => GridImpulse = value, true);
_cfg.OnValueChanged(CCVars.Superconduction, value => Superconduction = value, true);
_cfg.OnValueChanged(CCVars.AtmosMaxProcessTime, value => AtmosMaxProcessTime = value, true);
_cfg.OnValueChanged(CCVars.AtmosTickRate, value => AtmosTickRate = value, true);

View File

@@ -6,6 +6,7 @@ using System.Collections.Generic;
using Content.Server.Atmos.Components;
using Content.Server.Coordinates.Helpers;
using Content.Shared.Atmos;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Map;
using Robust.Shared.Maths;
@@ -462,6 +463,17 @@ namespace Content.Server.Atmos.EntitySystems
HandleDecompressionFloorRip(mapGrid, otherTile, sum);
}
if (GridImpulse && tileCount > 0)
{
var direction = ((Vector2)tiles[tileCount - 1].GridIndices - tile.GridIndices).Normalized;
var gridPhysics = ComponentManager.GetComponent<PhysicsComponent>(mapGrid.GridEntityId);
// TODO ATMOS: Come up with better values for these.
gridPhysics.ApplyLinearImpulse(direction * totalGasesRemoved * gridPhysics.Mass);
gridPhysics.ApplyAngularImpulse(Vector2.Cross(tile.GridIndices - gridPhysics.LocalCenter, direction) * totalGasesRemoved);
}
ArrayPool<TileAtmosphere>.Shared.Return(tiles);
ArrayPool<TileAtmosphere>.Shared.Return(spaceTiles);
ArrayPool<TileAtmosphere>.Shared.Return(progressionOrder);

View File

@@ -269,6 +269,14 @@ namespace Content.Shared.CCVar
public static readonly CVarDef<bool> MonstermosRipTiles =
CVarDef.Create<bool>("atmos.monstermos_rip_tiles", true, CVar.SERVERONLY);
/// <summary>
/// Whether explosive depressurization will cause the grid to gain an impulse.
/// Needs <see cref="MonstermosEqualization"/> and <see cref="MonstermosDepressurization"/> to be enabled to work.
/// </summary>
public static readonly CVarDef<bool> AtmosGridImpulse =
CVarDef.Create("atmos.grid_impulse", false, CVar.SERVERONLY);
/// <summary>
/// Whether atmos superconduction is enabled.
/// </summary>