Redirects :h to department radio channel for headsets (#13026)
This commit is contained in:
@@ -33,6 +33,8 @@ public sealed partial class ChatSystem
|
|||||||
{
|
{
|
||||||
_keyCodes.Add(proto.KeyCode, proto);
|
_keyCodes.Add(proto.KeyCode, proto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ShutdownRadio()
|
private void ShutdownRadio()
|
||||||
@@ -45,6 +47,10 @@ public sealed partial class ChatSystem
|
|||||||
// TODO: Turn common into a true frequency and support multiple aliases.
|
// TODO: Turn common into a true frequency and support multiple aliases.
|
||||||
var isRadioMessage = false;
|
var isRadioMessage = false;
|
||||||
RadioChannelPrototype? channel = null;
|
RadioChannelPrototype? channel = null;
|
||||||
|
|
||||||
|
// Check if have headset and grab headset UID for later
|
||||||
|
var hasHeadset = _inventory.TryGetSlotEntity(source, "ears", out var entityUid) & TryComp<HeadsetComponent>(entityUid, out var _headsetComponent);
|
||||||
|
|
||||||
// First check if this is a message to the base radio frequency
|
// First check if this is a message to the base radio frequency
|
||||||
if (message.StartsWith(';'))
|
if (message.StartsWith(';'))
|
||||||
{
|
{
|
||||||
@@ -54,11 +60,25 @@ public sealed partial class ChatSystem
|
|||||||
isRadioMessage = true;
|
isRadioMessage = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check now if the remaining message is a targeted radio message
|
|
||||||
|
// Check now if the remaining message is a radio message
|
||||||
if ((message.StartsWith(':') || message.StartsWith('.')) && message.Length >= 2)
|
if ((message.StartsWith(':') || message.StartsWith('.')) && message.Length >= 2)
|
||||||
{
|
{
|
||||||
// Strip remaining message prefix.
|
// Redirect to defaultChannel of headsetComp if it goes to "h" channel code after making sure defaultChannel exists
|
||||||
|
if (message[1] == 'h'
|
||||||
|
&& _headsetComponent != null
|
||||||
|
&& _headsetComponent.defaultChannel != null
|
||||||
|
&& _prototypeManager.TryIndex(_headsetComponent.defaultChannel, out RadioChannelPrototype? protoDefaultChannel))
|
||||||
|
{
|
||||||
|
// Set Channel to headset defaultChannel
|
||||||
|
channel = protoDefaultChannel;
|
||||||
|
}
|
||||||
|
else // otherwise it's a normal, targeted channel keycode
|
||||||
|
{
|
||||||
_keyCodes.TryGetValue(message[1], out channel);
|
_keyCodes.TryGetValue(message[1], out channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Strip remaining message prefix.
|
||||||
message = message[2..].TrimStart();
|
message = message[2..].TrimStart();
|
||||||
isRadioMessage = true;
|
isRadioMessage = true;
|
||||||
}
|
}
|
||||||
@@ -70,7 +90,8 @@ public sealed partial class ChatSystem
|
|||||||
if (message.Length <= 1)
|
if (message.Length <= 1)
|
||||||
return (string.Empty, null);
|
return (string.Empty, null);
|
||||||
|
|
||||||
if (channel == null)
|
// Check for headset before no-such-channel, otherwise you can get two PopupEntities if no headset and no channel
|
||||||
|
if (hasHeadset & channel == null )
|
||||||
{
|
{
|
||||||
_popup.PopupEntity(Loc.GetString("chat-manager-no-such-channel"), source, source);
|
_popup.PopupEntity(Loc.GetString("chat-manager-no-such-channel"), source, source);
|
||||||
channel = null;
|
channel = null;
|
||||||
@@ -79,7 +100,7 @@ public sealed partial class ChatSystem
|
|||||||
// Re-capitalize message since we removed the prefix.
|
// Re-capitalize message since we removed the prefix.
|
||||||
message = SanitizeMessageCapital(message);
|
message = SanitizeMessageCapital(message);
|
||||||
|
|
||||||
var hasHeadset = _inventory.TryGetSlotEntity(source, "ears", out var entityUid) && HasComp<HeadsetComponent>(entityUid);
|
|
||||||
|
|
||||||
if (!hasHeadset && !HasComp<IntrinsicRadioTransmitterComponent>(source))
|
if (!hasHeadset && !HasComp<IntrinsicRadioTransmitterComponent>(source))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ using Content.Server.Radio.EntitySystems;
|
|||||||
using Content.Shared.Inventory;
|
using Content.Shared.Inventory;
|
||||||
using Content.Shared.Radio;
|
using Content.Shared.Radio;
|
||||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Set;
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Set;
|
||||||
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||||
|
|
||||||
namespace Content.Server.Radio.Components;
|
namespace Content.Server.Radio.Components;
|
||||||
|
|
||||||
@@ -15,6 +16,15 @@ public sealed class HeadsetComponent : Component
|
|||||||
[DataField("channels", customTypeSerializer: typeof(PrototypeIdHashSetSerializer<RadioChannelPrototype>))]
|
[DataField("channels", customTypeSerializer: typeof(PrototypeIdHashSetSerializer<RadioChannelPrototype>))]
|
||||||
public readonly HashSet<string> Channels = new() { "Common" };
|
public readonly HashSet<string> Channels = new() { "Common" };
|
||||||
|
|
||||||
|
// Maybe make the defaultChannel an actual channel type some day, and use that for parsing messages
|
||||||
|
// [DataField("defaultChannel", customTypeSerializer: typeof(PrototypeIdHashSetSerializer<RadioChannelPrototype>))]
|
||||||
|
// public readonly HashSet<string> defaultChannel = new();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[DataField("defaultChannel", customTypeSerializer: typeof(PrototypeIdSerializer<RadioChannelPrototype>))]
|
||||||
|
public readonly string? defaultChannel;
|
||||||
|
|
||||||
[DataField("enabled")]
|
[DataField("enabled")]
|
||||||
public bool Enabled = true;
|
public bool Enabled = true;
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
channels:
|
channels:
|
||||||
- Common
|
- Common
|
||||||
- Supply
|
- Supply
|
||||||
|
defaultChannel: Supply
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Clothing/Ears/Headsets/cargo.rsi
|
sprite: Clothing/Ears/Headsets/cargo.rsi
|
||||||
- type: Clothing
|
- type: Clothing
|
||||||
@@ -39,6 +40,7 @@
|
|||||||
- Command
|
- Command
|
||||||
- Common
|
- Common
|
||||||
- Supply
|
- Supply
|
||||||
|
defaultChannel: Supply
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Clothing/Ears/Headsets/cargo.rsi
|
sprite: Clothing/Ears/Headsets/cargo.rsi
|
||||||
- type: Clothing
|
- type: Clothing
|
||||||
@@ -61,6 +63,7 @@
|
|||||||
- Security
|
- Security
|
||||||
- Service
|
- Service
|
||||||
- Supply
|
- Supply
|
||||||
|
defaultChannel: CentCom
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Clothing/Ears/Headsets/centcom.rsi
|
sprite: Clothing/Ears/Headsets/centcom.rsi
|
||||||
- type: Clothing
|
- type: Clothing
|
||||||
@@ -82,6 +85,7 @@
|
|||||||
- Security
|
- Security
|
||||||
- Service
|
- Service
|
||||||
- Supply
|
- Supply
|
||||||
|
defaultChannel: Command
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Clothing/Ears/Headsets/command.rsi
|
sprite: Clothing/Ears/Headsets/command.rsi
|
||||||
- type: Clothing
|
- type: Clothing
|
||||||
@@ -97,6 +101,7 @@
|
|||||||
channels:
|
channels:
|
||||||
- Common
|
- Common
|
||||||
- Engineering
|
- Engineering
|
||||||
|
defaultChannel: Engineering
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Clothing/Ears/Headsets/engineering.rsi
|
sprite: Clothing/Ears/Headsets/engineering.rsi
|
||||||
- type: Clothing
|
- type: Clothing
|
||||||
@@ -113,6 +118,7 @@
|
|||||||
- Command
|
- Command
|
||||||
- Common
|
- Common
|
||||||
- Engineering
|
- Engineering
|
||||||
|
defaultChannel: Engineering
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Clothing/Ears/Headsets/engineering.rsi
|
sprite: Clothing/Ears/Headsets/engineering.rsi
|
||||||
- type: Clothing
|
- type: Clothing
|
||||||
@@ -128,6 +134,7 @@
|
|||||||
channels:
|
channels:
|
||||||
- Common
|
- Common
|
||||||
- Medical
|
- Medical
|
||||||
|
defaultChannel: Medical
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Clothing/Ears/Headsets/medical.rsi
|
sprite: Clothing/Ears/Headsets/medical.rsi
|
||||||
- type: Clothing
|
- type: Clothing
|
||||||
@@ -144,6 +151,7 @@
|
|||||||
- Common
|
- Common
|
||||||
- Medical
|
- Medical
|
||||||
- Science
|
- Science
|
||||||
|
defaultChannel: Science
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Clothing/Ears/Headsets/medicalscience.rsi
|
sprite: Clothing/Ears/Headsets/medicalscience.rsi
|
||||||
- type: Clothing
|
- type: Clothing
|
||||||
@@ -159,6 +167,7 @@
|
|||||||
channels:
|
channels:
|
||||||
- Common
|
- Common
|
||||||
- Supply
|
- Supply
|
||||||
|
defaultChannel: Supply
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Clothing/Ears/Headsets/mining.rsi
|
sprite: Clothing/Ears/Headsets/mining.rsi
|
||||||
- type: Clothing
|
- type: Clothing
|
||||||
@@ -174,6 +183,7 @@
|
|||||||
channels:
|
channels:
|
||||||
- Common
|
- Common
|
||||||
- Science
|
- Science
|
||||||
|
defaultChannel: Science
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Clothing/Ears/Headsets/robotics.rsi
|
sprite: Clothing/Ears/Headsets/robotics.rsi
|
||||||
- type: Clothing
|
- type: Clothing
|
||||||
@@ -189,6 +199,7 @@
|
|||||||
channels:
|
channels:
|
||||||
- Common
|
- Common
|
||||||
- Science
|
- Science
|
||||||
|
defaultChannel: Science
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Clothing/Ears/Headsets/science.rsi
|
sprite: Clothing/Ears/Headsets/science.rsi
|
||||||
- type: Clothing
|
- type: Clothing
|
||||||
@@ -205,6 +216,7 @@
|
|||||||
- Command
|
- Command
|
||||||
- Common
|
- Common
|
||||||
- Science
|
- Science
|
||||||
|
defaultChannel: Science
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Clothing/Ears/Headsets/science.rsi
|
sprite: Clothing/Ears/Headsets/science.rsi
|
||||||
- type: Clothing
|
- type: Clothing
|
||||||
@@ -220,6 +232,7 @@
|
|||||||
channels:
|
channels:
|
||||||
- Common
|
- Common
|
||||||
- Security
|
- Security
|
||||||
|
defaultChannel: Security
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Clothing/Ears/Headsets/security.rsi
|
sprite: Clothing/Ears/Headsets/security.rsi
|
||||||
- type: Clothing
|
- type: Clothing
|
||||||
@@ -235,6 +248,7 @@
|
|||||||
channels:
|
channels:
|
||||||
- Common
|
- Common
|
||||||
- Service
|
- Service
|
||||||
|
defaultChannel: Service
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Clothing/Ears/Headsets/service.rsi
|
sprite: Clothing/Ears/Headsets/service.rsi
|
||||||
- type: Clothing
|
- type: Clothing
|
||||||
@@ -249,5 +263,6 @@
|
|||||||
- type: Headset
|
- type: Headset
|
||||||
channels:
|
channels:
|
||||||
- Common
|
- Common
|
||||||
|
defaultChannel: Common
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Clothing/Ears/Headsets/base.rsi
|
sprite: Clothing/Ears/Headsets/base.rsi
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
- Security
|
- Security
|
||||||
- Service
|
- Service
|
||||||
- Supply
|
- Supply
|
||||||
|
defaultChannel: CentCom
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Clothing/Ears/Headsets/centcom.rsi
|
sprite: Clothing/Ears/Headsets/centcom.rsi
|
||||||
- type: Clothing
|
- type: Clothing
|
||||||
@@ -49,6 +50,7 @@
|
|||||||
- Security
|
- Security
|
||||||
- Service
|
- Service
|
||||||
- Supply
|
- Supply
|
||||||
|
defaultChannel: Command
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Clothing/Ears/Headsets/command.rsi
|
sprite: Clothing/Ears/Headsets/command.rsi
|
||||||
- type: Clothing
|
- type: Clothing
|
||||||
@@ -64,6 +66,7 @@
|
|||||||
- Command
|
- Command
|
||||||
- Common
|
- Common
|
||||||
- Medical
|
- Medical
|
||||||
|
defaultChannel: Medical
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Clothing/Ears/Headsets/medical.rsi
|
sprite: Clothing/Ears/Headsets/medical.rsi
|
||||||
- type: Clothing
|
- type: Clothing
|
||||||
@@ -79,6 +82,7 @@
|
|||||||
- Command
|
- Command
|
||||||
- Common
|
- Common
|
||||||
- Security
|
- Security
|
||||||
|
defaultChannel: Security
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Clothing/Ears/Headsets/security.rsi
|
sprite: Clothing/Ears/Headsets/security.rsi
|
||||||
- type: Clothing
|
- type: Clothing
|
||||||
@@ -94,6 +98,7 @@
|
|||||||
- Command
|
- Command
|
||||||
- Common
|
- Common
|
||||||
- Engineering
|
- Engineering
|
||||||
|
defaultChannel: Engineering
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Clothing/Ears/Headsets/engineering.rsi
|
sprite: Clothing/Ears/Headsets/engineering.rsi
|
||||||
- type: Clothing
|
- type: Clothing
|
||||||
@@ -109,6 +114,7 @@
|
|||||||
- Command
|
- Command
|
||||||
- Common
|
- Common
|
||||||
- Science
|
- Science
|
||||||
|
defaultChannel: Science
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Clothing/Ears/Headsets/science.rsi
|
sprite: Clothing/Ears/Headsets/science.rsi
|
||||||
- type: Clothing
|
- type: Clothing
|
||||||
@@ -124,6 +130,7 @@
|
|||||||
- Command
|
- Command
|
||||||
- Common
|
- Common
|
||||||
- Supply
|
- Supply
|
||||||
|
defaultChannel: Supply
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Clothing/Ears/Headsets/cargo.rsi
|
sprite: Clothing/Ears/Headsets/cargo.rsi
|
||||||
- type: Clothing
|
- type: Clothing
|
||||||
@@ -138,6 +145,7 @@
|
|||||||
- type: Headset
|
- type: Headset
|
||||||
channels:
|
channels:
|
||||||
- Syndicate
|
- Syndicate
|
||||||
|
defaultChannel: Syndicate
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Clothing/Ears/Headsets/syndicate.rsi
|
sprite: Clothing/Ears/Headsets/syndicate.rsi
|
||||||
- type: Clothing
|
- type: Clothing
|
||||||
|
|||||||
Reference in New Issue
Block a user