Predict dumping (#32394)
* Predict dumping - This got soaped really fucking hard. - Dumping is predicted, this required disposals to be predicte.d - Disposals required mailing (because it's tightly coupled), and a smidge of other content systems. - I also had to fix a compnetworkgenerator issue at the same time so it wouldn't mispredict. * Fix a bunch of stuff * nasty merge * Some reviews * Some more reviews while I stash * Fix merge * Fix merge * Half of review * Review * re(h)f * lizards * feexes * feex
This commit is contained in:
@@ -2,7 +2,6 @@ using Content.Server.Administration.Logs;
|
||||
using Content.Server.Administration.Managers;
|
||||
using Content.Server.Administration.UI;
|
||||
using Content.Server.Disposal.Tube;
|
||||
using Content.Server.Disposal.Tube.Components;
|
||||
using Content.Server.EUI;
|
||||
using Content.Server.GameTicking;
|
||||
using Content.Server.Ghost.Roles;
|
||||
@@ -24,7 +23,6 @@ using Content.Shared.Verbs;
|
||||
using Robust.Server.Console;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Map.Components;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Content.Server.Atmos.Monitor.Components;
|
||||
using Content.Server.DeviceNetwork.Components;
|
||||
using Content.Server.DeviceNetwork.Systems;
|
||||
using Content.Server.Pinpointer;
|
||||
using Content.Server.Power.Components;
|
||||
|
||||
@@ -17,6 +17,7 @@ using Robust.Shared.Map.Components;
|
||||
using Robust.Shared.Timing;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using Content.Shared.DeviceNetwork.Components;
|
||||
|
||||
namespace Content.Server.Atmos.Consoles;
|
||||
|
||||
@@ -360,7 +361,7 @@ public sealed class AtmosMonitoringConsoleSystem : SharedAtmosMonitoringConsoleS
|
||||
chunk.AtmosPipeData[index] = atmosPipeData & ~mask;
|
||||
}
|
||||
|
||||
// Rebuild the tile's pipe data
|
||||
// Rebuild the tile's pipe data
|
||||
foreach (var ent in _sharedMapSystem.GetAnchoredEntities(gridUid, grid, coords))
|
||||
{
|
||||
if (!TryComp<AtmosPipeColorComponent>(ent, out var entAtmosPipeColor))
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
using Content.Server.Atmos.Monitor.Components;
|
||||
using Content.Server.Atmos.Piping.Components;
|
||||
using Content.Server.DeviceLinking.Systems;
|
||||
using Content.Server.DeviceNetwork;
|
||||
using Content.Server.DeviceNetwork.Components;
|
||||
using Content.Server.DeviceNetwork.Systems;
|
||||
using Content.Server.Popups;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Server.Power.EntitySystems;
|
||||
using Content.Shared.Access.Components;
|
||||
using Content.Shared.Access.Systems;
|
||||
@@ -22,8 +19,9 @@ using Content.Shared.Interaction;
|
||||
using Content.Shared.Power;
|
||||
using Content.Shared.Wires;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Player;
|
||||
using System.Linq;
|
||||
using Content.Shared.DeviceNetwork.Events;
|
||||
using Content.Shared.DeviceNetwork.Components;
|
||||
|
||||
namespace Content.Server.Atmos.Monitor.Systems;
|
||||
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using Content.Server.Atmos.Monitor.Components;
|
||||
using Content.Server.DeviceNetwork;
|
||||
using Content.Server.DeviceNetwork.Components;
|
||||
using Content.Server.DeviceNetwork.Systems;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Shared.Atmos.Monitor;
|
||||
using Content.Shared.DeviceNetwork;
|
||||
using Content.Shared.DeviceNetwork.Events;
|
||||
using Content.Shared.Power;
|
||||
using Content.Shared.Tag;
|
||||
using Robust.Server.Audio;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Utility;
|
||||
using Content.Shared.DeviceNetwork.Components;
|
||||
|
||||
namespace Content.Server.Atmos.Monitor.Systems;
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ using Content.Shared.Atmos.Monitor;
|
||||
using Content.Shared.Atmos.Piping.Components;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.DeviceNetwork;
|
||||
using Content.Shared.DeviceNetwork.Events;
|
||||
using Content.Shared.Power;
|
||||
using Content.Shared.Tag;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
@@ -1,18 +1,12 @@
|
||||
using Content.Server.AlertLevel;
|
||||
using Content.Server.Atmos.Monitor.Components;
|
||||
using Content.Server.DeviceNetwork.Components;
|
||||
using Content.Server.DeviceNetwork.Systems;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Server.Power.EntitySystems;
|
||||
using Content.Shared.Access.Systems;
|
||||
using Content.Shared.AlertLevel;
|
||||
using Content.Shared.Atmos.Monitor;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.DeviceNetwork;
|
||||
using Content.Shared.DeviceNetwork.Components;
|
||||
using Content.Shared.DeviceNetwork.Systems;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Emag.Systems;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Configuration;
|
||||
|
||||
namespace Content.Server.Atmos.Monitor.Systems;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
using Content.Server.Atmos.Monitor.Components;
|
||||
using Content.Server.Atmos.Monitor.Systems;
|
||||
using Content.Server.DeviceNetwork.Components;
|
||||
using Content.Server.Wires;
|
||||
using Content.Shared.Atmos.Monitor.Components;
|
||||
using Content.Shared.Wires;
|
||||
using Content.Shared.DeviceNetwork.Components;
|
||||
|
||||
namespace Content.Server.Atmos.Monitor;
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Server.Atmos.Monitor.Systems;
|
||||
using Content.Server.Atmos.Piping.Components;
|
||||
using Content.Server.DeviceNetwork;
|
||||
using Content.Server.DeviceNetwork.Components;
|
||||
using Content.Server.DeviceNetwork.Systems;
|
||||
using Content.Server.NodeContainer.EntitySystems;
|
||||
using Content.Server.NodeContainer.Nodes;
|
||||
@@ -12,8 +10,10 @@ using Content.Shared.Atmos.Piping.Binary.Systems;
|
||||
using Content.Shared.Atmos.Piping.Components;
|
||||
using Content.Shared.Audio;
|
||||
using Content.Shared.DeviceNetwork;
|
||||
using Content.Shared.DeviceNetwork.Events;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Server.GameObjects;
|
||||
using Content.Shared.DeviceNetwork.Components;
|
||||
|
||||
namespace Content.Server.Atmos.Piping.Binary.EntitySystems
|
||||
{
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using Content.Server.Atmos.Piping.Binary.Components;
|
||||
using Content.Server.Atmos.Piping.Unary.EntitySystems;
|
||||
using Content.Shared.Atmos;
|
||||
using Content.Shared.Atmos.Piping.Binary.Components;
|
||||
|
||||
@@ -2,10 +2,7 @@ using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Server.Atmos.Monitor.Systems;
|
||||
using Content.Server.Atmos.Piping.Components;
|
||||
using Content.Server.Atmos.Piping.Unary.Components;
|
||||
using Content.Server.DeviceNetwork;
|
||||
using Content.Server.DeviceNetwork.Components;
|
||||
using Content.Server.DeviceNetwork.Systems;
|
||||
using Content.Server.NodeContainer;
|
||||
using Content.Server.NodeContainer.EntitySystems;
|
||||
using Content.Server.NodeContainer.Nodes;
|
||||
using Content.Server.Power.Components;
|
||||
@@ -18,7 +15,9 @@ using Content.Shared.UserInterface;
|
||||
using Content.Shared.Administration.Logs;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.DeviceNetwork;
|
||||
using Content.Shared.DeviceNetwork.Events;
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.DeviceNetwork.Components;
|
||||
|
||||
namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|
||||
{
|
||||
|
||||
@@ -3,8 +3,6 @@ using Content.Server.Atmos.Monitor.Systems;
|
||||
using Content.Server.Atmos.Piping.Components;
|
||||
using Content.Server.Atmos.Piping.Unary.Components;
|
||||
using Content.Server.DeviceLinking.Systems;
|
||||
using Content.Server.DeviceNetwork;
|
||||
using Content.Server.DeviceNetwork.Components;
|
||||
using Content.Server.DeviceNetwork.Systems;
|
||||
using Content.Server.NodeContainer.EntitySystems;
|
||||
using Content.Server.NodeContainer.Nodes;
|
||||
@@ -20,7 +18,9 @@ using Content.Shared.Audio;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.DeviceLinking.Events;
|
||||
using Content.Shared.DeviceNetwork;
|
||||
using Content.Shared.DeviceNetwork.Components;
|
||||
using Content.Shared.DoAfter;
|
||||
using Content.Shared.DeviceNetwork.Events;
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Power;
|
||||
|
||||
@@ -1,25 +1,22 @@
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Server.Atmos.Monitor.Components;
|
||||
using Content.Server.Atmos.Monitor.Systems;
|
||||
using Content.Server.Atmos.Piping.Components;
|
||||
using Content.Server.Atmos.Piping.Unary.Components;
|
||||
using Content.Server.DeviceNetwork;
|
||||
using Content.Server.DeviceNetwork.Components;
|
||||
using Content.Server.DeviceNetwork.Systems;
|
||||
using Content.Server.NodeContainer;
|
||||
using Content.Server.NodeContainer.EntitySystems;
|
||||
using Content.Server.NodeContainer.Nodes;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Server.Power.EntitySystems;
|
||||
using Content.Shared.Administration.Logs;
|
||||
using Content.Shared.Atmos;
|
||||
using Content.Shared.Atmos.Piping.Unary.Visuals;
|
||||
using Content.Shared.Atmos.Monitor;
|
||||
using Content.Shared.Atmos.Piping.Components;
|
||||
using Content.Shared.Atmos.Piping.Unary.Components;
|
||||
using Content.Shared.Atmos.Piping.Unary.Visuals;
|
||||
using Content.Shared.Audio;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.DeviceNetwork;
|
||||
using Content.Shared.DeviceNetwork.Components;
|
||||
using Content.Shared.DeviceNetwork.Events;
|
||||
using Content.Shared.Power;
|
||||
using Content.Shared.Tools.Systems;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Linq;
|
||||
using Content.Server.DeviceNetwork.Systems;
|
||||
using Content.Server.PDA;
|
||||
using Content.Shared.CartridgeLoader;
|
||||
using Content.Shared.DeviceNetwork.Events;
|
||||
using Content.Shared.Interaction;
|
||||
using Robust.Server.Containers;
|
||||
using Robust.Server.GameObjects;
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
using Content.Server.DeviceNetwork;
|
||||
using Content.Server.DeviceNetwork.Components;
|
||||
using Content.Shared.CartridgeLoader;
|
||||
using Content.Shared.CartridgeLoader.Cartridges;
|
||||
using Content.Shared.DeviceNetwork;
|
||||
using Content.Shared.DeviceNetwork.Components;
|
||||
using Content.Shared.Popups;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Audio.Systems;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
namespace Content.Server.CartridgeLoader.Cartridges;
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
using Content.Server.Administration.Logs;
|
||||
using Content.Server.AlertLevel;
|
||||
using Content.Server.Chat.Systems;
|
||||
using Content.Server.DeviceNetwork.Components;
|
||||
using Content.Server.DeviceNetwork.Systems;
|
||||
using Content.Server.Interaction;
|
||||
using Content.Server.Popups;
|
||||
using Content.Server.RoundEnd;
|
||||
using Content.Server.Screens.Components;
|
||||
@@ -16,6 +14,7 @@ using Content.Shared.Chat;
|
||||
using Content.Shared.Communications;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.DeviceNetwork;
|
||||
using Content.Shared.DeviceNetwork.Components;
|
||||
using Content.Shared.IdentityManagement;
|
||||
using Content.Shared.Popups;
|
||||
using Robust.Server.GameObjects;
|
||||
|
||||
@@ -1,91 +1,8 @@
|
||||
using Content.Shared.Configurable;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Tools.Components;
|
||||
using Content.Shared.Tools.Systems;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.Player;
|
||||
using static Content.Shared.Configurable.ConfigurationComponent;
|
||||
|
||||
namespace Content.Server.Configurable;
|
||||
|
||||
public sealed class ConfigurationSystem : EntitySystem
|
||||
public sealed class ConfigurationSystem : SharedConfigurationSystem
|
||||
{
|
||||
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
|
||||
[Dependency] private readonly SharedToolSystem _toolSystem = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<ConfigurationComponent, ConfigurationUpdatedMessage>(OnUpdate);
|
||||
SubscribeLocalEvent<ConfigurationComponent, ComponentStartup>(OnStartup);
|
||||
SubscribeLocalEvent<ConfigurationComponent, InteractUsingEvent>(OnInteractUsing);
|
||||
SubscribeLocalEvent<ConfigurationComponent, ContainerIsInsertingAttemptEvent>(OnInsert);
|
||||
}
|
||||
|
||||
private void OnInteractUsing(EntityUid uid, ConfigurationComponent component, InteractUsingEvent args)
|
||||
{
|
||||
// TODO use activatable ui system
|
||||
if (args.Handled)
|
||||
return;
|
||||
|
||||
if (!_toolSystem.HasQuality(args.Used, component.QualityNeeded))
|
||||
return;
|
||||
|
||||
args.Handled = _uiSystem.TryOpenUi(uid, ConfigurationUiKey.Key, args.User);
|
||||
}
|
||||
|
||||
private void OnStartup(EntityUid uid, ConfigurationComponent component, ComponentStartup args)
|
||||
{
|
||||
UpdateUi(uid, component);
|
||||
}
|
||||
|
||||
private void UpdateUi(EntityUid uid, ConfigurationComponent component)
|
||||
{
|
||||
if (_uiSystem.HasUi(uid, ConfigurationUiKey.Key))
|
||||
_uiSystem.SetUiState(uid, ConfigurationUiKey.Key, new ConfigurationBoundUserInterfaceState(component.Config));
|
||||
}
|
||||
|
||||
private void OnUpdate(EntityUid uid, ConfigurationComponent component, ConfigurationUpdatedMessage args)
|
||||
{
|
||||
foreach (var key in component.Config.Keys)
|
||||
{
|
||||
var value = args.Config.GetValueOrDefault(key);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(value) || component.Validation != null && !component.Validation.IsMatch(value))
|
||||
continue;
|
||||
|
||||
component.Config[key] = value;
|
||||
}
|
||||
|
||||
UpdateUi(uid, component);
|
||||
|
||||
var updatedEvent = new ConfigurationUpdatedEvent(component);
|
||||
RaiseLocalEvent(uid, updatedEvent, false);
|
||||
|
||||
// TODO support float (spinbox) and enum (drop-down) configurations
|
||||
// TODO support verbs.
|
||||
}
|
||||
|
||||
private void OnInsert(EntityUid uid, ConfigurationComponent component, ContainerIsInsertingAttemptEvent args)
|
||||
{
|
||||
if (!_toolSystem.HasQuality(args.EntityUid, component.QualityNeeded))
|
||||
return;
|
||||
|
||||
args.Cancel();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sent when configuration values got changes
|
||||
/// </summary>
|
||||
public sealed class ConfigurationUpdatedEvent : EntityEventArgs
|
||||
{
|
||||
public ConfigurationComponent Configuration;
|
||||
|
||||
public ConfigurationUpdatedEvent(ConfigurationComponent configuration)
|
||||
{
|
||||
Configuration = configuration;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Content.Server.Administration.Logs;
|
||||
using Content.Shared.Containers;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Throwing;
|
||||
@@ -52,10 +53,3 @@ public sealed class ThrowInsertContainerSystem : EntitySystem
|
||||
_adminLogger.Add(LogType.Landed, LogImpact.Low, $"{ToPrettyString(args.Thrown)} thrown by {ToPrettyString(args.Component.Thrower.Value):player} landed in {ToPrettyString(ent)}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sent before the insertion is made.
|
||||
/// Allows preventing the insertion if any system on the entity should need to.
|
||||
/// </summary>
|
||||
[ByRefEvent]
|
||||
public record struct BeforeThrowInsertEvent(EntityUid ThrownEntity, bool Cancelled = false);
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
using Content.Server.DeviceLinking.Components;
|
||||
using Content.Server.DeviceNetwork;
|
||||
using Content.Server.DeviceNetwork.Components;
|
||||
using Content.Server.DeviceNetwork.Systems;
|
||||
using Content.Shared.DeviceLinking;
|
||||
using Content.Shared.DeviceLinking.Events;
|
||||
using Content.Shared.DeviceNetwork;
|
||||
using Content.Shared.DeviceNetwork.Events;
|
||||
using Content.Shared.DeviceNetwork.Components;
|
||||
|
||||
namespace Content.Server.DeviceLinking.Systems;
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ using Content.Server.DeviceLinking.Components;
|
||||
using Content.Server.DeviceNetwork;
|
||||
using Content.Server.Doors.Systems;
|
||||
using Content.Shared.DeviceLinking.Events;
|
||||
using Content.Shared.DeviceNetwork;
|
||||
using Content.Shared.Doors.Components;
|
||||
using Content.Shared.Doors;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Content.Server.DeviceLinking.Components;
|
||||
using Content.Server.DeviceNetwork;
|
||||
using Content.Shared.DeviceLinking.Events;
|
||||
using Content.Shared.DeviceNetwork;
|
||||
|
||||
namespace Content.Server.DeviceLinking.Systems;
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ using Content.Server.DeviceLinking.Components;
|
||||
using Content.Server.DeviceNetwork;
|
||||
using Content.Shared.DeviceLinking;
|
||||
using Content.Shared.DeviceLinking.Events;
|
||||
using Content.Shared.DeviceNetwork;
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Popups;
|
||||
|
||||
@@ -2,6 +2,7 @@ using Content.Server.DeviceLinking.Components;
|
||||
using Content.Server.DeviceNetwork;
|
||||
using Content.Shared.DeviceLinking;
|
||||
using Content.Shared.DeviceLinking.Events;
|
||||
using Content.Shared.DeviceNetwork;
|
||||
|
||||
namespace Content.Server.DeviceLinking.Systems;
|
||||
|
||||
|
||||
@@ -1,126 +0,0 @@
|
||||
using Content.Server.DeviceNetwork.Systems;
|
||||
using Content.Shared.DeviceNetwork;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
|
||||
namespace Content.Server.DeviceNetwork.Components
|
||||
{
|
||||
[RegisterComponent]
|
||||
[Access(typeof(DeviceNetworkSystem), typeof(DeviceNet))]
|
||||
public sealed partial class DeviceNetworkComponent : Component
|
||||
{
|
||||
public enum DeviceNetIdDefaults
|
||||
{
|
||||
Private,
|
||||
Wired,
|
||||
Wireless,
|
||||
Apc,
|
||||
AtmosDevices,
|
||||
Reserved = 100,
|
||||
// Ids outside this enum may exist
|
||||
// This exists to let yml use nice names instead of numbers
|
||||
}
|
||||
|
||||
[DataField("deviceNetId")]
|
||||
public DeviceNetIdDefaults NetIdEnum { get; set; }
|
||||
|
||||
public int DeviceNetId => (int) NetIdEnum;
|
||||
|
||||
/// <summary>
|
||||
/// The frequency that this device is listening on.
|
||||
/// </summary>
|
||||
[DataField("receiveFrequency")]
|
||||
public uint? ReceiveFrequency;
|
||||
|
||||
/// <summary>
|
||||
/// frequency prototype. Used to select a default frequency to listen to on. Used when the map is
|
||||
/// initialized.
|
||||
/// </summary>
|
||||
[DataField("receiveFrequencyId", customTypeSerializer: typeof(PrototypeIdSerializer<DeviceFrequencyPrototype>))]
|
||||
public string? ReceiveFrequencyId;
|
||||
|
||||
/// <summary>
|
||||
/// The frequency that this device going to try transmit on.
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("transmitFrequency")]
|
||||
public uint? TransmitFrequency;
|
||||
|
||||
/// <summary>
|
||||
/// frequency prototype. Used to select a default frequency to transmit on. Used when the map is
|
||||
/// initialized.
|
||||
/// </summary>
|
||||
[DataField("transmitFrequencyId", customTypeSerializer: typeof(PrototypeIdSerializer<DeviceFrequencyPrototype>))]
|
||||
public string? TransmitFrequencyId;
|
||||
|
||||
/// <summary>
|
||||
/// The address of the device, either on the network it is currently connected to or whatever address it
|
||||
/// most recently used.
|
||||
/// </summary>
|
||||
[DataField("address")]
|
||||
public string Address = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// If true, the address was customized and should be preserved across networks. If false, a randomly
|
||||
/// generated address will be created whenever this device connects to a network.
|
||||
/// </summary>
|
||||
[DataField("customAddress")]
|
||||
public bool CustomAddress = false;
|
||||
|
||||
/// <summary>
|
||||
/// Prefix to prepend to any automatically generated addresses. Helps players to identify devices. This gets
|
||||
/// localized.
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("prefix")]
|
||||
public string? Prefix;
|
||||
|
||||
/// <summary>
|
||||
/// Whether the device should listen for all device messages, regardless of the intended recipient.
|
||||
/// </summary>
|
||||
[DataField("receiveAll")]
|
||||
public bool ReceiveAll;
|
||||
|
||||
/// <summary>
|
||||
/// If the device should show its address upon an examine. Useful for devices
|
||||
/// that do not have a visible UI.
|
||||
/// </summary>
|
||||
[DataField("examinableAddress")]
|
||||
public bool ExaminableAddress;
|
||||
|
||||
/// <summary>
|
||||
/// Whether the device should attempt to join the network on map init.
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("autoConnect")]
|
||||
public bool AutoConnect = true;
|
||||
|
||||
/// <summary>
|
||||
/// Whether to send the broadcast recipients list to the sender so it can be filtered.
|
||||
/// <see cref="DeviceListSystem"/>
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("sendBroadcastAttemptEvent")]
|
||||
public bool SendBroadcastAttemptEvent = false;
|
||||
|
||||
/// <summary>
|
||||
/// Whether this device's address can be saved to device-lists
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("savableAddress")]
|
||||
public bool SavableAddress = true;
|
||||
|
||||
/// <summary>
|
||||
/// A list of device-lists that this device is on.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
[Access(typeof(DeviceListSystem))]
|
||||
public HashSet<EntityUid> DeviceLists = new();
|
||||
|
||||
/// <summary>
|
||||
/// A list of configurators that this device is on.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
[Access(typeof(NetworkConfiguratorSystem))]
|
||||
public HashSet<EntityUid> Configurators = new();
|
||||
}
|
||||
}
|
||||
@@ -1,239 +0,0 @@
|
||||
using Content.Server.DeviceNetwork.Components;
|
||||
using Robust.Shared.Random;
|
||||
using static Content.Server.DeviceNetwork.Components.DeviceNetworkComponent;
|
||||
|
||||
namespace Content.Server.DeviceNetwork;
|
||||
|
||||
/// <summary>
|
||||
/// Data class for storing and retrieving information about devices connected to a device network.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This basically just makes <see cref="DeviceNetworkComponent"/> accessible via their addresses and frequencies on
|
||||
/// some network.
|
||||
/// </remarks>
|
||||
public sealed class DeviceNet
|
||||
{
|
||||
/// <summary>
|
||||
/// Devices, mapped by their "Address", which is just an int that gets converted to Hex for displaying to users.
|
||||
/// This dictionary contains all devices connected to this network, though they may not be listening to any
|
||||
/// specific frequency.
|
||||
/// </summary>
|
||||
public readonly Dictionary<string, DeviceNetworkComponent> Devices = new();
|
||||
|
||||
/// <summary>
|
||||
/// Devices listening on a given frequency.
|
||||
/// </summary>
|
||||
public readonly Dictionary<uint, HashSet<DeviceNetworkComponent>> ListeningDevices = new();
|
||||
|
||||
/// <summary>
|
||||
/// Devices listening to all packets on a given frequency, regardless of the intended recipient.
|
||||
/// </summary>
|
||||
public readonly Dictionary<uint, HashSet<DeviceNetworkComponent>> ReceiveAllDevices = new();
|
||||
|
||||
private readonly IRobustRandom _random;
|
||||
public readonly int NetId;
|
||||
|
||||
public DeviceNet(int netId, IRobustRandom random)
|
||||
{
|
||||
_random = random;
|
||||
NetId = netId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add a device to the network.
|
||||
/// </summary>
|
||||
public bool Add(DeviceNetworkComponent device)
|
||||
{
|
||||
if (device.CustomAddress)
|
||||
{
|
||||
// Only add if the device's existing address is available.
|
||||
if (!Devices.TryAdd(device.Address, device))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Randomly generate a new address if the existing random one is invalid. Otherwise, keep the existing address
|
||||
if (string.IsNullOrWhiteSpace(device.Address) || Devices.ContainsKey(device.Address))
|
||||
device.Address = GenerateValidAddress(device.Prefix);
|
||||
|
||||
Devices[device.Address] = device;
|
||||
}
|
||||
|
||||
if (device.ReceiveFrequency is not uint freq)
|
||||
return true;
|
||||
|
||||
if (!ListeningDevices.TryGetValue(freq, out var devices))
|
||||
ListeningDevices[freq] = devices = new();
|
||||
|
||||
devices.Add(device);
|
||||
|
||||
if (!device.ReceiveAll)
|
||||
return true;
|
||||
|
||||
if (!ReceiveAllDevices.TryGetValue(freq, out var receiveAlldevices))
|
||||
ReceiveAllDevices[freq] = receiveAlldevices = new();
|
||||
|
||||
receiveAlldevices.Add(device);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove a device from the network.
|
||||
/// </summary>
|
||||
public bool Remove(DeviceNetworkComponent device)
|
||||
{
|
||||
if (device.Address == null || !Devices.Remove(device.Address))
|
||||
return false;
|
||||
|
||||
if (device.ReceiveFrequency is not uint freq)
|
||||
return true;
|
||||
|
||||
if (ListeningDevices.TryGetValue(freq, out var listening))
|
||||
{
|
||||
listening.Remove(device);
|
||||
if (listening.Count == 0)
|
||||
ListeningDevices.Remove(freq);
|
||||
}
|
||||
|
||||
if (device.ReceiveAll && ReceiveAllDevices.TryGetValue(freq, out var receiveAll))
|
||||
{
|
||||
receiveAll.Remove(device);
|
||||
if (receiveAll.Count == 0)
|
||||
ListeningDevices.Remove(freq);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Give an existing device a new randomly generated address. Useful if the device's address prefix was updated
|
||||
/// and they want a new address to reflect that, or something like that.
|
||||
/// </summary>
|
||||
public bool RandomizeAddress(string oldAddress, string? prefix = null)
|
||||
{
|
||||
if (!Devices.Remove(oldAddress, out var device))
|
||||
return false;
|
||||
|
||||
device.Address = GenerateValidAddress(prefix ?? device.Prefix);
|
||||
device.CustomAddress = false;
|
||||
Devices[device.Address] = device;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update the address of an existing device.
|
||||
/// </summary>
|
||||
public bool UpdateAddress(string oldAddress, string newAddress)
|
||||
{
|
||||
if (Devices.ContainsKey(newAddress))
|
||||
return false;
|
||||
|
||||
if (!Devices.Remove(oldAddress, out var device))
|
||||
return false;
|
||||
|
||||
device.Address = newAddress;
|
||||
device.CustomAddress = true;
|
||||
Devices[newAddress] = device;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Make an existing network device listen to a new frequency.
|
||||
/// </summary>
|
||||
public bool UpdateReceiveFrequency(string address, uint? newFrequency)
|
||||
{
|
||||
if (!Devices.TryGetValue(address, out var device))
|
||||
return false;
|
||||
|
||||
if (device.ReceiveFrequency == newFrequency)
|
||||
return true;
|
||||
|
||||
if (device.ReceiveFrequency is uint freq)
|
||||
{
|
||||
if (ListeningDevices.TryGetValue(freq, out var listening))
|
||||
{
|
||||
listening.Remove(device);
|
||||
if (listening.Count == 0)
|
||||
ListeningDevices.Remove(freq);
|
||||
}
|
||||
|
||||
if (device.ReceiveAll && ReceiveAllDevices.TryGetValue(freq, out var receiveAll))
|
||||
{
|
||||
receiveAll.Remove(device);
|
||||
if (receiveAll.Count == 0)
|
||||
ListeningDevices.Remove(freq);
|
||||
}
|
||||
}
|
||||
|
||||
device.ReceiveFrequency = newFrequency;
|
||||
|
||||
if (newFrequency == null)
|
||||
return true;
|
||||
|
||||
if (!ListeningDevices.TryGetValue(newFrequency.Value, out var devices))
|
||||
ListeningDevices[newFrequency.Value] = devices = new();
|
||||
|
||||
devices.Add(device);
|
||||
|
||||
if (!device.ReceiveAll)
|
||||
return true;
|
||||
|
||||
if (!ReceiveAllDevices.TryGetValue(newFrequency.Value, out var receiveAlldevices))
|
||||
ReceiveAllDevices[newFrequency.Value] = receiveAlldevices = new();
|
||||
|
||||
receiveAlldevices.Add(device);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Make an existing network device listen to a new frequency.
|
||||
/// </summary>
|
||||
public bool UpdateReceiveAll(string address, bool receiveAll)
|
||||
{
|
||||
if (!Devices.TryGetValue(address, out var device))
|
||||
return false;
|
||||
|
||||
if (device.ReceiveAll == receiveAll)
|
||||
return true;
|
||||
|
||||
device.ReceiveAll = receiveAll;
|
||||
|
||||
if (device.ReceiveFrequency is not uint freq)
|
||||
return true;
|
||||
|
||||
// remove or add to set of listening devices
|
||||
|
||||
HashSet<DeviceNetworkComponent>? devices;
|
||||
if (receiveAll)
|
||||
{
|
||||
if (!ReceiveAllDevices.TryGetValue(freq, out devices))
|
||||
ReceiveAllDevices[freq] = devices = new();
|
||||
devices.Add(device);
|
||||
}
|
||||
else if (ReceiveAllDevices.TryGetValue(freq, out devices))
|
||||
{
|
||||
devices.Remove(device);
|
||||
if (devices.Count == 0)
|
||||
ReceiveAllDevices.Remove(freq);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generates a valid address by randomly generating one and checking if it already exists on the network.
|
||||
/// </summary>
|
||||
private string GenerateValidAddress(string? prefix)
|
||||
{
|
||||
prefix = string.IsNullOrWhiteSpace(prefix) ? null : Loc.GetString(prefix);
|
||||
string address;
|
||||
do
|
||||
{
|
||||
var num = _random.Next();
|
||||
address = $"{prefix}{num >> 16:X4}-{num & 0xFFFF:X4}";
|
||||
}
|
||||
while (Devices.ContainsKey(address));
|
||||
|
||||
return address;
|
||||
}
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
using Content.Server.DeviceNetwork.Components;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Server.DeviceNetwork
|
||||
{
|
||||
/// <summary>
|
||||
/// A collection of constants to help with using device networks
|
||||
/// </summary>
|
||||
public static class DeviceNetworkConstants
|
||||
{
|
||||
/// <summary>
|
||||
/// Used by logic gates to transmit the state of their ports
|
||||
/// </summary>
|
||||
public const string LogicState = "logic_state";
|
||||
|
||||
#region Commands
|
||||
|
||||
/// <summary>
|
||||
/// The key for command names
|
||||
/// E.g. [DeviceNetworkConstants.Command] = "ping"
|
||||
/// </summary>
|
||||
public const string Command = "command";
|
||||
|
||||
/// <summary>
|
||||
/// The command for setting a devices state
|
||||
/// E.g. to turn a light on or off
|
||||
/// </summary>
|
||||
public const string CmdSetState = "set_state";
|
||||
|
||||
/// <summary>
|
||||
/// The command for a device that just updated its state
|
||||
/// E.g. suit sensors broadcasting owners vitals state
|
||||
/// </summary>
|
||||
public const string CmdUpdatedState = "updated_state";
|
||||
|
||||
#endregion
|
||||
|
||||
#region SetState
|
||||
|
||||
/// <summary>
|
||||
/// Used with the <see cref="CmdSetState"/> command to turn a device on or off
|
||||
/// </summary>
|
||||
public const string StateEnabled = "state_enabled";
|
||||
|
||||
#endregion
|
||||
|
||||
#region DisplayHelpers
|
||||
|
||||
/// <summary>
|
||||
/// Converts the unsigned int to string and inserts a number before the last digit
|
||||
/// </summary>
|
||||
public static string FrequencyToString(this uint frequency)
|
||||
{
|
||||
var result = frequency.ToString();
|
||||
if (result.Length <= 2)
|
||||
return result + ".0";
|
||||
|
||||
return result.Insert(result.Length - 1, ".");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Either returns the localized name representation of the corresponding <see cref="DeviceNetworkComponent.DeviceNetIdDefaults"/>
|
||||
/// or converts the id to string
|
||||
/// </summary>
|
||||
public static string DeviceNetIdToLocalizedName(this int id)
|
||||
{
|
||||
|
||||
if (!Enum.IsDefined(typeof(DeviceNetworkComponent.DeviceNetIdDefaults), id))
|
||||
return id.ToString();
|
||||
|
||||
var result = ((DeviceNetworkComponent.DeviceNetIdDefaults) id).ToString();
|
||||
var resultKebab = "device-net-id-" + CaseConversion.PascalToKebab(result);
|
||||
|
||||
return !Loc.TryGetString(resultKebab, out var name) ? result : name;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ using Content.Server.NodeContainer.EntitySystems;
|
||||
using JetBrains.Annotations;
|
||||
using Content.Server.Power.EntitySystems;
|
||||
using Content.Server.Power.Nodes;
|
||||
using Content.Shared.DeviceNetwork.Events;
|
||||
|
||||
namespace Content.Server.DeviceNetwork.Systems
|
||||
{
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
using System.Linq;
|
||||
using Content.Server.DeviceNetwork.Components;
|
||||
using Content.Shared.DeviceNetwork;
|
||||
using Content.Shared.DeviceNetwork.Components;
|
||||
using Content.Shared.DeviceNetwork.Events;
|
||||
using Content.Shared.DeviceNetwork.Systems;
|
||||
using Content.Shared.Interaction;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Map.Events;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Content.Shared.DeviceNetwork.Components;
|
||||
using Content.Shared.DeviceNetwork.Events;
|
||||
using Content.Shared.DeviceNetwork.Systems;
|
||||
using Robust.Server.GameObjects;
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Content.Server.DeviceNetwork.Components;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Server.Power.EntitySystems;
|
||||
using Content.Shared.DeviceNetwork.Events;
|
||||
|
||||
namespace Content.Server.DeviceNetwork.Systems;
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
using Content.Server.DeviceNetwork.Components;
|
||||
using Content.Shared.DeviceNetwork;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Random;
|
||||
using System.Buffers;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Numerics;
|
||||
using Content.Shared.DeviceNetwork.Components;
|
||||
using Content.Shared.DeviceNetwork.Events;
|
||||
using Content.Shared.DeviceNetwork.Systems;
|
||||
using Content.Shared.Examine;
|
||||
|
||||
namespace Content.Server.DeviceNetwork.Systems
|
||||
@@ -16,7 +16,7 @@ namespace Content.Server.DeviceNetwork.Systems
|
||||
/// Device networking allows machines and devices to communicate with each other while adhering to restrictions like range or being connected to the same powernet.
|
||||
/// </summary>
|
||||
[UsedImplicitly]
|
||||
public sealed class DeviceNetworkSystem : EntitySystem
|
||||
public sealed class DeviceNetworkSystem : SharedDeviceNetworkSystem
|
||||
{
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
[Dependency] private readonly IPrototypeManager _protoMan = default!;
|
||||
@@ -60,16 +60,7 @@ namespace Content.Server.DeviceNetwork.Systems
|
||||
SwapQueues();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends the given payload as a device network packet to the entity with the given address and frequency.
|
||||
/// Addresses are given to the DeviceNetworkComponent of an entity when connecting.
|
||||
/// </summary>
|
||||
/// <param name="uid">The EntityUid of the sending entity</param>
|
||||
/// <param name="address">The address of the entity that the packet gets sent to. If null, the message is broadcast to all devices on that frequency (except the sender)</param>
|
||||
/// <param name="frequency">The frequency to send on</param>
|
||||
/// <param name="data">The data to be sent</param>
|
||||
/// <returns>Returns true when the packet was successfully enqueued.</returns>
|
||||
public bool QueuePacket(EntityUid uid, string? address, NetworkPayload data, uint? frequency = null, int? network = null, DeviceNetworkComponent? device = null)
|
||||
public override bool QueuePacket(EntityUid uid, string? address, NetworkPayload data, uint? frequency = null, int? network = null, DeviceNetworkComponent? device = null)
|
||||
{
|
||||
if (!Resolve(uid, ref device, false))
|
||||
return false;
|
||||
@@ -368,96 +359,4 @@ namespace Content.Server.DeviceNetwork.Systems
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event raised before a device network packet is send.
|
||||
/// Subscribed to by other systems to prevent the packet from being sent.
|
||||
/// </summary>
|
||||
public sealed class BeforePacketSentEvent : CancellableEntityEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// The EntityUid of the entity the packet was sent from.
|
||||
/// </summary>
|
||||
public readonly EntityUid Sender;
|
||||
|
||||
public readonly TransformComponent SenderTransform;
|
||||
|
||||
/// <summary>
|
||||
/// The senders current position in world coordinates.
|
||||
/// </summary>
|
||||
public readonly Vector2 SenderPosition;
|
||||
|
||||
/// <summary>
|
||||
/// The network the packet will be sent to.
|
||||
/// </summary>
|
||||
public readonly string NetworkId;
|
||||
|
||||
public BeforePacketSentEvent(EntityUid sender, TransformComponent xform, Vector2 senderPosition, string networkId)
|
||||
{
|
||||
Sender = sender;
|
||||
SenderTransform = xform;
|
||||
SenderPosition = senderPosition;
|
||||
NetworkId = networkId;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sent to the sending entity before broadcasting network packets to recipients
|
||||
/// </summary>
|
||||
public sealed class BeforeBroadcastAttemptEvent : CancellableEntityEventArgs
|
||||
{
|
||||
public readonly IReadOnlySet<DeviceNetworkComponent> Recipients;
|
||||
public HashSet<DeviceNetworkComponent>? ModifiedRecipients;
|
||||
|
||||
public BeforeBroadcastAttemptEvent(IReadOnlySet<DeviceNetworkComponent> recipients)
|
||||
{
|
||||
Recipients = recipients;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event raised when a device network packet gets sent.
|
||||
/// </summary>
|
||||
public sealed class DeviceNetworkPacketEvent : EntityEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// The id of the network that this packet is being sent on.
|
||||
/// </summary>
|
||||
public int NetId;
|
||||
|
||||
/// <summary>
|
||||
/// The frequency the packet is sent on.
|
||||
/// </summary>
|
||||
public readonly uint Frequency;
|
||||
|
||||
/// <summary>
|
||||
/// Address of the intended recipient. Null if the message was broadcast.
|
||||
/// </summary>
|
||||
public string? Address;
|
||||
|
||||
/// <summary>
|
||||
/// The device network address of the sending entity.
|
||||
/// </summary>
|
||||
public readonly string SenderAddress;
|
||||
|
||||
/// <summary>
|
||||
/// The entity that sent the packet.
|
||||
/// </summary>
|
||||
public EntityUid Sender;
|
||||
|
||||
/// <summary>
|
||||
/// The data that is being sent.
|
||||
/// </summary>
|
||||
public readonly NetworkPayload Data;
|
||||
|
||||
public DeviceNetworkPacketEvent(int netId, string? address, uint frequency, string senderAddress, EntityUid sender, NetworkPayload data)
|
||||
{
|
||||
NetId = netId;
|
||||
Address = address;
|
||||
Frequency = frequency;
|
||||
SenderAddress = senderAddress;
|
||||
Sender = sender;
|
||||
Data = data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
using Content.Server.DeviceNetwork.Components;
|
||||
using Content.Server.DeviceNetwork.Components.Devices;
|
||||
using Content.Shared.DeviceNetwork;
|
||||
using Content.Shared.DeviceNetwork.Events;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.DeviceNetwork.Components;
|
||||
|
||||
namespace Content.Server.DeviceNetwork.Systems.Devices
|
||||
{
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System.Linq;
|
||||
using Content.Server.Administration.Logs;
|
||||
using Content.Server.DeviceLinking.Systems;
|
||||
using Content.Server.DeviceNetwork.Components;
|
||||
using Content.Shared.Access.Components;
|
||||
using Content.Shared.Access.Systems;
|
||||
using Content.Shared.Database;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Content.Server.DeviceNetwork.Components;
|
||||
using Content.Server.Medical.CrewMonitoring;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Server.Station.Systems;
|
||||
using Content.Shared.Power;
|
||||
using Content.Shared.DeviceNetwork.Components;
|
||||
|
||||
namespace Content.Server.DeviceNetwork.Systems;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Content.Server.DeviceNetwork.Components;
|
||||
using Content.Server.Station.Systems;
|
||||
using Content.Shared.DeviceNetwork.Events;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Map;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Content.Server.DeviceNetwork.Components;
|
||||
using Content.Shared.DeviceNetwork.Events;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace Content.Server.DeviceNetwork.Systems
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Content.Server.DeviceNetwork.Components;
|
||||
using Content.Shared.DeviceNetwork.Events;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace Content.Server.DeviceNetwork.Systems
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
using Content.Shared.Disposal.Components;
|
||||
|
||||
namespace Content.Server.Disposal.Mailing;
|
||||
|
||||
[Access(typeof(MailingUnitSystem))]
|
||||
[RegisterComponent]
|
||||
public sealed partial class MailingUnitComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// List of targets the mailing unit can send to.
|
||||
/// Each target is just a disposal routing tag
|
||||
/// </summary>
|
||||
[DataField("targetList")]
|
||||
public List<string> TargetList = new();
|
||||
|
||||
/// <summary>
|
||||
/// The target that gets attached to the disposal holders tag list on flush
|
||||
/// </summary>
|
||||
[DataField("target")]
|
||||
public string? Target;
|
||||
|
||||
/// <summary>
|
||||
/// The tag for this mailing unit
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("tag")]
|
||||
public string? Tag;
|
||||
|
||||
public SharedDisposalUnitComponent.DisposalUnitBoundUserInterfaceState? DisposalUnitInterfaceState;
|
||||
}
|
||||
@@ -1,204 +1,8 @@
|
||||
using Content.Server.Configurable;
|
||||
using Content.Server.DeviceNetwork;
|
||||
using Content.Server.DeviceNetwork.Components;
|
||||
using Content.Server.DeviceNetwork.Systems;
|
||||
using Content.Server.Disposal.Unit.EntitySystems;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Shared.DeviceNetwork;
|
||||
using Content.Shared.Disposal;
|
||||
using Content.Shared.Interaction;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Utility;
|
||||
using Content.Shared.Disposal.Mailing;
|
||||
|
||||
namespace Content.Server.Disposal.Mailing;
|
||||
|
||||
public sealed class MailingUnitSystem : EntitySystem
|
||||
public sealed class MailingUnitSystem : SharedMailingUnitSystem
|
||||
{
|
||||
[Dependency] private readonly DeviceNetworkSystem _deviceNetworkSystem = default!;
|
||||
[Dependency] private readonly UserInterfaceSystem _userInterfaceSystem = default!;
|
||||
|
||||
private const string MailTag = "mail";
|
||||
|
||||
private const string TagConfigurationKey = "tag";
|
||||
|
||||
private const string NetTag = "tag";
|
||||
private const string NetSrc = "src";
|
||||
private const string NetTarget = "target";
|
||||
private const string NetCmdSent = "mail_sent";
|
||||
private const string NetCmdRequest = "get_mailer_tag";
|
||||
private const string NetCmdResponse = "mailer_tag";
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<MailingUnitComponent, ComponentInit>(OnComponentInit);
|
||||
SubscribeLocalEvent<MailingUnitComponent, DeviceNetworkPacketEvent>(OnPacketReceived);
|
||||
SubscribeLocalEvent<MailingUnitComponent, BeforeDisposalFlushEvent>(OnBeforeFlush);
|
||||
SubscribeLocalEvent<MailingUnitComponent, ConfigurationSystem.ConfigurationUpdatedEvent>(OnConfigurationUpdated);
|
||||
SubscribeLocalEvent<MailingUnitComponent, ActivateInWorldEvent>(HandleActivate, before: new[] { typeof(DisposalUnitSystem) });
|
||||
SubscribeLocalEvent<MailingUnitComponent, DisposalUnitUIStateUpdatedEvent>(OnDisposalUnitUIStateChange);
|
||||
SubscribeLocalEvent<MailingUnitComponent, TargetSelectedMessage>(OnTargetSelected);
|
||||
}
|
||||
|
||||
|
||||
private void OnComponentInit(EntityUid uid, MailingUnitComponent component, ComponentInit args)
|
||||
{
|
||||
UpdateTargetList(uid, component);
|
||||
}
|
||||
|
||||
private void OnPacketReceived(EntityUid uid, MailingUnitComponent component, DeviceNetworkPacketEvent args)
|
||||
{
|
||||
if (!args.Data.TryGetValue(DeviceNetworkConstants.Command, out string? command) || !IsPowered(uid))
|
||||
return;
|
||||
|
||||
switch (command)
|
||||
{
|
||||
case NetCmdRequest:
|
||||
SendTagRequestResponse(uid, args, component.Tag);
|
||||
break;
|
||||
case NetCmdResponse when args.Data.TryGetValue(NetTag, out string? tag):
|
||||
//Add the received tag request response to the list of targets
|
||||
component.TargetList.Add(tag);
|
||||
UpdateUserInterface(uid, component);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends the given tag as a response to a <see cref="NetCmdRequest"/> if it's not null
|
||||
/// </summary>
|
||||
private void SendTagRequestResponse(EntityUid uid, DeviceNetworkPacketEvent args, string? tag)
|
||||
{
|
||||
if (tag == null)
|
||||
return;
|
||||
|
||||
var payload = new NetworkPayload
|
||||
{
|
||||
[DeviceNetworkConstants.Command] = NetCmdResponse,
|
||||
[NetTag] = tag
|
||||
};
|
||||
|
||||
_deviceNetworkSystem.QueuePacket(uid, args.Address, payload, args.Frequency);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Prevents the unit from flushing if no target is selected
|
||||
/// </summary>
|
||||
private void OnBeforeFlush(EntityUid uid, MailingUnitComponent component, BeforeDisposalFlushEvent args)
|
||||
{
|
||||
if (string.IsNullOrEmpty(component.Target))
|
||||
{
|
||||
args.Cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
args.Tags.Add(MailTag);
|
||||
args.Tags.Add(component.Target);
|
||||
|
||||
BroadcastSentMessage(uid, component);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Broadcast that a mail was sent including the src and target tags
|
||||
/// </summary>
|
||||
private void BroadcastSentMessage(EntityUid uid, MailingUnitComponent component, DeviceNetworkComponent? device = null)
|
||||
{
|
||||
if (string.IsNullOrEmpty(component.Tag) || string.IsNullOrEmpty(component.Target) || !Resolve(uid, ref device))
|
||||
return;
|
||||
|
||||
var payload = new NetworkPayload
|
||||
{
|
||||
[DeviceNetworkConstants.Command] = NetCmdSent,
|
||||
[NetSrc] = component.Tag,
|
||||
[NetTarget] = component.Target
|
||||
};
|
||||
|
||||
_deviceNetworkSystem.QueuePacket(uid, null, payload, null, null, device);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears the units target list and broadcasts a <see cref="NetCmdRequest"/>.
|
||||
/// The target list will then get populated with <see cref="NetCmdResponse"/> responses from all active mailing units on the same grid
|
||||
/// </summary>
|
||||
private void UpdateTargetList(EntityUid uid, MailingUnitComponent component, DeviceNetworkComponent? device = null)
|
||||
{
|
||||
if (!Resolve(uid, ref device, false))
|
||||
return;
|
||||
|
||||
var payload = new NetworkPayload
|
||||
{
|
||||
[DeviceNetworkConstants.Command] = NetCmdRequest
|
||||
};
|
||||
|
||||
component.TargetList.Clear();
|
||||
_deviceNetworkSystem.QueuePacket(uid, null, payload, null, null, device);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets called when the units tag got updated
|
||||
/// </summary>
|
||||
private void OnConfigurationUpdated(EntityUid uid, MailingUnitComponent component, ConfigurationSystem.ConfigurationUpdatedEvent args)
|
||||
{
|
||||
var configuration = args.Configuration.Config;
|
||||
if (!configuration.ContainsKey(TagConfigurationKey) || configuration[TagConfigurationKey] == string.Empty)
|
||||
{
|
||||
component.Tag = null;
|
||||
return;
|
||||
}
|
||||
|
||||
component.Tag = configuration[TagConfigurationKey];
|
||||
UpdateUserInterface(uid, component);
|
||||
}
|
||||
|
||||
private void HandleActivate(EntityUid uid, MailingUnitComponent component, ActivateInWorldEvent args)
|
||||
{
|
||||
if (args.Handled || !args.Complex)
|
||||
return;
|
||||
|
||||
if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
args.Handled = true;
|
||||
UpdateTargetList(uid, component);
|
||||
_userInterfaceSystem.OpenUi(uid, MailingUnitUiKey.Key, actor.PlayerSession);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets called when the disposal unit components ui state changes. This is required because the mailing unit requires a disposal unit component and overrides its ui
|
||||
/// </summary>
|
||||
private void OnDisposalUnitUIStateChange(EntityUid uid, MailingUnitComponent component, DisposalUnitUIStateUpdatedEvent args)
|
||||
{
|
||||
component.DisposalUnitInterfaceState = args.State;
|
||||
UpdateUserInterface(uid, component);
|
||||
}
|
||||
|
||||
private void UpdateUserInterface(EntityUid uid, MailingUnitComponent component)
|
||||
{
|
||||
if (component.DisposalUnitInterfaceState == null)
|
||||
return;
|
||||
|
||||
var state = new MailingUnitBoundUserInterfaceState(component.DisposalUnitInterfaceState, component.Target, component.TargetList.ShallowClone(), component.Tag);
|
||||
_userInterfaceSystem.SetUiState(uid, MailingUnitUiKey.Key, state);
|
||||
}
|
||||
|
||||
private void OnTargetSelected(EntityUid uid, MailingUnitComponent component, TargetSelectedMessage args)
|
||||
{
|
||||
component.Target = args.Target;
|
||||
UpdateUserInterface(uid, component);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the unit is powered if an <see cref="ApcPowerReceiverComponent"/> is present
|
||||
/// </summary>
|
||||
/// <returns>True if the power receiver component is powered or not present</returns>
|
||||
private bool IsPowered(EntityUid uid, ApcPowerReceiverComponent? powerReceiver = null)
|
||||
{
|
||||
if (Resolve(uid, ref powerReceiver) && !powerReceiver.Powered)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
using Content.Server.Disposal.Unit.EntitySystems;
|
||||
|
||||
namespace Content.Server.Disposal.Tube.Components
|
||||
{
|
||||
[RegisterComponent]
|
||||
[Access(typeof(DisposalTubeSystem), typeof(DisposalUnitSystem))]
|
||||
public sealed partial class DisposalEntryComponent : Component
|
||||
{
|
||||
public const string HolderPrototypeId = "DisposalHolder";
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Content.Server.Disposal.Tube.Components;
|
||||
namespace Content.Server.Disposal.Tube;
|
||||
|
||||
[RegisterComponent]
|
||||
[Access(typeof(DisposalTubeSystem))]
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Content.Server.Disposal.Tube.Components;
|
||||
namespace Content.Server.Disposal.Tube;
|
||||
|
||||
[RegisterComponent]
|
||||
[Access(typeof(DisposalTubeSystem))]
|
||||
@@ -1,12 +1,6 @@
|
||||
using Content.Server.UserInterface;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Player;
|
||||
using static Content.Shared.Disposal.Components.SharedDisposalRouterComponent;
|
||||
|
||||
namespace Content.Server.Disposal.Tube.Components
|
||||
namespace Content.Server.Disposal.Tube
|
||||
{
|
||||
[RegisterComponent]
|
||||
[Access(typeof(DisposalTubeSystem))]
|
||||
@@ -1,8 +1,7 @@
|
||||
using Content.Server.Disposal.Tube.Systems;
|
||||
using Content.Shared.DeviceLinking;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Server.Disposal.Tube.Components;
|
||||
namespace Content.Server.Disposal.Tube;
|
||||
|
||||
/// <summary>
|
||||
/// Requires <see cref="DisposalJunctionComponent"/> to function.
|
||||
@@ -1,8 +1,7 @@
|
||||
using Content.Server.DeviceLinking.Systems;
|
||||
using Content.Server.Disposal.Tube.Components;
|
||||
using Content.Shared.DeviceLinking.Events;
|
||||
|
||||
namespace Content.Server.Disposal.Tube.Systems;
|
||||
namespace Content.Server.Disposal.Tube;
|
||||
|
||||
/// <summary>
|
||||
/// Handles signals and the routing get next direction event.
|
||||
@@ -1,13 +1,6 @@
|
||||
using Content.Server.Disposal.Unit.Components;
|
||||
using Content.Server.UserInterface;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Player;
|
||||
using static Content.Shared.Disposal.Components.SharedDisposalTaggerComponent;
|
||||
|
||||
namespace Content.Server.Disposal.Tube.Components
|
||||
namespace Content.Server.Disposal.Tube
|
||||
{
|
||||
[RegisterComponent]
|
||||
public sealed partial class DisposalTaggerComponent : DisposalTransitComponent
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Content.Server.Disposal.Tube.Components
|
||||
namespace Content.Server.Disposal.Tube
|
||||
{
|
||||
// TODO: Different types of tubes eject in random direction with no exit point
|
||||
[RegisterComponent]
|
||||
@@ -1,9 +1,9 @@
|
||||
using Content.Server.Disposal.Unit.EntitySystems;
|
||||
using Content.Server.Disposal.Unit;
|
||||
using Content.Shared.Damage;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Containers;
|
||||
|
||||
namespace Content.Server.Disposal.Tube.Components;
|
||||
namespace Content.Server.Disposal.Tube;
|
||||
|
||||
[RegisterComponent]
|
||||
[Access(typeof(DisposalTubeSystem), typeof(DisposableSystem))]
|
||||
@@ -2,12 +2,12 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Server.Construction.Completions;
|
||||
using Content.Server.Disposal.Tube.Components;
|
||||
using Content.Server.Disposal.Unit.Components;
|
||||
using Content.Server.Disposal.Unit.EntitySystems;
|
||||
using Content.Server.Disposal.Unit;
|
||||
using Content.Server.Popups;
|
||||
using Content.Shared.Destructible;
|
||||
using Content.Shared.Disposal.Components;
|
||||
using Content.Shared.Disposal.Tube;
|
||||
using Content.Shared.Disposal.Unit;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Audio.Systems;
|
||||
@@ -16,12 +16,10 @@ using Robust.Shared.Map.Components;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Random;
|
||||
using static Content.Shared.Disposal.Components.SharedDisposalRouterComponent;
|
||||
using static Content.Shared.Disposal.Components.SharedDisposalTaggerComponent;
|
||||
|
||||
namespace Content.Server.Disposal.Tube
|
||||
{
|
||||
public sealed class DisposalTubeSystem : EntitySystem
|
||||
public sealed class DisposalTubeSystem : SharedDisposalTubeSystem
|
||||
{
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
[Dependency] private readonly SharedAppearanceSystem _appearanceSystem = default!;
|
||||
@@ -49,8 +47,8 @@ namespace Content.Server.Disposal.Tube
|
||||
SubscribeLocalEvent<DisposalBendComponent, GetDisposalsConnectableDirectionsEvent>(OnGetBendConnectableDirections);
|
||||
SubscribeLocalEvent<DisposalBendComponent, GetDisposalsNextDirectionEvent>(OnGetBendNextDirection);
|
||||
|
||||
SubscribeLocalEvent<DisposalEntryComponent, GetDisposalsConnectableDirectionsEvent>(OnGetEntryConnectableDirections);
|
||||
SubscribeLocalEvent<DisposalEntryComponent, GetDisposalsNextDirectionEvent>(OnGetEntryNextDirection);
|
||||
SubscribeLocalEvent<Shared.Disposal.Tube.DisposalEntryComponent, GetDisposalsConnectableDirectionsEvent>(OnGetEntryConnectableDirections);
|
||||
SubscribeLocalEvent<Shared.Disposal.Tube.DisposalEntryComponent, GetDisposalsNextDirectionEvent>(OnGetEntryNextDirection);
|
||||
|
||||
SubscribeLocalEvent<DisposalJunctionComponent, GetDisposalsConnectableDirectionsEvent>(OnGetJunctionConnectableDirections);
|
||||
SubscribeLocalEvent<DisposalJunctionComponent, GetDisposalsNextDirectionEvent>(OnGetJunctionNextDirection);
|
||||
@@ -64,13 +62,13 @@ namespace Content.Server.Disposal.Tube
|
||||
SubscribeLocalEvent<DisposalTaggerComponent, GetDisposalsConnectableDirectionsEvent>(OnGetTaggerConnectableDirections);
|
||||
SubscribeLocalEvent<DisposalTaggerComponent, GetDisposalsNextDirectionEvent>(OnGetTaggerNextDirection);
|
||||
|
||||
Subs.BuiEvents<DisposalRouterComponent>(DisposalRouterUiKey.Key, subs =>
|
||||
Subs.BuiEvents<DisposalRouterComponent>(SharedDisposalRouterComponent.DisposalRouterUiKey.Key, subs =>
|
||||
{
|
||||
subs.Event<BoundUIOpenedEvent>(OnOpenRouterUI);
|
||||
subs.Event<SharedDisposalRouterComponent.UiActionMessage>(OnUiAction);
|
||||
});
|
||||
|
||||
Subs.BuiEvents<DisposalTaggerComponent>(DisposalTaggerUiKey.Key, subs =>
|
||||
Subs.BuiEvents<DisposalTaggerComponent>(SharedDisposalTaggerComponent.DisposalTaggerUiKey.Key, subs =>
|
||||
{
|
||||
subs.Event<BoundUIOpenedEvent>(OnOpenTaggerUI);
|
||||
subs.Event<SharedDisposalTaggerComponent.UiActionMessage>(OnUiAction);
|
||||
@@ -161,12 +159,12 @@ namespace Content.Server.Disposal.Tube
|
||||
args.Next = previousDF == ev.Connectable[0] ? ev.Connectable[1] : ev.Connectable[0];
|
||||
}
|
||||
|
||||
private void OnGetEntryConnectableDirections(EntityUid uid, DisposalEntryComponent component, ref GetDisposalsConnectableDirectionsEvent args)
|
||||
private void OnGetEntryConnectableDirections(EntityUid uid, Shared.Disposal.Tube.DisposalEntryComponent component, ref GetDisposalsConnectableDirectionsEvent args)
|
||||
{
|
||||
args.Connectable = new[] { Transform(uid).LocalRotation.GetDir() };
|
||||
}
|
||||
|
||||
private void OnGetEntryNextDirection(EntityUid uid, DisposalEntryComponent component, ref GetDisposalsNextDirectionEvent args)
|
||||
private void OnGetEntryNextDirection(EntityUid uid, Shared.Disposal.Tube.DisposalEntryComponent component, ref GetDisposalsNextDirectionEvent args)
|
||||
{
|
||||
// Ejects contents when they come from the same direction the entry is facing.
|
||||
if (args.Holder.PreviousDirectionFrom != Direction.Invalid)
|
||||
@@ -283,10 +281,10 @@ namespace Content.Server.Disposal.Tube
|
||||
|
||||
private void OnOpenTaggerUI(EntityUid uid, DisposalTaggerComponent tagger, BoundUIOpenedEvent args)
|
||||
{
|
||||
if (_uiSystem.HasUi(uid, DisposalTaggerUiKey.Key))
|
||||
if (_uiSystem.HasUi(uid, SharedDisposalTaggerComponent.DisposalTaggerUiKey.Key))
|
||||
{
|
||||
_uiSystem.SetUiState(uid, DisposalTaggerUiKey.Key,
|
||||
new DisposalTaggerUserInterfaceState(tagger.Tag));
|
||||
_uiSystem.SetUiState(uid, SharedDisposalTaggerComponent.DisposalTaggerUiKey.Key,
|
||||
new SharedDisposalTaggerComponent.DisposalTaggerUserInterfaceState(tagger.Tag));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -298,7 +296,7 @@ namespace Content.Server.Disposal.Tube
|
||||
{
|
||||
if (router.Tags.Count <= 0)
|
||||
{
|
||||
_uiSystem.SetUiState(uid, DisposalRouterUiKey.Key, new DisposalRouterUserInterfaceState(""));
|
||||
_uiSystem.SetUiState(uid, SharedDisposalRouterComponent.DisposalRouterUiKey.Key, new SharedDisposalRouterComponent.DisposalRouterUserInterfaceState(""));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -312,7 +310,7 @@ namespace Content.Server.Disposal.Tube
|
||||
|
||||
taglist.Remove(taglist.Length - 2, 2);
|
||||
|
||||
_uiSystem.SetUiState(uid, DisposalRouterUiKey.Key, new DisposalRouterUserInterfaceState(taglist.ToString()));
|
||||
_uiSystem.SetUiState(uid, SharedDisposalRouterComponent.DisposalRouterUiKey.Key, new SharedDisposalRouterComponent.DisposalRouterUserInterfaceState(taglist.ToString()));
|
||||
}
|
||||
|
||||
private void OnAnchorChange(EntityUid uid, DisposalTubeComponent component, ref AnchorStateChangedEvent args)
|
||||
@@ -419,13 +417,13 @@ namespace Content.Server.Disposal.Tube
|
||||
_popups.PopupEntity(Loc.GetString("disposal-tube-component-popup-directions-text", ("directions", directions)), tubeId, recipient);
|
||||
}
|
||||
|
||||
public bool TryInsert(EntityUid uid, DisposalUnitComponent from, IEnumerable<string>? tags = default, DisposalEntryComponent? entry = null)
|
||||
public override bool TryInsert(EntityUid uid, DisposalUnitComponent from, IEnumerable<string>? tags = default, DisposalEntryComponent? entry = null)
|
||||
{
|
||||
if (!Resolve(uid, ref entry))
|
||||
return false;
|
||||
|
||||
var xform = Transform(uid);
|
||||
var holder = Spawn(DisposalEntryComponent.HolderPrototypeId, _transform.GetMapCoordinates(uid, xform: xform));
|
||||
var holder = Spawn(entry.HolderPrototypeId, _transform.GetMapCoordinates(uid, xform: xform));
|
||||
var holderComponent = Comp<DisposalHolderComponent>(holder);
|
||||
|
||||
foreach (var entity in from.Container.ContainedEntities.ToArray())
|
||||
@@ -436,7 +434,7 @@ namespace Content.Server.Disposal.Tube
|
||||
_atmosSystem.Merge(holderComponent.Air, from.Air);
|
||||
from.Air.Clear();
|
||||
|
||||
if (tags != default)
|
||||
if (tags != null)
|
||||
holderComponent.Tags.UnionWith(tags);
|
||||
|
||||
return _disposableSystem.EnterTube(holder, uid, holderComponent);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Content.Server.Disposal.Unit.Components;
|
||||
using Content.Server.Disposal.Unit;
|
||||
|
||||
namespace Content.Server.Disposal.Tube;
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using Content.Server.Administration;
|
||||
using Content.Server.Disposal.Tube;
|
||||
using Content.Server.Disposal.Tube.Components;
|
||||
using Content.Shared.Administration;
|
||||
using Robust.Shared.Console;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Content.Server.Disposal.Unit.Components;
|
||||
namespace Content.Server.Disposal.Unit;
|
||||
|
||||
/// <summary>
|
||||
/// A component added to entities that are currently in disposals.
|
||||
@@ -1,8 +1,7 @@
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Server.Body.Systems;
|
||||
using Content.Server.Disposal.Unit.Components;
|
||||
|
||||
namespace Content.Server.Disposal.Unit.EntitySystems;
|
||||
namespace Content.Server.Disposal.Unit;
|
||||
|
||||
public sealed class BeingDisposedSystem : EntitySystem
|
||||
{
|
||||
@@ -1,13 +0,0 @@
|
||||
using Content.Server.Atmos;
|
||||
using Content.Shared.Atmos;
|
||||
using Content.Shared.Disposal.Components;
|
||||
|
||||
namespace Content.Server.Disposal.Unit.Components;
|
||||
|
||||
// GasMixture life.
|
||||
[RegisterComponent]
|
||||
public sealed partial class DisposalUnitComponent : SharedDisposalUnitComponent
|
||||
{
|
||||
[DataField("air")]
|
||||
public GasMixture Air = new(Atmospherics.CellVolume);
|
||||
}
|
||||
@@ -1,9 +1,8 @@
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Server.Disposal.Tube;
|
||||
using Content.Server.Disposal.Tube.Components;
|
||||
using Content.Server.Disposal.Unit.Components;
|
||||
using Content.Shared.Body.Components;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Disposal.Components;
|
||||
using Content.Shared.Item;
|
||||
using Content.Shared.Throwing;
|
||||
using Robust.Shared.Audio.Systems;
|
||||
@@ -12,7 +11,7 @@ using Robust.Shared.Map.Components;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
|
||||
namespace Content.Server.Disposal.Unit.EntitySystems
|
||||
namespace Content.Server.Disposal.Unit
|
||||
{
|
||||
public sealed class DisposableSystem : EntitySystem
|
||||
{
|
||||
@@ -1,9 +1,8 @@
|
||||
using Content.Server.Atmos;
|
||||
using Content.Server.Disposal.Tube.Components;
|
||||
using Content.Shared.Atmos;
|
||||
using Robust.Shared.Containers;
|
||||
|
||||
namespace Content.Server.Disposal.Unit.Components
|
||||
namespace Content.Server.Disposal.Unit
|
||||
{
|
||||
[RegisterComponent]
|
||||
public sealed partial class DisposalHolderComponent : Component, IGasMixtureHolder
|
||||
44
Content.Server/Disposal/Unit/DisposalUnitSystem.cs
Normal file
44
Content.Server/Disposal/Unit/DisposalUnitSystem.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Shared.Atmos;
|
||||
using Content.Shared.Destructible;
|
||||
using Content.Shared.Disposal.Components;
|
||||
using Content.Shared.Disposal.Unit;
|
||||
using Content.Shared.Explosion;
|
||||
|
||||
namespace Content.Server.Disposal.Unit;
|
||||
|
||||
public sealed class DisposalUnitSystem : SharedDisposalUnitSystem
|
||||
{
|
||||
[Dependency] private readonly AtmosphereSystem _atmosSystem = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<DisposalUnitComponent, DestructionEventArgs>(OnDestruction);
|
||||
SubscribeLocalEvent<DisposalUnitComponent, BeforeExplodeEvent>(OnExploded);
|
||||
}
|
||||
|
||||
protected override void HandleAir(EntityUid uid, DisposalUnitComponent component, TransformComponent xform)
|
||||
{
|
||||
var air = component.Air;
|
||||
var indices = TransformSystem.GetGridTilePositionOrDefault((uid, xform));
|
||||
|
||||
if (_atmosSystem.GetTileMixture(xform.GridUid, xform.MapUid, indices, true) is { Temperature: > 0f } environment)
|
||||
{
|
||||
var transferMoles = 0.1f * (0.25f * Atmospherics.OneAtmosphere * 1.01f - air.Pressure) * air.Volume / (environment.Temperature * Atmospherics.R);
|
||||
|
||||
component.Air = environment.Remove(transferMoles);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDestruction(EntityUid uid, DisposalUnitComponent component, DestructionEventArgs args)
|
||||
{
|
||||
TryEjectContents(uid, component);
|
||||
}
|
||||
|
||||
private void OnExploded(Entity<DisposalUnitComponent> ent, ref BeforeExplodeEvent args)
|
||||
{
|
||||
args.Contents.AddRange(ent.Comp.Container.ContainedEntities);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Content.Server.Disposal.Unit.EntitySystems
|
||||
namespace Content.Server.Disposal.Unit
|
||||
{
|
||||
public record DoInsertDisposalUnitEvent(EntityUid? User, EntityUid ToInsert, EntityUid Unit);
|
||||
}
|
||||
@@ -1,823 +0,0 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using Content.Server.Administration.Logs;
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Server.Containers;
|
||||
using Content.Server.Disposal.Tube;
|
||||
using Content.Server.Disposal.Tube.Components;
|
||||
using Content.Server.Disposal.Unit.Components;
|
||||
using Content.Server.Popups;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Server.Power.EntitySystems;
|
||||
using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.Atmos;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.Destructible;
|
||||
using Content.Shared.Disposal;
|
||||
using Content.Shared.Disposal.Components;
|
||||
using Content.Shared.DoAfter;
|
||||
using Content.Shared.DragDrop;
|
||||
using Content.Shared.Emag.Systems;
|
||||
using Content.Shared.Explosion;
|
||||
using Content.Shared.Hands.Components;
|
||||
using Content.Shared.Hands.EntitySystems;
|
||||
using Content.Shared.IdentityManagement;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Item;
|
||||
using Content.Shared.Movement.Events;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Power;
|
||||
using Content.Shared.Verbs;
|
||||
using Robust.Server.Audio;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Map.Components;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Events;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Server.Disposal.Unit.EntitySystems;
|
||||
|
||||
public sealed class DisposalUnitSystem : SharedDisposalUnitSystem
|
||||
{
|
||||
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
||||
[Dependency] private readonly ActionBlockerSystem _actionBlockerSystem = default!;
|
||||
[Dependency] private readonly AppearanceSystem _appearance = default!;
|
||||
[Dependency] private readonly AtmosphereSystem _atmosSystem = default!;
|
||||
[Dependency] private readonly AudioSystem _audioSystem = default!;
|
||||
[Dependency] private readonly DisposalTubeSystem _disposalTubeSystem = default!;
|
||||
[Dependency] private readonly EntityLookupSystem _lookup = default!;
|
||||
[Dependency] private readonly PopupSystem _popupSystem = default!;
|
||||
[Dependency] private readonly PowerReceiverSystem _power = default!;
|
||||
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
|
||||
[Dependency] private readonly SharedDoAfterSystem _doAfterSystem = default!;
|
||||
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
|
||||
[Dependency] private readonly TransformSystem _transformSystem = default!;
|
||||
[Dependency] private readonly UserInterfaceSystem _ui = default!;
|
||||
[Dependency] private readonly SharedMapSystem _map = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<DisposalUnitComponent, ComponentGetState>(OnGetState);
|
||||
SubscribeLocalEvent<DisposalUnitComponent, PreventCollideEvent>(OnPreventCollide);
|
||||
SubscribeLocalEvent<DisposalUnitComponent, CanDropTargetEvent>(OnCanDragDropOn);
|
||||
SubscribeLocalEvent<DisposalUnitComponent, GotEmaggedEvent>(OnEmagged);
|
||||
|
||||
// Shouldn't need re-anchoring.
|
||||
SubscribeLocalEvent<DisposalUnitComponent, AnchorStateChangedEvent>(OnAnchorChanged);
|
||||
// TODO: Predict me when hands predicted
|
||||
SubscribeLocalEvent<DisposalUnitComponent, ContainerRelayMovementEntityEvent>(OnMovement);
|
||||
SubscribeLocalEvent<DisposalUnitComponent, PowerChangedEvent>(OnPowerChange);
|
||||
SubscribeLocalEvent<DisposalUnitComponent, ComponentInit>(OnDisposalInit);
|
||||
|
||||
SubscribeLocalEvent<DisposalUnitComponent, ActivateInWorldEvent>(OnActivate);
|
||||
SubscribeLocalEvent<DisposalUnitComponent, AfterInteractUsingEvent>(OnAfterInteractUsing);
|
||||
SubscribeLocalEvent<DisposalUnitComponent, DragDropTargetEvent>(OnDragDropOn);
|
||||
SubscribeLocalEvent<DisposalUnitComponent, DestructionEventArgs>(OnDestruction);
|
||||
SubscribeLocalEvent<DisposalUnitComponent, BeforeExplodeEvent>(OnExploded);
|
||||
|
||||
SubscribeLocalEvent<DisposalUnitComponent, GetVerbsEvent<InteractionVerb>>(AddInsertVerb);
|
||||
SubscribeLocalEvent<DisposalUnitComponent, GetVerbsEvent<AlternativeVerb>>(AddDisposalAltVerbs);
|
||||
SubscribeLocalEvent<DisposalUnitComponent, GetVerbsEvent<Verb>>(AddClimbInsideVerb);
|
||||
|
||||
SubscribeLocalEvent<DisposalUnitComponent, DisposalDoAfterEvent>(OnDoAfter);
|
||||
|
||||
SubscribeLocalEvent<DisposalUnitComponent, BeforeThrowInsertEvent>(OnThrowInsert);
|
||||
|
||||
SubscribeLocalEvent<DisposalUnitComponent, SharedDisposalUnitComponent.UiButtonPressedMessage>(OnUiButtonPressed);
|
||||
}
|
||||
|
||||
private void OnGetState(EntityUid uid, DisposalUnitComponent component, ref ComponentGetState args)
|
||||
{
|
||||
args.State = new DisposalUnitComponentState(
|
||||
component.FlushSound,
|
||||
component.State,
|
||||
component.NextPressurized,
|
||||
component.AutomaticEngageTime,
|
||||
component.NextFlush,
|
||||
component.Powered,
|
||||
component.Engaged,
|
||||
GetNetEntityList(component.RecentlyEjected));
|
||||
}
|
||||
|
||||
private void AddDisposalAltVerbs(EntityUid uid, SharedDisposalUnitComponent component, GetVerbsEvent<AlternativeVerb> args)
|
||||
{
|
||||
if (!args.CanAccess || !args.CanInteract)
|
||||
return;
|
||||
|
||||
// Behavior for if the disposals bin has items in it
|
||||
if (component.Container.ContainedEntities.Count > 0)
|
||||
{
|
||||
// Verbs to flush the unit
|
||||
AlternativeVerb flushVerb = new()
|
||||
{
|
||||
Act = () => ManualEngage(uid, component),
|
||||
Text = Loc.GetString("disposal-flush-verb-get-data-text"),
|
||||
Icon = new SpriteSpecifier.Texture(new("/Textures/Interface/VerbIcons/delete_transparent.svg.192dpi.png")),
|
||||
Priority = 1,
|
||||
};
|
||||
args.Verbs.Add(flushVerb);
|
||||
|
||||
// Verb to eject the contents
|
||||
AlternativeVerb ejectVerb = new()
|
||||
{
|
||||
Act = () => TryEjectContents(uid, component),
|
||||
Category = VerbCategory.Eject,
|
||||
Text = Loc.GetString("disposal-eject-verb-get-data-text")
|
||||
};
|
||||
args.Verbs.Add(ejectVerb);
|
||||
}
|
||||
}
|
||||
|
||||
private void AddClimbInsideVerb(EntityUid uid, SharedDisposalUnitComponent component, GetVerbsEvent<Verb> args)
|
||||
{
|
||||
// This is not an interaction, activation, or alternative verb type because unfortunately most users are
|
||||
// unwilling to accept that this is where they belong and don't want to accidentally climb inside.
|
||||
if (!args.CanAccess ||
|
||||
!args.CanInteract ||
|
||||
component.Container.ContainedEntities.Contains(args.User) ||
|
||||
!_actionBlockerSystem.CanMove(args.User))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!CanInsert(uid, component, args.User))
|
||||
return;
|
||||
|
||||
// Add verb to climb inside of the unit,
|
||||
Verb verb = new()
|
||||
{
|
||||
Act = () => TryInsert(uid, args.User, args.User),
|
||||
DoContactInteraction = true,
|
||||
Text = Loc.GetString("disposal-self-insert-verb-get-data-text")
|
||||
};
|
||||
// TODO VERB ICON
|
||||
// TODO VERB CATEGORY
|
||||
// create a verb category for "enter"?
|
||||
// See also, medical scanner. Also maybe add verbs for entering lockers/body bags?
|
||||
args.Verbs.Add(verb);
|
||||
}
|
||||
|
||||
private void AddInsertVerb(EntityUid uid, SharedDisposalUnitComponent component, GetVerbsEvent<InteractionVerb> args)
|
||||
{
|
||||
if (!args.CanAccess || !args.CanInteract || args.Hands == null || args.Using == null)
|
||||
return;
|
||||
|
||||
if (!_actionBlockerSystem.CanDrop(args.User))
|
||||
return;
|
||||
|
||||
if (!CanInsert(uid, component, args.Using.Value))
|
||||
return;
|
||||
|
||||
InteractionVerb insertVerb = new()
|
||||
{
|
||||
Text = Name(args.Using.Value),
|
||||
Category = VerbCategory.Insert,
|
||||
Act = () =>
|
||||
{
|
||||
_handsSystem.TryDropIntoContainer(args.User, args.Using.Value, component.Container, checkActionBlocker: false, args.Hands);
|
||||
_adminLogger.Add(LogType.Action, LogImpact.Medium, $"{ToPrettyString(args.User):player} inserted {ToPrettyString(args.Using.Value)} into {ToPrettyString(uid)}");
|
||||
AfterInsert(uid, component, args.Using.Value, args.User);
|
||||
}
|
||||
};
|
||||
|
||||
args.Verbs.Add(insertVerb);
|
||||
}
|
||||
|
||||
private void OnDoAfter(EntityUid uid, SharedDisposalUnitComponent component, DoAfterEvent args)
|
||||
{
|
||||
if (args.Handled || args.Cancelled || args.Args.Target == null || args.Args.Used == null)
|
||||
return;
|
||||
|
||||
AfterInsert(uid, component, args.Args.Target.Value, args.Args.User, doInsert: true);
|
||||
|
||||
args.Handled = true;
|
||||
}
|
||||
|
||||
private void OnThrowInsert(Entity<DisposalUnitComponent> ent, ref BeforeThrowInsertEvent args)
|
||||
{
|
||||
if (!CanInsert(ent, ent, args.ThrownEntity))
|
||||
args.Cancelled = true;
|
||||
}
|
||||
|
||||
public override void DoInsertDisposalUnit(EntityUid uid, EntityUid toInsert, EntityUid user, SharedDisposalUnitComponent? disposal = null)
|
||||
{
|
||||
if (!ResolveDisposals(uid, ref disposal))
|
||||
return;
|
||||
|
||||
if (!_containerSystem.Insert(toInsert, disposal.Container))
|
||||
return;
|
||||
|
||||
_adminLogger.Add(LogType.Action, LogImpact.Medium, $"{ToPrettyString(user):player} inserted {ToPrettyString(toInsert)} into {ToPrettyString(uid)}");
|
||||
AfterInsert(uid, disposal, toInsert, user);
|
||||
}
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
base.Update(frameTime);
|
||||
|
||||
var query = AllEntityQuery<DisposalUnitComponent, MetaDataComponent>();
|
||||
while (query.MoveNext(out var uid, out var unit, out var metadata))
|
||||
{
|
||||
if (!metadata.EntityPaused)
|
||||
Update(uid, unit, metadata, frameTime);
|
||||
}
|
||||
}
|
||||
|
||||
#region UI Handlers
|
||||
private void OnUiButtonPressed(EntityUid uid, SharedDisposalUnitComponent component, SharedDisposalUnitComponent.UiButtonPressedMessage args)
|
||||
{
|
||||
if (args.Actor is not { Valid: true } player)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch (args.Button)
|
||||
{
|
||||
case SharedDisposalUnitComponent.UiButton.Eject:
|
||||
TryEjectContents(uid, component);
|
||||
_adminLogger.Add(LogType.Action, LogImpact.Low, $"{ToPrettyString(player):player} hit eject button on {ToPrettyString(uid)}");
|
||||
break;
|
||||
case SharedDisposalUnitComponent.UiButton.Engage:
|
||||
ToggleEngage(uid, component);
|
||||
_adminLogger.Add(LogType.Action, LogImpact.Low, $"{ToPrettyString(player):player} hit flush button on {ToPrettyString(uid)}, it's now {(component.Engaged ? "on" : "off")}");
|
||||
break;
|
||||
case SharedDisposalUnitComponent.UiButton.Power:
|
||||
_power.TogglePower(uid, user: args.Actor);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException($"{ToPrettyString(player):player} attempted to hit a nonexistant button on {ToPrettyString(uid)}");
|
||||
}
|
||||
}
|
||||
|
||||
public void ToggleEngage(EntityUid uid, SharedDisposalUnitComponent component)
|
||||
{
|
||||
component.Engaged ^= true;
|
||||
|
||||
if (component.Engaged)
|
||||
{
|
||||
ManualEngage(uid, component);
|
||||
}
|
||||
else
|
||||
{
|
||||
Disengage(uid, component);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Eventbus Handlers
|
||||
|
||||
private void OnActivate(EntityUid uid, SharedDisposalUnitComponent component, ActivateInWorldEvent args)
|
||||
{
|
||||
if (args.Handled || !args.Complex)
|
||||
return;
|
||||
|
||||
if (!TryComp(args.User, out ActorComponent? actor))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
args.Handled = true;
|
||||
_ui.OpenUi(uid, SharedDisposalUnitComponent.DisposalUnitUiKey.Key, actor.PlayerSession);
|
||||
}
|
||||
|
||||
private void OnAfterInteractUsing(EntityUid uid, SharedDisposalUnitComponent component, AfterInteractUsingEvent args)
|
||||
{
|
||||
if (args.Handled || !args.CanReach)
|
||||
return;
|
||||
|
||||
if (!HasComp<HandsComponent>(args.User))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!CanInsert(uid, component, args.Used) || !_handsSystem.TryDropIntoContainer(args.User, args.Used, component.Container))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_adminLogger.Add(LogType.Action, LogImpact.Medium, $"{ToPrettyString(args.User):player} inserted {ToPrettyString(args.Used)} into {ToPrettyString(uid)}");
|
||||
AfterInsert(uid, component, args.Used, args.User);
|
||||
args.Handled = true;
|
||||
}
|
||||
|
||||
private void OnDisposalInit(EntityUid uid, SharedDisposalUnitComponent component, ComponentInit args)
|
||||
{
|
||||
component.Container = _containerSystem.EnsureContainer<Container>(uid, SharedDisposalUnitComponent.ContainerId);
|
||||
|
||||
UpdateInterface(uid, component, component.Powered);
|
||||
}
|
||||
|
||||
private void OnPowerChange(EntityUid uid, SharedDisposalUnitComponent component, ref PowerChangedEvent args)
|
||||
{
|
||||
if (!component.Running || args.Powered == component.Powered)
|
||||
return;
|
||||
|
||||
component.Powered = args.Powered;
|
||||
UpdateVisualState(uid, component);
|
||||
UpdateInterface(uid, component, args.Powered);
|
||||
|
||||
if (!args.Powered)
|
||||
{
|
||||
component.NextFlush = null;
|
||||
Dirty(uid, component);
|
||||
return;
|
||||
}
|
||||
|
||||
if (component.Engaged)
|
||||
{
|
||||
// Run ManualEngage to recalculate a new flush time
|
||||
ManualEngage(uid, component);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: This should just use the same thing as entity storage?
|
||||
private void OnMovement(EntityUid uid, SharedDisposalUnitComponent component, ref ContainerRelayMovementEntityEvent args)
|
||||
{
|
||||
var currentTime = GameTiming.CurTime;
|
||||
|
||||
if (!_actionBlockerSystem.CanMove(args.Entity))
|
||||
return;
|
||||
|
||||
if (!TryComp(args.Entity, out HandsComponent? hands) ||
|
||||
hands.Count == 0 ||
|
||||
currentTime < component.LastExitAttempt + ExitAttemptDelay)
|
||||
return;
|
||||
|
||||
component.LastExitAttempt = currentTime;
|
||||
Remove(uid, component, args.Entity);
|
||||
}
|
||||
|
||||
private void OnAnchorChanged(EntityUid uid, SharedDisposalUnitComponent component, ref AnchorStateChangedEvent args)
|
||||
{
|
||||
if (Terminating(uid))
|
||||
return;
|
||||
|
||||
UpdateVisualState(uid, component);
|
||||
if (!args.Anchored)
|
||||
TryEjectContents(uid, component);
|
||||
}
|
||||
|
||||
private void OnDestruction(EntityUid uid, SharedDisposalUnitComponent component, DestructionEventArgs args)
|
||||
{
|
||||
TryEjectContents(uid, component);
|
||||
}
|
||||
|
||||
private void OnDragDropOn(EntityUid uid, SharedDisposalUnitComponent component, ref DragDropTargetEvent args)
|
||||
{
|
||||
args.Handled = TryInsert(uid, args.Dragged, args.User);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void UpdateState(EntityUid uid, DisposalsPressureState state, SharedDisposalUnitComponent component, MetaDataComponent metadata)
|
||||
{
|
||||
if (component.State == state)
|
||||
return;
|
||||
|
||||
component.State = state;
|
||||
UpdateVisualState(uid, component);
|
||||
UpdateInterface(uid, component, component.Powered);
|
||||
Dirty(uid, component, metadata);
|
||||
|
||||
if (state == DisposalsPressureState.Ready)
|
||||
{
|
||||
component.NextPressurized = TimeSpan.Zero;
|
||||
|
||||
// Manually engaged
|
||||
if (component.Engaged)
|
||||
{
|
||||
component.NextFlush = GameTiming.CurTime + component.ManualFlushTime;
|
||||
}
|
||||
else if (component.Container.ContainedEntities.Count > 0)
|
||||
{
|
||||
component.NextFlush = GameTiming.CurTime + component.AutomaticEngageTime;
|
||||
}
|
||||
else
|
||||
{
|
||||
component.NextFlush = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Work out if we can stop updating this disposals component i.e. full pressure and nothing colliding.
|
||||
/// </summary>
|
||||
private void Update(EntityUid uid, SharedDisposalUnitComponent component, MetaDataComponent metadata, float frameTime)
|
||||
{
|
||||
var state = GetState(uid, component, metadata);
|
||||
|
||||
// Pressurizing, just check if we need a state update.
|
||||
if (component.NextPressurized > GameTiming.CurTime)
|
||||
{
|
||||
UpdateState(uid, state, component, metadata);
|
||||
return;
|
||||
}
|
||||
|
||||
if (component.NextFlush != null)
|
||||
{
|
||||
if (component.NextFlush.Value < GameTiming.CurTime)
|
||||
{
|
||||
TryFlush(uid, component);
|
||||
}
|
||||
}
|
||||
|
||||
UpdateState(uid, state, component, metadata);
|
||||
|
||||
Box2? disposalsBounds = null;
|
||||
var count = component.RecentlyEjected.Count;
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
if (!HasComp<PhysicsComponent>(uid))
|
||||
{
|
||||
component.RecentlyEjected.Clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
disposalsBounds = _lookup.GetWorldAABB(uid);
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = 0; i < component.RecentlyEjected.Count; i++)
|
||||
{
|
||||
var ejectedId = component.RecentlyEjected[i];
|
||||
if (HasComp<PhysicsComponent>(ejectedId))
|
||||
{
|
||||
// TODO: We need to use a specific collision method (which sloth hasn't coded yet) for actual bounds overlaps.
|
||||
// TODO: Come do this sloth :^)
|
||||
// Check for itemcomp as we won't just block the disposal unit "sleeping" for something it can't collide with anyway.
|
||||
if (!HasComp<ItemComponent>(ejectedId)
|
||||
&& _lookup.GetWorldAABB(ejectedId).Intersects(disposalsBounds!.Value))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
component.RecentlyEjected.RemoveAt(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
|
||||
if (count != component.RecentlyEjected.Count)
|
||||
Dirty(uid, component, metadata);
|
||||
}
|
||||
|
||||
public bool TryInsert(EntityUid unitId, EntityUid toInsertId, EntityUid? userId, DisposalUnitComponent? unit = null)
|
||||
{
|
||||
if (!Resolve(unitId, ref unit))
|
||||
return false;
|
||||
|
||||
if (userId.HasValue && !HasComp<HandsComponent>(userId) && toInsertId != userId) // Mobs like mouse can Jump inside even with no hands
|
||||
{
|
||||
_popupSystem.PopupEntity(Loc.GetString("disposal-unit-no-hands"), userId.Value, userId.Value, PopupType.SmallCaution);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!CanInsert(unitId, unit, toInsertId))
|
||||
return false;
|
||||
|
||||
bool insertingSelf = userId == toInsertId;
|
||||
|
||||
var delay = insertingSelf ? unit.EntryDelay : unit.DraggedEntryDelay;
|
||||
|
||||
if (userId != null && !insertingSelf)
|
||||
_popupSystem.PopupEntity(Loc.GetString("disposal-unit-being-inserted", ("user", Identity.Entity((EntityUid)userId, EntityManager))), toInsertId, toInsertId, PopupType.Large);
|
||||
|
||||
if (delay <= 0 || userId == null)
|
||||
{
|
||||
AfterInsert(unitId, unit, toInsertId, userId, doInsert: true);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Can't check if our target AND disposals moves currently so we'll just check target.
|
||||
// if you really want to check if disposals moves then add a predicate.
|
||||
var doAfterArgs = new DoAfterArgs(EntityManager, userId.Value, delay, new DisposalDoAfterEvent(), unitId, target: toInsertId, used: unitId)
|
||||
{
|
||||
BreakOnDamage = true,
|
||||
BreakOnMove = true,
|
||||
NeedHand = false,
|
||||
};
|
||||
|
||||
_doAfterSystem.TryStartDoAfter(doAfterArgs);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public bool TryFlush(EntityUid uid, SharedDisposalUnitComponent component)
|
||||
{
|
||||
if (!CanFlush(uid, component))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (component.NextFlush != null)
|
||||
component.NextFlush = component.NextFlush.Value + component.AutomaticEngageTime;
|
||||
|
||||
var beforeFlushArgs = new BeforeDisposalFlushEvent();
|
||||
RaiseLocalEvent(uid, beforeFlushArgs);
|
||||
|
||||
if (beforeFlushArgs.Cancelled)
|
||||
{
|
||||
Disengage(uid, component);
|
||||
return false;
|
||||
}
|
||||
|
||||
var xform = Transform(uid);
|
||||
if (!TryComp(xform.GridUid, out MapGridComponent? grid))
|
||||
return false;
|
||||
|
||||
var coords = xform.Coordinates;
|
||||
var entry = _map.GetLocal(xform.GridUid.Value, grid, coords)
|
||||
.FirstOrDefault(HasComp<DisposalEntryComponent>);
|
||||
|
||||
if (entry == default || component is not DisposalUnitComponent sDisposals)
|
||||
{
|
||||
component.Engaged = false;
|
||||
Dirty(uid, component);
|
||||
return false;
|
||||
}
|
||||
|
||||
HandleAir(uid, sDisposals, xform);
|
||||
|
||||
_disposalTubeSystem.TryInsert(entry, sDisposals, beforeFlushArgs.Tags);
|
||||
|
||||
component.NextPressurized = GameTiming.CurTime;
|
||||
if (!component.DisablePressure)
|
||||
component.NextPressurized += TimeSpan.FromSeconds(1f / PressurePerSecond);
|
||||
|
||||
component.Engaged = false;
|
||||
// stop queuing NOW
|
||||
component.NextFlush = null;
|
||||
|
||||
UpdateVisualState(uid, component, true);
|
||||
UpdateInterface(uid, component, component.Powered);
|
||||
|
||||
Dirty(uid, component);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void HandleAir(EntityUid uid, DisposalUnitComponent component, TransformComponent xform)
|
||||
{
|
||||
var air = component.Air;
|
||||
var indices = _transformSystem.GetGridTilePositionOrDefault((uid, xform));
|
||||
|
||||
if (_atmosSystem.GetTileMixture(xform.GridUid, xform.MapUid, indices, true) is { Temperature: > 0f } environment)
|
||||
{
|
||||
var transferMoles = 0.1f * (0.25f * Atmospherics.OneAtmosphere * 1.01f - air.Pressure) * air.Volume / (environment.Temperature * Atmospherics.R);
|
||||
|
||||
component.Air = environment.Remove(transferMoles);
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateInterface(EntityUid uid, SharedDisposalUnitComponent component, bool powered)
|
||||
{
|
||||
var compState = GetState(uid, component);
|
||||
var stateString = Loc.GetString($"disposal-unit-state-{compState}");
|
||||
var state = new SharedDisposalUnitComponent.DisposalUnitBoundUserInterfaceState(Name(uid), stateString, EstimatedFullPressure(uid, component), powered, component.Engaged);
|
||||
_ui.SetUiState(uid, SharedDisposalUnitComponent.DisposalUnitUiKey.Key, state);
|
||||
|
||||
var stateUpdatedEvent = new DisposalUnitUIStateUpdatedEvent(state);
|
||||
RaiseLocalEvent(uid, stateUpdatedEvent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the estimated time when the disposal unit will be back to full pressure.
|
||||
/// </summary>
|
||||
private TimeSpan EstimatedFullPressure(EntityUid uid, SharedDisposalUnitComponent component)
|
||||
{
|
||||
if (component.NextPressurized < GameTiming.CurTime)
|
||||
return TimeSpan.Zero;
|
||||
|
||||
return component.NextPressurized;
|
||||
}
|
||||
|
||||
public void UpdateVisualState(EntityUid uid, SharedDisposalUnitComponent component, bool flush = false)
|
||||
{
|
||||
if (!TryComp(uid, out AppearanceComponent? appearance))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Transform(uid).Anchored)
|
||||
{
|
||||
_appearance.SetData(uid, SharedDisposalUnitComponent.Visuals.VisualState, SharedDisposalUnitComponent.VisualState.UnAnchored, appearance);
|
||||
_appearance.SetData(uid, SharedDisposalUnitComponent.Visuals.Handle, SharedDisposalUnitComponent.HandleState.Normal, appearance);
|
||||
_appearance.SetData(uid, SharedDisposalUnitComponent.Visuals.Light, SharedDisposalUnitComponent.LightStates.Off, appearance);
|
||||
return;
|
||||
}
|
||||
|
||||
var state = GetState(uid, component);
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case DisposalsPressureState.Flushed:
|
||||
_appearance.SetData(uid, SharedDisposalUnitComponent.Visuals.VisualState, SharedDisposalUnitComponent.VisualState.OverlayFlushing, appearance);
|
||||
break;
|
||||
case DisposalsPressureState.Pressurizing:
|
||||
_appearance.SetData(uid, SharedDisposalUnitComponent.Visuals.VisualState, SharedDisposalUnitComponent.VisualState.OverlayCharging, appearance);
|
||||
break;
|
||||
case DisposalsPressureState.Ready:
|
||||
_appearance.SetData(uid, SharedDisposalUnitComponent.Visuals.VisualState, SharedDisposalUnitComponent.VisualState.Anchored, appearance);
|
||||
break;
|
||||
}
|
||||
|
||||
_appearance.SetData(uid, SharedDisposalUnitComponent.Visuals.Handle, component.Engaged
|
||||
? SharedDisposalUnitComponent.HandleState.Engaged
|
||||
: SharedDisposalUnitComponent.HandleState.Normal, appearance);
|
||||
|
||||
if (!component.Powered)
|
||||
{
|
||||
_appearance.SetData(uid, SharedDisposalUnitComponent.Visuals.Light, SharedDisposalUnitComponent.LightStates.Off, appearance);
|
||||
return;
|
||||
}
|
||||
|
||||
var lightState = SharedDisposalUnitComponent.LightStates.Off;
|
||||
|
||||
if (component.Container.ContainedEntities.Count > 0)
|
||||
{
|
||||
lightState |= SharedDisposalUnitComponent.LightStates.Full;
|
||||
}
|
||||
|
||||
if (state is DisposalsPressureState.Pressurizing or DisposalsPressureState.Flushed)
|
||||
{
|
||||
lightState |= SharedDisposalUnitComponent.LightStates.Charging;
|
||||
}
|
||||
else
|
||||
{
|
||||
lightState |= SharedDisposalUnitComponent.LightStates.Ready;
|
||||
}
|
||||
|
||||
_appearance.SetData(uid, SharedDisposalUnitComponent.Visuals.Light, lightState, appearance);
|
||||
}
|
||||
|
||||
public void Remove(EntityUid uid, SharedDisposalUnitComponent component, EntityUid toRemove)
|
||||
{
|
||||
_containerSystem.Remove(toRemove, component.Container);
|
||||
|
||||
if (component.Container.ContainedEntities.Count == 0)
|
||||
{
|
||||
// If not manually engaged then reset the flushing entirely.
|
||||
if (!component.Engaged)
|
||||
{
|
||||
component.NextFlush = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (!component.RecentlyEjected.Contains(toRemove))
|
||||
component.RecentlyEjected.Add(toRemove);
|
||||
|
||||
UpdateVisualState(uid, component);
|
||||
Dirty(uid, component);
|
||||
}
|
||||
|
||||
public bool CanFlush(EntityUid unit, SharedDisposalUnitComponent component)
|
||||
{
|
||||
return GetState(unit, component) == DisposalsPressureState.Ready
|
||||
&& component.Powered
|
||||
&& Comp<TransformComponent>(unit).Anchored;
|
||||
}
|
||||
|
||||
public void ManualEngage(EntityUid uid, SharedDisposalUnitComponent component, MetaDataComponent? metadata = null)
|
||||
{
|
||||
component.Engaged = true;
|
||||
UpdateVisualState(uid, component);
|
||||
UpdateInterface(uid, component, component.Powered);
|
||||
Dirty(uid, component);
|
||||
|
||||
if (!CanFlush(uid, component))
|
||||
return;
|
||||
|
||||
if (!Resolve(uid, ref metadata))
|
||||
return;
|
||||
|
||||
var pauseTime = Metadata.GetPauseTime(uid, metadata);
|
||||
var nextEngage = GameTiming.CurTime - pauseTime + component.ManualFlushTime;
|
||||
component.NextFlush = TimeSpan.FromSeconds(Math.Min((component.NextFlush ?? TimeSpan.MaxValue).TotalSeconds, nextEngage.TotalSeconds));
|
||||
}
|
||||
|
||||
public void Disengage(EntityUid uid, SharedDisposalUnitComponent component)
|
||||
{
|
||||
component.Engaged = false;
|
||||
|
||||
if (component.Container.ContainedEntities.Count == 0)
|
||||
{
|
||||
component.NextFlush = null;
|
||||
}
|
||||
|
||||
UpdateVisualState(uid, component);
|
||||
UpdateInterface(uid, component, component.Powered);
|
||||
Dirty(uid, component);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove all entities currently in the disposal unit.
|
||||
/// </summary>
|
||||
public void TryEjectContents(EntityUid uid, SharedDisposalUnitComponent component)
|
||||
{
|
||||
foreach (var entity in component.Container.ContainedEntities.ToArray())
|
||||
{
|
||||
Remove(uid, component, entity);
|
||||
}
|
||||
|
||||
if (!component.Engaged)
|
||||
{
|
||||
component.NextFlush = null;
|
||||
Dirty(uid, component);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool HasDisposals(EntityUid? uid)
|
||||
{
|
||||
return HasComp<DisposalUnitComponent>(uid);
|
||||
}
|
||||
|
||||
public override bool ResolveDisposals(EntityUid uid, [NotNullWhen(true)] ref SharedDisposalUnitComponent? component)
|
||||
{
|
||||
if (component != null)
|
||||
return true;
|
||||
|
||||
TryComp<DisposalUnitComponent>(uid, out var storage);
|
||||
component = storage;
|
||||
return component != null;
|
||||
}
|
||||
|
||||
public override bool CanInsert(EntityUid uid, SharedDisposalUnitComponent component, EntityUid entity)
|
||||
{
|
||||
if (!base.CanInsert(uid, component, entity))
|
||||
return false;
|
||||
|
||||
return _containerSystem.CanInsert(entity, component.Container);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If something is inserted (or the likes) then we'll queue up an automatic flush in the future.
|
||||
/// </summary>
|
||||
public void QueueAutomaticEngage(EntityUid uid, SharedDisposalUnitComponent component, MetaDataComponent? metadata = null)
|
||||
{
|
||||
if (component.Deleted || !component.AutomaticEngage || !component.Powered && component.Container.ContainedEntities.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var pauseTime = Metadata.GetPauseTime(uid, metadata);
|
||||
var automaticTime = GameTiming.CurTime + component.AutomaticEngageTime - pauseTime;
|
||||
var flushTime = TimeSpan.FromSeconds(Math.Min((component.NextFlush ?? TimeSpan.MaxValue).TotalSeconds, automaticTime.TotalSeconds));
|
||||
|
||||
component.NextFlush = flushTime;
|
||||
Dirty(uid, component);
|
||||
}
|
||||
|
||||
public void AfterInsert(EntityUid uid, SharedDisposalUnitComponent component, EntityUid inserted, EntityUid? user = null, bool doInsert = false)
|
||||
{
|
||||
_audioSystem.PlayPvs(component.InsertSound, uid);
|
||||
|
||||
if (doInsert && !_containerSystem.Insert(inserted, component.Container))
|
||||
return;
|
||||
|
||||
if (user != inserted && user != null)
|
||||
_adminLogger.Add(LogType.Action, LogImpact.Medium, $"{ToPrettyString(user.Value):player} inserted {ToPrettyString(inserted)} into {ToPrettyString(uid)}");
|
||||
|
||||
QueueAutomaticEngage(uid, component);
|
||||
|
||||
_ui.CloseUi(uid, SharedDisposalUnitComponent.DisposalUnitUiKey.Key, inserted);
|
||||
|
||||
// Maybe do pullable instead? Eh still fine.
|
||||
Joints.RecursiveClearJoints(inserted);
|
||||
UpdateVisualState(uid, component);
|
||||
}
|
||||
|
||||
private void OnExploded(Entity<DisposalUnitComponent> ent, ref BeforeExplodeEvent args)
|
||||
{
|
||||
args.Contents.AddRange(ent.Comp.Container.ContainedEntities);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sent before the disposal unit flushes it's contents.
|
||||
/// Allows adding tags for sorting and preventing the disposal unit from flushing.
|
||||
/// </summary>
|
||||
public sealed class DisposalUnitUIStateUpdatedEvent : EntityEventArgs
|
||||
{
|
||||
public SharedDisposalUnitComponent.DisposalUnitBoundUserInterfaceState State;
|
||||
|
||||
public DisposalUnitUIStateUpdatedEvent(SharedDisposalUnitComponent.DisposalUnitBoundUserInterfaceState state)
|
||||
{
|
||||
State = state;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sent before the disposal unit flushes it's contents.
|
||||
/// Allows adding tags for sorting and preventing the disposal unit from flushing.
|
||||
/// </summary>
|
||||
public sealed class BeforeDisposalFlushEvent : CancellableEntityEventArgs
|
||||
{
|
||||
public readonly List<string> Tags = new();
|
||||
}
|
||||
@@ -7,6 +7,7 @@ using Content.Shared.Fax;
|
||||
using Content.Shared.Follower;
|
||||
using Content.Shared.Ghost;
|
||||
using Content.Shared.Paper;
|
||||
using Content.Shared.DeviceNetwork.Components;
|
||||
|
||||
namespace Content.Server.Fax.AdminUI;
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
using Content.Server.Administration;
|
||||
using Content.Server.Administration.Managers;
|
||||
using Content.Server.Chat.Managers;
|
||||
using Content.Server.DeviceNetwork;
|
||||
using Content.Server.DeviceNetwork.Components;
|
||||
using Content.Server.DeviceNetwork.Systems;
|
||||
using Content.Server.Popups;
|
||||
using Content.Server.Power.Components;
|
||||
@@ -12,7 +10,7 @@ using Content.Shared.Administration.Logs;
|
||||
using Content.Shared.Containers.ItemSlots;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.DeviceNetwork;
|
||||
using Content.Shared.Emag.Components;
|
||||
using Content.Shared.DeviceNetwork.Events;
|
||||
using Content.Shared.Emag.Systems;
|
||||
using Content.Shared.Fax;
|
||||
using Content.Shared.Fax.Systems;
|
||||
@@ -27,9 +25,9 @@ using Robust.Shared.Audio;
|
||||
using Robust.Shared.Audio.Systems;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Content.Shared.NameModifier.Components;
|
||||
using Content.Shared.Power;
|
||||
using Content.Shared.DeviceNetwork.Components;
|
||||
|
||||
namespace Content.Server.Fax;
|
||||
|
||||
|
||||
@@ -19,6 +19,8 @@ using Robust.Shared.Timing;
|
||||
using Robust.Shared.Audio.Systems;
|
||||
using Content.Shared.Damage.Systems;
|
||||
using Content.Shared.Damage.Components;
|
||||
using Content.Shared.DeviceNetwork;
|
||||
using Content.Shared.DeviceNetwork.Events;
|
||||
using Content.Shared.Power;
|
||||
|
||||
namespace Content.Server.Light.EntitySystems
|
||||
|
||||
@@ -2,6 +2,8 @@ using System.Linq;
|
||||
using Content.Server.DeviceNetwork;
|
||||
using Content.Server.DeviceNetwork.Systems;
|
||||
using Content.Server.PowerCell;
|
||||
using Content.Shared.DeviceNetwork;
|
||||
using Content.Shared.DeviceNetwork.Events;
|
||||
using Content.Shared.Medical.CrewMonitoring;
|
||||
using Content.Shared.Medical.SuitSensor;
|
||||
using Content.Shared.Pinpointer;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
using Content.Server.DeviceNetwork;
|
||||
using Content.Server.DeviceNetwork.Components;
|
||||
using Content.Server.DeviceNetwork.Systems;
|
||||
using Content.Server.Medical.SuitSensors;
|
||||
using Content.Shared.DeviceNetwork;
|
||||
using Content.Shared.DeviceNetwork.Events;
|
||||
using Content.Shared.Medical.SuitSensor;
|
||||
using Robust.Shared.Timing;
|
||||
using Content.Shared.DeviceNetwork.Components;
|
||||
|
||||
namespace Content.Server.Medical.CrewMonitoring;
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
using System.Numerics;
|
||||
using Content.Server.Access.Systems;
|
||||
using Content.Server.DeviceNetwork;
|
||||
using Content.Server.DeviceNetwork.Components;
|
||||
using Content.Server.DeviceNetwork.Systems;
|
||||
using Content.Server.Emp;
|
||||
using Content.Server.Medical.CrewMonitoring;
|
||||
@@ -26,6 +24,7 @@ using Robust.Shared.Map;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Random;
|
||||
using Robust.Shared.Timing;
|
||||
using Content.Shared.DeviceNetwork.Components;
|
||||
|
||||
namespace Content.Server.Medical.SuitSensors;
|
||||
|
||||
|
||||
@@ -2,27 +2,23 @@ using Content.Server.Access.Systems;
|
||||
using Content.Server.AlertLevel;
|
||||
using Content.Server.CartridgeLoader;
|
||||
using Content.Server.Chat.Managers;
|
||||
using Content.Server.DeviceNetwork.Components;
|
||||
using Content.Server.Instruments;
|
||||
using Content.Server.Light.EntitySystems;
|
||||
using Content.Server.PDA.Ringer;
|
||||
using Content.Server.Station.Systems;
|
||||
using Content.Server.Store.Components;
|
||||
using Content.Server.Store.Systems;
|
||||
using Content.Server.Traitor.Uplink;
|
||||
using Content.Shared.Access.Components;
|
||||
using Content.Shared.CartridgeLoader;
|
||||
using Content.Shared.Chat;
|
||||
using Content.Shared.Light;
|
||||
using Content.Shared.Light.Components;
|
||||
using Content.Shared.Light.EntitySystems;
|
||||
using Content.Shared.PDA;
|
||||
using Content.Shared.Store.Components;
|
||||
using Robust.Server.Containers;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Utility;
|
||||
using Content.Shared.DeviceNetwork.Components;
|
||||
|
||||
namespace Content.Server.PDA
|
||||
{
|
||||
|
||||
@@ -15,7 +15,6 @@ namespace Content.Server.Power.EntitySystems
|
||||
public sealed class PowerReceiverSystem : SharedPowerReceiverSystem
|
||||
{
|
||||
[Dependency] private readonly IAdminManager _adminManager = default!;
|
||||
|
||||
private EntityQuery<ApcPowerReceiverComponent> _recQuery;
|
||||
private EntityQuery<ApcPowerProviderComponent> _provQuery;
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ using Content.Server.NodeContainer.Nodes;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Shared.Atmos;
|
||||
using Content.Shared.DeviceNetwork;
|
||||
using Content.Shared.DeviceNetwork.Events;
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.Power;
|
||||
using Content.Shared.Power.EntitySystems;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using Content.Server.DeviceNetwork.Components;
|
||||
using Content.Server.Power.EntitySystems;
|
||||
using Content.Server.PowerCell;
|
||||
using Content.Shared.DeviceNetwork.Components;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Content.Server.Administration.Logs;
|
||||
using Content.Server.DeviceNetwork;
|
||||
using Content.Server.DeviceNetwork.Systems;
|
||||
using Content.Server.Radio.EntitySystems;
|
||||
using Content.Shared.Lock;
|
||||
@@ -10,7 +9,7 @@ using Content.Shared.Robotics.Components;
|
||||
using Content.Shared.Robotics.Systems;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Timing;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Content.Shared.DeviceNetwork.Events;
|
||||
|
||||
namespace Content.Server.Research.Systems;
|
||||
|
||||
|
||||
@@ -4,8 +4,6 @@ using Content.Server.AlertLevel;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Server.Chat.Managers;
|
||||
using Content.Server.Chat.Systems;
|
||||
using Content.Server.DeviceNetwork;
|
||||
using Content.Server.DeviceNetwork.Components;
|
||||
using Content.Server.DeviceNetwork.Systems;
|
||||
using Content.Server.GameTicking;
|
||||
using Content.Server.Screens.Components;
|
||||
@@ -21,6 +19,7 @@ using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Timing;
|
||||
using Content.Shared.DeviceNetwork.Components;
|
||||
using Timer = Robust.Shared.Timing.Timer;
|
||||
|
||||
namespace Content.Server.RoundEnd
|
||||
|
||||
@@ -2,6 +2,8 @@ using Content.Shared.TextScreen;
|
||||
using Content.Server.Screens.Components;
|
||||
using Content.Server.DeviceNetwork.Components;
|
||||
using Content.Server.DeviceNetwork.Systems;
|
||||
using Content.Shared.DeviceNetwork.Components;
|
||||
using Content.Shared.DeviceNetwork.Events;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
|
||||
@@ -63,7 +65,7 @@ public sealed class ScreenSystem : EntitySystem
|
||||
/// <summary>
|
||||
/// Determines if/how a timer packet affects this screen.
|
||||
/// Currently there are 2 broadcast domains: Arrivals, and every other screen.
|
||||
/// Domain is determined by the <see cref="DeviceNetworkComponent.TransmitFrequencyId"/> on each timer.
|
||||
/// Domain is determined by the <see cref="Shared.DeviceNetwork.Components.DeviceNetworkComponent.TransmitFrequencyId"/> on each timer.
|
||||
/// Each broadcast domain is divided into subnets. Screen MapUid determines subnet.
|
||||
/// Subnets are the shuttle, source, and dest. Source/dest change each jump.
|
||||
/// This is required to send different timers to the shuttle/terminal/station.
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using Content.Server.DeviceNetwork.Systems;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Shared.DeviceNetwork;
|
||||
using Content.Shared.DeviceNetwork.Events;
|
||||
|
||||
namespace Content.Server.SensorMonitoring;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Content.Server.DeviceNetwork.Components;
|
||||
using Content.Shared.SensorMonitoring;
|
||||
using Content.Shared.SensorMonitoring;
|
||||
using Robust.Shared.Collections;
|
||||
using ConsoleUIState = Content.Shared.SensorMonitoring.SensorMonitoringConsoleBoundInterfaceState;
|
||||
using Content.Shared.DeviceNetwork.Components;
|
||||
using IncrementalUIState = Content.Shared.SensorMonitoring.SensorMonitoringIncrementalUpdate;
|
||||
|
||||
namespace Content.Server.SensorMonitoring;
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
using Content.Server.Atmos.Monitor.Components;
|
||||
using Content.Server.Atmos.Monitor.Systems;
|
||||
using Content.Server.Atmos.Piping.Binary.Components;
|
||||
using Content.Server.Atmos.Piping.Components;
|
||||
using Content.Server.Atmos.Piping.Unary.Components;
|
||||
using Content.Server.DeviceNetwork;
|
||||
using Content.Server.DeviceNetwork.Components;
|
||||
using Content.Server.DeviceNetwork.Systems;
|
||||
using Content.Server.Power.Generation.Teg;
|
||||
using Content.Shared.Atmos.Monitor;
|
||||
@@ -12,6 +9,7 @@ using Content.Shared.Atmos.Piping.Binary.Components;
|
||||
using Content.Shared.Atmos.Piping.Unary.Components;
|
||||
using Content.Shared.DeviceNetwork;
|
||||
using Content.Shared.DeviceNetwork.Components;
|
||||
using Content.Shared.DeviceNetwork.Events;
|
||||
using Content.Shared.DeviceNetwork.Systems;
|
||||
using Content.Shared.SensorMonitoring;
|
||||
using Robust.Server.GameObjects;
|
||||
|
||||
@@ -2,7 +2,6 @@ using System.Linq;
|
||||
using System.Numerics;
|
||||
using Content.Server.Administration;
|
||||
using Content.Server.Chat.Managers;
|
||||
using Content.Server.DeviceNetwork.Components;
|
||||
using Content.Server.DeviceNetwork.Systems;
|
||||
using Content.Server.GameTicking;
|
||||
using Content.Server.GameTicking.Events;
|
||||
@@ -19,6 +18,7 @@ using Content.Shared.Administration;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.Damage.Components;
|
||||
using Content.Shared.DeviceNetwork;
|
||||
using Content.Shared.DeviceNetwork.Components;
|
||||
using Content.Shared.GameTicking;
|
||||
using Content.Shared.Mobs.Components;
|
||||
using Content.Shared.Movement.Components;
|
||||
@@ -26,20 +26,17 @@ using Content.Shared.Parallax.Biomes;
|
||||
using Content.Shared.Salvage;
|
||||
using Content.Shared.Shuttles.Components;
|
||||
using Content.Shared.Tiles;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Collections;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.EntitySerialization;
|
||||
using Robust.Shared.EntitySerialization.Systems;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Map.Components;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Random;
|
||||
using Robust.Shared.Spawners;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Utility;
|
||||
using TimedDespawnComponent = Robust.Shared.Spawners.TimedDespawnComponent;
|
||||
|
||||
namespace Content.Server.Shuttles.Systems;
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Threading;
|
||||
using Content.Server.DeviceNetwork.Components;
|
||||
using Content.Server.Screens.Components;
|
||||
using Content.Server.Shuttles.Components;
|
||||
using Content.Server.Shuttles.Events;
|
||||
@@ -14,6 +13,7 @@ using Content.Shared.Shuttles.Systems;
|
||||
using Content.Shared.UserInterface;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Player;
|
||||
using Content.Shared.DeviceNetwork.Components;
|
||||
using Timer = Robust.Shared.Timing.Timer;
|
||||
|
||||
namespace Content.Server.Shuttles.Systems;
|
||||
|
||||
@@ -6,7 +6,6 @@ using Content.Server.Administration.Logs;
|
||||
using Content.Server.Administration.Managers;
|
||||
using Content.Server.Chat.Systems;
|
||||
using Content.Server.Communications;
|
||||
using Content.Server.DeviceNetwork.Components;
|
||||
using Content.Server.DeviceNetwork.Systems;
|
||||
using Content.Server.GameTicking.Events;
|
||||
using Content.Server.Pinpointer;
|
||||
@@ -37,6 +36,7 @@ using Robust.Shared.Player;
|
||||
using Robust.Shared.Random;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Utility;
|
||||
using Content.Shared.DeviceNetwork.Components;
|
||||
|
||||
namespace Content.Server.Shuttles.Systems;
|
||||
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
using Content.Shared.DeviceNetwork;
|
||||
using Content.Shared.Emag.Components;
|
||||
using Content.Shared.Movement.Components;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Robotics;
|
||||
using Content.Shared.Silicons.Borgs.Components;
|
||||
using Content.Server.DeviceNetwork;
|
||||
using Content.Server.DeviceNetwork.Components;
|
||||
using Content.Server.DeviceNetwork.Systems;
|
||||
using Content.Server.Explosion.Components;
|
||||
using Content.Shared.DeviceNetwork.Components;
|
||||
using Content.Shared.DeviceNetwork.Events;
|
||||
using Content.Shared.Emag.Systems;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ using Content.Server.DeviceNetwork;
|
||||
using Content.Server.DeviceNetwork.Systems;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Shared.DeviceNetwork;
|
||||
using Content.Shared.DeviceNetwork.Events;
|
||||
using Content.Shared.Power;
|
||||
using Content.Shared.UserInterface;
|
||||
using Content.Shared.SurveillanceCamera;
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
using Content.Server.DeviceNetwork;
|
||||
using Content.Server.DeviceNetwork.Components;
|
||||
using Content.Server.DeviceNetwork.Systems;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.DeviceNetwork;
|
||||
using Content.Shared.DeviceNetwork.Events;
|
||||
using Content.Shared.Power;
|
||||
using Content.Shared.SurveillanceCamera;
|
||||
using Content.Shared.Verbs;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Content.Shared.DeviceNetwork.Components;
|
||||
|
||||
namespace Content.Server.SurveillanceCamera;
|
||||
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
using Content.Server.DeviceNetwork;
|
||||
using Content.Server.DeviceNetwork.Components;
|
||||
using Content.Server.DeviceNetwork.Systems;
|
||||
using Content.Server.Emp;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.DeviceNetwork;
|
||||
using Content.Shared.DeviceNetwork.Events;
|
||||
using Content.Shared.Power;
|
||||
using Content.Shared.SurveillanceCamera;
|
||||
using Content.Shared.Verbs;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Content.Shared.DeviceNetwork.Components;
|
||||
|
||||
namespace Content.Server.SurveillanceCamera;
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@ using Content.Server.Power.Components;
|
||||
using Content.Server.Repairable;
|
||||
using Content.Shared.Destructible;
|
||||
using Content.Shared.DeviceNetwork;
|
||||
using Content.Shared.DeviceNetwork.Components;
|
||||
using Content.Shared.DeviceNetwork.Events;
|
||||
using Content.Shared.Power;
|
||||
using Content.Shared.Turrets;
|
||||
using Content.Shared.Weapons.Ranged.Events;
|
||||
|
||||
Reference in New Issue
Block a user