mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 18:31:17 +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
84 lines
3.4 KiB
C#
84 lines
3.4 KiB
C#
using Content.Shared.DeviceNetwork;
|
|
using Content.Shared.DeviceNetwork.Components;
|
|
using Content.Shared.Interaction;
|
|
using Content.Shared.Popups;
|
|
using Robust.Shared.Audio;
|
|
using Robust.Shared.Audio.Systems;
|
|
|
|
namespace Content.Shared.CartridgeLoader.Cartridges;
|
|
|
|
public sealed partial class NetProbeCartridgeSystem : EntitySystem
|
|
{
|
|
[Dependency] private CartridgeLoaderSystem _cartridgeLoaderSystem = default!;
|
|
[Dependency] private SharedPopupSystem _popupSystem = default!;
|
|
[Dependency] private SharedAudioSystem _audioSystem = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<NetProbeCartridgeComponent, CartridgeUiReadyEvent>(OnUiReady);
|
|
SubscribeLocalEvent<NetProbeCartridgeComponent, CartridgeRelayedEvent<AfterInteractEvent>>(AfterInteract);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Saves name, address... etc. of the device that was clicked into a list on the component when the device isn't already present in that list
|
|
/// </summary>
|
|
private void AfterInteract(EntityUid uid, NetProbeCartridgeComponent component, CartridgeRelayedEvent<AfterInteractEvent> args)
|
|
{
|
|
if (args.Args.Handled || !args.Args.CanReach || !args.Args.Target.HasValue)
|
|
return;
|
|
|
|
var target = args.Args.Target.Value;
|
|
|
|
if (!TryComp<DeviceNetworkComponent>(target, out var networkComponent))
|
|
return;
|
|
|
|
// Check if device is already present in list
|
|
foreach (var probedDevice in component.ProbedDevices)
|
|
{
|
|
if (probedDevice.Address == networkComponent.Address)
|
|
return;
|
|
}
|
|
|
|
// Play scanning sound with slightly randomized pitch
|
|
// Why is there no NextFloat(float min, float max)???
|
|
var audioParams = component.SoundScan?.Params ?? AudioParams.Default;
|
|
audioParams = audioParams.AddVolume(-2f).WithVariation(0.2f);
|
|
_audioSystem.PlayPredicted(component.SoundScan, target, args.Args.User, audioParams);
|
|
_popupSystem.PopupCursor(Loc.GetString("net-probe-scan", ("device", target)), args.Args.User);
|
|
|
|
// Limit the amount of saved probe results to 9
|
|
// This is hardcoded because the UI doesn't support a dynamic number of results
|
|
if (component.ProbedDevices.Count >= component.MaxSavedDevices)
|
|
component.ProbedDevices.RemoveAt(0);
|
|
|
|
var device = new ProbedNetworkDevice(
|
|
Name(target),
|
|
networkComponent.Address,
|
|
DeviceLocalizationHelpers.FrequencyToString(networkComponent.ReceiveFrequency),
|
|
DeviceLocalizationHelpers.DeviceNetIdToLocalizedName(networkComponent.DeviceNetId, Loc)
|
|
);
|
|
|
|
component.ProbedDevices.Add(device);
|
|
Dirty(uid, component);
|
|
UpdateUiState(uid, args.Loader, component);
|
|
}
|
|
|
|
/// <summary>
|
|
/// This gets called when the ui fragment needs to be updated for the first time after activating
|
|
/// </summary>
|
|
private void OnUiReady(EntityUid uid, NetProbeCartridgeComponent component, CartridgeUiReadyEvent args)
|
|
{
|
|
UpdateUiState(uid, args.Loader, component);
|
|
}
|
|
|
|
private void UpdateUiState(EntityUid uid, EntityUid loaderUid, NetProbeCartridgeComponent? component)
|
|
{
|
|
if (!Resolve(uid, ref component))
|
|
return;
|
|
|
|
var state = new NetProbeUiState(component.ProbedDevices);
|
|
_cartridgeLoaderSystem.UpdateCartridgeUiState(loaderUid, state);
|
|
}
|
|
}
|