Merge branch 'master' into 2020-08-31-click-attack

This commit is contained in:
Víctor Aguilera Puerto
2020-09-01 03:25:14 +02:00
25 changed files with 325 additions and 60 deletions

View File

@@ -2,6 +2,8 @@
using Content.Server.GameObjects.Components.NodeContainer;
using Content.Server.GameObjects.Components.NodeContainer.Nodes;
using Content.Shared.GameObjects.Components.Atmos;
using Content.Shared.GameObjects.Atmos;
using Robust.Server.GameObjects;
using Robust.Shared.Log;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
@@ -14,6 +16,21 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping
/// </summary>
public abstract class BasePumpComponent : PipeNetDeviceComponent
{
/// <summary>
/// If the pump is currently pumping.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
public bool PumpEnabled
{
get => _pumpEnabled;
set
{
_pumpEnabled = value;
UpdateAppearance();
}
}
private bool _pumpEnabled = true;
/// <summary>
/// Needs to be same <see cref="PipeDirection"/> as that of a <see cref="Pipe"/> on this entity.
/// </summary>
@@ -32,6 +49,8 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping
[ViewVariables]
private PipeNode _outletPipe;
private AppearanceComponent _appearance;
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
@@ -57,13 +76,23 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping
Logger.Error($"{typeof(BasePumpComponent)} 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 (!PumpEnabled)
return;
PumpGas(_inletPipe.Air, _outletPipe.Air);
}
protected abstract void PumpGas(GasMixture inletGas, GasMixture outletGas);
private void UpdateAppearance()
{
_appearance?.SetData(PumpVisuals.VisualState, new PumpVisualState(_inletDirection, _outletDirection, _inletPipe.ConduitLayer, _outletPipe.ConduitLayer, PumpEnabled));
}
}
}

View File

@@ -246,9 +246,12 @@ namespace Content.Server.GameObjects.Components.Instruments
public void HandSelected(HandSelectedEventArgs eventArgs)
{
var session = eventArgs.User?.GetComponent<BasicActorComponent>()?.playerSession;
if (eventArgs.User == null || !eventArgs.User.TryGetComponent(out BasicActorComponent? actor))
return;
if (session == null) return;
var session = actor.playerSession;
if (session.Status != SessionStatus.InGame) return;
InstrumentPlayer = session;
}