Skip to content

Commit

Permalink
Merge pull request #1331 from NullWanderer/2024/06/06-upstream-merge
Browse files Browse the repository at this point in the history
Upstream merge
  • Loading branch information
NullWanderer authored Jun 11, 2024
2 parents 3a9e50e + 976aa67 commit 21cd750
Show file tree
Hide file tree
Showing 674 changed files with 6,612 additions and 4,254 deletions.
41 changes: 15 additions & 26 deletions Content.Benchmarks/PvsBenchmark.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
#nullable enable
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using BenchmarkDotNet.Attributes;
using Content.IntegrationTests;
using Content.IntegrationTests.Pair;
using Content.Server.Mind;
using Content.Server.Warps;
using Robust.Server.GameObjects;
using Robust.Shared;
using Robust.Shared.Analyzers;
using Robust.Shared.Enums;
using Robust.Shared.GameObjects;
using Robust.Shared.GameStates;
using Robust.Shared.Map;
using Robust.Shared.Network;
using Robust.Shared.Player;
using Robust.Shared.Random;

Expand Down Expand Up @@ -58,15 +56,20 @@ public void Setup()
_pair.Server.CfgMan.SetCVar(CVars.NetPvsAsync, false);
_sys = _entMan.System<SharedTransformSystem>();

SetupAsync().Wait();
}

private async Task SetupAsync()
{
// Spawn the map
_pair.Server.ResolveDependency<IRobustRandom>().SetSeed(42);
_pair.Server.WaitPost(() =>
await _pair.Server.WaitPost(() =>
{
var success = _entMan.System<MapLoaderSystem>().TryLoad(_mapId, Map, out _);
if (!success)
throw new Exception("Map load failed");
_pair.Server.MapMan.DoMapInitialize(_mapId);
}).Wait();
});

// Get list of ghost warp positions
_spawns = _entMan.AllComponentsList<WarpPointComponent>()
Expand All @@ -76,17 +79,19 @@ public void Setup()

Array.Resize(ref _players, PlayerCount);

// Spawn "Players".
_pair.Server.WaitPost(() =>
// Spawn "Players"
_players = await _pair.Server.AddDummySessions(PlayerCount);
await _pair.Server.WaitPost(() =>
{
var mind = _pair.Server.System<MindSystem>();
for (var i = 0; i < PlayerCount; i++)
{
var pos = _spawns[i % _spawns.Length];
var uid =_entMan.SpawnEntity("MobHuman", pos);
_pair.Server.ConsoleHost.ExecuteCommand($"setoutfit {_entMan.GetNetEntity(uid)} CaptainGear");
_players[i] = new DummySession{AttachedEntity = uid};
mind.ControlMob(_players[i].UserId, uid);
}
}).Wait();
});

// Repeatedly move players around so that they "explore" the map and see lots of entities.
// This will populate their PVS data with out-of-view entities.
Expand Down Expand Up @@ -168,20 +173,4 @@ public void CycleTick()
}).Wait();
_pair.Server.PvsTick(_players);
}

private sealed class DummySession : ICommonSession
{
public SessionStatus Status => SessionStatus.InGame;
public EntityUid? AttachedEntity {get; set; }
public NetUserId UserId => default;
public string Name => string.Empty;
public short Ping => default;
public INetChannel Channel { get; set; } = default!;
public LoginType AuthType => default;
public HashSet<EntityUid> ViewSubscriptions { get; } = new();
public DateTime ConnectedTime { get; set; }
public SessionState State => default!;
public SessionData Data => default!;
public bool ClientSide { get; set; }
}
}
4 changes: 3 additions & 1 deletion Content.Client/Access/UI/AgentIDCardBoundUserInterface.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using Content.Shared.Access.Systems;
using Content.Shared.StatusIcon;
using Robust.Client.GameObjects;
using Robust.Shared.Prototypes;

namespace Content.Client.Access.UI
{
Expand Down Expand Up @@ -40,7 +42,7 @@ private void OnJobChanged(string newJob)
SendMessage(new AgentIDCardJobChangedMessage(newJob));
}

public void OnJobIconChanged(string newJobIconId)
public void OnJobIconChanged(ProtoId<StatusIconPrototype> newJobIconId)
{
SendMessage(new AgentIDCardJobIconChangedMessage(newJobIconId));
}
Expand Down
8 changes: 3 additions & 5 deletions Content.Client/Access/UI/AgentIDCardWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,16 @@ public AgentIDCardWindow(AgentIDCardBoundUserInterface bui)
JobLineEdit.OnFocusExit += e => OnJobChanged?.Invoke(e.Text);
}

public void SetAllowedIcons(HashSet<string> icons, string currentJobIconId)
public void SetAllowedIcons(HashSet<ProtoId<StatusIconPrototype>> icons, string currentJobIconId)
{
IconGrid.DisposeAllChildren();

var jobIconGroup = new ButtonGroup();
var i = 0;
foreach (var jobIconId in icons)
{
if (!_prototypeManager.TryIndex<StatusIconPrototype>(jobIconId, out var jobIcon))
{
if (!_prototypeManager.TryIndex(jobIconId, out var jobIcon))
continue;
}

String styleBase = StyleBase.ButtonOpenBoth;
var modulo = i % JobIconColumnCount;
Expand Down Expand Up @@ -77,7 +75,7 @@ public void SetAllowedIcons(HashSet<string> icons, string currentJobIconId)
};

jobIconButton.AddChild(jobIconTexture);
jobIconButton.OnPressed += _ => _bui.OnJobIconChanged(jobIcon.ID);
jobIconButton.OnPressed += _ => _bui.OnJobIconChanged(jobIconId);
IconGrid.AddChild(jobIconButton);

if (jobIconId.Equals(currentJobIconId))
Expand Down
12 changes: 9 additions & 3 deletions Content.Client/Access/UI/IdCardConsoleWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ public sealed partial class IdCardConsoleWindow : DefaultWindow
private string? _lastJobTitle;
private string? _lastJobProto;

// The job that will be picked if the ID doesn't have a job on the station.
private static ProtoId<JobPrototype> _defaultJob = "Passenger";

public IdCardConsoleWindow(IdCardConsoleBoundUserInterface owner, IPrototypeManager prototypeManager,
List<ProtoId<AccessLevelPrototype>> accessLevels)
{
Expand Down Expand Up @@ -65,7 +68,6 @@ public IdCardConsoleWindow(IdCardConsoleBoundUserInterface owner, IPrototypeMana
}

JobPresetOptionButton.OnItemSelected += SelectJobPreset;

_accessButtons.Populate(accessLevels, prototypeManager);
AccessLevelControlContainer.AddChild(_accessButtons);

Expand Down Expand Up @@ -172,11 +174,15 @@ public void UpdateState(IdCardConsoleBoundUserInterfaceState state)
new List<ProtoId<AccessLevelPrototype>>());

var jobIndex = _jobPrototypeIds.IndexOf(state.TargetIdJobPrototype);
if (jobIndex >= 0)
// If the job index is < 0 that means they don't have a job registered in the station records.
// For example, a new ID from a box would have no job index.
if (jobIndex < 0)
{
JobPresetOptionButton.SelectId(jobIndex);
jobIndex = _jobPrototypeIds.IndexOf(_defaultJob);
}

JobPresetOptionButton.SelectId(jobIndex);

_lastFullName = state.TargetIdFullName;
_lastJobTitle = state.TargetIdJobTitle;
_lastJobProto = state.TargetIdJobPrototype;
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Administration/UI/BanPanel/BanPanel.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public BanPanel()
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
foreach (var proto in prototypeManager.EnumeratePrototypes<DepartmentPrototype>())
{
CreateRoleGroup(proto.ID, proto.Roles, proto.Color);
CreateRoleGroup(proto.ID, proto.Roles.Select(p => p.Id), proto.Color);
}

CreateRoleGroup("Antagonist", prototypeManager.EnumeratePrototypes<AntagPrototype>().Select(p => p.ID), Color.Red);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public sealed class ExplosionDebugOverlay : Overlay

public override OverlaySpace Space => OverlaySpace.WorldSpace | OverlaySpace.ScreenSpace;

public Matrix3 SpaceMatrix;
public Matrix3x2 SpaceMatrix;
public MapId Map;

private readonly Font _font;
Expand Down Expand Up @@ -78,15 +78,16 @@ private void DrawScreen(OverlayDrawArgs args)
if (SpaceTiles == null)
return;

gridBounds = Matrix3.Invert(SpaceMatrix).TransformBox(args.WorldBounds);
Matrix3x2.Invert(SpaceMatrix, out var invSpace);
gridBounds = invSpace.TransformBox(args.WorldBounds);

DrawText(handle, gridBounds, SpaceMatrix, SpaceTiles, SpaceTileSize);
}

private void DrawText(
DrawingHandleScreen handle,
Box2 gridBounds,
Matrix3 transform,
Matrix3x2 transform,
Dictionary<int, List<Vector2i>> tileSets,
ushort tileSize)
{
Expand All @@ -103,7 +104,7 @@ private void DrawText(
if (!gridBounds.Contains(centre))
continue;

var worldCenter = transform.Transform(centre);
var worldCenter = Vector2.Transform(centre, transform);

var screenCenter = _eyeManager.WorldToScreen(worldCenter);

Expand All @@ -119,7 +120,7 @@ private void DrawText(
if (tileSets.TryGetValue(0, out var set))
{
var epicenter = set.First();
var worldCenter = transform.Transform((epicenter + Vector2Helpers.Half) * tileSize);
var worldCenter = Vector2.Transform((epicenter + Vector2Helpers.Half) * tileSize, transform);
var screenCenter = _eyeManager.WorldToScreen(worldCenter) + new Vector2(-24, -24);
var text = $"{Intensity[0]:F2}\nΣ={TotalIntensity:F1}\nΔ={Slope:F1}";
handle.DrawString(_font, screenCenter, text);
Expand Down Expand Up @@ -148,11 +149,12 @@ private void DrawWorld(in OverlayDrawArgs args)
if (SpaceTiles == null)
return;

gridBounds = Matrix3.Invert(SpaceMatrix).TransformBox(args.WorldBounds).Enlarged(2);
Matrix3x2.Invert(SpaceMatrix, out var invSpace);
gridBounds = invSpace.TransformBox(args.WorldBounds).Enlarged(2);
handle.SetTransform(SpaceMatrix);

DrawTiles(handle, gridBounds, SpaceTiles, SpaceTileSize);
handle.SetTransform(Matrix3.Identity);
handle.SetTransform(Matrix3x2.Identity);
}

private void DrawTiles(
Expand Down
16 changes: 11 additions & 5 deletions Content.Client/Administration/UI/Tabs/ObjectsTab/ObjectsTab.xaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
<Control xmlns="https://spacestation14.io"
xmlns:cc="clr-namespace:Content.Client.Administration.UI.CustomControls">
xmlns:cc="clr-namespace:Content.Client.Administration.UI.CustomControls"
xmlns:ot="clr-namespace:Content.Client.Administration.UI.Tabs.ObjectsTab"
xmlns:co="clr-namespace:Content.Client.UserInterface.Controls">
<BoxContainer Orientation="Vertical">
<BoxContainer Orientation="Horizontal">
<Label HorizontalExpand="True" SizeFlagsStretchRatio="0.50"
Text="{Loc Object type:}" />
<LineEdit Name="SearchLineEdit" PlaceHolder="{Loc Search...}" HorizontalExpand="True" SizeFlagsStretchRatio="1"/>
<OptionButton Name="ObjectTypeOptions" HorizontalExpand="True" SizeFlagsStretchRatio="0.25"/>
</BoxContainer>
<BoxContainer Orientation="Horizontal" HorizontalExpand="True">
</BoxContainer>
<cc:HSeparator/>
<ScrollContainer HorizontalExpand="True" VerticalExpand="True">
<BoxContainer Orientation="Vertical" Name="ObjectList">
</BoxContainer>
</ScrollContainer>
<BoxContainer Orientation="Vertical" HorizontalExpand="True" VerticalExpand="True">
<ot:ObjectsTabHeader Name="ListHeader"/>
<cc:HSeparator/>
<co:SearchListContainer Name="SearchList" Access="Public" VerticalExpand="True"/>
</BoxContainer>
</BoxContainer>
</Control>
Loading

0 comments on commit 21cd750

Please sign in to comment.