Internals improvements (#11677)
This commit is contained in:
@@ -7,7 +7,6 @@ using Content.Server.UserInterface;
|
|||||||
using Content.Shared.Actions;
|
using Content.Shared.Actions;
|
||||||
using Content.Shared.Atmos;
|
using Content.Shared.Atmos;
|
||||||
using Content.Shared.Atmos.Components;
|
using Content.Shared.Atmos.Components;
|
||||||
using Content.Shared.Audio;
|
|
||||||
using Content.Shared.Toggleable;
|
using Content.Shared.Toggleable;
|
||||||
using Content.Shared.Examine;
|
using Content.Shared.Examine;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
@@ -25,6 +24,7 @@ namespace Content.Server.Atmos.EntitySystems
|
|||||||
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
|
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
|
||||||
[Dependency] private readonly ExplosionSystem _explosions = default!;
|
[Dependency] private readonly ExplosionSystem _explosions = default!;
|
||||||
[Dependency] private readonly InternalsSystem _internals = default!;
|
[Dependency] private readonly InternalsSystem _internals = default!;
|
||||||
|
[Dependency] private readonly SharedAudioSystem _audioSys = default!;
|
||||||
[Dependency] private readonly SharedContainerSystem _containers = default!;
|
[Dependency] private readonly SharedContainerSystem _containers = default!;
|
||||||
[Dependency] private readonly SharedActionsSystem _actions = default!;
|
[Dependency] private readonly SharedActionsSystem _actions = default!;
|
||||||
[Dependency] private readonly UserInterfaceSystem _ui = default!;
|
[Dependency] private readonly UserInterfaceSystem _ui = default!;
|
||||||
@@ -68,13 +68,13 @@ namespace Content.Server.Atmos.EntitySystems
|
|||||||
public void UpdateUserInterface(GasTankComponent component, bool initialUpdate = false)
|
public void UpdateUserInterface(GasTankComponent component, bool initialUpdate = false)
|
||||||
{
|
{
|
||||||
var internals = GetInternalsComponent(component);
|
var internals = GetInternalsComponent(component);
|
||||||
_ui.GetUiOrNull(component.Owner, SharedGasTankUiKey.Key)?.SetState(
|
_ui.TrySetUiState(component.Owner, SharedGasTankUiKey.Key,
|
||||||
new GasTankBoundUserInterfaceState
|
new GasTankBoundUserInterfaceState
|
||||||
{
|
{
|
||||||
TankPressure = component.Air?.Pressure ?? 0,
|
TankPressure = component.Air?.Pressure ?? 0,
|
||||||
OutputPressure = initialUpdate ? component.OutputPressure : null,
|
OutputPressure = initialUpdate ? component.OutputPressure : null,
|
||||||
InternalsConnected = component.IsConnected,
|
InternalsConnected = component.IsConnected,
|
||||||
CanConnectInternals = IsFunctional(component) && internals != null
|
CanConnectInternals = CanConnectToInternals(component)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,12 +189,13 @@ namespace Content.Server.Atmos.EntitySystems
|
|||||||
|
|
||||||
public bool CanConnectToInternals(GasTankComponent component)
|
public bool CanConnectToInternals(GasTankComponent component)
|
||||||
{
|
{
|
||||||
return !component.IsConnected && IsFunctional(component);
|
var internals = GetInternalsComponent(component);
|
||||||
|
return internals != null && internals.BreathToolEntity != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ConnectToInternals(GasTankComponent component)
|
public void ConnectToInternals(GasTankComponent component)
|
||||||
{
|
{
|
||||||
if (!CanConnectToInternals(component)) return;
|
if (component.IsConnected || !CanConnectToInternals(component)) return;
|
||||||
var internals = GetInternalsComponent(component);
|
var internals = GetInternalsComponent(component);
|
||||||
if (internals == null) return;
|
if (internals == null) return;
|
||||||
|
|
||||||
@@ -209,7 +210,7 @@ namespace Content.Server.Atmos.EntitySystems
|
|||||||
component.ConnectStream?.Stop();
|
component.ConnectStream?.Stop();
|
||||||
|
|
||||||
if (component.ConnectSound != null)
|
if (component.ConnectSound != null)
|
||||||
component.ConnectStream = SoundSystem.Play(component.ConnectSound.GetSound(), Filter.Pvs(component.Owner, entityManager: EntityManager), component.Owner, component.ConnectSound.Params);
|
component.ConnectStream = _audioSys.Play(component.ConnectSound, Filter.Pvs(component.Owner, entityManager: EntityManager), component.Owner, component.ConnectSound.Params);
|
||||||
|
|
||||||
UpdateUserInterface(component);
|
UpdateUserInterface(component);
|
||||||
}
|
}
|
||||||
@@ -228,7 +229,7 @@ namespace Content.Server.Atmos.EntitySystems
|
|||||||
component.DisconnectStream?.Stop();
|
component.DisconnectStream?.Stop();
|
||||||
|
|
||||||
if (component.DisconnectSound != null)
|
if (component.DisconnectSound != null)
|
||||||
component.DisconnectStream = SoundSystem.Play(component.DisconnectSound.GetSound(), Filter.Pvs(component.Owner, entityManager: EntityManager), component.Owner, component.DisconnectSound.Params);
|
component.DisconnectStream = _audioSys.Play(component.DisconnectSound, Filter.Pvs(component.Owner, entityManager: EntityManager), component.Owner, component.DisconnectSound.Params);
|
||||||
|
|
||||||
UpdateUserInterface(component);
|
UpdateUserInterface(component);
|
||||||
}
|
}
|
||||||
@@ -287,7 +288,7 @@ namespace Content.Server.Atmos.EntitySystems
|
|||||||
if(environment != null)
|
if(environment != null)
|
||||||
_atmosphereSystem.Merge(environment, component.Air);
|
_atmosphereSystem.Merge(environment, component.Air);
|
||||||
|
|
||||||
SoundSystem.Play(component.RuptureSound.GetSound(), Filter.Pvs(component.Owner), Transform(component.Owner).Coordinates, AudioHelpers.WithVariation(0.125f));
|
_audioSys.Play(component.RuptureSound, Filter.Pvs(component.Owner), Transform(component.Owner).Coordinates, AudioParams.Default.WithVariation(0.125f));
|
||||||
|
|
||||||
QueueDel(component.Owner);
|
QueueDel(component.Owner);
|
||||||
return;
|
return;
|
||||||
@@ -320,11 +321,6 @@ namespace Content.Server.Atmos.EntitySystems
|
|||||||
component.Integrity++;
|
component.Integrity++;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsFunctional(GasTankComponent component)
|
|
||||||
{
|
|
||||||
return GetInternalsComponent(component) != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the gas mixture for the gas analyzer
|
/// Returns the gas mixture for the gas analyzer
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ public sealed class InternalsSystem : EntitySystem
|
|||||||
// Prioritise
|
// Prioritise
|
||||||
// 1. exo-slot tanks
|
// 1. exo-slot tanks
|
||||||
// 2. in-hand tanks
|
// 2. in-hand tanks
|
||||||
// 3. pocket tanks
|
// 3. pocket/belt tanks
|
||||||
InventoryComponent? inventory = null;
|
InventoryComponent? inventory = null;
|
||||||
ContainerManagerComponent? containerManager = null;
|
ContainerManagerComponent? containerManager = null;
|
||||||
|
|
||||||
@@ -153,7 +153,7 @@ public sealed class InternalsSystem : EntitySystem
|
|||||||
|
|
||||||
if (Resolve(component.Owner, ref inventory, false))
|
if (Resolve(component.Owner, ref inventory, false))
|
||||||
{
|
{
|
||||||
var enumerator = new InventorySystem.ContainerSlotEnumerator(component.Owner, inventory.TemplateId, _protoManager, _inventory, SlotFlags.POCKET);
|
var enumerator = new InventorySystem.ContainerSlotEnumerator(component.Owner, inventory.TemplateId, _protoManager, _inventory, SlotFlags.POCKET | SlotFlags.BELT);
|
||||||
|
|
||||||
while (enumerator.MoveNext(out var container))
|
while (enumerator.MoveNext(out var container))
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user