From 07f97fffa61bf03ed73f32101b03ca6702405e06 Mon Sep 17 00:00:00 2001 From: Whatstone <166147148+whatston3@users.noreply.github.com> Date: Mon, 5 Oct 2026 01:58:03 +0000 Subject: [PATCH] Cleanup: Resolve/suppress many obsolete warnings, delete EntityPrototypeHelpers. (#46141) * Resolve warnings, mostly obsolete * resolve via the entitymanager directly, not wref * Ent, why not * minimize test diff * StorageTest: consistent print order * ChameleonProj: use Disguised value consistently * GasArrayTest: TryComp * OrganPickingMarker: cache ILocalizationManager avoids warning from Loc.TryGetString, and avoids multiple IoCManager hits * FormattedMessage.FromMarkup to FromMarkupOrThrow * rerun tests :pray: --- .../AdminMessagePopupWindow.xaml.cs | 4 +- .../UI/ChameleonBoundUserInterface.cs | 5 +-- .../Humanoid/OrganMarkingPicker.xaml.cs | 12 ++---- .../Tests/Atmos/GasArrayTest.cs | 4 +- Content.IntegrationTests/Tests/CargoTest.cs | 3 +- .../Tests/FillLevelSpriteTest.cs | 3 +- .../Tests/Lathe/LatheTest.cs | 5 +-- .../Tests/Puller/PullerTest.cs | 3 +- .../Tests/Storage/StorageTest.cs | 19 +++++---- .../Tests/VendingMachineRestockTest.cs | 3 +- .../Actions/Commands/AddActionCommand.cs | 5 +-- .../Converters/EntityCoordinatesConverter.cs | 5 ++- Content.Server/Administration/ServerApi.cs | 3 +- .../Construction/Completions/GivePrototype.cs | 6 ++- .../Completions/SpawnPrototype.cs | 6 ++- Content.Server/Decals/DecalSystem.cs | 28 +++++++------ .../Behaviors/SpawnEntitiesBehavior.cs | 3 +- .../Commands/AddObjectiveCommand.cs | 3 +- Content.Server/Objectives/ObjectivesSystem.cs | 6 +-- .../EntitySystems/StorageSystem.Fill.cs | 22 +++++----- Content.Server/Traits/TraitSystem.cs | 3 +- .../Weather/Commands/WeatherAddCommand.cs | 3 +- .../Weather/Commands/WeatherRemoveCommand.cs | 3 +- .../Weather/Commands/WeatherSetCommand.cs | 3 +- Content.Shared/Actions/SharedActionsSystem.cs | 6 ++- ...edSolutionContainerSystem.Compatibility.cs | 7 +--- .../SharedSolutionContainerSystem.cs | 1 - .../Damage/Systems/SharedGodmodeSystem.cs | 4 +- .../DecalGridChunkCollectionTypeSerializer.cs | 21 +++++----- Content.Shared/Decals/DecalGridComponent.cs | 7 +++- Content.Shared/Decals/SharedDecalSystem.cs | 13 +++--- .../Kitchen/SharedKitchenSpikeSystem.cs | 2 +- .../Systems/SharedChameleonProjectorSystem.cs | 16 ++++---- .../Prototypes/EntityPrototypeHelpers.cs | 40 ------------------- Content.Shared/Stacks/SharedStackSystem.cs | 2 +- .../StatusEffect/StatusEffectsComponent.cs | 6 ++- .../StatusEffect/StatusEffectsSystem.cs | 2 +- 37 files changed, 125 insertions(+), 162 deletions(-) delete mode 100644 Content.Shared/Prototypes/EntityPrototypeHelpers.cs diff --git a/Content.Client/Administration/UI/AdminRemarks/AdminMessagePopupWindow.xaml.cs b/Content.Client/Administration/UI/AdminRemarks/AdminMessagePopupWindow.xaml.cs index b88bd1728f..d3becbf6bd 100644 --- a/Content.Client/Administration/UI/AdminRemarks/AdminMessagePopupWindow.xaml.cs +++ b/Content.Client/Administration/UI/AdminRemarks/AdminMessagePopupWindow.xaml.cs @@ -42,7 +42,7 @@ public sealed partial class AdminMessagePopupWindow : Control public void SetState(AdminMessageEuiState state) { - Timer = (float) state.Time.TotalSeconds; + Timer = (float)state.Time.TotalSeconds; MessageContainer.RemoveAllChildren(); @@ -52,7 +52,7 @@ public sealed partial class AdminMessagePopupWindow : Control } Description.SetMessage( - FormattedMessage.FromMarkup(Loc.GetString("admin-notes-message-desc", ("count", state.Messages.Length)))); + FormattedMessage.FromMarkupOrThrow(Loc.GetString("admin-notes-message-desc", ("count", state.Messages.Length)))); } private void OnDismissButtonPressed(BaseButton.ButtonEventArgs obj) diff --git a/Content.Client/Clothing/UI/ChameleonBoundUserInterface.cs b/Content.Client/Clothing/UI/ChameleonBoundUserInterface.cs index 9fe36d683c..035dbe7b09 100644 --- a/Content.Client/Clothing/UI/ChameleonBoundUserInterface.cs +++ b/Content.Client/Clothing/UI/ChameleonBoundUserInterface.cs @@ -1,9 +1,7 @@ using Content.Client.Clothing.Systems; using Content.Shared.Clothing.Components; using Content.Shared.Tag; -using Content.Shared.Prototypes; using JetBrains.Annotations; -using Robust.Client.GameObjects; using Robust.Client.UserInterface; using Robust.Shared.Prototypes; @@ -54,7 +52,8 @@ public sealed partial class ChameleonBoundUserInterface : BoundUserInterface newTargets.Add(target); } _menu?.UpdateState(newTargets, st.SelectedId); - } else + } + else { _menu?.UpdateState(targets, st.SelectedId); } diff --git a/Content.Client/Humanoid/OrganMarkingPicker.xaml.cs b/Content.Client/Humanoid/OrganMarkingPicker.xaml.cs index f426d79c43..728cdf3fe1 100644 --- a/Content.Client/Humanoid/OrganMarkingPicker.xaml.cs +++ b/Content.Client/Humanoid/OrganMarkingPicker.xaml.cs @@ -1,9 +1,7 @@ -using System.Linq; using Content.Shared.Body; using Content.Shared.Humanoid; using Content.Shared.Humanoid.Markings; using Robust.Client.AutoGenerated; -using Robust.Client.GameObjects; using Robust.Client.UserInterface; using Robust.Client.UserInterface.XAML; using Robust.Shared.Prototypes; @@ -14,9 +12,7 @@ namespace Content.Client.Humanoid; public sealed partial class OrganMarkingPicker : Control { [Dependency] private MarkingManager _marking = default!; - [Dependency] private IEntityManager _entity = default!; - - private readonly SpriteSystem _sprite; + [Dependency] private ILocalizationManager _loc = default!; private readonly MarkingsViewModel _markingsModel; private readonly HashSet _layers; @@ -33,8 +29,6 @@ public sealed partial class OrganMarkingPicker : Control _group = group; _organ = organ; - _sprite = _entity.System(); - UpdateMarkings(); } @@ -79,10 +73,10 @@ public sealed partial class OrganMarkingPicker : Control var control = new LayerMarkingPicker(_markingsModel, _organ, layer, allMarkings); LayerTabs.AddChild(control); - if (Loc.TryGetString($"markings-layer-{layer}-{_group.Id}", out var layerTitle)) + if (_loc.TryGetString($"markings-layer-{layer}-{_group.Id}", out var layerTitle)) LayerTabs.SetTabTitle(i, layerTitle); else - LayerTabs.SetTabTitle(i, Loc.GetString($"markings-layer-{layer}")); + LayerTabs.SetTabTitle(i, _loc.GetString($"markings-layer-{layer}")); i++; } diff --git a/Content.IntegrationTests/Tests/Atmos/GasArrayTest.cs b/Content.IntegrationTests/Tests/Atmos/GasArrayTest.cs index 4b05fc16c3..6edfc9fe7b 100644 --- a/Content.IntegrationTests/Tests/Atmos/GasArrayTest.cs +++ b/Content.IntegrationTests/Tests/Atmos/GasArrayTest.cs @@ -50,7 +50,7 @@ public sealed class GasArrayTest : GameTest var gasTank = SProtoMan.Index(GasTankTestDummyId); using (Assert.EnterMultipleScope()) { - Assert.That(gasTank.TryGetComponent(out var gasTankComponent, _compFactory)); + Assert.That(gasTank.TryComp(out var gasTankComponent, _compFactory)); Assert.That(gasTankComponent!.Air.GetMoles(Gas.Oxygen), Is.EqualTo(10)); Assert.That(gasTankComponent!.Air.GetMoles(Gas.Frezon), Is.EqualTo(20)); @@ -63,7 +63,7 @@ public sealed class GasArrayTest : GameTest var legacyGasTank = SProtoMan.Index(GasTankLegacyTestDummyId); using (Assert.EnterMultipleScope()) { - Assert.That(legacyGasTank.TryGetComponent(out var gasTankComponent, _compFactory)); + Assert.That(legacyGasTank.TryComp(out var gasTankComponent, _compFactory)); Assert.That(gasTankComponent!.Air.GetMoles(3), Is.EqualTo(10)); diff --git a/Content.IntegrationTests/Tests/CargoTest.cs b/Content.IntegrationTests/Tests/CargoTest.cs index 4a9bf0f0e6..7b99cfd951 100644 --- a/Content.IntegrationTests/Tests/CargoTest.cs +++ b/Content.IntegrationTests/Tests/CargoTest.cs @@ -6,7 +6,6 @@ using Content.Server.Cargo.Components; using Content.Server.Cargo.Systems; using Content.Shared.Cargo.Prototypes; using Content.Shared.Mobs.Components; -using Content.Shared.Prototypes; using Content.Shared.Stacks; using Content.Shared.Storage; using Content.Shared.Tools.Components; @@ -119,7 +118,7 @@ public sealed class CargoTest : GameTest ); } - if (proto.HasComponent(_sCompFact)) + if (proto.HasComp(_sCompFact)) { Assert.That( staticPriceComp.Price, diff --git a/Content.IntegrationTests/Tests/FillLevelSpriteTest.cs b/Content.IntegrationTests/Tests/FillLevelSpriteTest.cs index 6bee3aad7b..0e8eb3bc9d 100644 --- a/Content.IntegrationTests/Tests/FillLevelSpriteTest.cs +++ b/Content.IntegrationTests/Tests/FillLevelSpriteTest.cs @@ -2,7 +2,6 @@ using System.Linq; using Content.IntegrationTests.Fixtures; using Content.Shared.Chemistry; using Content.Shared.Chemistry.Components; -using Content.Shared.Prototypes; using Robust.Client.GameObjects; using Robust.Shared.GameObjects; using Robust.Shared.Prototypes; @@ -43,7 +42,7 @@ public sealed class FillLevelSpriteTest : GameTest { Assert.That(proto.TryComp(out var visuals, componentFactory)); Assert.That(proto.TryComp(out var sprite, componentFactory)); - if (!proto.HasComponent(componentFactory)) + if (!proto.HasComp(componentFactory)) { Assert.Fail(@$"{proto.ID} has SolutionContainerVisualsComponent but no AppearanceComponent."); } diff --git a/Content.IntegrationTests/Tests/Lathe/LatheTest.cs b/Content.IntegrationTests/Tests/Lathe/LatheTest.cs index 3f614d21b8..6e9073ae03 100644 --- a/Content.IntegrationTests/Tests/Lathe/LatheTest.cs +++ b/Content.IntegrationTests/Tests/Lathe/LatheTest.cs @@ -3,7 +3,6 @@ using System.Linq; using Content.IntegrationTests.Fixtures; using Content.Shared.Lathe; using Content.Shared.Materials; -using Content.Shared.Prototypes; using Content.Shared.Research.Prototypes; using Content.Shared.Whitelist; using Robust.Shared.GameObjects; @@ -35,13 +34,13 @@ public sealed class LatheTest : GameTest var latheProtos = protoMan.EnumeratePrototypes() .Where(p => !p.Abstract) .Where(p => !pair.IsTestPrototype(p)) - .Where(p => p.HasComponent()); + .Where(p => p.HasComp(compFactory)); // Find every EntityPrototype that can be inserted into a MaterialStorage var materialEntityProtos = protoMan.EnumeratePrototypes() .Where(p => !p.Abstract) .Where(p => !pair.IsTestPrototype(p)) - .Where(p => p.HasComponent()); + .Where(p => p.HasComp(compFactory)); // Spawn all of the above material EntityPrototypes - we need actual entities to do whitelist checks var materialEntities = new List(materialEntityProtos.Count()); diff --git a/Content.IntegrationTests/Tests/Puller/PullerTest.cs b/Content.IntegrationTests/Tests/Puller/PullerTest.cs index e6d6655661..09f5226c80 100644 --- a/Content.IntegrationTests/Tests/Puller/PullerTest.cs +++ b/Content.IntegrationTests/Tests/Puller/PullerTest.cs @@ -1,7 +1,6 @@ using Content.IntegrationTests.Fixtures; using Content.Shared.Hands.Components; using Content.Shared.Movement.Pulling.Components; -using Content.Shared.Prototypes; using Robust.Shared.GameObjects; using Robust.Shared.Prototypes; @@ -36,7 +35,7 @@ public sealed class PullerTest : GameTest if (!puller.NeedsHands) continue; - Assert.That(proto.HasComponent(compFactory), $"Found puller {proto} with NeedsHand pulling but has no hands?"); + Assert.That(proto.HasComp(compFactory), $"Found puller {proto} with NeedsHand pulling but has no hands?"); } }); }); diff --git a/Content.IntegrationTests/Tests/Storage/StorageTest.cs b/Content.IntegrationTests/Tests/Storage/StorageTest.cs index 4823d2bd15..ea65754692 100644 --- a/Content.IntegrationTests/Tests/Storage/StorageTest.cs +++ b/Content.IntegrationTests/Tests/Storage/StorageTest.cs @@ -6,7 +6,6 @@ using Content.IntegrationTests.Fixtures.Attributes; using Content.Server.Item; using Content.Shared.Containers; using Content.Shared.Item; -using Content.Shared.Prototypes; using Content.Shared.Storage; using Content.Shared.Storage.Components; using Content.Shared.Storage.EntitySystems; @@ -54,6 +53,7 @@ public sealed class StorageTest : GameTest } [Test] + [Obsolete("StorageFillComponent is obsolete.")] public async Task TestStorageFillPrototypes() { var pair = Pair; @@ -82,6 +82,7 @@ public sealed class StorageTest : GameTest } [Test] + [Obsolete("StorageFillComponent is obsolete.")] public async Task TestSufficientSpaceForFill() { var pair = Pair; @@ -101,7 +102,7 @@ public sealed class StorageTest : GameTest { foreach (var (proto, fill) in pair.GetPrototypesWithComponent()) { - if (proto.HasComponent(compFact)) + if (proto.HasComp(compFact)) continue; StorageComponent? storage = null; @@ -168,6 +169,7 @@ public sealed class StorageTest : GameTest } [Test] + [Obsolete("StorageFillComponent is obsolete.")] public async Task TestSufficientSpaceForEntityStorageFill() { var pair = Pair; @@ -182,7 +184,7 @@ public sealed class StorageTest : GameTest foreach (var (proto, fill) in pair.GetPrototypesWithComponent()) { - if (proto.HasComponent(compFact)) + if (proto.HasComp(compFact)) continue; await server.WaitAssertion(() => @@ -222,6 +224,7 @@ public sealed class StorageTest : GameTest return 0; } + [Obsolete("StorageFillComponent is obsolete.")] private int GetFillSize(StorageFillComponent fill, bool getCount, IPrototypeManager protoMan, IComponentFactory compFact, SharedItemSystem itemSystem) { var totalSize = 0; @@ -250,15 +253,17 @@ public sealed class StorageTest : GameTest Assert.Multiple(() => { - foreach (var (proto, fill) in pair.GetPrototypesWithComponent()) +#pragma warning disable CS0618 // StorageFillComponent is obsolete, but this test is still needed while it exists. + foreach (var (proto, fill) in pair.GetPrototypesWithComponent()) { - Assert.That(!proto.HasComp(compFact), $"Prototype {proto.ID} has both {nameof(EntityTableContainerFillComponent)} and {nameof(StorageFillComponent)}."); - Assert.That(!proto.HasComp(compFact), $"Prototype {proto.ID} has both {nameof(EntityTableContainerFillComponent)} and {nameof(ContainerFillComponent)}."); + Assert.That(!proto.HasComp(compFact), $"Prototype {proto.ID} has both {nameof(StorageFillComponent)} and {nameof(EntityTableContainerFillComponent)}."); + Assert.That(!proto.HasComp(compFact), $"Prototype {proto.ID} has both {nameof(StorageFillComponent)} and {nameof(ContainerFillComponent)}."); } +#pragma warning restore CS0618 foreach (var (proto, fill) in pair.GetPrototypesWithComponent()) { - Assert.That(!proto.HasComp(compFact), $"Prototype {proto.ID} has both {nameof(ContainerFillComponent)} and {nameof(StorageFillComponent)}."); + Assert.That(!proto.HasComp(compFact), $"Prototype {proto.ID} has both {nameof(ContainerFillComponent)} and {nameof(EntityTableContainerFillComponent)}."); } }); } diff --git a/Content.IntegrationTests/Tests/VendingMachineRestockTest.cs b/Content.IntegrationTests/Tests/VendingMachineRestockTest.cs index 2ada6e571d..fe146c1fd0 100644 --- a/Content.IntegrationTests/Tests/VendingMachineRestockTest.cs +++ b/Content.IntegrationTests/Tests/VendingMachineRestockTest.cs @@ -9,7 +9,6 @@ using Content.Shared.Damage; using Content.Shared.Damage.Prototypes; using Content.Shared.Damage.Systems; using Content.Shared.EntityTable; -using Content.Shared.Prototypes; using Content.Shared.Storage.EntitySystems; using Content.Shared.VendingMachines; using Content.Shared.VendingMachines.Components; @@ -130,7 +129,7 @@ namespace Content.IntegrationTests.Tests { if (proto.Abstract || pair.IsTestPrototype(proto) - || !proto.HasComponent()) + || !proto.HasComp(compFact)) continue; restockEntities.Add(proto.ID); diff --git a/Content.Server/Actions/Commands/AddActionCommand.cs b/Content.Server/Actions/Commands/AddActionCommand.cs index f5fa7c8e1f..dde08b1785 100644 --- a/Content.Server/Actions/Commands/AddActionCommand.cs +++ b/Content.Server/Actions/Commands/AddActionCommand.cs @@ -3,7 +3,6 @@ using Content.Server.Administration; using Content.Shared.Actions; using Content.Shared.Actions.Components; using Content.Shared.Administration; -using Content.Shared.Prototypes; using Robust.Shared.Console; using Robust.Shared.Prototypes; @@ -38,7 +37,7 @@ public sealed partial class AddActionCommand : LocalizedEntityCommands } if (!_prototypeManager.TryIndex(args[1], out var proto) || - !proto.HasComponent()) + !proto.HasComp(EntityManager.ComponentFactory)) { shell.WriteError(Loc.GetString("cmd-addaction-action-not-found", ("action", args[1]))); return; @@ -63,7 +62,7 @@ public sealed partial class AddActionCommand : LocalizedEntityCommands return CompletionResult.Empty; var actionPrototypes = _prototypeManager.EnumeratePrototypes() - .Where(p => p.HasComponent()) + .Where(p => p.HasComp(EntityManager.ComponentFactory)) .Select(p => p.ID) .Order(); diff --git a/Content.Server/Administration/Logs/Converters/EntityCoordinatesConverter.cs b/Content.Server/Administration/Logs/Converters/EntityCoordinatesConverter.cs index 3a0ffeb758..641df450e8 100644 --- a/Content.Server/Administration/Logs/Converters/EntityCoordinatesConverter.cs +++ b/Content.Server/Administration/Logs/Converters/EntityCoordinatesConverter.cs @@ -23,7 +23,10 @@ public sealed class EntityCoordinatesConverter : AdminLogConverter(value.EntityId).MapUid; + if (mapUid.HasValue) { WriteEntityInfo(writer, mapUid.Value, entities, "map"); diff --git a/Content.Server/Administration/ServerApi.cs b/Content.Server/Administration/ServerApi.cs index 4554dba2fb..759d0ebc28 100644 --- a/Content.Server/Administration/ServerApi.cs +++ b/Content.Server/Administration/ServerApi.cs @@ -18,7 +18,6 @@ using Content.Shared.Database; using Content.Shared.GameTicking; using Content.Shared.GameTicking.Components; using Content.Shared.GameTicking.Prototypes; -using Content.Shared.Prototypes; using Robust.Server.ServerStatus; using Robust.Shared.Asynchronous; using Robust.Shared.Configuration; @@ -516,7 +515,7 @@ public sealed partial class ServerApi : IPostInjectInit if (gameRule.Abstract) continue; - if (gameRule.HasComponent(_componentFactory)) + if (gameRule.HasComp(_componentFactory)) gameRules.Add(gameRule.ID); } diff --git a/Content.Server/Construction/Completions/GivePrototype.cs b/Content.Server/Construction/Completions/GivePrototype.cs index 22c5473c8d..441375224e 100644 --- a/Content.Server/Construction/Completions/GivePrototype.cs +++ b/Content.Server/Construction/Completions/GivePrototype.cs @@ -2,7 +2,6 @@ using Content.Server.Stack; using Content.Shared.Construction; using Content.Shared.Hands.Components; using Content.Shared.Hands.EntitySystems; -using Content.Shared.Prototypes; using Content.Shared.Stacks; using JetBrains.Annotations; using Robust.Shared.Prototypes; @@ -24,7 +23,10 @@ public sealed partial class GivePrototype : IGraphAction if (string.IsNullOrEmpty(Prototype)) return; - if (EntityPrototypeHelpers.HasComponent(Prototype)) + // TODO: pass PrototypeManager into IGraphAction + var protoMan = IoCManager.Resolve(); + + if (protoMan.TryIndex(Prototype, out var entProto) && entProto.HasComp(entityManager.ComponentFactory)) { var stackSystem = entityManager.EntitySysManager.GetEntitySystem(); var stacks = stackSystem.SpawnMultipleNextToOrDrop(Prototype, Amount, userUid ?? uid); diff --git a/Content.Server/Construction/Completions/SpawnPrototype.cs b/Content.Server/Construction/Completions/SpawnPrototype.cs index cb6af955f6..853df94f7f 100644 --- a/Content.Server/Construction/Completions/SpawnPrototype.cs +++ b/Content.Server/Construction/Completions/SpawnPrototype.cs @@ -1,6 +1,5 @@ using Content.Server.Stack; using Content.Shared.Construction; -using Content.Shared.Prototypes; using Content.Shared.Stacks; using JetBrains.Annotations; using Robust.Shared.Prototypes; @@ -24,7 +23,10 @@ namespace Content.Server.Construction.Completions var coordinates = entityManager.GetComponent(uid).Coordinates; - if (EntityPrototypeHelpers.HasComponent(Prototype)) + // TODO: pass the PrototypeManager into IGraphAction. + var protoMan = IoCManager.Resolve(); + + if (protoMan.TryIndex(Prototype, out EntityPrototype? proto) && proto.HasComp(entityManager.ComponentFactory)) { var stackEnt = entityManager.SpawnEntity(Prototype, coordinates); var stack = entityManager.GetComponent(stackEnt); diff --git a/Content.Server/Decals/DecalSystem.cs b/Content.Server/Decals/DecalSystem.cs index 61f530c356..5049c168dd 100644 --- a/Content.Server/Decals/DecalSystem.cs +++ b/Content.Server/Decals/DecalSystem.cs @@ -23,23 +23,24 @@ public sealed partial class DecalSystem : SharedDecalSystem [Dependency] private EntityQuery _gridQuery; - private static readonly Vector2 _boundsMinExpansion = new(0.01f, 0.01f); - private static readonly Vector2 _boundsMaxExpansion = new(1.01f, 1.01f); + private static readonly Vector2 BoundsMinExpansion = new(0.01f, 0.01f); + private static readonly Vector2 BoundsMaxExpansion = new(1.01f, 1.01f); public override void Initialize() { base.Initialize(); SubscribeLocalEvent(OnTileChanged); - SubscribeLocalEvent(OnLegacyDecalGridStartup); SubscribeLocalEvent(OnBeforeSerialization); SubscribeLocalEvent(OnGridSplit); } - private void OnLegacyDecalGridStartup(EntityUid uid, DecalGridComponent component, ComponentStartup args) + [SubscribeLocalEvent] + [Obsolete("Uses obsolete DecalGridComponent.")] + private void OnLegacyDecalGridStartup(Entity ent, ref ComponentStartup args) { - MigrateLegacyDecalGrid(uid, component); - RemCompDeferred(uid, component); + MigrateLegacyDecalGrid(ent); + RemCompDeferred(ent, ent.Comp); } private void OnBeforeSerialization(BeforeSerializationEvent ev) @@ -55,12 +56,14 @@ public sealed partial class DecalSystem : SharedDecalSystem foreach (var uid in ev.Entities) { +#pragma warning disable CS0618 // DecalGridComponent compatibility behaviour. if (!TryComp(uid, out var component)) continue; - MigrateLegacyDecalGrid(uid, component); + MigrateLegacyDecalGrid((uid, component)); RemComp(uid, component); migrated.Add(uid); +#pragma warning restore CS0618 } foreach (var uid in migrated) @@ -72,14 +75,15 @@ public sealed partial class DecalSystem : SharedDecalSystem } } - private void MigrateLegacyDecalGrid(EntityUid uid, DecalGridComponent component) + [Obsolete("Uses obsolete DecalGridComponent.")] + private void MigrateLegacyDecalGrid(Entity ent) { // Old maps store grid-wide decal chunks; convert them into chunk entities and remove the legacy component. - foreach (var chunk in component.ChunkCollection.ChunkCollection.Values) + foreach (var chunk in ent.Comp.ChunkCollection.ChunkCollection.Values) { foreach (var (id, decal) in chunk.Decals) { - AddDecalWithId(uid, id, decal); + AddDecalWithId(ent, id, decal); } } } @@ -95,7 +99,7 @@ public sealed partial class DecalSystem : SharedDecalSystem foreach (var tile in _mapSystem.GetAllTiles(ev.Grid, grid)) { var tilePos = (Vector2)tile.GridIndices; - var bounds = new Box2(tilePos - _boundsMinExpansion, tilePos + _boundsMaxExpansion); + var bounds = new Box2(tilePos - BoundsMinExpansion, tilePos + BoundsMaxExpansion); foreach (var (id, decal) in GetDecalsIntersecting(ev.OldGrid, bounds)) { @@ -123,7 +127,7 @@ public sealed partial class DecalSystem : SharedDecalSystem if (!_turf.IsSpace(change.NewTile)) continue; - var tilePos = (Vector2) change.GridIndices; + var tilePos = (Vector2)change.GridIndices; var bounds = new Box2(tilePos, tilePos + Vector2.One); foreach (var (id, _) in GetDecalsIntersecting(args.Entity, bounds)) diff --git a/Content.Server/Destructible/Thresholds/Behaviors/SpawnEntitiesBehavior.cs b/Content.Server/Destructible/Thresholds/Behaviors/SpawnEntitiesBehavior.cs index 31c63b606c..2f1d7f8a15 100644 --- a/Content.Server/Destructible/Thresholds/Behaviors/SpawnEntitiesBehavior.cs +++ b/Content.Server/Destructible/Thresholds/Behaviors/SpawnEntitiesBehavior.cs @@ -1,7 +1,6 @@ using System.Numerics; using Content.Shared.Destructible.Thresholds; using Content.Shared.Forensics.Components; -using Content.Shared.Prototypes; using Content.Shared.Stacks; using Robust.Server.GameObjects; using Robust.Shared.Prototypes; @@ -52,7 +51,7 @@ namespace Content.Server.Destructible.Thresholds.Behaviors if (count == 0) continue; - if (EntityPrototypeHelpers.HasComponent(entityId, system.PrototypeManager, system.EntityManager.ComponentFactory)) + if (system.PrototypeManager.TryIndex(entityId, out var prototype) && prototype.HasComp(system.EntityManager.ComponentFactory)) { var spawned = SpawnInContainer ? system.EntityManager.SpawnNextToOrDrop(entityId, owner) diff --git a/Content.Server/Objectives/Commands/AddObjectiveCommand.cs b/Content.Server/Objectives/Commands/AddObjectiveCommand.cs index 4679555100..722cc549a8 100644 --- a/Content.Server/Objectives/Commands/AddObjectiveCommand.cs +++ b/Content.Server/Objectives/Commands/AddObjectiveCommand.cs @@ -3,7 +3,6 @@ using Content.Server.Administration; using Content.Shared.Administration; using Content.Shared.Mind; using Content.Shared.Objectives.Components; -using Content.Shared.Prototypes; using Robust.Server.Player; using Robust.Shared.Console; using Robust.Shared.Prototypes; @@ -41,7 +40,7 @@ public sealed partial class AddObjectiveCommand : LocalizedEntityCommands } if (!_prototypes.TryIndex(args[1], out var proto) || - !proto.HasComponent()) + !proto.HasComp(EntityManager.ComponentFactory)) { shell.WriteError(Loc.GetString("cmd-addobjective-objective-not-found", ("obj", args[1]))); return; diff --git a/Content.Server/Objectives/ObjectivesSystem.cs b/Content.Server/Objectives/ObjectivesSystem.cs index 44db00da87..fa38c1bcf8 100644 --- a/Content.Server/Objectives/ObjectivesSystem.cs +++ b/Content.Server/Objectives/ObjectivesSystem.cs @@ -1,4 +1,3 @@ -using Content.Server.GameTicking; using Content.Server.Shuttles.Systems; using Content.Shared.Cuffs.Components; using Content.Shared.GameTicking.Components; @@ -14,7 +13,6 @@ using System.Text; using Content.Server.Objectives.Commands; using Content.Shared.CCVar; using Content.Shared.GameTicking; -using Content.Shared.Prototypes; using Content.Shared.Roles.Jobs; using Robust.Server.Player; using Robust.Shared.Configuration; @@ -214,7 +212,7 @@ public sealed partial class ObjectivesSystem : SharedObjectivesSystem } } - var successRate = totalObjectives > 0 ? (float) completedObjectives / totalObjectives : 0f; + var successRate = totalObjectives > 0 ? (float)completedObjectives / totalObjectives : 0f; agentSummaries.Add((agentSummary.ToString(), successRate, completedObjectives)); } @@ -324,7 +322,7 @@ public sealed partial class ObjectivesSystem : SharedObjectivesSystem private void CreateCompletions() { _objectives = ProtoMan.EnumeratePrototypes() - .Where(p => p.HasComponent()) + .Where(p => p.HasComp(EntityManager.ComponentFactory)) .Select(p => p.ID) .Order(); } diff --git a/Content.Server/Storage/EntitySystems/StorageSystem.Fill.cs b/Content.Server/Storage/EntitySystems/StorageSystem.Fill.cs index c48b396435..d7af7d334f 100644 --- a/Content.Server/Storage/EntitySystems/StorageSystem.Fill.cs +++ b/Content.Server/Storage/EntitySystems/StorageSystem.Fill.cs @@ -1,7 +1,6 @@ using System.Linq; using Content.Server.Spawners.Components; using Content.Shared.Item; -using Content.Shared.Prototypes; using Content.Shared.Storage; using Content.Shared.Storage.Components; using Robust.Shared.Prototypes; @@ -11,25 +10,27 @@ namespace Content.Server.Storage.EntitySystems; public sealed partial class StorageSystem { - private void OnStorageFillMapInit(EntityUid uid, StorageFillComponent component, MapInitEvent args) + [Obsolete("StorageFillComponent is obsolete.")] + private void OnStorageFillMapInit(Entity ent, ref MapInitEvent args) { - if (component.Contents.Count == 0) + if (ent.Comp.Contents.Count == 0) return; - if (TryComp(uid, out var storageComp)) + if (TryComp(ent, out var storageComp)) { - FillStorage((uid, component, storageComp)); + FillStorage((ent, ent.Comp, storageComp)); } - else if (TryComp(uid, out var entityStorageComp)) + else if (TryComp(ent, out var entityStorageComp)) { - FillEntityStorage((uid, component, entityStorageComp)); + FillEntityStorage((ent, ent.Comp, entityStorageComp)); } else { - Log.Error($"StorageFillComponent couldn't find any StorageComponent ({uid})"); + Log.Error($"StorageFillComponent couldn't find any StorageComponent ({ent})"); } } + [Obsolete("StorageFillComponent is obsolete.")] private void FillStorage(Entity entity) { var (uid, component, storage) = entity; @@ -48,7 +49,7 @@ public sealed partial class StorageSystem // No, you are not allowed to fill a container with entity spawners. DebugTools.Assert(!ProtoMan.Index(spawnPrototype) - .HasComponent(typeof(RandomSpawnerComponent))); + .HasComp(Factory)); if (!TryComp(ent, out var itemComp)) { @@ -85,6 +86,7 @@ public sealed partial class StorageSystem } } + [Obsolete("StorageFillComponent is obsolete.")] private void FillEntityStorage(Entity entity) { var (uid, component, entityStorageComp) = entity; @@ -99,7 +101,7 @@ public sealed partial class StorageSystem { // No, you are not allowed to fill a container with entity spawners. DebugTools.Assert(!ProtoMan.Index(item) - .HasComponent(typeof(RandomSpawnerComponent))); + .HasComp(Factory)); var ent = Spawn(item, coordinates); // handle depending on storage component, again this should be unified after ECS diff --git a/Content.Server/Traits/TraitSystem.cs b/Content.Server/Traits/TraitSystem.cs index be5142146b..d3ba233567 100644 --- a/Content.Server/Traits/TraitSystem.cs +++ b/Content.Server/Traits/TraitSystem.cs @@ -4,7 +4,6 @@ using Content.Shared.Hands.EntitySystems; using Content.Shared.Roles; using Content.Shared.Traits; using Content.Shared.Whitelist; -using Robust.Shared.Prototypes; namespace Content.Server.Traits; @@ -44,8 +43,10 @@ public sealed partial class TraitSystem : EntitySystem continue; // Add all components required by the prototype +#pragma warning disable CS0618 // Enabling compatibility behaviour for TraitPrototype.Components if (traitPrototype.Components.Count > 0) EntityManager.AddComponents(args.Mob, traitPrototype.Components, false); +#pragma warning restore CS0618 // Add all JobSpecials required by the prototype foreach (var special in traitPrototype.Specials) diff --git a/Content.Server/Weather/Commands/WeatherAddCommand.cs b/Content.Server/Weather/Commands/WeatherAddCommand.cs index c3ea94ca1f..cf81abeaf2 100644 --- a/Content.Server/Weather/Commands/WeatherAddCommand.cs +++ b/Content.Server/Weather/Commands/WeatherAddCommand.cs @@ -1,6 +1,5 @@ using Content.Server.Administration; using Content.Shared.Administration; -using Content.Shared.Prototypes; using Content.Shared.Weather; using Robust.Shared.Console; using Robust.Shared.Map; @@ -73,7 +72,7 @@ public sealed partial class WeatherAddCommand : LocalizedEntityCommands var opts = new List(); foreach (var proto in _proto.EnumeratePrototypes()) { - if (!proto.HasComponent(_compFactory)) + if (!proto.HasComp(_compFactory)) continue; opts.Add(new CompletionOption(proto.ID, proto.Name)); diff --git a/Content.Server/Weather/Commands/WeatherRemoveCommand.cs b/Content.Server/Weather/Commands/WeatherRemoveCommand.cs index 19ae23133e..d5cd25a75e 100644 --- a/Content.Server/Weather/Commands/WeatherRemoveCommand.cs +++ b/Content.Server/Weather/Commands/WeatherRemoveCommand.cs @@ -1,6 +1,5 @@ using Content.Server.Administration; using Content.Shared.Administration; -using Content.Shared.Prototypes; using Content.Shared.Weather; using Robust.Shared.Console; using Robust.Shared.Map; @@ -69,7 +68,7 @@ public sealed partial class WeatherRemoveCommand : LocalizedEntityCommands var opts = new List(); foreach (var proto in _proto.EnumeratePrototypes()) { - if (!proto.HasComponent(_compFactory)) + if (!proto.HasComp(_compFactory)) continue; opts.Add(new CompletionOption(proto.ID, proto.Name)); diff --git a/Content.Server/Weather/Commands/WeatherSetCommand.cs b/Content.Server/Weather/Commands/WeatherSetCommand.cs index ee787085c1..e38f90b2ec 100644 --- a/Content.Server/Weather/Commands/WeatherSetCommand.cs +++ b/Content.Server/Weather/Commands/WeatherSetCommand.cs @@ -1,6 +1,5 @@ using Content.Server.Administration; using Content.Shared.Administration; -using Content.Shared.Prototypes; using Content.Shared.Weather; using Robust.Shared.Console; using Robust.Shared.Map; @@ -75,7 +74,7 @@ public sealed partial class WeatherSetCommand : LocalizedEntityCommands var opts = new List(); foreach (var proto in _proto.EnumeratePrototypes()) { - if (!proto.HasComponent(_compFactory)) + if (!proto.HasComp(_compFactory)) continue; opts.Add(new CompletionOption(proto.ID, proto.Name)); diff --git a/Content.Shared/Actions/SharedActionsSystem.cs b/Content.Shared/Actions/SharedActionsSystem.cs index 0248e41aa4..f36f0a64c9 100644 --- a/Content.Shared/Actions/SharedActionsSystem.cs +++ b/Content.Shared/Actions/SharedActionsSystem.cs @@ -590,13 +590,15 @@ public abstract partial class SharedActionsSystem : EntitySystem ev.Action = action; // TODO: This is where we'd add support for event lists - if (!action.Comp.RaiseOnUser && action.Comp.Container is {} container && !_mindQuery.HasComp(container)) + if (!action.Comp.RaiseOnUser && action.Comp.Container is { } container && !_mindQuery.HasComp(container)) target = container; +#pragma warning disable CS0618 // Enabling RaiseOnAction compatibility behaviour. if (action.Comp.RaiseOnAction) target = action; +#pragma warning restore CS0618 - RaiseLocalEvent(target, (object) ev, broadcast: true); + RaiseLocalEvent(target, (object)ev, broadcast: true); handled = ev.Handled; if (!handled) diff --git a/Content.Shared/Chemistry/EntitySystems/SharedSolutionContainerSystem.Compatibility.cs b/Content.Shared/Chemistry/EntitySystems/SharedSolutionContainerSystem.Compatibility.cs index b23ef95919..411950cc1f 100644 --- a/Content.Shared/Chemistry/EntitySystems/SharedSolutionContainerSystem.Compatibility.cs +++ b/Content.Shared/Chemistry/EntitySystems/SharedSolutionContainerSystem.Compatibility.cs @@ -12,11 +12,8 @@ namespace Content.Shared.Chemistry.EntitySystems; /// public abstract partial class SharedSolutionContainerSystem { - public void InitializeContainerManager() - { - SubscribeLocalEvent(OnSolutionContainerInit); - } - + [SubscribeLocalEvent] + [Obsolete("Uses obsolete SolutionContainerManagerComponent.")] private void OnSolutionContainerInit(Entity container, ref MapInitEvent args) { // Create the manager, this should also create a container, so we ensure it exists. diff --git a/Content.Shared/Chemistry/EntitySystems/SharedSolutionContainerSystem.cs b/Content.Shared/Chemistry/EntitySystems/SharedSolutionContainerSystem.cs index b4ccdd7e09..a605084cbb 100644 --- a/Content.Shared/Chemistry/EntitySystems/SharedSolutionContainerSystem.cs +++ b/Content.Shared/Chemistry/EntitySystems/SharedSolutionContainerSystem.cs @@ -86,7 +86,6 @@ public abstract partial class SharedSolutionContainerSystem : EntitySystem base.Initialize(); InitializeRelays(); - InitializeContainerManager(); SubscribeLocalEvent(OnSolutionGetState); SubscribeLocalEvent(OnSolutionHandleState); diff --git a/Content.Shared/Damage/Systems/SharedGodmodeSystem.cs b/Content.Shared/Damage/Systems/SharedGodmodeSystem.cs index 5a041a59e4..b3bcac82b4 100644 --- a/Content.Shared/Damage/Systems/SharedGodmodeSystem.cs +++ b/Content.Shared/Damage/Systems/SharedGodmodeSystem.cs @@ -4,7 +4,6 @@ using Content.Shared.Destructible; using Content.Shared.Glue; using Content.Shared.Lube; using Content.Shared.Nutrition; -using Content.Shared.Prototypes; using Content.Shared.Rejuvenate; using Content.Shared.Slippery; using Content.Shared.StatusEffect; @@ -21,7 +20,6 @@ public abstract partial class SharedGodmodeSystem : EntitySystem SubscribeLocalEvent(OnBeforeDamageChanged); SubscribeLocalEvent(OnBeforeStatusEffect); - SubscribeLocalEvent(OnBeforeOldStatusEffect); SubscribeLocalEvent(OnBeforeStaminaDamage); SubscribeLocalEvent(BeforeEdible); SubscribeLocalEvent(OnSlipAttempt); @@ -44,6 +42,8 @@ public abstract partial class SharedGodmodeSystem : EntitySystem args.Cancelled = true; } + [SubscribeLocalEvent] + [Obsolete("BeforeOldStatusEffectAddedEvent is obsolete.")] private void OnBeforeOldStatusEffect(Entity ent, ref BeforeOldStatusEffectAddedEvent args) { // Old status effect system doesn't distinguish between good and bad status effects diff --git a/Content.Shared/Decals/DecalGridChunkCollectionTypeSerializer.cs b/Content.Shared/Decals/DecalGridChunkCollectionTypeSerializer.cs index 2f8d11af08..9f35c2221c 100644 --- a/Content.Shared/Decals/DecalGridChunkCollectionTypeSerializer.cs +++ b/Content.Shared/Decals/DecalGridChunkCollectionTypeSerializer.cs @@ -1,8 +1,6 @@ using System.Globalization; -using System.Linq; using System.Numerics; using Robust.Shared.GameStates; -using Robust.Shared.Map; using Robust.Shared.Serialization; using Robust.Shared.Serialization.Manager; using Robust.Shared.Serialization.Markdown; @@ -12,7 +10,10 @@ using Robust.Shared.Serialization.Markdown.Validation; using Robust.Shared.Serialization.Markdown.Value; using Robust.Shared.Serialization.TypeSerializers.Interfaces; using Robust.Shared.Utility; + +#pragma warning disable CS0618 // Obsolete: enabling compatibility features. using static Content.Shared.Decals.DecalGridComponent; +#pragma warning restore CS0618 namespace Content.Shared.Decals { @@ -28,7 +29,7 @@ namespace Content.Shared.Decals IDependencyCollection dependencies, ISerializationContext? context = null) { node.TryGetValue("version", out var versionNode); - var version = ((ValueDataNode?) versionNode)?.AsInt() ?? VersionUnspecified; + var version = ((ValueDataNode?)versionNode)?.AsInt() ?? VersionUnspecified; return version switch { @@ -45,7 +46,7 @@ namespace Content.Shared.Decals ISerializationManager.InstantiationDelegate? _ = default) { node.TryGetValue("version", out var versionNode); - var version = ((ValueDataNode?) versionNode)?.AsInt() ?? VersionUnspecified; + var version = ((ValueDataNode?)versionNode)?.AsInt() ?? VersionUnspecified; return version switch { @@ -81,7 +82,7 @@ namespace Content.Shared.Decals chunk.Decals[index.Id] = decal; if (uid <= DecalChunkComponent.MaxServerDecalId) - nextIndex = Math.Max(nextIndex, (ushort) (uid + 1)); + nextIndex = Math.Max(nextIndex, (ushort)(uid + 1)); } } @@ -220,20 +221,20 @@ namespace Content.Shared.Decals { var used = usedIds.GetOrNew(chunk); - if (id <= DecalChunkComponent.MaxServerDecalId && used.Add((ushort) id)) + if (id <= DecalChunkComponent.MaxServerDecalId && used.Add((ushort)id)) { - nextIndex = Math.Max(nextIndex, (ushort) (id + 1)); - return new DecalIndex(chunk, (ushort) id); + nextIndex = Math.Max(nextIndex, (ushort)(id + 1)); + return new DecalIndex(chunk, (ushort)id); } for (var i = 0; i <= DecalChunkComponent.MaxServerDecalId; i++) { - var remapped = (ushort) i; + var remapped = (ushort)i; if (!used.Add(remapped)) continue; - nextIndex = Math.Max(nextIndex, (ushort) (remapped + 1)); + nextIndex = Math.Max(nextIndex, (ushort)(remapped + 1)); return new DecalIndex(chunk, remapped); } diff --git a/Content.Shared/Decals/DecalGridComponent.cs b/Content.Shared/Decals/DecalGridComponent.cs index 124311fcdc..b49d4a7d55 100644 --- a/Content.Shared/Decals/DecalGridComponent.cs +++ b/Content.Shared/Decals/DecalGridComponent.cs @@ -3,7 +3,10 @@ using Robust.Shared.Serialization; using Robust.Shared.Serialization.TypeSerializers.Implementations.Generic; using Robust.Shared.Timing; using Robust.Shared.Utility; + +#pragma warning disable CS0618 // This IS the obsolete component, this warning is redundant. using static Content.Shared.Decals.DecalGridComponent; +#pragma warning restore CS0618 namespace Content.Shared.Decals { @@ -18,7 +21,7 @@ namespace Content.Shared.Decals { [Access(Other = AccessPermissions.ReadExecute)] [DataField(serverOnly: true)] - public DecalGridChunkCollection ChunkCollection = new(new ()); + public DecalGridChunkCollection ChunkCollection = new(new()); /// /// Dictionary mapping decals to their corresponding grid chunks. @@ -34,7 +37,7 @@ namespace Content.Shared.Decals [Serializable, NetSerializable] public sealed partial class DecalChunk { - [IncludeDataField(customTypeSerializer:typeof(DictionarySerializer))] + [IncludeDataField(customTypeSerializer: typeof(DictionarySerializer))] public Dictionary Decals; [NonSerialized] diff --git a/Content.Shared/Decals/SharedDecalSystem.cs b/Content.Shared/Decals/SharedDecalSystem.cs index 9f31f87ddd..bdd83f8790 100644 --- a/Content.Shared/Decals/SharedDecalSystem.cs +++ b/Content.Shared/Decals/SharedDecalSystem.cs @@ -20,7 +20,6 @@ namespace Content.Shared.Decals { base.Initialize(); - SubscribeLocalEvent(OnGetState); SubscribeLocalEvent(OnChunkStartup); SubscribeAllEvent(OnDecalPlacementRequest); SubscribeAllEvent(OnDecalRemovalRequest); @@ -35,26 +34,28 @@ namespace Content.Shared.Decals RebuildFreeDecalIds(ent.Comp); } - private void OnGetState(EntityUid uid, DecalGridComponent component, ref ComponentGetState args) + [SubscribeLocalEvent] + [Obsolete("Uses obsolete DecalGridComponent.")] + private void OnGetState(Entity ent, ref ComponentGetState args) { if (PvsEnabled && !args.ReplayState) return; // Should this be a full component state or a delta-state? - if (args.FromTick <= component.CreationTick || args.FromTick <= component.ForceTick) + if (args.FromTick <= ent.Comp.CreationTick || args.FromTick <= ent.Comp.ForceTick) { - args.State = new DecalGridState(component.ChunkCollection.ChunkCollection); + args.State = new DecalGridState(ent.Comp.ChunkCollection.ChunkCollection); return; } var data = new Dictionary(); - foreach (var (index, chunk) in component.ChunkCollection.ChunkCollection) + foreach (var (index, chunk) in ent.Comp.ChunkCollection.ChunkCollection) { if (chunk.LastModified >= args.FromTick) data[index] = chunk; } - args.State = new DecalGridDeltaState(data, new(component.ChunkCollection.ChunkCollection.Keys)); + args.State = new DecalGridDeltaState(data, new(ent.Comp.ChunkCollection.ChunkCollection.Keys)); } public HashSet<(DecalIndex Index, Decal Decal)> GetDecalsInRange(EntityUid gridId, Vector2 position, float distance = 0.75f, Func? validDelegate = null) diff --git a/Content.Shared/Kitchen/SharedKitchenSpikeSystem.cs b/Content.Shared/Kitchen/SharedKitchenSpikeSystem.cs index 8c99feaa4b..547fda8485 100644 --- a/Content.Shared/Kitchen/SharedKitchenSpikeSystem.cs +++ b/Content.Shared/Kitchen/SharedKitchenSpikeSystem.cs @@ -151,7 +151,7 @@ public sealed partial class SharedKitchenSpikeSystem : EntitySystem if (butcherable.SpawnedEntities.Count == 0) { - _popupSystem.PopupClient(Loc.GetString("comp-kitchen-spike-butcher-empty", ("victim", Identity.Entity(victim.Value, EntityManager))), ent, args.User, PopupType.MediumCaution); + _popupSystem.PopupEntity(Loc.GetString("comp-kitchen-spike-butcher-empty", ("victim", Identity.Entity(victim.Value, EntityManager))), ent, args.User, PopupType.MediumCaution); return; } diff --git a/Content.Shared/Polymorph/Systems/SharedChameleonProjectorSystem.cs b/Content.Shared/Polymorph/Systems/SharedChameleonProjectorSystem.cs index 6d18027b4e..10964d2554 100644 --- a/Content.Shared/Polymorph/Systems/SharedChameleonProjectorSystem.cs +++ b/Content.Shared/Polymorph/Systems/SharedChameleonProjectorSystem.cs @@ -108,7 +108,7 @@ public abstract partial class SharedChameleonProjectorSystem : EntitySystem private void OnInteract(Entity ent, ref AfterInteractEvent args) { - if (args.Handled || !args.CanReach || args.Target is not {} target) + if (args.Handled || !args.CanReach || args.Target is not { } target) return; args.Handled = true; @@ -169,18 +169,18 @@ public abstract partial class SharedChameleonProjectorSystem : EntitySystem private void OnToggleNoRot(Entity ent, ref DisguiseToggleNoRotEvent args) { - if (ent.Comp.Disguised is not {} uid) + if (ent.Comp.Disguised is not { } uid) return; var xform = Transform(uid); _xform.SetLocalRotationNoLerp(uid, 0, xform); - xform.NoLocalRotation = !xform.NoLocalRotation; + _xform.SetNoLocalRotation(uid, !xform.NoLocalRotation, xform); args.Handled = true; } private void OnToggleAnchored(Entity ent, ref DisguiseToggleAnchoredEvent args) { - if (ent.Comp.Disguised is not {} uid) + if (ent.Comp.Disguised is not { } uid) return; var xform = Transform(uid); @@ -294,12 +294,12 @@ public abstract partial class SharedChameleonProjectorSystem : EntitySystem if (!Resolve(disguised, ref disguised.Comp, false)) return; - if (ent.Comp.Disguised == null) + if (ent.Comp.Disguised is not { } user) return; - var xform = Transform(ent.Comp.Disguised.Value); - xform.NoLocalRotation = false; - _xform.Unanchor(disguised, xform); + var xform = Transform(user); + _xform.SetNoLocalRotation(user, false, xform); + _xform.Unanchor(user, xform); ent.Comp.Disguised = null; Del(disguised.Comp.Disguise); diff --git a/Content.Shared/Prototypes/EntityPrototypeHelpers.cs b/Content.Shared/Prototypes/EntityPrototypeHelpers.cs deleted file mode 100644 index d2e5387d17..0000000000 --- a/Content.Shared/Prototypes/EntityPrototypeHelpers.cs +++ /dev/null @@ -1,40 +0,0 @@ -using JetBrains.Annotations; -using Robust.Shared.Prototypes; - -namespace Content.Shared.Prototypes -{ - [UsedImplicitly] - [Obsolete("More efficient methods exist in EntityPrototype.HasComp and EntitySystem's proxy methods")] - public static class EntityPrototypeHelpers - { - [Obsolete("More efficient methods exist in EntityPrototype.HasComp and EntitySystem's proxy methods")] - public static bool HasComponent(this EntityPrototype prototype, IComponentFactory? componentFactory = null) where T : IComponent - { - return prototype.HasComponent(typeof(T), componentFactory); - } - - [Obsolete("More efficient methods exist in EntityPrototype.HasComp and EntitySystem's proxy methods")] - public static bool HasComponent(this EntityPrototype prototype, Type component, IComponentFactory? componentFactory = null) - { - componentFactory ??= IoCManager.Resolve(); - - var registration = componentFactory.GetRegistration(component); - - return prototype.Components.ContainsKey(registration.Name); - } - - [Obsolete("More efficient methods exist in EntityPrototype.HasComp and EntitySystem's proxy methods")] - public static bool HasComponent(string prototype, IPrototypeManager? prototypeManager = null, IComponentFactory? componentFactory = null) where T : IComponent - { - return HasComponent(prototype, typeof(T), prototypeManager, componentFactory); - } - - [Obsolete("More efficient methods exist in EntityPrototype.HasComp and EntitySystem's proxy methods")] - public static bool HasComponent(string prototype, Type component, IPrototypeManager? prototypeManager = null, IComponentFactory? componentFactory = null) - { - prototypeManager ??= IoCManager.Resolve(); - - return prototypeManager.TryIndex(prototype, out EntityPrototype? proto) && proto.HasComponent(component, componentFactory); - } - } -} diff --git a/Content.Shared/Stacks/SharedStackSystem.cs b/Content.Shared/Stacks/SharedStackSystem.cs index 771aced664..961c453d52 100644 --- a/Content.Shared/Stacks/SharedStackSystem.cs +++ b/Content.Shared/Stacks/SharedStackSystem.cs @@ -38,7 +38,7 @@ public abstract partial class SharedStackSystem : EntitySystem base.Initialize(); _vvm.GetTypeHandler() - .AddPath(nameof(StackComponent.Count), (_, comp) => comp.Count, SetCount); + .AddPath(nameof(StackComponent.Count), (_, comp) => comp.Count, (uid, value, comp) => SetCount((uid, comp), value)); } public override void Shutdown() diff --git a/Content.Shared/StatusEffect/StatusEffectsComponent.cs b/Content.Shared/StatusEffect/StatusEffectsComponent.cs index d61af62537..02c3ab2be1 100644 --- a/Content.Shared/StatusEffect/StatusEffectsComponent.cs +++ b/Content.Shared/StatusEffect/StatusEffectsComponent.cs @@ -6,6 +6,7 @@ namespace Content.Shared.StatusEffect [RegisterComponent] [NetworkedComponent] [Access(typeof(StatusEffectsSystem))] + [Obsolete("Use StatusEffectContainerComponent and Content.Shared.StatusEffectNew.StatusEffectsSystem instead.")] public sealed partial class StatusEffectsComponent : Component { [ViewVariables] @@ -19,7 +20,8 @@ namespace Content.Shared.StatusEffect } [RegisterComponent] - public sealed partial class ActiveStatusEffectsComponent : Component {} + [Obsolete("Use the new Content.Shared.StatusEffectNew.StatusEffectsSystem instead.")] + public sealed partial class ActiveStatusEffectsComponent : Component { } /// /// Holds information about an active status effect. @@ -47,7 +49,7 @@ namespace Content.Shared.StatusEffect [ViewVariables] public string? RelevantComponent; - public StatusEffectState((TimeSpan, TimeSpan) cooldown, bool refresh, string? relevantComponent=null) + public StatusEffectState((TimeSpan, TimeSpan) cooldown, bool refresh, string? relevantComponent = null) { Cooldown = cooldown; CooldownRefresh = refresh; diff --git a/Content.Shared/StatusEffect/StatusEffectsSystem.cs b/Content.Shared/StatusEffect/StatusEffectsSystem.cs index 3bbce59101..5cc49dd320 100644 --- a/Content.Shared/StatusEffect/StatusEffectsSystem.cs +++ b/Content.Shared/StatusEffect/StatusEffectsSystem.cs @@ -136,7 +136,7 @@ namespace Content.Shared.StatusEffect // If they already have the comp, we just won't bother updating anything. if (!HasComp(uid, Factory.GetRegistration(component).Type)) { - var newComponent = (Component) Factory.GetComponent(component); + var newComponent = (Component)Factory.GetComponent(component); AddComp(uid, newComponent); status.ActiveEffects[key].RelevantComponent = component; }