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

This commit is contained in:
Víctor Aguilera Puerto
2020-09-09 22:12:38 +02:00
committed by GitHub
21 changed files with 488 additions and 154 deletions

View File

@@ -0,0 +1,38 @@
using Content.Server.Atmos;
using Content.Server.GameObjects.Components.Temperature;
using Content.Shared.Atmos;
using Robust.Shared.GameObjects;
namespace Content.Server.GameObjects.Components.Atmos
{
/// <summary>
/// Represents that entity can be exposed to Atmo
/// </summary>
[RegisterComponent]
public class AtmosExposedComponent
: Component
{
public override string Name => "AtmosExposed";
public void Update(TileAtmosphere tile, float timeDelta)
{
if (Owner.TryGetComponent<TemperatureComponent>(out var temperatureComponent))
{
if (tile.Air != null)
{
var temperatureDelta = tile.Air.Temperature - temperatureComponent.CurrentTemperature;
var heat = temperatureDelta * (tile.Air.HeatCapacity * temperatureComponent.HeatCapacity / (tile.Air.HeatCapacity + temperatureComponent.HeatCapacity));
temperatureComponent.ReceiveHeat(heat);
}
temperatureComponent.Update();
}
if (Owner.TryGetComponent<BarotraumaComponent>(out var barotraumaComponent))
{
barotraumaComponent.Update(tile.Air?.Pressure ?? 0);
}
}
}
}

View File

@@ -1,14 +1,12 @@
using System;
using System.Runtime.CompilerServices;
using Content.Server.GameObjects.Components.Mobs;
using Content.Server.GameObjects.EntitySystems;
using Content.Server.Interfaces.GameObjects;
using Content.Shared.Atmos;
using Content.Shared.GameObjects.Components.Damage;
using Content.Shared.Damage;
using Content.Shared.GameObjects.Components.Mobs;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.GameObjects;
namespace Content.Server.GameObjects.Components.Atmos
@@ -19,21 +17,14 @@ namespace Content.Server.GameObjects.Components.Atmos
[RegisterComponent]
public class BarotraumaComponent : Component
{
[Robust.Shared.IoC.Dependency] private readonly IEntityManager _entityManager = default!;
public override string Name => "Barotrauma";
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Update(float frameTime)
public void Update(float airPressure)
{
if (!Owner.TryGetComponent(out IDamageableComponent damageable)) return;
Owner.TryGetComponent(out ServerStatusEffectsComponent status);
var coordinates = Owner.Transform.Coordinates;
var gridAtmos = EntitySystem.Get<AtmosphereSystem>().GetGridAtmosphere(coordinates.GetGridId(_entityManager));
var tile = gridAtmos?.GetTile(coordinates);
var pressure = 1f;
var highPressureMultiplier = 1f;
var lowPressureMultiplier = 1f;
@@ -43,8 +34,7 @@ namespace Content.Server.GameObjects.Components.Atmos
lowPressureMultiplier *= protection.LowPressureMultiplier;
}
if (tile?.Air != null)
pressure = MathF.Max(tile.Air.Pressure, 1f);
var pressure = MathF.Max(airPressure, 1f);
switch (pressure)
{