Headsets (#2023)
* add headset component * add basic headset logic * fix formatting in listening component, add dependency to headset * test function for headset * implement headset as listener * ANNIHILATES ListeningComponent, refactor of radio/listener sys * basic headset functionality * rename RadioComponent to HandheldRadioComponent * change channel to list of channels * basic headset implementation complete * message now always excludes ';' * add radio color; state channel freq. and source name * undocumented game breaking bug commit (DO NOT RESEARCH) actually just changes frequency from 1457 (what signalers are set to by default) to 1459, the actual frequency for common * Add more sprites * Reorganizes * Added job headsets * Adds headset as an ignored component * Jobs now spawn with headsets * remove system.tracing * Catchup commits * Add headset property serialization * Turn GetChannels into a property * ListenRange property and serializatioon * Adjust interfaces * Address reviews * Cleanup * Address reviews * Update rsi * Fix licenses and copyright * Fix missing textures * Merge fixes * Move headset textures from objects/devices to clothing/ears * Fix rsi state names and add equipped states * Fix headsets not working * Add missing brackets to channel number in chat * heck * Fix broken rsi * Fix radio id and names * Put quotes around headset messages * Fix method names * Fix handheld radios * Fix capitalization when using radio channels and trim * Remove unnecessary dependency * Indent that * Separate this part * Goodbye icons * Implement IActivate in HandheldRadioComponent * Add examine tooltip to radios and headsets * Rename IListen methods Co-authored-by: Bright <nsmoak10@yahoo.com> Co-authored-by: Swept <jamesurquhartwebb@gmail.com> Co-authored-by: Bright0 <55061890+Bright0@users.noreply.github.com>
This commit is contained in:
@@ -1,14 +1,21 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Content.Server.GameObjects.Components;
|
||||
using Content.Server.GameObjects.Components.GUI;
|
||||
using Content.Server.GameObjects.Components.Headset;
|
||||
using Content.Server.GameObjects.Components.Items.Storage;
|
||||
using Content.Server.GameObjects.Components.Observer;
|
||||
using Content.Server.GameObjects.EntitySystems;
|
||||
using Content.Server.Interfaces;
|
||||
using Content.Server.Interfaces.Chat;
|
||||
using Content.Shared.Chat;
|
||||
using Content.Shared.GameObjects.Components.Inventory;
|
||||
using Content.Shared.GameObjects.EntitySystems;
|
||||
using Content.Shared.Interfaces;
|
||||
using Robust.Server.Console;
|
||||
using Robust.Server.Interfaces.GameObjects;
|
||||
using Robust.Server.Interfaces.Player;
|
||||
using Robust.Shared.GameObjects.Systems;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.Interfaces.Network;
|
||||
using Robust.Shared.IoC;
|
||||
@@ -37,7 +44,6 @@ namespace Content.Server.Chat
|
||||
//TODO: make prio based?
|
||||
private List<TransformChat> _chatTransformHandlers;
|
||||
|
||||
[Dependency] private readonly IEntitySystemManager _entitySystemManager = default!;
|
||||
[Dependency] private readonly IServerNetManager _netManager = default!;
|
||||
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||
[Dependency] private readonly IMoMMILink _mommiLink = default!;
|
||||
@@ -90,16 +96,16 @@ namespace Content.Server.Chat
|
||||
return;
|
||||
}
|
||||
|
||||
// Get entity's PlayerSession
|
||||
IPlayerSession playerSession = source.GetComponent<IActorComponent>().playerSession;
|
||||
|
||||
// Check if message exceeds the character limit if the sender is a player
|
||||
if (playerSession != null)
|
||||
if (message.Length > MaxMessageLength)
|
||||
{
|
||||
DispatchServerMessage(playerSession, Loc.GetString(MaxLengthExceededMessage, MaxMessageLength));
|
||||
return;
|
||||
}
|
||||
if (source.TryGetComponent(out IActorComponent actor) &&
|
||||
message.Length > MaxMessageLength)
|
||||
{
|
||||
var feedback = Loc.GetString(MaxLengthExceededMessage, MaxMessageLength);
|
||||
|
||||
DispatchServerMessage(actor.playerSession, feedback);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var handler in _chatTransformHandlers)
|
||||
{
|
||||
@@ -107,21 +113,47 @@ namespace Content.Server.Chat
|
||||
message = handler(source, message);
|
||||
}
|
||||
|
||||
// Ensure the first letter inside the message string is always a capital letter
|
||||
message = message[0].ToString().ToUpper() + message.Remove(0,1);
|
||||
message = message.Trim();
|
||||
|
||||
var pos = source.Transform.Coordinates;
|
||||
var clients = _playerManager.GetPlayersInRange(pos, VoiceRange).Select(p => p.ConnectedClient);
|
||||
|
||||
if (message.StartsWith(';'))
|
||||
{
|
||||
// Remove semicolon
|
||||
message = message.Substring(1).TrimStart();
|
||||
|
||||
// Capitalize first letter
|
||||
message = message[0].ToString().ToUpper() +
|
||||
message.Remove(0,1);
|
||||
|
||||
if (source.TryGetComponent(out InventoryComponent inventory) &&
|
||||
inventory.TryGetSlotItem(EquipmentSlotDefines.Slots.EARS, out ItemComponent item) &&
|
||||
item.Owner.TryGetComponent(out HeadsetComponent headset))
|
||||
{
|
||||
headset.RadioRequested = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
source.PopupMessage(Loc.GetString("You don't have a headset on!"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Capitalize first letter
|
||||
message = message[0].ToString().ToUpper() +
|
||||
message.Remove(0,1);
|
||||
}
|
||||
|
||||
var listeners = EntitySystem.Get<ListeningSystem>();
|
||||
listeners.PingListeners(source, message);
|
||||
|
||||
var msg = _netManager.CreateNetMessage<MsgChatMessage>();
|
||||
msg.Channel = ChatChannel.Local;
|
||||
msg.Message = message;
|
||||
msg.MessageWrap = $"{source.Name} says, \"{{0}}\"";
|
||||
msg.MessageWrap = Loc.GetString("{0} says, \"{{0}}\"", source.Name);
|
||||
msg.SenderEntity = source.Uid;
|
||||
_netManager.ServerSendToMany(msg, clients.ToList());
|
||||
|
||||
var listeners = _entitySystemManager.GetEntitySystem<ListeningSystem>();
|
||||
listeners.PingListeners(source, pos, message);
|
||||
}
|
||||
|
||||
public void EntityMe(IEntity source, string action)
|
||||
|
||||
Reference in New Issue
Block a user