mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 10:21:18 +03:00
* Refactor DeviceNetwork * Singleton * NetworkPayloads refactor * Reorganize DeviceNetworkSystem * Surveillance cameras * Fix code * Fix build * Fix test fail by rewriting entire singleton logic * Properly predict examine * Update DeviceNetworkSystem.API.cs * Update EntityTest.cs * Update DeviceNetworkSystem.cs * Alright I'll do this expensive check fine * Fix disposals debug assert * Implement device network static events support * Use frozen dictionaries for performance * Update SharedDeviceNetworkSystem.Payloads.cs * Parallel payload handling support * Fix some spagetti-code * Optimize NetworkPayload cancellation * Parallel payloads are now cancellable * Fix screens * Fix robotics console * Allow new methods for shared * Mail fix * Turret fix * Fix network system method usage + signal and borg fix * finally fix atmos devices OH MY GOOOD * Remove stupid parallelism from fax * Fix surveiollance cameras * Working on a single thing for 2 days straight award * Fix the test? * Update units.yml * Add IDevice interface because why not * Add more device network suffixes * Fix camera router failing test * yaml linter peak * Improve docs for DeviceNetworkHandlers * fix build * Update CartridgeLoaderSystem.Relay.cs * Remove parallel system and EntitySystem post init * Add more docs and also events * Remove unnecessary caching * Update DevicePayloadComponentSystem.cs * Back to entity events * Implement DeviceData * Remove serializable from payloads * Update DeviceData.cs * Add a prototype for a singleton * Fix tests * Fix air alarms * Update DeviceNetworkSystem.cs * Fix cameras * Make camera router event-less * Fix atmos sync payloads, add more docs * Remove singleton + instant packets * oops remove public access * Fix tests? * Why the hell overload effect makes puddle sparks * Apparently it was redundant * Update gates.yml * Finish documentation * Review * Mark relay properties as obsolete * Struct payloads support (#blazinglyfastmemorysafe) * Update DeviceNetworkTest.cs * Make device structs stuff better * Move address prefix to DeviceNetworkComponent * Locale fixes * Fix tests * Doesn't know boolean logic award * Update AtmosAlarmableSystem.cs * Fix address predicted examine * Partial fix to air alarmables * Fix deployable turrets UI * Fix firelocks, maybe * Apparently Activatable UI was enough lol * Fix surveillance cameras * Rename `QueuePacket` into `SendPacket` * Simplify DeviceData as much as possible * Update DeviceData.cs * Update FaxMachineComponent.cs * Remove DeviceData because its stupid * Update ScreenSystem.cs * Fix build (camera map broken still) * Fix map * fix usings * Review changes * Build fix
117 lines
4.9 KiB
C#
117 lines
4.9 KiB
C#
using Content.Server.Atmos.EntitySystems;
|
|
using Content.Server.Atmos.Monitor.Payloads;
|
|
using Content.Server.DeviceNetwork.Systems;
|
|
using Content.Server.NodeContainer.EntitySystems;
|
|
using Content.Server.NodeContainer.Nodes;
|
|
using Content.Server.Power.Components;
|
|
using Content.Shared.Atmos.Components;
|
|
using Content.Shared.Atmos.Piping.Binary.Components;
|
|
using Content.Shared.Atmos.Piping.Binary.Systems;
|
|
using Content.Shared.Atmos.Piping.Components;
|
|
using Content.Shared.Audio;
|
|
using Content.Shared.DeviceNetwork.Events;
|
|
using JetBrains.Annotations;
|
|
using Robust.Server.GameObjects;
|
|
|
|
namespace Content.Server.Atmos.Piping.Binary.EntitySystems
|
|
{
|
|
[UsedImplicitly]
|
|
public sealed partial class GasVolumePumpSystem : SharedGasVolumePumpSystem
|
|
{
|
|
[Dependency] private AtmosphereSystem _atmosphereSystem = default!;
|
|
[Dependency] private UserInterfaceSystem _userInterfaceSystem = default!;
|
|
[Dependency] private SharedAmbientSoundSystem _ambientSoundSystem = default!;
|
|
[Dependency] private NodeContainerSystem _nodeContainer = default!;
|
|
[Dependency] private DeviceNetworkSystem _deviceNetwork = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<GasVolumePumpComponent, AtmosDeviceUpdateEvent>(OnVolumePumpUpdated);
|
|
SubscribeLocalEvent<GasVolumePumpComponent, AtmosDeviceDisabledEvent>(OnVolumePumpLeaveAtmosphere);
|
|
}
|
|
|
|
private void OnVolumePumpUpdated(EntityUid uid, GasVolumePumpComponent pump, ref AtmosDeviceUpdateEvent args)
|
|
{
|
|
if (!pump.Enabled ||
|
|
(TryComp<ApcPowerReceiverComponent>(uid, out var power) && !power.Powered) ||
|
|
!_nodeContainer.TryGetNodes(uid, pump.InletName, pump.OutletName, out PipeNode? inlet, out PipeNode? outlet))
|
|
{
|
|
_ambientSoundSystem.SetAmbience(uid, false);
|
|
return;
|
|
}
|
|
|
|
var inputStartingPressure = inlet.Air.Pressure;
|
|
var outputStartingPressure = outlet.Air.Pressure;
|
|
|
|
var previouslyBlocked = pump.Blocked;
|
|
pump.Blocked = false;
|
|
|
|
// Pump mechanism won't do anything if the pressure is too high/too low unless you overclock it.
|
|
if ((inputStartingPressure <= pump.LowerThreshold) || (outputStartingPressure >= pump.HigherThreshold) && !pump.Overclocked)
|
|
{
|
|
pump.Blocked = true;
|
|
}
|
|
|
|
// Overclocked pumps can only force gas a certain amount.
|
|
if ((outputStartingPressure - inputStartingPressure >= pump.OverclockThreshold) && pump.Overclocked)
|
|
{
|
|
pump.Blocked = true;
|
|
}
|
|
|
|
if (previouslyBlocked != pump.Blocked)
|
|
UpdateAppearance(uid, pump);
|
|
if (pump.Blocked)
|
|
return;
|
|
|
|
// We multiply the transfer rate in L/s by the seconds passed since the last process to get the liters.
|
|
var transferVol = pump.TransferRate * _atmosphereSystem.PumpSpeedup() * args.dt;
|
|
var transferRatio = transferVol / inlet.Air.Volume;
|
|
|
|
// Make sure we don't pump over the pressure limit.
|
|
var limitRatio = AtmosphereSystem.FractionToMaxPressure(inlet.Air, outlet.Air, pump.HigherThreshold);
|
|
|
|
// This might end up negative under overclock conditions, but such cases are handled correctly by the
|
|
// `RemoveRatio` method
|
|
var removedRatio = Math.Min(transferRatio, limitRatio);
|
|
var removed = inlet.Air.RemoveRatio(removedRatio);
|
|
|
|
// Some of the gas from the mixture leaks when overclocked.
|
|
if (pump.Overclocked)
|
|
{
|
|
var tile = _atmosphereSystem.GetTileMixture(uid, excite: true);
|
|
|
|
if (tile != null)
|
|
{
|
|
var leaked = removed.RemoveRatio(pump.LeakRatio);
|
|
_atmosphereSystem.Merge(tile, leaked);
|
|
}
|
|
}
|
|
|
|
pump.LastMolesTransferred = removed.TotalMoles;
|
|
|
|
_atmosphereSystem.Merge(outlet.Air, removed);
|
|
_ambientSoundSystem.SetAmbience(uid, removed.TotalMoles > 0f);
|
|
}
|
|
|
|
private void OnVolumePumpLeaveAtmosphere(EntityUid uid, GasVolumePumpComponent pump, ref AtmosDeviceDisabledEvent args)
|
|
{
|
|
pump.Enabled = false;
|
|
Dirty(uid, pump);
|
|
UpdateAppearance(uid, pump);
|
|
_userInterfaceSystem.CloseUi(uid, GasVolumePumpUiKey.Key);
|
|
}
|
|
|
|
[SubscribeLocalEvent]
|
|
private void OnSyncPayload(Entity<GasVolumePumpComponent> ent, ref DeviceNetworkPacketEvent<AtmosSyncPayload> args)
|
|
{
|
|
var data = new GasVolumePumpDataPayload
|
|
{
|
|
LastMolesTransferred = ent.Comp.LastMolesTransferred,
|
|
};
|
|
|
|
_deviceNetwork.SendPacket(ent.Owner, args.SenderAddress, ref data);
|
|
}
|
|
}
|
|
}
|