-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
261 changed files
with
10,376 additions
and
21,867 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
Content.IntegrationTests/Tests/Minds/MindTest.DeleteAllThenGhost.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
Content.Server/Anomaly/Components/InjectionAnomalyComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using Content.Server.Anomaly.Effects; | ||
using Robust.Shared.Prototypes; | ||
|
||
namespace Content.Server.Anomaly.Components; | ||
|
||
/// <summary> | ||
/// This component allows the anomaly to inject liquid from the SolutionContainer | ||
/// into the surrounding entities with the InjectionSolution component | ||
/// </summary> | ||
|
||
[RegisterComponent, Access(typeof(InjectionAnomalySystem))] | ||
public sealed partial class InjectionAnomalyComponent : Component | ||
{ | ||
/// <summary> | ||
/// the maximum amount of injection of a substance into an entity per pulsation | ||
/// scales with Severity | ||
/// </summary> | ||
[DataField, ViewVariables(VVAccess.ReadWrite)] | ||
public float MaxSolutionInjection = 15; | ||
/// <summary> | ||
/// the maximum amount of injection of a substance into an entity in the supercritical phase | ||
/// </summary> | ||
[DataField, ViewVariables(VVAccess.ReadWrite)] | ||
public float SuperCriticalSolutionInjection = 50; | ||
|
||
/// <summary> | ||
/// The maximum radius in which the anomaly injects reagents into the surrounding containers. | ||
/// </summary> | ||
[DataField, ViewVariables(VVAccess.ReadWrite)] | ||
public float InjectRadius = 3; | ||
/// <summary> | ||
/// The maximum radius in which the anomaly injects reagents into the surrounding containers. | ||
/// </summary> | ||
[DataField, ViewVariables(VVAccess.ReadWrite)] | ||
public float SuperCriticalInjectRadius = 15; | ||
|
||
/// <summary> | ||
/// The name of the prototype of the special effect that appears above the entities into which the injection was carried out | ||
/// </summary> | ||
[DataField, ViewVariables(VVAccess.ReadOnly)] | ||
public EntProtoId VisualEffectPrototype = "PuddleSparkle"; | ||
/// <summary> | ||
/// Solution name that can be drained. | ||
/// </summary> | ||
[DataField, ViewVariables(VVAccess.ReadWrite)] | ||
public string Solution { get; set; } = "default"; | ||
} |
29 changes: 29 additions & 0 deletions
29
Content.Server/Anomaly/Components/PuddleCreateAnomalyComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using Content.Server.Anomaly.Effects; | ||
|
||
namespace Content.Server.Anomaly.Components; | ||
|
||
/// <summary> | ||
/// This component allows the anomaly to create puddles from the solutionContainer | ||
/// </summary> | ||
[RegisterComponent, Access(typeof(PuddleCreateAnomalySystem))] | ||
public sealed partial class PuddleCreateAnomalyComponent : Component | ||
{ | ||
/// <summary> | ||
/// The maximum amount of solution that an anomaly can splash out of the storage on the floor during pulsation. | ||
/// Scales with Severity. | ||
/// </summary> | ||
[DataField, ViewVariables(VVAccess.ReadWrite)] | ||
public float MaxPuddleSize = 100; | ||
|
||
/// <summary> | ||
/// The maximum amount of solution that an anomaly can splash out of the storage on the floor during supercritical event | ||
/// </summary> | ||
[DataField, ViewVariables(VVAccess.ReadWrite)] | ||
public float SuperCriticalPuddleSize = 1000; | ||
|
||
/// <summary> | ||
/// Solution name that can be drained. | ||
/// </summary> | ||
[DataField, ViewVariables(VVAccess.ReadWrite)] | ||
public string Solution { get; set; } = "default"; | ||
} |
Oops, something went wrong.