Skip to content

Commit

Permalink
Merge branch 'space-syndicate:master' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
lapatison authored May 6, 2024
2 parents aa04080 + c55f443 commit 695acb4
Show file tree
Hide file tree
Showing 293 changed files with 124,949 additions and 104,939 deletions.
2 changes: 1 addition & 1 deletion Content.Client/Chat/UI/EmotesMenu.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<TextureRect VerticalAlignment="Center" HorizontalAlignment="Center" TextureScale="2 2" TexturePath="/Textures/Clothing/Head/Soft/mimesoft.rsi/icon.png"/>
</ui:RadialMenuTextureButton>
<ui:RadialMenuTextureButton StyleClasses="RadialMenuButton" SetSize="64 64" ToolTip="{Loc 'emote-menu-category-vocal'}" TargetLayer="Vocal" Visible="False">
<TextureRect VerticalAlignment="Center" HorizontalAlignment="Center" TextureScale="2 2" TexturePath="/Textures/Interface/Actions/scream.png"/>
<TextureRect VerticalAlignment="Center" HorizontalAlignment="Center" TextureScale="2 2" TexturePath="/Textures/Interface/Emotes/vocal.png"/>
</ui:RadialMenuTextureButton>
<ui:RadialMenuTextureButton StyleClasses="RadialMenuButton" SetSize="64 64" ToolTip="{Loc 'emote-menu-category-hands'}" TargetLayer="Hands" Visible="False">
<TextureRect VerticalAlignment="Center" HorizontalAlignment="Center" TextureScale="2 2" TexturePath="/Textures/Clothing/Hands/Gloves/latex.rsi/icon.png"/>
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Shuttles/UI/BaseShuttleControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ protected void DrawCircles(DrawingHandleScreen handle)
var textDimensions = handle.GetDimensions(Font, text, UIScale);

handle.DrawCircle(origin, scaledRadius, color, false);
handle.DrawString(Font, ScalePosition(new Vector2(0f, -radius)) - new Vector2(0f, textDimensions.Y), text, color);
handle.DrawString(Font, ScalePosition(new Vector2(0f, -radius)) - new Vector2(0f, textDimensions.Y), text, UIScale, color);
}

const int gridLinesRadial = 8;
Expand Down
5 changes: 1 addition & 4 deletions Content.Client/Station/StationSpawningSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,4 @@

namespace Content.Client.Station;

public sealed class StationSpawningSystem : SharedStationSpawningSystem
{

}
public sealed class StationSpawningSystem : SharedStationSpawningSystem;
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using Content.Client.Cooldown;
using Content.Shared.Alert;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Timing;
Expand Down Expand Up @@ -117,7 +116,9 @@ protected override void FrameUpdate(FrameEventArgs args)
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
_entityManager.QueueDeleteEntity(_spriteViewEntity);

if (!_entityManager.Deleted(_spriteViewEntity))
_entityManager.QueueDeleteEntity(_spriteViewEntity);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
using static Robust.UnitTesting.RobustIntegrationTest;

namespace Content.IntegrationTests.Tests.Interaction;

Expand Down Expand Up @@ -54,7 +55,7 @@ public static implicit operator EntitySpecifier((string, int) tuple)
/// <summary>
/// Convert applicable entity prototypes into stack prototypes.
/// </summary>
public void ConvertToStack(IPrototypeManager protoMan, IComponentFactory factory)
public async Task ConvertToStack(IPrototypeManager protoMan, IComponentFactory factory, ServerIntegrationInstance server)
{
if (Converted)
return;
Expand All @@ -73,11 +74,14 @@ public void ConvertToStack(IPrototypeManager protoMan, IComponentFactory factory
return;
}

if (entProto.TryGetComponent<StackComponent>(factory.GetComponentName(typeof(StackComponent)),
out var stackComp))
StackComponent? stack = null;
await server.WaitPost(() =>
{
Prototype = stackComp.StackTypeId;
}
entProto.TryGetComponent(factory.GetComponentName(typeof(StackComponent)), out stack);
});

if (stack != null)
Prototype = stack.StackTypeId;
}
}

Expand All @@ -100,11 +104,14 @@ await Server.WaitPost(() =>
return default;
}

if (entProto.TryGetComponent<StackComponent>(Factory.GetComponentName(typeof(StackComponent)),
out var stackComp))
StackComponent? stack = null;
await Server.WaitPost(() =>
{
return await SpawnEntity((stackComp.StackTypeId, spec.Quantity), coords);
}
entProto.TryGetComponent(Factory.GetComponentName(typeof(StackComponent)), out stack);
});

if (stack != null)
return await SpawnEntity((stack.StackTypeId, spec.Quantity), coords);

Assert.That(spec.Quantity, Is.EqualTo(1), "SpawnEntity only supports returning a singular entity");
await Server.WaitPost(() => uid = SEntMan.SpawnEntity(spec.Prototype, coords));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Robust.Shared.GameObjects;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
using static Robust.UnitTesting.RobustIntegrationTest;

namespace Content.IntegrationTests.Tests.Interaction;

Expand Down Expand Up @@ -111,7 +112,7 @@ public EntitySpecifierCollection Clone()
/// <summary>
/// Convert applicable entity prototypes into stack prototypes.
/// </summary>
public void ConvertToStacks(IPrototypeManager protoMan, IComponentFactory factory)
public async Task ConvertToStacks(IPrototypeManager protoMan, IComponentFactory factory, ServerIntegrationInstance server)
{
if (Converted)
return;
Expand All @@ -130,14 +131,17 @@ public void ConvertToStacks(IPrototypeManager protoMan, IComponentFactory factor
continue;
}

if (!entProto.TryGetComponent<StackComponent>(factory.GetComponentName(typeof(StackComponent)),
out var stackComp))
StackComponent? stack = null;
await server.WaitPost(() =>
{
entProto.TryGetComponent(factory.GetComponentName(typeof(StackComponent)), out stack);
});

if (stack == null)
continue;
}

toRemove.Add(id);
toAdd.Add((stackComp.StackTypeId, quantity));
toAdd.Add((stack.StackTypeId, quantity));
}

foreach (var id in toRemove)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@
using System.Numerics;
using System.Reflection;
using Content.Client.Construction;
using Content.Server.Atmos;
using Content.Server.Atmos.Components;
using Content.Server.Atmos.EntitySystems;
using Content.Server.Construction.Components;
using Content.Server.Gravity;
using Content.Server.Item;
using Content.Server.Power.Components;
using Content.Shared.Atmos;
using Content.Shared.Construction.Prototypes;
Expand Down Expand Up @@ -634,7 +631,7 @@ protected async Task AssertEntityLookup(
var entities = await DoEntityLookup(flags);
var found = ToEntityCollection(entities);
expected.Remove(found);
expected.ConvertToStacks(ProtoMan, Factory);
await expected.ConvertToStacks(ProtoMan, Factory, Server);

if (expected.Entities.Count == 0)
return;
Expand Down Expand Up @@ -670,7 +667,7 @@ protected async Task<EntityUid> FindEntity(
LookupFlags flags = LookupFlags.Uncontained | LookupFlags.Contained,
bool shouldSucceed = true)
{
spec.ConvertToStack(ProtoMan, Factory);
await spec.ConvertToStack(ProtoMan, Factory, Server);

var entities = await DoEntityLookup(flags);
foreach (var uid in entities)
Expand Down
55 changes: 35 additions & 20 deletions Content.IntegrationTests/Tests/StorageTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,23 +92,32 @@ public async Task TestSufficientSpaceForFill()
var allSizes = protoMan.EnumeratePrototypes<ItemSizePrototype>().ToList();
allSizes.Sort();

Assert.Multiple(() =>
await Assert.MultipleAsync(async () =>
{
foreach (var proto in pair.GetPrototypesWithComponent<StorageFillComponent>())
{
if (proto.HasComponent<EntityStorageComponent>(compFact))
continue;

if (!proto.TryGetComponent<StorageComponent>("Storage", out var storage))
StorageComponent? storage = null;
ItemComponent? item = null;
StorageFillComponent fill = default!;
var size = 0;
await server.WaitAssertion(() =>
{
Assert.Fail($"Entity {proto.ID} has storage-fill without a storage component!");
continue;
}
if (!proto.TryGetComponent("Storage", out storage))
{
Assert.Fail($"Entity {proto.ID} has storage-fill without a storage component!");
return;
}

proto.TryGetComponent<ItemComponent>("Item", out var item);
proto.TryGetComponent("Item", out item);
fill = (StorageFillComponent) proto.Components[id].Component;
size = GetFillSize(fill, false, protoMan, itemSys);
});

var fill = (StorageFillComponent) proto.Components[id].Component;
var size = GetFillSize(fill, false, protoMan, itemSys);
if (storage == null)
continue;

var maxSize = storage.MaxItemSize;
if (storage.MaxItemSize == null)
Expand Down Expand Up @@ -138,7 +147,13 @@ public async Task TestSufficientSpaceForFill()
if (!protoMan.TryIndex<EntityPrototype>(entry.PrototypeId, out var fillItem))
continue;

if (!fillItem.TryGetComponent<ItemComponent>("Item", out var entryItem))
ItemComponent? entryItem = null;
await server.WaitPost(() =>
{
fillItem.TryGetComponent("Item", out entryItem);
});

if (entryItem == null)
continue;

Assert.That(protoMan.Index(entryItem.Size).Weight,
Expand All @@ -164,25 +179,25 @@ public async Task TestSufficientSpaceForEntityStorageFill()

var itemSys = entMan.System<SharedItemSystem>();

Assert.Multiple(() =>
foreach (var proto in pair.GetPrototypesWithComponent<StorageFillComponent>())
{
foreach (var proto in pair.GetPrototypesWithComponent<StorageFillComponent>())
{
if (proto.HasComponent<StorageComponent>(compFact))
continue;
if (proto.HasComponent<StorageComponent>(compFact))
continue;

if (!proto.TryGetComponent<EntityStorageComponent>("EntityStorage", out var entStorage))
{
await server.WaitAssertion(() =>
{
if (!proto.TryGetComponent("EntityStorage", out EntityStorageComponent? entStorage))
Assert.Fail($"Entity {proto.ID} has storage-fill without a storage component!");
continue;
}

if (entStorage == null)
return;

var fill = (StorageFillComponent) proto.Components[id].Component;
var size = GetFillSize(fill, true, protoMan, itemSys);
Assert.That(size, Is.LessThanOrEqualTo(entStorage.Capacity),
$"{proto.ID} storage fill is too large.");
}
});
});
}
await pair.CleanReturnAsync();
}

Expand Down
27 changes: 10 additions & 17 deletions Content.IntegrationTests/Tests/Utility/EntityWhitelistTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ public async Task Test()
var testMap = await pair.CreateTestMap();
var mapCoordinates = testMap.MapCoords;

var sEntities = server.ResolveDependency<IEntityManager>();
var sEntities = server.EntMan;
var sys = server.System<EntityWhitelistSystem>();

await server.WaitAssertion(() =>
{
Expand All @@ -80,22 +81,14 @@ await server.WaitAssertion(() =>
Components = new[] { $"{ValidComponent}" },
Tags = new() { "WhitelistTestValidTag" }
};
whitelistInst.UpdateRegistrations();
Assert.That(whitelistInst, Is.Not.Null);

Assert.Multiple(() =>
{
Assert.That(whitelistInst.Components, Is.Not.Null);
Assert.That(whitelistInst.Tags, Is.Not.Null);
});

Assert.Multiple(() =>
{
Assert.That(whitelistInst.IsValid(validComponent), Is.True);
Assert.That(whitelistInst.IsValid(WhitelistTestValidTag), Is.True);
Assert.That(sys.IsValid(whitelistInst, validComponent), Is.True);
Assert.That(sys.IsValid(whitelistInst, WhitelistTestValidTag), Is.True);

Assert.That(whitelistInst.IsValid(invalidComponent), Is.False);
Assert.That(whitelistInst.IsValid(WhitelistTestInvalidTag), Is.False);
Assert.That(sys.IsValid(whitelistInst, invalidComponent), Is.False);
Assert.That(sys.IsValid(whitelistInst, WhitelistTestInvalidTag), Is.False);
});

// Test from serialized
Expand All @@ -111,11 +104,11 @@ await server.WaitAssertion(() =>

Assert.Multiple(() =>
{
Assert.That(whitelistSer.IsValid(validComponent), Is.True);
Assert.That(whitelistSer.IsValid(WhitelistTestValidTag), Is.True);
Assert.That(sys.IsValid(whitelistSer, validComponent), Is.True);
Assert.That(sys.IsValid(whitelistSer, WhitelistTestValidTag), Is.True);

Assert.That(whitelistSer.IsValid(invalidComponent), Is.False);
Assert.That(whitelistSer.IsValid(WhitelistTestInvalidTag), Is.False);
Assert.That(sys.IsValid(whitelistSer, invalidComponent), Is.False);
Assert.That(sys.IsValid(whitelistSer, WhitelistTestInvalidTag), Is.False);
});
});
await pair.CleanReturnAsync();
Expand Down
4 changes: 2 additions & 2 deletions Content.Server/Access/Systems/PresetIdCardSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ private void PlayerJobsAssigned(RulePlayerJobsAssignedEvent ev)
var station = _stationSystem.GetOwningStation(uid);

// If we're not on an extended access station, the ID is already configured correctly from MapInit.
if (station == null || !Comp<StationJobsComponent>(station.Value).ExtendedAccess)
return;
if (station == null || !TryComp<StationJobsComponent>(station.Value, out var jobsComp) || !jobsComp.ExtendedAccess)
continue;

SetupIdAccess(uid, card, true);
SetupIdName(uid, card);
Expand Down
10 changes: 10 additions & 0 deletions Content.Server/AlertLevel/AlertLevelSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,16 @@ private void OnPrototypeReload(PrototypesReloadedEventArgs args)
RaiseLocalEvent(new AlertLevelPrototypeReloadedEvent());
}

public string GetLevel(EntityUid station, AlertLevelComponent? alert = null)
{
if (!Resolve(station, ref alert))
{
return string.Empty;
}

return alert.CurrentLevel;
}

public float GetAlertLevelDelay(EntityUid station, AlertLevelComponent? alert = null)
{
if (!Resolve(station, ref alert))
Expand Down
9 changes: 6 additions & 3 deletions Content.Server/Antag/AntagSelectionSystem.API.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Content.Shared.Mind;
using JetBrains.Annotations;
using Robust.Shared.Audio;
using Robust.Shared.Enums;
using Robust.Shared.Player;

namespace Content.Server.Antag;
Expand Down Expand Up @@ -63,15 +64,17 @@ public int GetTargetAntagCount(Entity<AntagSelectionComponent> ent, AntagSelecti
/// </summary>
public int GetTargetAntagCount(Entity<AntagSelectionComponent> ent, AntagSelectionPlayerPool? pool, AntagSelectionDefinition def)
{
var poolSize = pool?.Count ?? _playerManager.Sessions.Length;
var poolSize = pool?.Count ?? _playerManager.Sessions
.Count(s => s.State.Status is not SessionStatus.Disconnected and not SessionStatus.Zombie);

// factor in other definitions' affect on the count.
var countOffset = 0;
foreach (var otherDef in ent.Comp.Definitions)
{
countOffset += Math.Clamp(poolSize / otherDef.PlayerRatio, otherDef.Min, otherDef.Max) * otherDef.PlayerRatio;
countOffset += Math.Clamp((poolSize - countOffset) / otherDef.PlayerRatio, otherDef.Min, otherDef.Max) * otherDef.PlayerRatio;
}
// make sure we don't double-count the current selection
countOffset -= Math.Clamp((poolSize + countOffset) / def.PlayerRatio, def.Min, def.Max) * def.PlayerRatio;
countOffset -= Math.Clamp(poolSize / def.PlayerRatio, def.Min, def.Max) * def.PlayerRatio;

return Math.Clamp((poolSize - countOffset) / def.PlayerRatio, def.Min, def.Max);
}
Expand Down
Loading

0 comments on commit 695acb4

Please sign in to comment.