Skip to content

Commit

Permalink
Merge pull request #199 from SpicyDarkFox/dbg
Browse files Browse the repository at this point in the history
Фиксы багов
  • Loading branch information
SpicyDarkFox authored Sep 25, 2024
2 parents 660d0e8 + 828a46d commit 0829e50
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
24 changes: 23 additions & 1 deletion Content.Client/Corvax/TTS/TTSSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@
using Robust.Shared.Configuration;
using Robust.Shared.ContentPack;
using Robust.Shared.Player;
using Robust.Client.Player;
using Robust.Shared.Utility;
using Content.Client.Language.Systems;
using Content.Client.Administration.Managers;
using Content.Shared.Administration;
using Content.Shared.Ghost;
using System.Linq;
using JetBrains.Annotations;


namespace Content.Client.Corvax.TTS;
Expand All @@ -28,6 +31,7 @@ public sealed class TTSSystem : EntitySystem
[Dependency] private readonly IResourceCache _resourceCache = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly ISharedPlayerManager _playerManager = default!;
[Dependency] private readonly IPlayerManager _player = default!;
[Dependency] private readonly LanguageSystem _language = default!;
[Dependency] private readonly IClientAdminManager _adminMgr = default!;

Expand Down Expand Up @@ -108,14 +112,32 @@ private void OnPlayTTS(PlayTTSEvent ev)
if (ev.SourceUid != null)
{
var sourceUid = GetEntity(ev.SourceUid.Value);
Filter sources = Filter.Pvs(player ?? EntityUid.Invalid);
var sourceExists = false;
foreach (var src in sources.Recipients)
{
if (src.AttachedEntity != null && src.AttachedEntity == sourceUid)
{
sourceExists = true;
break;
}
else
continue;
}
if (!sourceExists) //если в диапазоне Pvs нет источника, то звук не проигрывается
return;

Logger.Warning($"Playing TTS on Entity {sourceUid}");
_audio.PlayEntity(soundPath, new EntityUid(), sourceUid); // recipient arg ignored on client
}
else
{
//_audio.PlayGlobal(soundPath, Filter.Local(), false); // поскольку источника нет/не видно, то пусть молчит
Logger.Warning("Playing TTS Globally");
_audio.PlayGlobal(soundPath, Filter.Local(), false);
}

_contentRoot.RemoveFile(filePath);
Logger.Warning($"TTS File successfully removed!");
}

private float AdjustVolume(bool isWhisper)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile,
}

#if LPP_Sponsors
if (sponsorTier >= 5 && !whitelisted)
if (sponsorTier >= 5 || (whitelisted && job.Requirements != null && job.Requirements.OfType<CharacterWhitelistRequirement>().Any()))
{
reason = null;
return true;
Expand Down Expand Up @@ -232,7 +232,7 @@ public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile,
}

#if LPP_Sponsors
if (sponsorTier >= 5 && !whitelisted)
if (sponsorTier >= 5 || (whitelisted && job.Requirements != null && job.Requirements.OfType<CharacterWhitelistRequirement>().Any()))
{
reason = null;
return true;
Expand Down Expand Up @@ -306,7 +306,7 @@ public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile,
}

#if LPP_Sponsors
if (sponsorTier >= 5 && !whitelisted)
if (sponsorTier >= 5 || (whitelisted && job.Requirements != null && job.Requirements.OfType<CharacterWhitelistRequirement>().Any()))
{
reason = null;
return true;
Expand Down

0 comments on commit 0829e50

Please sign in to comment.