diff --git a/.editorconfig b/.editorconfig index 8a5cf43521..a87e5e0651 100644 --- a/.editorconfig +++ b/.editorconfig @@ -77,6 +77,8 @@ csharp_style_expression_bodied_methods = false:suggestion #csharp_style_expression_bodied_operators = false:silent csharp_style_expression_bodied_properties = true:suggestion +csharp_style_namespace_declarations = file_scoped:suggestion + # Pattern matching preferences #csharp_style_pattern_matching_over_as_with_null_check = true:suggestion #csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion diff --git a/.github/workflows/build-docfx.yml b/.github/workflows/build-docfx.yml index 3ef0497496..1f010b7291 100644 --- a/.github/workflows/build-docfx.yml +++ b/.github/workflows/build-docfx.yml @@ -27,7 +27,7 @@ jobs: run: dotnet restore - name: Build Project - run: dotnet build --no-restore /p:WarningsAsErrors=nullable + run: dotnet build --no-restore - name: Build DocFX uses: nikeee/docfx-action@v1.0.0 diff --git a/.github/workflows/build-map-renderer.yml b/.github/workflows/build-map-renderer.yml index 2dd284ef05..b7bf957867 100644 --- a/.github/workflows/build-map-renderer.yml +++ b/.github/workflows/build-map-renderer.yml @@ -42,7 +42,7 @@ jobs: run: dotnet restore - name: Build Project - run: dotnet build Content.MapRenderer --configuration Release --no-restore /p:WarningsAsErrors=nullable /m + run: dotnet build Content.MapRenderer --configuration Release --no-restore /m - name: Run Map Renderer run: dotnet run --project Content.MapRenderer Dev diff --git a/.github/workflows/build-test-debug.yml b/.github/workflows/build-test-debug.yml index 293852adb9..cdef25f37a 100644 --- a/.github/workflows/build-test-debug.yml +++ b/.github/workflows/build-test-debug.yml @@ -42,7 +42,7 @@ jobs: run: dotnet restore - name: Build Project - run: dotnet build --configuration DebugOpt --no-restore /p:WarningsAsErrors=nullable /m + run: dotnet build --configuration DebugOpt --no-restore /m - name: Run Content.Tests run: dotnet test --no-build --configuration DebugOpt Content.Tests/Content.Tests.csproj -- NUnit.ConsoleOut=0 diff --git a/Content.Benchmarks/SpawnEquipDeleteBenchmark.cs b/Content.Benchmarks/SpawnEquipDeleteBenchmark.cs index 0638d945aa..9b878eac40 100644 --- a/Content.Benchmarks/SpawnEquipDeleteBenchmark.cs +++ b/Content.Benchmarks/SpawnEquipDeleteBenchmark.cs @@ -8,6 +8,7 @@ using Robust.Shared; using Robust.Shared.Analyzers; using Robust.Shared.GameObjects; using Robust.Shared.Map; +using Robust.Shared.Prototypes; namespace Content.Benchmarks; @@ -18,9 +19,11 @@ namespace Content.Benchmarks; [Virtual, MemoryDiagnoser] public class SpawnEquipDeleteBenchmark { + private static readonly EntProtoId Mob = "MobHuman"; + private static readonly ProtoId CaptainStartingGear = "CaptainGear"; + private TestPair _pair = default!; private StationSpawningSystem _spawnSys = default!; - private const string Mob = "MobHuman"; private StartingGearPrototype _gear = default!; private EntityUid _entity; private EntityCoordinates _coords; @@ -39,7 +42,7 @@ public class SpawnEquipDeleteBenchmark var mapData = await _pair.CreateTestMap(); _coords = mapData.GridCoords; _spawnSys = server.System(); - _gear = server.ProtoMan.Index("CaptainGear"); + _gear = server.ProtoMan.Index(CaptainStartingGear); } [GlobalCleanup] diff --git a/Content.Client/Access/UI/GroupedAccessLevelChecklist.xaml.cs b/Content.Client/Access/UI/GroupedAccessLevelChecklist.xaml.cs index da68653ce5..4f07c31009 100644 --- a/Content.Client/Access/UI/GroupedAccessLevelChecklist.xaml.cs +++ b/Content.Client/Access/UI/GroupedAccessLevelChecklist.xaml.cs @@ -15,6 +15,8 @@ namespace Content.Client.Access.UI; [GenerateTypedNameReferences] public sealed partial class GroupedAccessLevelChecklist : BoxContainer { + private static readonly ProtoId GeneralAccessGroup = "General"; + [Dependency] private readonly IPrototypeManager _protoManager = default!; private bool _isMonotone; @@ -63,7 +65,7 @@ public sealed partial class GroupedAccessLevelChecklist : BoxContainer // Ensure that the 'general' access group is added to handle // misc. access levels that aren't associated with any group - if (_protoManager.TryIndex("General", out var generalAccessProto)) + if (_protoManager.TryIndex(GeneralAccessGroup, out var generalAccessProto)) _groupedAccessLevels.TryAdd(generalAccessProto, new()); // Assign known access levels with their associated groups diff --git a/Content.Client/Actions/ActionsSystem.cs b/Content.Client/Actions/ActionsSystem.cs index d5beca7aea..0305b0973f 100644 --- a/Content.Client/Actions/ActionsSystem.cs +++ b/Content.Client/Actions/ActionsSystem.cs @@ -211,7 +211,7 @@ namespace Content.Client.Actions else { var request = new RequestPerformActionEvent(GetNetEntity(action)); - EntityManager.RaisePredictiveEvent(request); + RaisePredictiveEvent(request); } } diff --git a/Content.Client/Administration/AdminNameOverlay.cs b/Content.Client/Administration/AdminNameOverlay.cs index 0d424cbff0..abeed65732 100644 --- a/Content.Client/Administration/AdminNameOverlay.cs +++ b/Content.Client/Administration/AdminNameOverlay.cs @@ -1,3 +1,4 @@ +using System.Collections.Frozen; using System.Linq; using System.Numerics; using Content.Client.Administration.Systems; @@ -24,6 +25,7 @@ internal sealed class AdminNameOverlay : Overlay private readonly EntityLookupSystem _entityLookup; private readonly IUserInterfaceManager _userInterfaceManager; private readonly SharedRoleSystem _roles; + private readonly IPrototypeManager _prototypeManager; private readonly Font _font; private readonly Font _fontBold; private AdminOverlayAntagFormat _overlayFormat; @@ -36,8 +38,9 @@ internal sealed class AdminNameOverlay : Overlay private float _overlayMergeDistance; //TODO make this adjustable via GUI? - private readonly ProtoId[] _filter = - ["SoloAntagonist", "TeamAntagonist", "SiliconAntagonist", "FreeAgent"]; + private static readonly FrozenSet> Filter = + new ProtoId[] {"SoloAntagonist", "TeamAntagonist", "SiliconAntagonist", "FreeAgent"} + .ToFrozenSet(); private readonly string _antagLabelClassic = Loc.GetString("admin-overlay-antag-classic"); @@ -49,7 +52,8 @@ internal sealed class AdminNameOverlay : Overlay EntityLookupSystem entityLookup, IUserInterfaceManager userInterfaceManager, IConfigurationManager config, - SharedRoleSystem roles) + SharedRoleSystem roles, + IPrototypeManager prototypeManager) { _system = system; _entityManager = entityManager; @@ -57,6 +61,7 @@ internal sealed class AdminNameOverlay : Overlay _entityLookup = entityLookup; _userInterfaceManager = userInterfaceManager; _roles = roles; + _prototypeManager = prototypeManager; ZIndex = 200; // Setting these to a specific ttf would break the antag symbols _font = resourceCache.NotoStack(); @@ -125,6 +130,14 @@ internal sealed class AdminNameOverlay : Overlay foreach (var info in sortable.OrderBy(s => s.Item4.Y).ToList()) { var playerInfo = info.Item1; + var rolePrototype = playerInfo.RoleProto == null + ? null + : _prototypeManager.Index(playerInfo.RoleProto.Value); + + var roleName = Loc.GetString(rolePrototype?.Name ?? RoleTypePrototype.FallbackName); + var roleColor = rolePrototype?.Color ?? RoleTypePrototype.FallbackColor; + var roleSymbol = rolePrototype?.Symbol ?? RoleTypePrototype.FallbackSymbol; + var aabb = info.Item2; var entity = info.Item3; var screenCoordinatesCenter = info.Item4; @@ -209,7 +222,7 @@ internal sealed class AdminNameOverlay : Overlay switch (_overlaySymbolStyle) { case AdminOverlayAntagSymbolStyle.Specific: - symbol = playerInfo.RoleProto.Symbol; + symbol = roleSymbol; break; case AdminOverlayAntagSymbolStyle.Basic: symbol = Loc.GetString("player-tab-antag-prefix"); @@ -225,17 +238,17 @@ internal sealed class AdminNameOverlay : Overlay switch (_overlayFormat) { case AdminOverlayAntagFormat.Roletype: - color = playerInfo.RoleProto.Color; - symbol = _filter.Contains(playerInfo.RoleProto) ? symbol : string.Empty; - text = _filter.Contains(playerInfo.RoleProto) - ? Loc.GetString(playerInfo.RoleProto.Name).ToUpper() + color = roleColor; + symbol = IsFiltered(playerInfo.RoleProto) ? symbol : string.Empty; + text = IsFiltered(playerInfo.RoleProto) + ? roleName.ToUpper() : string.Empty; break; case AdminOverlayAntagFormat.Subtype: - color = playerInfo.RoleProto.Color; - symbol = _filter.Contains(playerInfo.RoleProto) ? symbol : string.Empty; - text = _filter.Contains(playerInfo.RoleProto) - ? _roles.GetRoleSubtypeLabel(playerInfo.RoleProto.Name, playerInfo.Subtype).ToUpper() + color = roleColor; + symbol = IsFiltered(playerInfo.RoleProto) ? symbol : string.Empty; + text = IsFiltered(playerInfo.RoleProto) + ? _roles.GetRoleSubtypeLabel(roleName, playerInfo.Subtype).ToUpper() : string.Empty; break; default: @@ -258,4 +271,12 @@ internal sealed class AdminNameOverlay : Overlay drawnOverlays.Add((screenCoordinatesCenter, currentOffset)); } } + + private static bool IsFiltered(ProtoId? roleProtoId) + { + if (roleProtoId == null) + return false; + + return Filter.Contains(roleProtoId.Value); + } } diff --git a/Content.Client/Administration/Systems/AdminSystem.Overlay.cs b/Content.Client/Administration/Systems/AdminSystem.Overlay.cs index a630df4521..e000bdc0ba 100644 --- a/Content.Client/Administration/Systems/AdminSystem.Overlay.cs +++ b/Content.Client/Administration/Systems/AdminSystem.Overlay.cs @@ -4,6 +4,7 @@ using Robust.Client.Graphics; using Robust.Client.ResourceManagement; using Robust.Client.UserInterface; using Robust.Shared.Configuration; +using Robust.Shared.Prototypes; namespace Content.Client.Administration.Systems { @@ -17,6 +18,7 @@ namespace Content.Client.Administration.Systems [Dependency] private readonly IUserInterfaceManager _userInterfaceManager = default!; [Dependency] private readonly IConfigurationManager _configurationManager = default!; [Dependency] private readonly SharedRoleSystem _roles = default!; + [Dependency] private readonly IPrototypeManager _proto = default!; private AdminNameOverlay _adminNameOverlay = default!; @@ -33,7 +35,8 @@ namespace Content.Client.Administration.Systems _entityLookup, _userInterfaceManager, _configurationManager, - _roles); + _roles, + _proto); _adminManager.AdminStatusUpdated += OnAdminStatusUpdated; } diff --git a/Content.Client/Administration/UI/AdminCamera/AdminCameraControl.xaml b/Content.Client/Administration/UI/AdminCamera/AdminCameraControl.xaml new file mode 100644 index 0000000000..1413eff00c --- /dev/null +++ b/Content.Client/Administration/UI/AdminCamera/AdminCameraControl.xaml @@ -0,0 +1,20 @@ + + + + + + + + + +