Implement automatic mode switching for the network configurator and multitool (#16603)
This commit is contained in:
@@ -204,6 +204,9 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
|
|||||||
_uiSystem.TryCloseAll(uid, NetworkConfiguratorUiKey.Configure);
|
_uiSystem.TryCloseAll(uid, NetworkConfiguratorUiKey.Configure);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Toggles between linking and listing mode
|
||||||
|
/// </summary>
|
||||||
private void SwitchMode(EntityUid? userUid, EntityUid configuratorUid, NetworkConfiguratorComponent configurator)
|
private void SwitchMode(EntityUid? userUid, EntityUid configuratorUid, NetworkConfiguratorComponent configurator)
|
||||||
{
|
{
|
||||||
if (Delay(configurator))
|
if (Delay(configurator))
|
||||||
@@ -217,15 +220,32 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
|
|||||||
if (!configurator.LinkModeActive)
|
if (!configurator.LinkModeActive)
|
||||||
configurator.ActiveDeviceLink = null;
|
configurator.ActiveDeviceLink = null;
|
||||||
|
|
||||||
var locString = configurator.LinkModeActive ? "network-configurator-mode-link" : "network-configurator-mode-list";
|
UpdateModeAppearance(userUid.Value, configuratorUid, configurator);
|
||||||
_popupSystem.PopupEntity(Loc.GetString("network-configurator-switched-mode", ("mode", Loc.GetString(locString))),
|
}
|
||||||
configuratorUid, userUid.Value);
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sets the mode to linking or list depending on the link mode parameter
|
||||||
|
/// </summary>>
|
||||||
|
private void SetMode(EntityUid configuratorUid, NetworkConfiguratorComponent configurator, EntityUid userUid, bool linkMode)
|
||||||
|
{
|
||||||
|
configurator.LinkModeActive = linkMode;
|
||||||
|
|
||||||
|
if (!linkMode)
|
||||||
|
configurator.ActiveDeviceLink = null;
|
||||||
|
|
||||||
|
UpdateModeAppearance(userUid, configuratorUid, configurator);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates the configurators appearance and plays a sound indicating that the mode switched
|
||||||
|
/// </summary>
|
||||||
|
private void UpdateModeAppearance(EntityUid userUid, EntityUid configuratorUid, NetworkConfiguratorComponent configurator)
|
||||||
|
{
|
||||||
Dirty(configurator);
|
Dirty(configurator);
|
||||||
_appearanceSystem.SetData(configuratorUid, NetworkConfiguratorVisuals.Mode, configurator.LinkModeActive);
|
_appearanceSystem.SetData(configuratorUid, NetworkConfiguratorVisuals.Mode, configurator.LinkModeActive);
|
||||||
|
|
||||||
var pitch = configurator.LinkModeActive ? 1 : 0.8f;
|
var pitch = configurator.LinkModeActive ? 1 : 0.8f;
|
||||||
_audioSystem.PlayPvs(configurator.SoundSwitchMode, userUid.Value, AudioParams.Default.WithVolume(1.5f).WithPitchScale(pitch));
|
_audioSystem.PlayPvs(configurator.SoundSwitchMode, userUid, AudioParams.Default.WithVolume(1.5f).WithPitchScale(pitch));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -262,6 +282,8 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
|
|||||||
if (!canReach || !target.HasValue)
|
if (!canReach || !target.HasValue)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
DetermineMode(uid, configurator, target, user);
|
||||||
|
|
||||||
if (configurator.LinkModeActive)
|
if (configurator.LinkModeActive)
|
||||||
{
|
{
|
||||||
TryLinkDevice(uid, configurator, target, user);
|
TryLinkDevice(uid, configurator, target, user);
|
||||||
@@ -277,6 +299,23 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
|
|||||||
OpenDeviceListUi(target, user, configurator);
|
OpenDeviceListUi(target, user, configurator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void DetermineMode(EntityUid configuratorUid, NetworkConfiguratorComponent configurator, EntityUid? target, EntityUid userUid)
|
||||||
|
{
|
||||||
|
var hasLinking = HasComp<DeviceLinkSinkComponent>(target) || HasComp<DeviceLinkSourceComponent>(target);
|
||||||
|
|
||||||
|
if (hasLinking && HasComp<DeviceListComponent>(target) || hasLinking == configurator.LinkModeActive)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (hasLinking)
|
||||||
|
{
|
||||||
|
SetMode(configuratorUid, configurator, userUid, true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (HasComp<DeviceNetworkComponent>(target))
|
||||||
|
SetMode(configuratorUid, configurator, userUid, false);
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Verbs
|
#region Verbs
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ public sealed class NetworkConfiguratorComponent : Component
|
|||||||
public SoundSpecifier SoundNoAccess = new SoundPathSpecifier("/Audio/Machines/custom_deny.ogg");
|
public SoundSpecifier SoundNoAccess = new SoundPathSpecifier("/Audio/Machines/custom_deny.ogg");
|
||||||
|
|
||||||
[DataField("soundSwitchMode")]
|
[DataField("soundSwitchMode")]
|
||||||
public SoundSpecifier SoundSwitchMode = new SoundPathSpecifier("/Audio/Machines/beep.ogg");
|
public SoundSpecifier SoundSwitchMode = new SoundPathSpecifier("/Audio/Machines/quickbeep.ogg");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable, NetSerializable]
|
[Serializable, NetSerializable]
|
||||||
|
|||||||
@@ -27,3 +27,8 @@
|
|||||||
license: "CC-BY-4.0"
|
license: "CC-BY-4.0"
|
||||||
copyright: "Created by AUDACITIER (freesound), converted to MONO and .ogg and edited by EmoGarbage404 (github)."
|
copyright: "Created by AUDACITIER (freesound), converted to MONO and .ogg and edited by EmoGarbage404 (github)."
|
||||||
source: "https://freesound.org/people/AUDACITIER/sounds/629196/"
|
source: "https://freesound.org/people/AUDACITIER/sounds/629196/"
|
||||||
|
|
||||||
|
- files: ["quickbeep.ogg"]
|
||||||
|
license: "CC0-1.0"
|
||||||
|
copyright: "Created by BasedUser#2215 on discord"
|
||||||
|
source: "https://discord.com/channels/310555209753690112/536955542913024015/1066824680188690452"
|
||||||
|
|||||||
BIN
Resources/Audio/Machines/quickbeep.ogg
Normal file
BIN
Resources/Audio/Machines/quickbeep.ogg
Normal file
Binary file not shown.
@@ -7,8 +7,8 @@ cloning-console-window-no-patient-data-text = No patient data.
|
|||||||
cloning-console-window-id-blank = ID:
|
cloning-console-window-id-blank = ID:
|
||||||
cloning-console-window-scanner-details-label = Genetic Scanner Status
|
cloning-console-window-scanner-details-label = Genetic Scanner Status
|
||||||
cloning-console-window-pod-details-label = Cloning Pod Status
|
cloning-console-window-pod-details-label = Cloning Pod Status
|
||||||
cloning-console-window-no-scanner-detected-label = Link a genetic scanner with a multitool.
|
cloning-console-window-no-scanner-detected-label = Link a genetic scanner with a multitool or network configurator.
|
||||||
cloning-console-window-no-clone-pod-detected-label = Link a cloning pod with a multitool.
|
cloning-console-window-no-clone-pod-detected-label = Link a cloning pod with a multitool or network configurator.
|
||||||
cloning-console-window-scanner-far-label = Genetic Scanner Too Far Away
|
cloning-console-window-scanner-far-label = Genetic Scanner Too Far Away
|
||||||
cloning-console-window-clone-pod-far-label = Cloning Pod Too Far Away
|
cloning-console-window-clone-pod-far-label = Cloning Pod Too Far Away
|
||||||
cloning-console-eject-body-button = Eject Body
|
cloning-console-eject-body-button = Eject Body
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ book-text-atmos-alarms = Air alarms are located throughout stations to allow man
|
|||||||
- Fill: Disables scrubbers and sets vents to their maximum pressure
|
- Fill: Disables scrubbers and sets vents to their maximum pressure
|
||||||
- Panic: Disables vents and sets scrubbers to siphon
|
- Panic: Disables vents and sets scrubbers to siphon
|
||||||
|
|
||||||
A multitool can be used to link devices to air alarms.
|
A multitool or network configurator can be used to link devices to air alarms.
|
||||||
|
|
||||||
book-text-atmos-vents =
|
book-text-atmos-vents =
|
||||||
Below is a quick reference guide to several atmospheric devices:
|
Below is a quick reference guide to several atmospheric devices:
|
||||||
|
|||||||
Reference in New Issue
Block a user