Skip to content

Commit

Permalink
Merge branch 'master' into newsprites
Browse files Browse the repository at this point in the history
  • Loading branch information
Ichaie authored Nov 2, 2024
2 parents e1faf0c + 97e0403 commit b02b722
Show file tree
Hide file tree
Showing 79 changed files with 45,312 additions and 35,537 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using Content.Server.Atmos.EntitySystems;
using Content.Server.Atmos.Piping.Components;
using Content.Server.Atmos.Piping.Trinary.Components;
using Content.Server.NodeContainer;
using Content.Server.NodeContainer.EntitySystems;
using Content.Server.NodeContainer.Nodes;
using Content.Shared.Atmos.Piping;
Expand All @@ -13,7 +11,6 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
[UsedImplicitly]
public sealed class PressureControlledValveSystem : EntitySystem
{
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
[Dependency] private readonly SharedAmbientSoundSystem _ambientSoundSystem = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly NodeContainerSystem _nodeContainer = default!;
Expand All @@ -40,39 +37,26 @@ private void OnUpdate(EntityUid uid, PressureControlledValveComponent comp, ref
return;
}

// If output is higher than input, flip input/output to enable bidirectional flow.
if (outletNode.Air.Pressure > inletNode.Air.Pressure)
{
PipeNode temp = outletNode;
outletNode = inletNode;
inletNode = temp;
}

float control = (controlNode.Air.Pressure - outletNode.Air.Pressure) - comp.Threshold;
float transferRate;
if (control < 0)
{
comp.Enabled = false;
transferRate = 0;
}
else
// If the pressure in either inlet or outlet exceeds the side pressure, act as an open pipe.
if (!comp.Enabled && (controlNode.Air.Pressure < inletNode.Air.Pressure
|| controlNode.Air.Pressure < outletNode.Air.Pressure))
{
inletNode.AddAlwaysReachable(outletNode);
outletNode.AddAlwaysReachable(inletNode);
comp.Enabled = true;
transferRate = Math.Min(control * comp.Gain, comp.MaxTransferRate * _atmosphereSystem.PumpSpeedup());
UpdateAppearance(uid, comp);
_ambientSoundSystem.SetAmbience(uid, true);
return;
}
UpdateAppearance(uid, comp);

// We multiply the transfer rate in L/s by the seconds passed since the last process to get the liters.
var transferVolume = transferRate * args.dt;
if (transferVolume <= 0)
{
_ambientSoundSystem.SetAmbience(uid, false);
if (!comp.Enabled)
return;
}

_ambientSoundSystem.SetAmbience(uid, true);
var removed = inletNode.Air.RemoveVolume(transferVolume);
_atmosphereSystem.Merge(outletNode.Air, removed);
inletNode.RemoveAlwaysReachable(outletNode);
outletNode.RemoveAlwaysReachable(inletNode);
comp.Enabled = false;
UpdateAppearance(uid, comp);
_ambientSoundSystem.SetAmbience(uid, false);
}

private void OnFilterLeaveAtmosphere(EntityUid uid, PressureControlledValveComponent comp, ref AtmosDeviceDisabledEvent args)
Expand Down
4 changes: 2 additions & 2 deletions Content.Server/Chat/Systems/ChatSystem.Emote.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ private void CacheEmotes()
/// <param name="emoteId">The id of emote prototype. Should has valid <see cref="EmotePrototype.ChatMessages"/></param>
/// <param name="hideLog">Whether or not this message should appear in the adminlog window</param>
/// <param name="range">Conceptual range of transmission, if it shows in the chat window, if it shows to far-away ghosts or ghosts at all...</param>
/// <param name="nameOverride">The name to use for the speaking entity. Usually this should just be modified via <see cref="TransformSpeakerNameEvent"/>. If this is set, the event will not get raised.</param>
/// <param name="nameOverride">The name to use for the speaking entity. Usually this should just be modified via <see cref="TransformSpeakerSpeechEvent"/>. If this is set, the event will not get raised.</param>
public void TryEmoteWithChat(
EntityUid source,
string emoteId,
Expand All @@ -74,7 +74,7 @@ public void TryEmoteWithChat(
/// <param name="hideLog">Whether or not this message should appear in the adminlog window</param>
/// <param name="hideChat">Whether or not this message should appear in the chat window</param>
/// <param name="range">Conceptual range of transmission, if it shows in the chat window, if it shows to far-away ghosts or ghosts at all...</param>
/// <param name="nameOverride">The name to use for the speaking entity. Usually this should just be modified via <see cref="TransformSpeakerNameEvent"/>. If this is set, the event will not get raised.</param>
/// <param name="nameOverride">The name to use for the speaking entity. Usually this should just be modified via <see cref="TransformSpeakerSpeechEvent"/>. If this is set, the event will not get raised.</param>
public void TryEmoteWithChat(
EntityUid source,
EmotePrototype emote,
Expand Down
29 changes: 7 additions & 22 deletions Content.Server/Chat/Systems/ChatSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using Content.Server.Language;
using Content.Server.Speech.Components;
using Content.Server.Speech.EntitySystems;
using Content.Server.Chat;
using Content.Server.Station.Components;
using Content.Server.Station.Systems;
using Content.Shared.ActionBlocker;
Expand Down Expand Up @@ -147,7 +146,7 @@ private void OnGameChange(GameRunLevelChangedEvent ev)
/// <param name="hideLog">Whether or not this message should appear in the adminlog window</param>
/// <param name="shell"></param>
/// <param name="player">The player doing the speaking</param>
/// <param name="nameOverride">The name to use for the speaking entity. Usually this should just be modified via <see cref="TransformSpeakerNameEvent"/>. If this is set, the event will not get raised.</param>
/// <param name="nameOverride">The name to use for the speaking entity. Usually this should just be modified via <see cref="TransformSpeakerSpeechEvent"/>. If this is set, the event will not get raised.</param>
public void TrySendInGameICMessage(
EntityUid source,
string message,
Expand All @@ -170,7 +169,7 @@ public void TrySendInGameICMessage(
/// <param name="range">Conceptual range of transmission, if it shows in the chat window, if it shows to far-away ghosts or ghosts at all...</param>
/// <param name="shell"></param>
/// <param name="player">The player doing the speaking</param>
/// <param name="nameOverride">The name to use for the speaking entity. Usually this should just be modified via <see cref="TransformSpeakerNameEvent"/>. If this is set, the event will not get raised.</param>
/// <param name="nameOverride">The name to use for the speaking entity. Usually this should just be modified via <see cref="TransformSpeakerSpeechEvent"/>. If this is set, the event will not get raised.</param>
/// <param name="ignoreActionBlocker">If set to true, action blocker will not be considered for whether an entity can send this message.</param>
public void TrySendInGameICMessage(
EntityUid source,
Expand Down Expand Up @@ -421,11 +420,11 @@ private void SendEntitySpeak(
}
else
{
var nameEv = new TransformSpeakerNameEvent(source, Name(source));
var nameEv = new TransformSpeakerSpeechEvent(source, Name(source));
RaiseLocalEvent(source, nameEv);
name = nameEv.Name;
name = nameEv.VoiceName ?? Name(source);
// Check for a speech verb override
if (nameEv.SpeechVerb != null && _prototypeManager.TryIndex<SpeechVerbPrototype>(nameEv.SpeechVerb, out var proto))
if (nameEv.SpeechVerb != null && _prototypeManager.TryIndex(nameEv.SpeechVerb, out var proto))
speech = proto;
}

Expand Down Expand Up @@ -493,9 +492,9 @@ private void SendEntityWhisper(
}
else
{
var nameEv = new TransformSpeakerNameEvent(source, Name(source));
var nameEv = new TransformSpeakerSpeechEvent(source, Name(source));
RaiseLocalEvent(source, nameEv);
name = nameEv.Name;
name = nameEv.VoiceName ?? Name(source);
}
name = FormattedMessage.EscapeText(name);

Expand Down Expand Up @@ -990,20 +989,6 @@ public record ExpandICChatRecipientstEvent(EntityUid Source, float VoiceRange, D
{
}

public sealed class TransformSpeakerNameEvent : EntityEventArgs
{
public EntityUid Sender;
public string Name;
public string? SpeechVerb;

public TransformSpeakerNameEvent(EntityUid sender, string name, string? speechVerb = null)
{
Sender = sender;
Name = name;
SpeechVerb = speechVerb;
}
}

/// <summary>
/// Raised broadcast in order to transform speech.transmit
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,110 +1,30 @@
using Content.Server.Administration.Logs;
using Content.Server.Chat.Systems;
using Content.Server.Popups;
using Content.Server.VoiceMask;
using Content.Shared.Database;
using Content.Server.VoiceMask;
using Content.Shared.Implants;
using Content.Shared.Implants.Components;
using Content.Shared.Popups;
using Content.Shared.Preferences;
using Content.Shared.Tag;
using Content.Shared.VoiceMask;
using Robust.Server.GameObjects;
using Robust.Shared.Containers;

namespace Content.Server.Implants;

public sealed class SubdermalBionicSyrinxImplantSystem : EntitySystem
{
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
[Dependency] private readonly PopupSystem _popupSystem = default!;
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
[Dependency] private readonly TagSystem _tag = default!;

[ValidatePrototypeId<TagPrototype>]
public const string BionicSyrinxImplant = "BionicSyrinxImplant";

private const string BionicSyrinxImplant = "BionicSyrinxImplant";

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<VoiceMaskerComponent, ImplantImplantedEvent>(OnInsert);
SubscribeLocalEvent<SyrinxVoiceMaskComponent, TransformSpeakerNameEvent>(OnSpeakerNameTransform);
SubscribeLocalEvent<SyrinxVoiceMaskComponent, VoiceMaskChangeNameMessage>(OnChangeName);
// We need to remove the SyrinxVoiceMaskComponent from the owner before the implant
// is removed, so we need to execute before the SubdermalImplantSystem.
SubscribeLocalEvent<VoiceMaskerComponent, EntGotRemovedFromContainerMessage>(OnRemove, before: new[] { typeof(SubdermalImplantSystem) });
SubscribeLocalEvent<VoiceMaskComponent, ImplantImplantedEvent>(OnInsert);
}

private void OnInsert(EntityUid uid, VoiceMaskerComponent component, ImplantImplantedEvent args)
private void OnInsert(EntityUid uid, VoiceMaskComponent component, ImplantImplantedEvent args)
{
if (!args.Implanted.HasValue ||
!_tag.HasTag(args.Implant, BionicSyrinxImplant))
return;

var voicemask = EnsureComp<SyrinxVoiceMaskComponent>(args.Implanted.Value);
voicemask.VoiceName = MetaData(args.Implanted.Value).EntityName;
Dirty(args.Implanted.Value, voicemask);
}

private void OnRemove(EntityUid uid, VoiceMaskerComponent component, EntGotRemovedFromContainerMessage args)
{
if (!TryComp<SubdermalImplantComponent>(uid, out var implanted) || implanted.ImplantedEntity == null)
return;

RemComp<SyrinxVoiceMaskComponent>(implanted.ImplantedEntity.Value);
}

/// <summary>
/// Copy from VoiceMaskSystem, adapted to work with SyrinxVoiceMaskComponent.
/// </summary>
private void OnChangeName(EntityUid uid, SyrinxVoiceMaskComponent component, VoiceMaskChangeNameMessage message)
{
if (message.Name.Length > HumanoidCharacterProfile.MaxNameLength || message.Name.Length <= 0)
{
_popupSystem.PopupEntity(Loc.GetString("voice-mask-popup-failure"), uid, message.Actor, PopupType.SmallCaution);
return;
}

component.VoiceName = message.Name;
_adminLogger.Add(LogType.Action, LogImpact.Medium, $"{ToPrettyString(message.Actor):player} set voice of {ToPrettyString(uid):mask}: {component.VoiceName}");

_popupSystem.PopupEntity(Loc.GetString("voice-mask-popup-success"), uid, message.Actor);
TrySetLastKnownName(uid, message.Name);
UpdateUI(uid, component);
}

/// <summary>
/// Copy from VoiceMaskSystem, adapted to work with SyrinxVoiceMaskComponent.
/// </summary>
private void TrySetLastKnownName(EntityUid implanted, string lastName)
{
if (!HasComp<VoiceMaskComponent>(implanted)
|| !TryComp<VoiceMaskerComponent>(implanted, out var maskComp))
return;

maskComp.LastSetName = lastName;
}

/// <summary>
/// Copy from VoiceMaskSystem, adapted to work with SyrinxVoiceMaskComponent.
/// </summary>
private void UpdateUI(EntityUid owner, SyrinxVoiceMaskComponent? component = null)
{
if (!Resolve(owner, ref component, logMissing: false))
return;

if (_uiSystem.TryGetOpenUi(owner, VoiceMaskUIKey.Key, out _))
_uiSystem.SetUiState(new(owner, null), VoiceMaskUIKey.Key, new VoiceMaskBuiState(component.VoiceName, null));
}

/// <summary>
/// Copy from VoiceMaskSystem, adapted to work with SyrinxVoiceMaskComponent.
/// </summary>
private void OnSpeakerNameTransform(EntityUid uid, SyrinxVoiceMaskComponent component, TransformSpeakerNameEvent args)
{
if (component.Enabled)
args.Name = component.VoiceName;
// Update the name so it's the entities default name. You can't take it off like a voice mask so it's important!
component.VoiceMaskName = Name(args.Implanted.Value);
}
}
9 changes: 0 additions & 9 deletions Content.Server/DeltaV/VoiceMask/SyrinxVoiceMaskComponent.cs

This file was deleted.

4 changes: 2 additions & 2 deletions Content.Server/Radio/EntitySystems/RadioDeviceSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,11 @@ private void OnReceiveRadio(EntityUid uid, RadioSpeakerComponent component, ref
if (uid == args.RadioSource)
return;

var nameEv = new TransformSpeakerNameEvent(args.MessageSource, Name(args.MessageSource));
var nameEv = new TransformSpeakerSpeechEvent(args.MessageSource, Name(args.MessageSource));
RaiseLocalEvent(args.MessageSource, nameEv);

var name = Loc.GetString("speech-name-relay", ("speaker", Name(uid)),
("originalName", nameEv.Name));
("originalName", nameEv.VoiceName ?? Name(args.MessageSource)));

// log to chat so people can identity the speaker/source, but avoid clogging ghost chat if there are many radios
var message = args.OriginalChatMsg.Message; // The chat system will handle the rest and re-obfuscate if needed.
Expand Down
23 changes: 3 additions & 20 deletions Content.Server/Radio/EntitySystems/RadioSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
using Content.Server.Language;
using Content.Server.Power.Components;
using Content.Server.Radio.Components;
using Content.Server.Speech;
using Content.Server.VoiceMask;
using Content.Shared.Chat;
using Content.Shared.Database;
using Content.Shared.Language;
Expand Down Expand Up @@ -92,28 +90,13 @@ public void SendRadioMessage(EntityUid messageSource, string message, RadioChann
if (!_messages.Add(message))
return;

var name = TryComp(messageSource, out VoiceMaskComponent? mask) && mask.Enabled
? mask.VoiceName
: MetaData(messageSource).EntityName;

// Delta-V: Support syrinx voice mask on radio.
if (TryComp(messageSource, out SyrinxVoiceMaskComponent? syrinx) && syrinx.Enabled)
name = syrinx.VoiceName;
var evt = new TransformSpeakerSpeechEvent(messageSource, Name(messageSource));
RaiseLocalEvent(messageSource, evt);
var name = evt.VoiceName ?? Name(messageSource);

name = FormattedMessage.EscapeText(name);

// most radios are relayed to chat, so lets parse the chat message beforehand
SpeechVerbPrototype speech;
if (mask != null
&& mask.Enabled
&& mask.SpeechVerb != null
&& _prototype.TryIndex<SpeechVerbPrototype>(mask.SpeechVerb, out var proto))
{
speech = proto;
}
else
speech = _chat.GetSpeechVerb(messageSource, message);

var content = escapeMarkup
? FormattedMessage.EscapeText(message)
: message;
Expand Down
Loading

0 comments on commit b02b722

Please sign in to comment.