Skip to content

Commit

Permalink
Merge pull request #302 from Rxup/upstream-sync
Browse files Browse the repository at this point in the history
Upstream sync
  • Loading branch information
Rxup authored Nov 9, 2023
2 parents 7cf0ca4 + 823e51f commit 163a9c5
Show file tree
Hide file tree
Showing 624 changed files with 177,083 additions and 179,782 deletions.
15 changes: 11 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,17 @@ jobs:
cd RobustToolbox
git fetch --depth=1
- name: Package all
run: |
Tools/package_server_build.py -p win-x64 linux-x64
Tools/package_client_build.py
- name: Install dependencies
run: dotnet restore

- name: Build Packaging
run: dotnet build Content.Packaging --configuration Release --no-restore /m

- name: Package server
run: dotnet run --project Content.Packaging server --platform win-x64 --platform linux-x64 --platform osx-x64 --platform linux-arm64

- name: Package client
run: dotnet run --project Content.Packaging client --no-wipe-release

- name: Update Build Info
run: Tools/gen_build_info.py
Expand Down
12 changes: 8 additions & 4 deletions .github/workflows/test-packaging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,15 @@ jobs:
- name: Install dependencies
run: dotnet restore

- name: Package client
run: |
Tools/package_server_build.py -p win-x64 linux-x64 osx-x64 linux-arm64
Tools/package_client_build.py
- name: Build Packaging
run: dotnet build Content.Packaging --configuration Release --no-restore /m

- name: Package server
run: dotnet run --project Content.Packaging server --platform win-x64 --platform linux-x64 --platform osx-x64 --platform linux-arm64

- name: Package client
run: dotnet run --project Content.Packaging client --no-wipe-release

- name: Update Build Info
run: Tools/gen_build_info.py

Expand Down
8 changes: 8 additions & 0 deletions Content.Client/Construction/UI/ConstructionMenuPresenter.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System.Linq;
using Content.Client.UserInterface.Systems.MenuBar.Widgets;
using Content.Shared.Construction.Prototypes;
using Content.Shared.Tag;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.Placement;
using Robust.Client.Player;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.Utility;
Expand All @@ -25,6 +27,7 @@ internal sealed class ConstructionMenuPresenter : IDisposable
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IPlacementManager _placementManager = default!;
[Dependency] private readonly IUserInterfaceManager _uiManager = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;

private readonly IConstructionMenuView _constructionView;

Expand Down Expand Up @@ -152,6 +155,11 @@ private void OnViewPopulateRecipes(object? sender, (string search, string catago
if (recipe.Hide)
continue;

if (_playerManager.LocalSession == null
|| _playerManager.LocalEntity == null
|| (recipe.EntityWhitelist != null && !recipe.EntityWhitelist.IsValid(_playerManager.LocalEntity.Value)))
continue;

if (!string.IsNullOrEmpty(search))
{
if (!recipe.Name.ToLowerInvariant().Contains(search.Trim().ToLowerInvariant()))
Expand Down
43 changes: 43 additions & 0 deletions Content.Client/Overlays/ShowSyndicateIconsSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using Content.Shared.Overlays;
using Content.Shared.StatusIcon.Components;
using Content.Shared.NukeOps;
using Content.Shared.StatusIcon;
using Robust.Shared.Prototypes;

namespace Content.Client.Overlays;
public sealed class ShowSyndicateIconsSystem : EquipmentHudSystem<ShowSyndicateIconsComponent>
{
[Dependency] private readonly IPrototypeManager _prototype = default!;

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<NukeOperativeComponent, GetStatusIconsEvent>(OnGetStatusIconsEvent);
}

private void OnGetStatusIconsEvent(EntityUid uid, NukeOperativeComponent nukeOperativeComponent, ref GetStatusIconsEvent args)
{
if (!IsActive || args.InContainer)
{
return;
}

var healthIcons = SyndicateIcon(uid, nukeOperativeComponent);

args.StatusIcons.AddRange(healthIcons);
}

private IReadOnlyList<StatusIconPrototype> SyndicateIcon(EntityUid uid, NukeOperativeComponent nukeOperativeComponent)
{
var result = new List<StatusIconPrototype>();

if (_prototype.TryIndex<StatusIconPrototype>(nukeOperativeComponent.SyndStatusIcon, out var syndicateicon))
{
result.Add(syndicateicon);
}

return result;
}
}

24 changes: 24 additions & 0 deletions Content.Client/PowerCell/PowerCellSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Content.Shared.PowerCell;
using Content.Shared.PowerCell.Components;
using JetBrains.Annotations;
using Robust.Client.GameObjects;

Expand All @@ -15,6 +16,29 @@ public override void Initialize()
SubscribeLocalEvent<PowerCellVisualsComponent, AppearanceChangeEvent>(OnPowerCellVisualsChange);
}

/// <inheritdoc/>
public override bool HasActivatableCharge(EntityUid uid, PowerCellDrawComponent? battery = null, PowerCellSlotComponent? cell = null,
EntityUid? user = null)
{
if (!Resolve(uid, ref battery, ref cell, false))
return true;

return battery.CanUse;
}

/// <inheritdoc/>
public override bool HasDrawCharge(
EntityUid uid,
PowerCellDrawComponent? battery = null,
PowerCellSlotComponent? cell = null,
EntityUid? user = null)
{
if (!Resolve(uid, ref battery, ref cell, false))
return true;

return battery.CanDraw;
}

private void OnPowerCellVisualsChange(EntityUid uid, PowerCellVisualsComponent component, ref AppearanceChangeEvent args)
{
if (args.Sprite == null)
Expand Down
6 changes: 4 additions & 2 deletions Content.Client/Roles/RoleSystem.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
namespace Content.Client.Roles;
using Content.Shared.Roles;

public sealed class RoleSystem : EntitySystem
namespace Content.Client.Roles;

public sealed class RoleSystem : SharedRoleSystem
{
}
11 changes: 7 additions & 4 deletions Content.Client/Storage/UI/StorageWindow.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Numerics;
using Content.Client.Items.Systems;
using Content.Client.Message;
using Robust.Client.Graphics;
using Robust.Client.UserInterface.Controls;
Expand All @@ -23,6 +24,7 @@ public sealed class StorageWindow : FancyWindow
private readonly IEntityManager _entityManager;

private readonly SharedStorageSystem _storage;
private readonly ItemSystem _item;

private readonly RichTextLabel _information;
public readonly ContainerButton StorageContainerButton;
Expand All @@ -34,6 +36,7 @@ public StorageWindow(IEntityManager entityManager)
{
_entityManager = entityManager;
_storage = _entityManager.System<SharedStorageSystem>();
_item = _entityManager.System<ItemSystem>();
SetSize = new Vector2(240, 320);
Title = Loc.GetString("comp-storage-window-title");
RectClipContent = true;
Expand Down Expand Up @@ -69,7 +72,7 @@ public StorageWindow(IEntityManager entityManager)
_information.SetMessage(Loc.GetString("comp-storage-window-weight",
("weight", 0),
("maxWeight", 0),
("size", SharedItemSystem.GetItemSizeLocale(ItemSize.Normal))));
("size", _item.GetItemSizeLocale(SharedStorageSystem.DefaultStorageMaxItemSize))));

vBox.AddChild(_information);

Expand Down Expand Up @@ -117,14 +120,14 @@ private void SetStorageInformation(Entity<StorageComponent> uid)
_information.SetMarkup(Loc.GetString("comp-storage-window-weight",
("weight", _storage.GetCumulativeItemSizes(uid, uid.Comp)),
("maxWeight", uid.Comp.MaxTotalWeight),
("size", SharedItemSystem.GetItemSizeLocale(_storage.GetMaxItemSize((uid, uid.Comp))))));
("size", _item.GetItemSizeLocale(_storage.GetMaxItemSize((uid, uid.Comp))))));
}
else
{
_information.SetMarkup(Loc.GetString("comp-storage-window-slots",
("itemCount", uid.Comp.Container.ContainedEntities.Count),
("maxCount", uid.Comp.MaxSlots),
("size", SharedItemSystem.GetItemSizeLocale(_storage.GetMaxItemSize((uid, uid.Comp))))));
("size", _item.GetItemSizeLocale(_storage.GetMaxItemSize((uid, uid.Comp))))));
}
}

Expand Down Expand Up @@ -167,7 +170,7 @@ public void GenerateButton(ListData data, ListContainerButton button)
{
Align = Label.AlignMode.Right,
Text = item?.Size != null
? $"{SharedItemSystem.GetItemSizeWeight(item.Size)}"
? $"{_item.GetItemSizeWeight(item.Size)}"
: Loc.GetString("comp-storage-no-item-size")
}
}
Expand Down
5 changes: 3 additions & 2 deletions Content.Client/VendingMachines/UI/VendingMachineMenu.xaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<DefaultWindow xmlns="https://spacestation14.io">
<DefaultWindow xmlns="https://spacestation14.io">
<BoxContainer Orientation="Vertical">
<LineEdit Name="SearchBar" PlaceHolder="{Loc 'vending-machine-component-search-filter'}" HorizontalExpand="True" Margin ="0 4" Access="Public"/>
<ItemList Name="VendingContents"
SizeFlagsStretchRatio="8"
VerticalExpand="True">
VerticalExpand="True"
SelectMode="Button">
</ItemList>
</BoxContainer>
</DefaultWindow>
58 changes: 44 additions & 14 deletions Content.IntegrationTests/Tests/StorageTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ public async Task StorageSizeArbitrageTest()
var server = pair.Server;

var protoManager = server.ResolveDependency<IPrototypeManager>();
var entMan = server.ResolveDependency<IEntityManager>();

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

await server.WaitAssertion(() =>
{
Expand All @@ -37,7 +40,9 @@ await server.WaitAssertion(() =>
!proto.TryGetComponent<ItemComponent>("Item", out var item))
continue;

Assert.That(storage.MaxItemSize.Value, Is.LessThanOrEqualTo(item.Size), $"Found storage arbitrage on {proto.ID}");
Assert.That(itemSys.GetSizePrototype(storage.MaxItemSize.Value).Weight,
Is.LessThanOrEqualTo(itemSys.GetSizePrototype(item.Size).Weight),
$"Found storage arbitrage on {proto.ID}");
}
});
await pair.CleanReturnAsync();
Expand Down Expand Up @@ -77,10 +82,16 @@ public async Task TestSufficientSpaceForFill()
await using var pair = await PoolManager.GetServerClient();
var server = pair.Server;

var entMan = server.ResolveDependency<IEntityManager>();
var protoMan = server.ResolveDependency<IPrototypeManager>();
var compFact = server.ResolveDependency<IComponentFactory>();
var id = compFact.GetComponentName(typeof(StorageFillComponent));

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

var allSizes = protoMan.EnumeratePrototypes<ItemSizePrototype>().ToList();
allSizes.Sort();

Assert.Multiple(() =>
{
foreach (var proto in PoolManager.GetPrototypesWithComponent<StorageFillComponent>(server))
Expand All @@ -97,14 +108,29 @@ public async Task TestSufficientSpaceForFill()
proto.TryGetComponent<ItemComponent>("Item", out var item);

var fill = (StorageFillComponent) proto.Components[id].Component;
var size = GetFillSize(fill, false, protoMan);
var maxSize = storage.MaxItemSize ??
(item?.Size == null
? SharedStorageSystem.DefaultStorageMaxItemSize
: (ItemSize) Math.Max(0, (int) item.Size - 1));
var size = GetFillSize(fill, false, protoMan, itemSys);

var maxSize = storage.MaxItemSize;
if (storage.MaxItemSize == null)
{
if (item?.Size == null)
{
maxSize = SharedStorageSystem.DefaultStorageMaxItemSize;
}
else
{
var curIndex = allSizes.IndexOf(protoMan.Index(item.Size));
var index = Math.Max(0, curIndex - 1);
maxSize = allSizes[index].ID;
}
}

if (maxSize == null)
continue;

if (storage.MaxSlots != null)
{
Assert.That(GetFillSize(fill, true, protoMan), Is.LessThanOrEqualTo(storage.MaxSlots),
Assert.That(GetFillSize(fill, true, protoMan, itemSys), Is.LessThanOrEqualTo(storage.MaxSlots),
$"{proto.ID} storage fill has too many items.");
}
else
Expand All @@ -123,14 +149,14 @@ public async Task TestSufficientSpaceForFill()
if (!fillItem.TryGetComponent<ItemComponent>("Item", out var entryItem))
continue;

Assert.That(entryItem.Size, Is.LessThanOrEqualTo(maxSize),
Assert.That(protoMan.Index(entryItem.Size).Weight,
Is.LessThanOrEqualTo(protoMan.Index(maxSize.Value).Weight),
$"Entity {proto.ID} has storage-fill item, {entry.PrototypeId}, that is too large");
}
}
});

await pair.CleanReturnAsync();

}

[Test]
Expand All @@ -139,10 +165,13 @@ public async Task TestSufficientSpaceForEntityStorageFill()
await using var pair = await PoolManager.GetServerClient();
var server = pair.Server;

var entMan = server.ResolveDependency<IEntityManager>();
var protoMan = server.ResolveDependency<IPrototypeManager>();
var compFact = server.ResolveDependency<IComponentFactory>();
var id = compFact.GetComponentName(typeof(StorageFillComponent));

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

Assert.Multiple(() =>
{
foreach (var proto in PoolManager.GetPrototypesWithComponent<StorageFillComponent>(server))
Expand All @@ -157,15 +186,15 @@ public async Task TestSufficientSpaceForEntityStorageFill()
}

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

private int GetEntrySize(EntitySpawnEntry entry, bool getCount, IPrototypeManager protoMan)
private int GetEntrySize(EntitySpawnEntry entry, bool getCount, IPrototypeManager protoMan, SharedItemSystem itemSystem)
{
if (entry.PrototypeId == null)
return 0;
Expand All @@ -179,20 +208,21 @@ private int GetEntrySize(EntitySpawnEntry entry, bool getCount, IPrototypeManage
if (getCount)
return entry.Amount;


if (proto.TryGetComponent<ItemComponent>("Item", out var item))
return SharedItemSystem.GetItemSizeWeight(item.Size) * entry.Amount;
return itemSystem.GetItemSizeWeight(item.Size) * entry.Amount;

Assert.Fail($"Prototype is missing item comp: {entry.PrototypeId}");
return 0;
}

private int GetFillSize(StorageFillComponent fill, bool getCount, IPrototypeManager protoMan)
private int GetFillSize(StorageFillComponent fill, bool getCount, IPrototypeManager protoMan, SharedItemSystem itemSystem)
{
var totalSize = 0;
var groups = new Dictionary<string, int>();
foreach (var entry in fill.Contents)
{
var size = GetEntrySize(entry, getCount, protoMan);
var size = GetEntrySize(entry, getCount, protoMan, itemSystem);

if (entry.GroupId == null)
totalSize += size;
Expand Down
Loading

0 comments on commit 163a9c5

Please sign in to comment.