Skip to content

Commit

Permalink
Merge pull request #259 from Rxup/upstream-sync
Browse files Browse the repository at this point in the history
Upstream sync
  • Loading branch information
Rxup authored Oct 5, 2023
2 parents ed6415a + 5dcda7b commit 9f9147f
Show file tree
Hide file tree
Showing 237 changed files with 47,071 additions and 66,376 deletions.
32 changes: 32 additions & 0 deletions Content.Client/Antag/AntagStatusIconSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using Content.Shared.StatusIcon;
using Content.Shared.StatusIcon.Components;
using Robust.Shared.Prototypes;
using Content.Shared.Ghost;
using Robust.Client.Player;

namespace Content.Client.Antag;

/// <summary>
/// Used for assigning specified icons for antags.
/// </summary>
public abstract class AntagStatusIconSystem<T> : SharedStatusIconSystem
where T : Component
{
[Dependency] private readonly IPrototypeManager _prototype = default!;
[Dependency] private readonly IPlayerManager _player = default!;

/// <summary>
/// Will check if the local player has the same component as the one who called it and give the status icon.
/// </summary>
/// <param name="antagStatusIcon">The status icon that your antag uses</param>
/// <param name="args">The GetStatusIcon event.</param>
protected virtual void GetStatusIcon(string antagStatusIcon, ref GetStatusIconsEvent args)
{
var ent = _player.LocalPlayer?.ControlledEntity;

if (!HasComp<T>(ent) && !HasComp<GhostComponent>(ent))
return;

args.StatusIcons.Add(_prototype.Index<StatusIconPrototype>(antagStatusIcon));
}
}
8 changes: 5 additions & 3 deletions Content.Client/Corvax/TTS/TTSSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,14 @@ public sealed class TTSSystem : EntitySystem
[Dependency] private readonly IConfigurationManager _cfg = default!;
[Dependency] private readonly IResourceCache _resourceCache = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly IClydeAudio _clyde = default!;

private ISawmill _sawmill = default!;
private readonly MemoryContentRoot _contentRoot = new();
private static readonly ResPath Prefix = ResPath.Root / "TTS";

private float _volume = 0.0f;
private int _fileIdx = 0;
private ulong _fileIdx = 0;

public override void Initialize()
{
Expand All @@ -43,12 +44,12 @@ public override void Initialize()
_cfg.OnValueChanged(CCCVars.TTSVolume, OnTtsVolumeChanged, true);
SubscribeNetworkEvent<PlayTTSEvent>(OnPlayTTS);
SubscribeLocalEvent<RoundRestartCleanupEvent>(OnRoundRestart);

}

private void OnRoundRestart(RoundRestartCleanupEvent ev)
{
_contentRoot.Clear();
_fileIdx = 0;
}

public override void Shutdown()
Expand Down Expand Up @@ -84,7 +85,8 @@ private void OnPlayTTS(PlayTTSEvent ev)
if (ev.SourceUid != null)
{
var sourceUid = GetEntity(ev.SourceUid.Value);
_audio.PlayEntity(soundPath, EntityUid.Invalid, sourceUid); // recipient arg ignored on client
if(sourceUid.Valid)
_audio.PlayEntity(soundPath, EntityUid.Invalid, sourceUid); // recipient arg ignored on client
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Popups/PopupSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public override void PopupEntity(string message, EntityUid uid, Filter filter, b
public override void PopupClient(string message, EntityUid uid, EntityUid recipient, PopupType type = PopupType.Small)
{
if (_timing.IsFirstTimePredicted)
PopupEntity(message, uid, recipient);
PopupEntity(message, uid, recipient, type);
}

public override void PopupEntity(string message, EntityUid uid, PopupType type = PopupType.Small)
Expand Down
35 changes: 35 additions & 0 deletions Content.Client/Revolutionary/RevolutionarySystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using Content.Shared.Revolutionary.Components;
using Content.Client.Antag;
using Content.Shared.StatusIcon.Components;

namespace Content.Client.Revolutionary;

/// <summary>
/// Used for the client to get status icons from other revs.
/// </summary>
public sealed class RevolutionarySystem : AntagStatusIconSystem<RevolutionaryComponent>
{
public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<RevolutionaryComponent, GetStatusIconsEvent>(GetRevIcon);
SubscribeLocalEvent<HeadRevolutionaryComponent, GetStatusIconsEvent>(GetHeadRevIcon);
}

/// <summary>
/// Checks if the person who triggers the GetStatusIcon event is also a Rev or a HeadRev.
/// </summary>
private void GetRevIcon(EntityUid uid, RevolutionaryComponent comp, ref GetStatusIconsEvent args)
{
if (!HasComp<HeadRevolutionaryComponent>(uid))
{
GetStatusIcon(comp.RevStatusIcon, ref args);
}
}

private void GetHeadRevIcon(EntityUid uid, HeadRevolutionaryComponent comp, ref GetStatusIconsEvent args)
{
GetStatusIcon(comp.HeadRevStatusIcon, ref args);
}
}
14 changes: 10 additions & 4 deletions Content.Client/SS220/AnnounceTTS/AnnounceTTSSystem.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
using System.Diagnostics.CodeAnalysis;
using System.IO;
using Content.Shared.Corvax.CCCVars;
using Content.Shared.SS220.AnnounceTTS;
using Content.Shared.GameTicking;
using Content.Shared.SS220.AnnounceTTS;
using Robust.Client.Graphics;
using Robust.Client.ResourceManagement;
using Robust.Shared.Configuration;
using Robust.Shared.Utility;
using Robust.Shared.Audio;
using Robust.Shared.Configuration;
using Robust.Shared.ContentPack;
using Robust.Shared.Utility;

namespace Content.Client.SS220.AnnounceTTS;


// ReSharper disable once InconsistentNaming
public sealed class AnnounceTTSSystem : EntitySystem
{
Expand Down Expand Up @@ -50,6 +54,7 @@ public override void Shutdown()
private void OnAnnounceTTSPlay(AnnounceTTSEvent ev)
{
var volume = _volume;

if (!_resourceCache.TryGetResource<AudioResource>(new ResPath(ev.AnnouncementSound), out var audio))
{
_sawmill.Error($"Server tried to play audio file {ev.AnnouncementSound} which does not exist.");
Expand All @@ -75,13 +80,14 @@ private void ProcessEntityQueue()

private bool TryCreateAudioSource(byte[] data, float volume, [NotNullWhen(true)] out IClydeAudioSource? source)
{
var dataStream = new MemoryStream(data) { Position = 0 };
using var dataStream = new MemoryStream(data);
var audioStream = _clyde.LoadAudioOggVorbis(dataStream);
source = _clyde.CreateAudioSource(audioStream);
source?.SetMaxDistance(float.MaxValue);
source?.SetReferenceDistance(1f);
source?.SetRolloffFactor(1f);
source?.SetVolume(volume);

return source != null;
}

Expand Down
15 changes: 4 additions & 11 deletions Content.Client/Zombies/ZombieSystem.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
using System.Linq;
using System.Linq;
using Content.Client.Antag;
using Content.Shared.Humanoid;
using Content.Shared.StatusIcon;
using Content.Shared.StatusIcon.Components;
using Content.Shared.Zombies;
using Robust.Client.GameObjects;
using Robust.Client.Player;
using Robust.Shared.Prototypes;

namespace Content.Client.Zombies;

public sealed class ZombieSystem : SharedZombieSystem
public sealed class ZombieSystem : AntagStatusIconSystem<ZombieComponent>
{
[Dependency] private readonly IPlayerManager _player = default!;
[Dependency] private readonly IPrototypeManager _prototype = default!;

public override void Initialize()
{
Expand All @@ -38,9 +34,6 @@ private void OnStartup(EntityUid uid, ZombieComponent component, ComponentStartu

private void OnGetStatusIcon(EntityUid uid, ZombieComponent component, ref GetStatusIconsEvent args)
{
if (!HasComp<ZombieComponent>(_player.LocalPlayer?.ControlledEntity))
return;

args.StatusIcons.Add(_prototype.Index<StatusIconPrototype>(component.ZombieStatusIcon));
GetStatusIcon(component.ZombieStatusIcon, ref args);
}
}
3 changes: 2 additions & 1 deletion Content.IntegrationTests/Tests/PostMapInitTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ public sealed class PostMapInitTest
"Kettle",
"MeteorArena",
//backmen
"ShwrAdventurer"
"ShwrAdventurer",
"ShwrBig"
};

/// <summary>
Expand Down
22 changes: 22 additions & 0 deletions Content.Server/Administration/Systems/AdminVerbSystem.Antags.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Content.Server.GameTicking;
using Content.Server.GameTicking.Rules;
using Content.Server.GenericAntag;
using Content.Server.Ninja.Systems;
Expand All @@ -11,6 +12,8 @@
using Robust.Server.GameObjects;
using Robust.Server.Player;
using Robust.Shared.Utility;
using Content.Server.GameTicking.Rules.Components;
using System.Linq;

namespace Content.Server.Administration.Systems;

Expand All @@ -20,7 +23,9 @@ public sealed partial class AdminVerbSystem
[Dependency] private readonly TraitorRuleSystem _traitorRule = default!;
[Dependency] private readonly NukeopsRuleSystem _nukeopsRule = default!;
[Dependency] private readonly PiratesRuleSystem _piratesRule = default!;
[Dependency] private readonly RevolutionaryRuleSystem _revolutionaryRule = default!;
[Dependency] private readonly SharedMindSystem _minds = default!;
[Dependency] private readonly GameTicker _gameTicker = default!;

// All antag verbs have names so invokeverb works.
private void AddAntagVerbs(GetVerbsEvent<Verb> args)
Expand Down Expand Up @@ -173,5 +178,22 @@ private void AddAntagVerbs(GetVerbsEvent<Verb> args)
Message = Loc.GetString("admin-verb-make-pirate"),
};
args.Verbs.Add(pirate);

//todo come here at some point dear lort.
Verb headRev = new()
{
Text = Loc.GetString("admin-verb-text-make-head-rev"),
Category = VerbCategory.Antag,
Icon = new SpriteSpecifier.Texture(new("/Textures/Interface/Misc/job_icons.rsi/HeadRevolutionary.png")),
Act = () =>
{
if (!_minds.TryGetMind(args.Target, out var mindId, out var mind))
return;
_revolutionaryRule.OnHeadRevAdmin(mindId, mind);
},
Impact = LogImpact.High,
Message = Loc.GetString("admin-verb-make-head-rev"),
};
args.Verbs.Add(headRev);
}
}
Loading

0 comments on commit 9f9147f

Please sign in to comment.