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

This commit is contained in:
Víctor Aguilera Puerto
2020-09-12 15:52:20 +02:00
committed by GitHub
20 changed files with 355 additions and 11 deletions

View File

@@ -2,6 +2,8 @@
using Content.Server.GameObjects.Components.NodeContainer;
using Content.Server.GameObjects.Components.NodeContainer.Nodes;
using Content.Server.GameObjects.EntitySystems;
using Content.Shared.GameObjects.Atmos;
using Robust.Server.GameObjects;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Log;
using Robust.Shared.ViewVariables;
@@ -23,6 +25,20 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping
private AtmosphereSystem _atmosSystem;
[ViewVariables(VVAccess.ReadWrite)]
public bool SiphonEnabled
{
get => _siphonEnabled;
set
{
_siphonEnabled = value;
UpdateAppearance();
}
}
private bool _siphonEnabled = true;
private AppearanceComponent _appearance;
public override void Initialize()
{
base.Initialize();
@@ -40,10 +56,15 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping
Logger.Error($"{typeof(BaseSiphonComponent)} on entity {Owner.Uid} could not find compatible {nameof(PipeNode)}s on its {nameof(NodeContainerComponent)}.");
return;
}
Owner.TryGetComponent(out _appearance);
UpdateAppearance();
}
public override void Update()
{
if (!SiphonEnabled)
return;
var tileAtmos = Owner.Transform.Coordinates.GetTileAtmosphere(_entityManager);
if (tileAtmos == null)
return;
@@ -52,5 +73,10 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping
}
protected abstract void ScrubGas(GasMixture inletGas, GasMixture outletGas);
private void UpdateAppearance()
{
_appearance?.SetData(SiphonVisuals.VisualState, new SiphonVisualState(SiphonEnabled));
}
}
}

View File

@@ -2,6 +2,8 @@
using Content.Server.GameObjects.Components.NodeContainer;
using Content.Server.GameObjects.Components.NodeContainer.Nodes;
using Content.Server.GameObjects.EntitySystems;
using Content.Shared.GameObjects.Atmos;
using Robust.Server.GameObjects;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Log;
using Robust.Shared.ViewVariables;
@@ -23,6 +25,20 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping
private AtmosphereSystem _atmosSystem;
[ViewVariables(VVAccess.ReadWrite)]
public bool VentEnabled
{
get => _ventEnabled;
set
{
_ventEnabled = value;
UpdateAppearance();
}
}
private bool _ventEnabled = true;
private AppearanceComponent _appearance;
public override void Initialize()
{
base.Initialize();
@@ -40,10 +56,15 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping
Logger.Error($"{typeof(BaseVentComponent)} on entity {Owner.Uid} could not find compatible {nameof(PipeNode)}s on its {nameof(NodeContainerComponent)}.");
return;
}
Owner.TryGetComponent(out _appearance);
UpdateAppearance();
}
public override void Update()
{
if (!VentEnabled)
return;
var tileAtmos = Owner.Transform.Coordinates.GetTileAtmosphere(_entityManager);
if (tileAtmos == null)
return;
@@ -52,5 +73,10 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping
}
protected abstract void VentGas(GasMixture inletGas, GasMixture outletGas);
private void UpdateAppearance()
{
_appearance?.SetData(VentVisuals.VisualState, new VentVisualState(VentEnabled));
}
}
}

View File

@@ -13,12 +13,17 @@ namespace Content.Server.Utility
/// </summary>
/// <param name="source">The entity on which to popup the message.</param>
/// <param name="message">The message to show.</param>
/// <param name="playerManager">
/// The instance of player manager to use, will be resolved automatically
/// if null.
/// </param>
/// <param name="range">
/// The range in which to search for players, defaulting to one screen.
/// </param>
public static void PopupMessageOtherClients(this IEntity source, string message, int range = 15)
public static void PopupMessageOtherClients(this IEntity source, string message, IPlayerManager playerManager = null, int range = 15)
{
var playerManager = IoCManager.Resolve<IPlayerManager>();
playerManager ??= IoCManager.Resolve<IPlayerManager>();
var viewers = playerManager.GetPlayersInRange(source.Transform.Coordinates, range);
foreach (var viewer in viewers)
@@ -33,5 +38,24 @@ namespace Content.Server.Utility
source.PopupMessage(viewer.AttachedEntity, message);
}
}
/// <summary>
/// Pops up a message at the given entity's location for everyone,
/// including itself, to see.
/// </summary>
/// <param name="source">The entity above which to show the message.</param>
/// <param name="message">The message to be seen.</param>
/// <param name="playerManager">
/// The instance of player manager to use, will be resolved automatically
/// if null.
/// </param>
/// <param name="range">
/// The range in which to search for players, defaulting to one screen.
/// </param>
public static void PopupMessageEveryone(this IEntity source, string message, IPlayerManager playerManager = null, int range = 15)
{
source.PopupMessage(message);
source.PopupMessageOtherClients(message, playerManager, range);
}
}
}