Skip to content

Commit

Permalink
Merge branch 'DeltaV-Station:master' into untimedspawner
Browse files Browse the repository at this point in the history
  • Loading branch information
FluffiestFloof authored Oct 10, 2023
2 parents 7a624ef + f4b379b commit f4f9d98
Show file tree
Hide file tree
Showing 487 changed files with 129,938 additions and 181,178 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));
}
}
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);
}
}
8 changes: 8 additions & 0 deletions Content.Client/Sericulture/SericultureSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using Content.Shared.Sericulture;

namespace Content.Client.Sericulture;

/// <summary>
/// <inheritdoc/>
/// </summary>
public sealed partial class SericultureSystem : SharedSericultureSystem { }
24 changes: 0 additions & 24 deletions Content.Client/UserInterface/Controls/RecordedSplitContainer.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System.Numerics;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Input;

namespace Content.Client.UserInterface.Controls;

Expand All @@ -10,8 +8,6 @@ namespace Content.Client.UserInterface.Controls;
/// </summary>
public sealed class RecordedSplitContainer : SplitContainer
{
public Action<Vector2, Vector2>? OnSplitResizeFinish;

public double? DesiredSplitCenter;

protected override Vector2 ArrangeOverride(Vector2 finalSize)
Expand All @@ -30,24 +26,4 @@ protected override Vector2 ArrangeOverride(Vector2 finalSize)

return base.ArrangeOverride(finalSize);
}

protected override void KeyBindUp(GUIBoundKeyEventArgs args)
{
base.KeyBindUp(args);

if (args.Function != EngineKeyFunctions.UIClick)
{
return;
}

if (ChildCount != 2)
{
return;
}

var first = GetChild(0);
var second = GetChild(1);

OnSplitResizeFinish?.Invoke(first.Size, second.Size);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public SeparatedChatGameScreen()
SetAnchorAndMarginPreset(Hotbar, LayoutPreset.BottomWide, margin: 5);
SetAnchorAndMarginPreset(Alerts, LayoutPreset.CenterRight, margin: 10);

ScreenContainer.OnSplitResizeFinish += (first, second) =>
ScreenContainer.OnSplitResizeFinished += () =>
OnChatResized?.Invoke(new Vector2(ScreenContainer.SplitFraction, 0));
}

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);
}
}
8 changes: 8 additions & 0 deletions Content.IntegrationTests/Pair/TestPair.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
#nullable enable
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Content.Server.GameTicking;
using Content.Server.Players;
using Content.Shared.Mind;
using Content.Shared.Players;
using Robust.Server.Player;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Network;
Expand All @@ -25,6 +30,9 @@ public sealed partial class TestPair
public RobustIntegrationTest.ServerIntegrationInstance Server { get; private set; } = default!;
public RobustIntegrationTest.ClientIntegrationInstance Client { get; private set; } = default!;

public IPlayerSession? Player => (IPlayerSession?) Server.PlayerMan.Sessions.FirstOrDefault();
public PlayerData? PlayerData => Player?.Data.ContentData();

public PoolTestLogHandler ServerLogHandler { get; private set; } = default!;
public PoolTestLogHandler ClientLogHandler { get; private set; } = default!;

Expand Down
71 changes: 71 additions & 0 deletions Content.IntegrationTests/Tests/ConfigPresetTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
using System.Collections.Generic;
using System.IO;
using Content.Server.Entry;
using Robust.Shared.Configuration;
using Robust.Shared.ContentPack;

namespace Content.IntegrationTests.Tests;

[TestFixture]
public sealed class ConfigPresetTests
{
[Test]
public async Task TestLoadAll()
{
var pair = await PoolManager.GetServerClient();
var server = pair.Server;

var resources = server.ResolveDependency<IResourceManager>();
var config = server.ResolveDependency<IConfigurationManager>();

await server.WaitPost(() =>
{
var originalCVars = new List<(string, object)>();
foreach (var cvar in config.GetRegisteredCVars())
{
var value = config.GetCVar<object>(cvar);
originalCVars.Add((cvar, value));
}

var originalCvarsStream = new MemoryStream();
config.SaveToTomlStream(originalCvarsStream, config.GetRegisteredCVars());
originalCvarsStream.Position = 0;

var presets = resources.ContentFindFiles(EntryPoint.ConfigPresetsDir);
Assert.Multiple(() =>
{
foreach (var preset in presets)
{
var stream = resources.ContentFileRead(preset);
Assert.DoesNotThrow(() => config.LoadDefaultsFromTomlStream(stream));
}
});

config.LoadDefaultsFromTomlStream(originalCvarsStream);

foreach (var originalCVar in originalCVars)
{
var (name, originalValue) = originalCVar;
var newValue = config.GetCVar<object>(name);
var originalValueType = originalValue.GetType();
var newValueType = newValue.GetType();
if (originalValueType.IsEnum || newValueType.IsEnum)
{
originalValue = Enum.ToObject(originalValueType, originalValue);
newValue = Enum.ToObject(originalValueType, newValue);
}

if (originalValueType == typeof(float) || newValueType == typeof(float))
{
originalValue = Convert.ToSingle(originalValue);
newValue = Convert.ToSingle(newValue);
}

if (!Equals(newValue, originalValue))
Assert.Fail($"CVar {name} was not reset to its original value.");
}
});

await pair.CleanReturnAsync();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#nullable enable
using Robust.Shared.Console;
using Robust.Shared.Map;

namespace Content.IntegrationTests.Tests.Minds;

[TestFixture]
public sealed partial class MindTests
{
[Test]
public async Task DeleteAllThenGhost()
{
var settings = new PoolSettings
{
Dirty = true,
DummyTicker = false,
Connected = true
};
await using var pair = await PoolManager.GetServerClient(settings);

// Client is connected with a valid entity & mind
Assert.That(pair.Client.EntMan.EntityExists(pair.Client.Player?.ControlledEntity));
Assert.That(pair.Server.EntMan.EntityExists(pair.PlayerData?.Mind));

// Delete **everything**
var conHost = pair.Server.ResolveDependency<IConsoleHost>();
await pair.Server.WaitPost(() => conHost.ExecuteCommand("entities delete"));
await pair.RunTicksSync(5);

Assert.That(pair.Server.EntMan.EntityCount, Is.EqualTo(0));
Assert.That(pair.Client.EntMan.EntityCount, Is.EqualTo(0));

// Create a new map.
int mapId = 1;
await pair.Server.WaitPost(() => conHost.ExecuteCommand($"addmap {mapId}"));
await pair.RunTicksSync(5);

// Client is not attached to anything
Assert.Null(pair.Client.Player?.ControlledEntity);
Assert.Null(pair.PlayerData?.Mind);

// Attempt to ghost
var cConHost = pair.Client.ResolveDependency<IConsoleHost>();
await pair.Client.WaitPost(() => cConHost.ExecuteCommand("ghost"));
await pair.RunTicksSync(10);

// Client should be attached to a ghost placed on the new map.
Assert.That(pair.Client.EntMan.EntityExists(pair.Client.Player?.ControlledEntity));
Assert.That(pair.Server.EntMan.EntityExists(pair.PlayerData?.Mind));
var xform = pair.Client.Transform(pair.Client.Player!.ControlledEntity!.Value);
Assert.That(xform.MapID, Is.EqualTo(new MapId(mapId)));

await pair.CleanReturnAsync();
}
}
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.Zombies;
using Content.Shared.Administration;
Expand All @@ -8,6 +9,8 @@
using Content.Shared.Verbs;
using Robust.Server.GameObjects;
using Robust.Shared.Utility;
using Content.Server.GameTicking.Rules.Components;
using System.Linq;

namespace Content.Server.Administration.Systems;

Expand All @@ -17,7 +20,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 @@ -100,5 +105,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 f4f9d98

Please sign in to comment.