Add an atmos throw velocity cap, adjustible console variables, and fix throw directions for station rotation (#7631)
This commit is contained in:
@@ -9,6 +9,10 @@ namespace Content.Server.Atmos.EntitySystems
|
|||||||
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
||||||
|
|
||||||
public bool SpaceWind { get; private set; }
|
public bool SpaceWind { get; private set; }
|
||||||
|
public float SpaceWindPressureForceDivisorThrow { get; private set; }
|
||||||
|
public float SpaceWindPressureForceDivisorPush { get; private set; }
|
||||||
|
public float SpaceWindMaxVelocity { get; private set; }
|
||||||
|
public float SpaceWindMaxPushForce { get; private set; }
|
||||||
public bool MonstermosEqualization { get; private set; }
|
public bool MonstermosEqualization { get; private set; }
|
||||||
public bool MonstermosDepressurization { get; private set; }
|
public bool MonstermosDepressurization { get; private set; }
|
||||||
public bool MonstermosRipTiles { get; private set; }
|
public bool MonstermosRipTiles { get; private set; }
|
||||||
@@ -23,6 +27,10 @@ namespace Content.Server.Atmos.EntitySystems
|
|||||||
private void InitializeCVars()
|
private void InitializeCVars()
|
||||||
{
|
{
|
||||||
_cfg.OnValueChanged(CCVars.SpaceWind, value => SpaceWind = value, true);
|
_cfg.OnValueChanged(CCVars.SpaceWind, value => SpaceWind = value, true);
|
||||||
|
_cfg.OnValueChanged(CCVars.SpaceWindPressureForceDivisorThrow, value => SpaceWindPressureForceDivisorThrow = value, true);
|
||||||
|
_cfg.OnValueChanged(CCVars.SpaceWindPressureForceDivisorPush, value => SpaceWindPressureForceDivisorPush = value, true);
|
||||||
|
_cfg.OnValueChanged(CCVars.SpaceWindMaxVelocity, value => SpaceWindMaxVelocity = value, true);
|
||||||
|
_cfg.OnValueChanged(CCVars.SpaceWindMaxPushForce, value => SpaceWindMaxPushForce = value, true);
|
||||||
_cfg.OnValueChanged(CCVars.MonstermosEqualization, value => MonstermosEqualization = value, true);
|
_cfg.OnValueChanged(CCVars.MonstermosEqualization, value => MonstermosEqualization = value, true);
|
||||||
_cfg.OnValueChanged(CCVars.MonstermosDepressurization, value => MonstermosDepressurization = value, true);
|
_cfg.OnValueChanged(CCVars.MonstermosDepressurization, value => MonstermosDepressurization = value, true);
|
||||||
_cfg.OnValueChanged(CCVars.MonstermosRipTiles, value => MonstermosRipTiles = value, true);
|
_cfg.OnValueChanged(CCVars.MonstermosRipTiles, value => MonstermosRipTiles = value, true);
|
||||||
|
|||||||
@@ -104,6 +104,9 @@ namespace Content.Server.Atmos.EntitySystems
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Used by ExperiencePressureDifference to correct push/throw directions from tile-relative to physics world.
|
||||||
|
var gridWorldRotation = xforms.GetComponent(gridAtmosphere.Owner).WorldRotation;
|
||||||
|
|
||||||
foreach (var entity in _lookup.GetEntitiesIntersecting(tile.GridIndex, tile.GridIndices))
|
foreach (var entity in _lookup.GetEntitiesIntersecting(tile.GridIndex, tile.GridIndices))
|
||||||
{
|
{
|
||||||
// Ideally containers would have their own EntityQuery internally or something given recursively it may need to slam GetComp<T> anyway.
|
// Ideally containers would have their own EntityQuery internally or something given recursively it may need to slam GetComp<T> anyway.
|
||||||
@@ -125,6 +128,7 @@ namespace Content.Server.Atmos.EntitySystems
|
|||||||
tile.PressureDifference,
|
tile.PressureDifference,
|
||||||
tile.PressureDirection, 0,
|
tile.PressureDirection, 0,
|
||||||
tile.PressureSpecificTarget?.GridIndices.ToEntityCoordinates(tile.GridIndex, _mapManager) ?? EntityCoordinates.Invalid,
|
tile.PressureSpecificTarget?.GridIndices.ToEntityCoordinates(tile.GridIndex, _mapManager) ?? EntityCoordinates.Invalid,
|
||||||
|
gridWorldRotation,
|
||||||
xforms.GetComponent(entity),
|
xforms.GetComponent(entity),
|
||||||
body);
|
body);
|
||||||
}
|
}
|
||||||
@@ -140,6 +144,7 @@ namespace Content.Server.Atmos.EntitySystems
|
|||||||
_spaceWindSoundCooldown = 0;
|
_spaceWindSoundCooldown = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Called from AtmosphereSystem.LINDA.cs with SpaceWind CVar check handled there.
|
||||||
private void ConsiderPressureDifference(GridAtmosphereComponent gridAtmosphere, TileAtmosphere tile, TileAtmosphere other, float difference)
|
private void ConsiderPressureDifference(GridAtmosphereComponent gridAtmosphere, TileAtmosphere tile, TileAtmosphere other, float difference)
|
||||||
{
|
{
|
||||||
gridAtmosphere.HighPressureDelta.Add(tile);
|
gridAtmosphere.HighPressureDelta.Add(tile);
|
||||||
@@ -157,6 +162,7 @@ namespace Content.Server.Atmos.EntitySystems
|
|||||||
AtmosDirection direction,
|
AtmosDirection direction,
|
||||||
float pressureResistanceProbDelta,
|
float pressureResistanceProbDelta,
|
||||||
EntityCoordinates throwTarget,
|
EntityCoordinates throwTarget,
|
||||||
|
Angle gridWorldRotation,
|
||||||
TransformComponent? xform = null,
|
TransformComponent? xform = null,
|
||||||
PhysicsComponent? physics = null)
|
PhysicsComponent? physics = null)
|
||||||
{
|
{
|
||||||
@@ -188,18 +194,28 @@ namespace Content.Server.Atmos.EntitySystems
|
|||||||
|
|
||||||
if (maxForce > MovedByPressureComponent.ThrowForce)
|
if (maxForce > MovedByPressureComponent.ThrowForce)
|
||||||
{
|
{
|
||||||
|
var moveForce = maxForce;
|
||||||
|
moveForce /= (throwTarget != EntityCoordinates.Invalid) ? SpaceWindPressureForceDivisorThrow : SpaceWindPressureForceDivisorPush;
|
||||||
|
moveForce *= MathHelper.Clamp(moveProb, 0, 100);
|
||||||
|
|
||||||
|
// Apply a sanity clamp to prevent being thrown through objects.
|
||||||
|
var maxSafeForceForObject = SpaceWindMaxVelocity * physics.Mass;
|
||||||
|
moveForce = MathF.Min(moveForce, maxSafeForceForObject);
|
||||||
|
|
||||||
|
// Grid-rotation adjusted direction
|
||||||
|
var dirVec = (direction.ToAngle() + gridWorldRotation).ToWorldVec();
|
||||||
|
|
||||||
// TODO: Technically these directions won't be correct but uhh I'm just here for optimisations buddy not to fix my old bugs.
|
// TODO: Technically these directions won't be correct but uhh I'm just here for optimisations buddy not to fix my old bugs.
|
||||||
if (throwTarget != EntityCoordinates.Invalid)
|
if (throwTarget != EntityCoordinates.Invalid)
|
||||||
{
|
{
|
||||||
var moveForce = maxForce * MathHelper.Clamp(moveProb, 0, 100) / 15f;
|
var pos = ((throwTarget.ToMap(EntityManager).Position - xform.WorldPosition).Normalized + dirVec).Normalized;
|
||||||
var pos = ((throwTarget.Position - xform.Coordinates.Position).Normalized + direction.ToDirection().ToVec()).Normalized;
|
|
||||||
physics.ApplyLinearImpulse(pos * moveForce);
|
physics.ApplyLinearImpulse(pos * moveForce);
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var moveForce = MathF.Min(maxForce * MathHelper.Clamp(moveProb, 0, 100) / 2500f, 20f);
|
moveForce = MathF.Min(moveForce, SpaceWindMaxPushForce);
|
||||||
physics.ApplyLinearImpulse(direction.ToDirection().ToVec() * moveForce);
|
physics.ApplyLinearImpulse(dirVec * moveForce);
|
||||||
}
|
}
|
||||||
|
|
||||||
component.LastHighPressureMovementAirCycle = cycle;
|
component.LastHighPressureMovementAirCycle = cycle;
|
||||||
|
|||||||
@@ -544,6 +544,32 @@ namespace Content.Shared.CCVar
|
|||||||
public static readonly CVarDef<bool> SpaceWind =
|
public static readonly CVarDef<bool> SpaceWind =
|
||||||
CVarDef.Create("atmos.space_wind", true, CVar.SERVERONLY);
|
CVarDef.Create("atmos.space_wind", true, CVar.SERVERONLY);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Divisor from maxForce (pressureDifference * 2.25f) to force applied on objects.
|
||||||
|
/// </summary>
|
||||||
|
public static readonly CVarDef<float> SpaceWindPressureForceDivisorThrow =
|
||||||
|
CVarDef.Create("atmos.space_wind_pressure_force_divisor_throw", 15f, CVar.SERVERONLY);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Divisor from maxForce (pressureDifference * 2.25f) to force applied on objects.
|
||||||
|
/// </summary>
|
||||||
|
public static readonly CVarDef<float> SpaceWindPressureForceDivisorPush =
|
||||||
|
CVarDef.Create("atmos.space_wind_pressure_force_divisor_push", 2500f, CVar.SERVERONLY);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The maximum velocity (not force) that may be applied to an object by atmospheric pressure differences.
|
||||||
|
/// Useful to prevent clipping through objects.
|
||||||
|
/// </summary>
|
||||||
|
public static readonly CVarDef<float> SpaceWindMaxVelocity =
|
||||||
|
CVarDef.Create("atmos.space_wind_max_velocity", 30f, CVar.SERVERONLY);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The maximum force that may be applied to an object by pushing (i.e. not throwing) atmospheric pressure differences.
|
||||||
|
/// A "throwing" atmospheric pressure difference ignores this limit, but not the max. velocity limit.
|
||||||
|
/// </summary>
|
||||||
|
public static readonly CVarDef<float> SpaceWindMaxPushForce =
|
||||||
|
CVarDef.Create("atmos.space_wind_max_push_force", 20f, CVar.SERVERONLY);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether monstermos tile equalization is enabled.
|
/// Whether monstermos tile equalization is enabled.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user