Merge branch 'master' into 2020-08-19-firelocks

# Conflicts:
#	Content.Server/GameObjects/Components/Atmos/AirtightComponent.cs
This commit is contained in:
Víctor Aguilera Puerto
2020-09-06 16:56:43 +02:00
197 changed files with 846 additions and 670 deletions

View File

@@ -2,31 +2,35 @@
using System.Diagnostics.CodeAnalysis;
using Content.Server.GameObjects.EntitySystems;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Map;
namespace Content.Server.Atmos
{
public static class AtmosHelpers
{
public static TileAtmosphere? GetTileAtmosphere(this GridCoordinates coordinates)
public static TileAtmosphere? GetTileAtmosphere(this EntityCoordinates coordinates, IEntityManager? entityManager = null)
{
var gridAtmos = EntitySystem.Get<AtmosphereSystem>().GetGridAtmosphere(coordinates.GridID);
entityManager ??= IoCManager.Resolve<IEntityManager>();
var gridAtmos = EntitySystem.Get<AtmosphereSystem>().GetGridAtmosphere(coordinates.GetGridId(entityManager));
return gridAtmos?.GetTile(coordinates);
}
public static GasMixture? GetTileAir(this GridCoordinates coordinates)
public static GasMixture? GetTileAir(this EntityCoordinates coordinates)
{
return coordinates.GetTileAtmosphere()?.Air;
}
public static bool TryGetTileAtmosphere(this GridCoordinates coordinates, [MaybeNullWhen(false)] out TileAtmosphere atmosphere)
public static bool TryGetTileAtmosphere(this EntityCoordinates coordinates, [MaybeNullWhen(false)] out TileAtmosphere atmosphere)
{
// ReSharper disable once ConditionIsAlwaysTrueOrFalse
return !Equals(atmosphere = coordinates.GetTileAtmosphere()!, default);
}
public static bool TryGetTileAir(this GridCoordinates coordinates, [MaybeNullWhen(false)] out GasMixture air)
public static bool TryGetTileAir(this EntityCoordinates coordinates, [MaybeNullWhen(false)] out GasMixture air)
{
// ReSharper disable once ConditionIsAlwaysTrueOrFalse
return !Equals(air = coordinates.GetTileAir()!, default);

View File

@@ -53,7 +53,7 @@ namespace Content.Server.Atmos
{
tank.TryRemoveReagent(_fuelType, ReagentUnit.New(_fuelCost));
var playerPos = eventArgs.User.Transform.GridPosition;
var playerPos = eventArgs.User.Transform.Coordinates;
var direction = (eventArgs.ClickLocation.Position - playerPos.Position).Normalized;
playerPos.Offset(direction/2);

View File

@@ -8,9 +8,9 @@ using Robust.Shared.IoC;
using Robust.Shared.Maths;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
using Content.Server.GameObjects.Components.Atmos;
using Content.Server.Interfaces;
using Content.Shared.Atmos;
using Robust.Shared.Map;
namespace Content.Server.Atmos
{
@@ -18,6 +18,8 @@ namespace Content.Server.Atmos
class GasVaporComponent : Component, ICollideBehavior, IGasMixtureHolder
{
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
public override string Name => "GasVapor";
[ViewVariables] public GasMixture Air { get; set; }
@@ -76,10 +78,10 @@ namespace Content.Server.Atmos
foreach (var tile in tiles)
{
var pos = tile.GridIndices.ToGridCoordinates(_mapManager, tile.GridIndex);
var atmos = AtmosHelpers.GetTileAtmosphere(pos);
var pos = tile.GridIndices.ToEntityCoordinates(_mapManager, tile.GridIndex);
var atmos = pos.GetTileAtmosphere(_entityManager);
if (atmos.Air == null)
if (atmos?.Air == null)
{
return;
}

View File

@@ -26,7 +26,7 @@ namespace Content.Server.Atmos
private const float ThrowForce = 100f;
public void ExperiencePressureDifference(int cycle, float pressureDifference, AtmosDirection direction,
float pressureResistanceProbDelta, GridCoordinates throwTarget)
float pressureResistanceProbDelta, EntityCoordinates throwTarget)
{
if (ControlledComponent == null)
return;
@@ -52,10 +52,10 @@ namespace Content.Server.Atmos
if (maxForce > ThrowForce)
{
if (throwTarget != GridCoordinates.InvalidGrid)
if (throwTarget != EntityCoordinates.Invalid)
{
var moveForce = maxForce * MathHelper.Clamp(moveProb, 0, 100) / 150f;
var pos = ((throwTarget.Position - transform.GridPosition.Position).Normalized + direction.ToDirection().ToVec()).Normalized;
var pos = ((throwTarget.Position - transform.Coordinates.Position).Normalized + direction.ToDirection().ToVec()).Normalized;
LinearVelocity = pos * moveForce;
}
@@ -74,7 +74,7 @@ namespace Content.Server.Atmos
{
base.UpdateAfterProcessing();
if (ControlledComponent != null && !_physicsManager.IsWeightless(ControlledComponent.Owner.Transform.GridPosition))
if (ControlledComponent != null && !_physicsManager.IsWeightless(ControlledComponent.Owner.Transform.Coordinates))
{
LinearVelocity *= 0.85f;
if (MathF.Abs(LinearVelocity.Length) < 1f)

View File

@@ -128,7 +128,7 @@ namespace Content.Server.Atmos
/// <param name="coordinates"></param>
/// <param name="createSpace"></param>
/// <returns></returns>
TileAtmosphere GetTile(GridCoordinates coordinates, bool createSpace = true);
TileAtmosphere GetTile(EntityCoordinates coordinates, bool createSpace = true);
/// <summary>
/// Returns if the tile in question is air-blocked.

View File

@@ -9,8 +9,10 @@ using Content.Server.Interfaces;
using Content.Shared.Atmos;
using Content.Shared.Audio;
using Content.Shared.Maps;
using Content.Shared.Utility;
using JetBrains.Annotations;
using Robust.Server.GameObjects.EntitySystems;
using Robust.Server.GameObjects.EntitySystems.TileLookup;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Components;
@@ -31,6 +33,7 @@ namespace Content.Server.Atmos
[Robust.Shared.IoC.Dependency] private readonly IRobustRandom _robustRandom = default!;
[Robust.Shared.IoC.Dependency] private readonly IEntityManager _entityManager = default!;
[Robust.Shared.IoC.Dependency] private readonly IMapManager _mapManager = default!;
private readonly GridTileLookupSystem _gridTileLookupSystem = default!;
private static readonly TileAtmosphereComparer Comparer = new TileAtmosphereComparer();
@@ -115,6 +118,7 @@ namespace Content.Server.Atmos
{
IoCManager.InjectDependencies(this);
_gridAtmosphereComponent = atmosphereComponent;
_gridTileLookupSystem = _entityManager.EntitySysManager.GetEntitySystem<GridTileLookupSystem>();
GridIndex = gridIndex;
GridIndices = gridIndices;
Air = mixture;
@@ -185,10 +189,10 @@ namespace Content.Server.Atmos
{
if(_soundCooldown == 0)
EntitySystem.Get<AudioSystem>().PlayAtCoords("/Audio/Effects/space_wind.ogg",
GridIndices.ToGridCoordinates(_mapManager, GridIndex), AudioHelpers.WithVariation(0.125f).WithVolume(MathHelper.Clamp(PressureDifference / 10, 10, 100)));
GridIndices.ToEntityCoordinates(_mapManager, GridIndex), AudioHelpers.WithVariation(0.125f).WithVolume(MathHelper.Clamp(PressureDifference / 10, 10, 100)));
}
foreach (var entity in _entityManager.GetEntitiesIntersecting(_mapManager.GetGrid(GridIndex).ParentMapId, Box2.UnitCentered.Translated(GridIndices)))
foreach (var entity in _gridTileLookupSystem.GetEntitiesIntersecting(GridIndex, GridIndices))
{
if (!entity.TryGetComponent(out ICollidableComponent physics)
|| !entity.TryGetComponent(out MovedByPressureComponent pressure)
@@ -200,7 +204,7 @@ namespace Content.Server.Atmos
var pressureMovements = physics.EnsureController<HighPressureMovementController>();
if (pressure.LastHighPressureMovementAirCycle < _gridAtmosphereComponent.UpdateCounter)
{
pressureMovements.ExperiencePressureDifference(_gridAtmosphereComponent.UpdateCounter, PressureDifference, _pressureDirection, 0, PressureSpecificTarget?.GridIndices.ToGridCoordinates(_mapManager, GridIndex) ?? GridCoordinates.InvalidGrid);
pressureMovements.ExperiencePressureDifference(_gridAtmosphereComponent.UpdateCounter, PressureDifference, _pressureDirection, 0, PressureSpecificTarget?.GridIndices.ToEntityCoordinates(_mapManager, GridIndex) ?? EntityCoordinates.Invalid);
}
}