Skip to content

Commit

Permalink
Merge branch 'new-frontiers-14:master' into weedchurch
Browse files Browse the repository at this point in the history
  • Loading branch information
terezi committed Sep 24, 2023
2 parents 304c9d1 + fb9646a commit 233f78f
Show file tree
Hide file tree
Showing 413 changed files with 30,059 additions and 2,972 deletions.
161 changes: 154 additions & 7 deletions Content.Server/Chat/Systems/ChatSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
using Robust.Shared.Random;
using Robust.Shared.Replays;
using Robust.Shared.Utility;
using Content.Shared.Inventory;
using Content.Shared.Hands.EntitySystems;
using Content.Server.PowerCell;
using Content.Server.VulpLangauge;

namespace Content.Server.Chat.Systems;

Expand All @@ -53,6 +57,9 @@ public sealed partial class ChatSystem : SharedChatSystem
[Dependency] private readonly MobStateSystem _mobStateSystem = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
[Dependency] private readonly InventorySystem _inventorySystem = default!;
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
[Dependency] private readonly PowerCellSystem _cell = default!;

public const int VoiceRange = 10; // how far voice goes in world units
public const int WhisperClearRange = 2; // how far whisper goes while still being understandable, in world units
Expand Down Expand Up @@ -388,9 +395,24 @@ private void SendEntitySpeak(
("fontSize", speech.FontSize),
("message", FormattedMessage.EscapeText(message)));

SendInVoiceRange(ChatChannel.Local, message, wrappedMessage, source, range);
var Canilunzt = false;
var CanilunztMessage = "";
var CanilunztwrappedMessage = "";
if (IsCanilunztSpeaker(source) && !HasCanilunztTranslator(source))
{
Canilunzt = true;
CanilunztMessage = MessagetoCanilunzt(message);
CanilunztwrappedMessage = Loc.GetString(speech.Bold ? "chat-manager-entity-say-bold-wrap-message" : "chat-manager-entity-say-wrap-message",
("entityName", name),
("verb", Loc.GetString(_random.Pick(speech.SpeechVerbStrings))),
("fontType", speech.FontId),
("fontSize", speech.FontSize),
("message", FormattedMessage.EscapeText(CanilunztMessage)));
}

var ev = new EntitySpokeEvent(source, message, null, null);
SendInVoiceRange(ChatChannel.Local, message, wrappedMessage, source, range, Canilunzt, CanilunztMessage, CanilunztwrappedMessage);

var ev = new EntitySpokeEvent(source, message, null, null, Canilunzt);
RaiseLocalEvent(source, ev, true);

// To avoid logging any messages sent by entities that are not players, like vendors, cloning, etc.
Expand Down Expand Up @@ -461,6 +483,27 @@ private void SendEntityWhisper(
var wrappedUnknownMessage = Loc.GetString("chat-manager-entity-whisper-unknown-wrap-message",
("message", FormattedMessage.EscapeText(obfuscatedMessage)));

var canilunzt = false;
var canilunztmessage = "";
var canilunztobfuscatedMessage = "";
var canilunztwrappedMessage = "";
var canilunztwrappedobfuscatedMessage = "";
var canilunztwrappedUnknownMessage = "";
if (IsCanilunztSpeaker(source) && !HasCanilunztTranslator(source))
{
canilunzt = true;
canilunztmessage = MessagetoCanilunzt(message);
canilunztobfuscatedMessage = ObfuscateMessageReadability(canilunztmessage, 0.2f);
canilunztwrappedMessage = Loc.GetString("chat-manager-entity-whisper-wrap-message",
("entityName", name), ("message", FormattedMessage.EscapeText(canilunztmessage)));

canilunztwrappedobfuscatedMessage = Loc.GetString("chat-manager-entity-whisper-wrap-message",
("entityName", nameIdentity), ("message", FormattedMessage.EscapeText(canilunztobfuscatedMessage)));

canilunztwrappedUnknownMessage = Loc.GetString("chat-manager-entity-whisper-unknown-wrap-message",
("message", FormattedMessage.EscapeText(canilunztobfuscatedMessage)));
}


foreach (var (session, data) in GetRecipients(source, WhisperMuffledRange))
{
Expand All @@ -473,6 +516,15 @@ private void SendEntityWhisper(
if (MessageRangeCheck(session, data, range) != MessageRangeCheckResult.Full)
continue; // Won't get logged to chat, and ghosts are too far away to see the pop-up, so we just won't send it to them.

if (canilunzt && !IsCanilunztListener(listener))
{
message = canilunztmessage;
obfuscatedMessage = canilunztobfuscatedMessage;
wrappedMessage = canilunztwrappedMessage;
wrappedobfuscatedMessage = canilunztwrappedobfuscatedMessage;
wrappedUnknownMessage = canilunztwrappedUnknownMessage;
}

if (data.Range <= WhisperClearRange)
_chatManager.ChatMessageToOne(ChatChannel.Whisper, message, wrappedMessage, source, false, session.ConnectedClient);
//If listener is too far, they only hear fragments of the message
Expand All @@ -486,8 +538,9 @@ private void SendEntityWhisper(

_replay.RecordServerMessage(new ChatMessage(ChatChannel.Whisper, message, wrappedMessage, GetNetEntity(source), MessageRangeHideChatForReplay(range)));

var ev = new EntitySpokeEvent(source, message, channel, obfuscatedMessage);
var ev = new EntitySpokeEvent(source, message, channel, obfuscatedMessage, canilunzt);
RaiseLocalEvent(source, ev, true);

if (!hideLog)
if (originalMessage == message)
{
Expand Down Expand Up @@ -532,7 +585,7 @@ private void SendEntityEmote(

if (checkEmote)
TryEmoteChatInput(source, action);
SendInVoiceRange(ChatChannel.Emotes, action, wrappedMessage, source, range);
SendInVoiceRange(ChatChannel.Emotes, action, wrappedMessage, source, range, false, "", "");
if (!hideLog)
if (name != Name(source))
_adminLogger.Add(LogType.Chat, LogImpact.Low, $"Emote from {ToPrettyString(source):user} as {name}: {action}");
Expand All @@ -559,7 +612,7 @@ private void SendLOOC(EntityUid source, IPlayerSession player, string message, b
("entityName", name),
("message", FormattedMessage.EscapeText(message)));

SendInVoiceRange(ChatChannel.LOOC, message, wrappedMessage, source, hideChat ? ChatTransmitRange.HideChat : ChatTransmitRange.Normal);
SendInVoiceRange(ChatChannel.LOOC, message, wrappedMessage, source, hideChat ? ChatTransmitRange.HideChat : ChatTransmitRange.Normal, false, "", "");
_adminLogger.Add(LogType.Chat, LogImpact.Low, $"LOOC from {player:Player}: {message}");
}

Expand Down Expand Up @@ -640,14 +693,27 @@ private MessageRangeCheckResult MessageRangeCheck(ICommonSession session, ICChat
/// <summary>
/// Sends a chat message to the given players in range of the source entity.
/// </summary>
private void SendInVoiceRange(ChatChannel channel, string message, string wrappedMessage, EntityUid source, ChatTransmitRange range)
private void SendInVoiceRange(ChatChannel channel, string message, string wrappedMessage, EntityUid source, ChatTransmitRange range, bool Canilunzt, string CanilunztMessage, string CanilunztwrappedMessage)
{
foreach (var (session, data) in GetRecipients(source, VoiceRange))
{
var entRange = MessageRangeCheck(session, data, range);
if (entRange == MessageRangeCheckResult.Disallowed)
continue;
var entHideChat = entRange == MessageRangeCheckResult.HideChat;

EntityUid listener;

if (session.AttachedEntity is not { Valid: true } playerEntity)
continue;
listener = session.AttachedEntity.Value;

if (Canilunzt && !IsCanilunztListener(listener))
{
message = CanilunztMessage;
wrappedMessage = CanilunztwrappedMessage;
}

_chatManager.ChatMessageToOne(channel, message, wrappedMessage, source, entHideChat, session.ConnectedClient);
}

Expand Down Expand Up @@ -797,6 +863,85 @@ private string ObfuscateMessageReadability(string message, float chance)
return modifiedMessage.ToString();
}

private static readonly IReadOnlyList<string> CanilunztSyllables = new List<string>{
"rur","ya","cen","rawr","bar","kuk","tek","qat","uk","wu","vuh","tah","tch","schz","auch","ist","ein","entch","zwichs","tut","mir","wo","bis","es","vor","nic","gro","lll","enem","zandt","tzch","noch","hel","ischt","far","wa","baram","iereng","tech","lach","sam","mak","lich","gen","or","ag","eck","gec","stag","onn","bin","ket","jarl","vulf","einech","cresthz","azunein","ghzth"
}.AsReadOnly();

public string MessagetoCanilunzt(string message)
{
var msg = message;
var words = message.Split();
var accentedMessage = new StringBuilder(message.Length + 2);
for (var i = 0; i < words.Length; i++)
{
accentedMessage.Append(_random.Pick(CanilunztSyllables));
if (i < words.Length - 1)
accentedMessage.Append(' ');
}
accentedMessage.Append('.');
msg = accentedMessage.ToString();

return msg;
}

public bool IsCanilunztSpeaker(EntityUid source)
{
if (HasComp<VulpLanguageSpeakerComponent>(source))
{
return true;
}
return false;
}

public bool IsCanilunztListener(EntityUid source)
{
if (HasComp<VulpLangaugeListenerComponent>(source) || HasComp<GhostComponent>(source))
{
return true;
}
return false;
}

private bool CheckItemForCanilunztTranslator(EntityUid source)
{
if (HasComp<VulpTranslatorComponent>(source))
{
if (_cell.TryUseActivatableCharge(source))
{
return true;
}
}
return false;
}

public bool HasCanilunztTranslator(EntityUid source)
{
foreach (var item in _handsSystem.EnumerateHeld(source))
{
if (CheckItemForCanilunztTranslator(item))
{
return true;
}
}

if (_inventorySystem.TryGetSlotEntity(source, "pocket1", out var item2))
{
if (item2 is { Valid : true } stationUid && CheckItemForCanilunztTranslator(stationUid))
{
return true;
}
}
else if (_inventorySystem.TryGetSlotEntity(source, "pocket2", out var item3))
{
if (item3 is { Valid : true } stationUid && CheckItemForCanilunztTranslator(stationUid))
{
return true;
}
}

return false;
}

#endregion
}

Expand Down Expand Up @@ -843,19 +988,21 @@ public sealed class EntitySpokeEvent : EntityEventArgs
public readonly EntityUid Source;
public readonly string Message;
public readonly string? ObfuscatedMessage; // not null if this was a whisper
public readonly bool Canilunzt; // If is a Canilunzt Message

/// <summary>
/// If the entity was trying to speak into a radio, this was the channel they were trying to access. If a radio
/// message gets sent on this channel, this should be set to null to prevent duplicate messages.
/// </summary>
public RadioChannelPrototype? Channel;

public EntitySpokeEvent(EntityUid source, string message, RadioChannelPrototype? channel, string? obfuscatedMessage)
public EntitySpokeEvent(EntityUid source, string message, RadioChannelPrototype? channel, string? obfuscatedMessage, bool canilunzt)
{
Source = source;
Message = message;
Channel = channel;
ObfuscatedMessage = obfuscatedMessage;
Canilunzt = canilunzt;
}
}

Expand Down
19 changes: 17 additions & 2 deletions Content.Server/Explosion/EntitySystems/TriggerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
using Content.Shared.Mobs;
using Content.Shared.Mobs.Components;
using Content.Shared.Weapons.Ranged.Events;
using Content.Server.Station.Systems;

namespace Content.Server.Explosion.EntitySystems
{
Expand Down Expand Up @@ -61,6 +62,7 @@ public sealed partial class TriggerSystem : EntitySystem
[Dependency] private readonly SharedTransformSystem _transformSystem = default!;
[Dependency] private readonly RadioSystem _radioSystem = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly StationSystem _station = default!;

public override void Initialize()
{
Expand Down Expand Up @@ -167,8 +169,21 @@ private void HandleRattleTrigger(EntityUid uid, RattleComponent component, Trigg
var y = (int) pos.Y;
var posText = $"({x}, {y})";

var critMessage = Loc.GetString(component.CritMessage, ("user", implanted.ImplantedEntity.Value), ("position", posText));
var deathMessage = Loc.GetString(component.DeathMessage, ("user", implanted.ImplantedEntity.Value), ("position", posText));
// Gets station location of the implant
var station = _station.GetOwningStation(uid);
var stationName = station is null ? null : Name(station.Value);

if (!(stationName == null))
{
stationName += " ";
}
else
{
stationName = "";
}

var critMessage = Loc.GetString(component.CritMessage, ("user", implanted.ImplantedEntity.Value), ("grid", stationName!), ("position", posText));
var deathMessage = Loc.GetString(component.DeathMessage, ("user", implanted.ImplantedEntity.Value), ("grid", stationName!), ("position", posText));

if (!TryComp<MobStateComponent>(implanted.ImplantedEntity, out var mobstate))
return;
Expand Down
4 changes: 4 additions & 0 deletions Content.Server/Radio/EntitySystems/HeadsetSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ private void UpdateRadioChannels(EntityUid uid, HeadsetComponent headset, Encryp

private void OnSpeak(EntityUid uid, WearingHeadsetComponent component, EntitySpokeEvent args)
{
if (args.Canilunzt)
{
return;
}
if (args.Channel != null
&& TryComp(component.Headset, out EncryptionKeyHolderComponent? keys)
&& keys.Channels.Contains(args.Channel.ID))
Expand Down
4 changes: 4 additions & 0 deletions Content.Server/Radio/EntitySystems/RadioSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ public override void Initialize()

private void OnIntrinsicSpeak(EntityUid uid, IntrinsicRadioTransmitterComponent component, EntitySpokeEvent args)
{
if (args.Canilunzt)
{
return;
}
if (args.Channel != null && component.Channels.Contains(args.Channel.ID))
{
SendRadioMessage(uid, args.Message, args.Channel, uid);
Expand Down
4 changes: 4 additions & 0 deletions Content.Server/Speech/EntitySystems/ListeningSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ public override void Initialize()

private void OnSpeak(EntitySpokeEvent ev)
{
if (ev.Canilunzt)
{
return;
}
PingListeners(ev.Source, ev.Message, ev.ObfuscatedMessage);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,17 @@ public sealed partial class SurveillanceCameraComponent : Component
[DataField("id")]
public string CameraId { get; set; } = "camera";

[ViewVariables]
public EntityUid? CameraIdUser = null;

[ViewVariables(VVAccess.ReadWrite)]
[DataField("nameSet")]
public bool NameSet { get; set; }

[ViewVariables(VVAccess.ReadWrite)]
[DataField("nameSetUser")]
public bool NameSetUser { get; set; }

[ViewVariables(VVAccess.ReadWrite)]
[DataField("networkSet")]
public bool NetworkSet { get; set; }
Expand Down
Loading

0 comments on commit 233f78f

Please sign in to comment.