]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Kill `ComponentExt` (#20907)
authorKara <lunarautomaton6@gmail.com>
Wed, 11 Oct 2023 09:19:46 +0000 (02:19 -0700)
committerGitHub <noreply@github.com>
Wed, 11 Oct 2023 09:19:46 +0000 (20:19 +1100)
Content.IntegrationTests/Tests/Interaction/Click/InteractionSystemTests.cs
Content.Server/Chemistry/EntitySystems/SolutionInjectOnCollideSystem.cs
Content.Server/Ghost/Roles/GhostRoleSystem.cs
Content.Server/Tabletop/TabletopSystem.Session.cs
Content.Shared/Singularity/Components/SingularityDistortionComponent.cs
Content.Shared/Singularity/EntitySystems/SharedSingularitySystem.cs

index b05f2732651b746d419658d79b6849ff3e3f59d2..cef74aa386f52658f96164270c6a0eb07e2c76ec 100644 (file)
@@ -63,11 +63,11 @@ namespace Content.IntegrationTests.Tests.Interaction.Click
             await server.WaitAssertion(() =>
             {
                 user = sEntities.SpawnEntity(null, coords);
-                user.EnsureComponent<HandsComponent>();
+                sEntities.EnsureComponent<HandsComponent>(user);
                 handSys.AddHand(user, "hand", HandLocation.Left);
                 target = sEntities.SpawnEntity(null, coords);
                 item = sEntities.SpawnEntity(null, coords);
-                item.EnsureComponent<ItemComponent>();
+                sEntities.EnsureComponent<ItemComponent>(item);
             });
 
             await server.WaitRunTicks(1);
@@ -134,11 +134,11 @@ namespace Content.IntegrationTests.Tests.Interaction.Click
             await server.WaitAssertion(() =>
             {
                 user = sEntities.SpawnEntity(null, coords);
-                user.EnsureComponent<HandsComponent>();
+                sEntities.EnsureComponent<HandsComponent>(user);
                 handSys.AddHand(user, "hand", HandLocation.Left);
                 target = sEntities.SpawnEntity(null, new MapCoordinates(new Vector2(1.9f, 0), mapId));
                 item = sEntities.SpawnEntity(null, coords);
-                item.EnsureComponent<ItemComponent>();
+                sEntities.EnsureComponent<ItemComponent>(item);
                 wall = sEntities.SpawnEntity("DummyDebugWall", new MapCoordinates(new Vector2(1, 0), sEntities.GetComponent<TransformComponent>(user).MapID));
             });
 
@@ -204,11 +204,11 @@ namespace Content.IntegrationTests.Tests.Interaction.Click
             await server.WaitAssertion(() =>
             {
                 user = sEntities.SpawnEntity(null, coords);
-                user.EnsureComponent<HandsComponent>();
+                sEntities.EnsureComponent<HandsComponent>(user);
                 handSys.AddHand(user, "hand", HandLocation.Left);
                 target = sEntities.SpawnEntity(null, new MapCoordinates(new Vector2(SharedInteractionSystem.InteractionRange - 0.1f, 0), mapId));
                 item = sEntities.SpawnEntity(null, coords);
-                item.EnsureComponent<ItemComponent>();
+                sEntities.EnsureComponent<ItemComponent>(item);
             });
 
             await server.WaitRunTicks(1);
@@ -274,11 +274,11 @@ namespace Content.IntegrationTests.Tests.Interaction.Click
             await server.WaitAssertion(() =>
             {
                 user = sEntities.SpawnEntity(null, coords);
-                user.EnsureComponent<HandsComponent>();
+                sEntities.EnsureComponent<HandsComponent>(user);
                 handSys.AddHand(user, "hand", HandLocation.Left);
                 target = sEntities.SpawnEntity(null, new MapCoordinates(new Vector2(SharedInteractionSystem.InteractionRange + 0.01f, 0), mapId));
                 item = sEntities.SpawnEntity(null, coords);
-                item.EnsureComponent<ItemComponent>();
+                sEntities.EnsureComponent<ItemComponent>(item);
             });
 
             await server.WaitRunTicks(1);
@@ -346,11 +346,11 @@ namespace Content.IntegrationTests.Tests.Interaction.Click
             await server.WaitAssertion(() =>
             {
                 user = sEntities.SpawnEntity(null, coords);
-                user.EnsureComponent<HandsComponent>();
+                sEntities.EnsureComponent<HandsComponent>(user);
                 handSys.AddHand(user, "hand", HandLocation.Left);
                 target = sEntities.SpawnEntity(null, coords);
                 item = sEntities.SpawnEntity(null, coords);
-                item.EnsureComponent<ItemComponent>();
+                sEntities.EnsureComponent<ItemComponent>(item);
                 containerEntity = sEntities.SpawnEntity(null, coords);
                 container = conSystem.EnsureContainer<Container>(containerEntity, "InteractionTestContainer");
             });
index 9848463e3f00ced6d8a9f050348f8d2b0cfb9cee..666a90ce73d3176c38124172ae8634a5e3b0e9be 100644 (file)
@@ -22,16 +22,9 @@ namespace Content.Server.Chemistry.EntitySystems
         public override void Initialize()
         {
             base.Initialize();
-            SubscribeLocalEvent<SolutionInjectOnCollideComponent, ComponentInit>(HandleInit);
             SubscribeLocalEvent<SolutionInjectOnCollideComponent, StartCollideEvent>(HandleInjection);
         }
 
-        private void HandleInit(EntityUid uid, SolutionInjectOnCollideComponent component, ComponentInit args)
-        {
-            component.Owner
-                .EnsureComponentWarn<SolutionContainerManagerComponent>($"{nameof(SolutionInjectOnCollideComponent)} requires a SolutionContainerManager on {component.Owner}!");
-        }
-
         private void HandleInjection(EntityUid uid, SolutionInjectOnCollideComponent component, ref StartCollideEvent args)
         {
             var target = args.OtherEntity;
index 98a62d39707c2abed9eeac1f63dba27fdeb43175..671b91392c40803c64fd6c7715fbc8a2b560a50d 100644 (file)
@@ -343,7 +343,7 @@ namespace Content.Server.Ghost.Roles
             if (ghostRole.MakeSentient)
                 MakeSentientCommand.MakeSentient(mob, EntityManager, ghostRole.AllowMovement, ghostRole.AllowSpeech);
 
-            mob.EnsureComponent<MindContainerComponent>();
+            EnsureComp<MindContainerComponent>(mob);
 
             GhostRoleInternalCreateMindAndTransfer(args.Player, uid, mob, ghostRole);
 
index ef96733a121255d211c52d9a9c5ce76407a89b61..e9dea0c66a21f9886469cd002f4806f4acb9de5a 100644 (file)
@@ -81,7 +81,7 @@ namespace Content.Server.Tabletop
                 CloseSessionFor(player, gamer.Tabletop, false);
 
             // Set the entity as an absolute GAMER.
-            attachedEntity.EnsureComponent<TabletopGamerComponent>().Tabletop = uid;
+            EnsureComp<TabletopGamerComponent>(attachedEntity).Tabletop = uid;
 
             // Create a camera for the gamer to use
             var camera = CreateCamera(tabletop, player);
@@ -139,7 +139,7 @@ namespace Content.Server.Tabletop
             var camera = EntityManager.SpawnEntity(null, session.Position.Offset(offset));
 
             // Add an eye component and disable FOV
-            var eyeComponent = camera.EnsureComponent<EyeComponent>();
+            var eyeComponent = EnsureComp<EyeComponent>(camera);
             _eye.SetDrawFov(camera, false, eyeComponent);
             _eye.SetZoom(camera, tabletop.CameraZoom, eyeComponent);
 
index 73313661de169d5ff1b1a9467c4879eed2fab826..1382dd45f49e0522ad2554590ce8f41142fbb55e 100644 (file)
@@ -1,31 +1,17 @@
+using Content.Shared.Singularity.EntitySystems;
 using Robust.Shared.GameStates;
-using Robust.Shared.Serialization;
 
 namespace Content.Shared.Singularity.Components
 {
     [RegisterComponent, NetworkedComponent]
     [AutoGenerateComponentState]
+    [Access(typeof(SharedSingularitySystem))]
     public sealed partial class SingularityDistortionComponent : Component
     {
-        // TODO: use access and remove this funny stuff
-        [DataField("intensity")]
-        private float _intensity = 31.25f;
+        [DataField, AutoNetworkedField, ViewVariables(VVAccess.ReadWrite)]
+        public float Intensity = 31.25f;
 
-        [DataField("falloffPower")]
-        private float _falloffPower = MathF.Sqrt(2f);
-
-        [ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
-        public float Intensity
-        {
-            get => _intensity;
-            set => this.SetAndDirtyIfChanged(ref _intensity, value);
-        }
-
-        [ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
-        public float FalloffPower
-        {
-            get => _falloffPower;
-            set => this.SetAndDirtyIfChanged(ref _falloffPower, value);
-        }
+        [DataField, AutoNetworkedField, ViewVariables(VVAccess.ReadWrite)]
+        public float FalloffPower = MathF.Sqrt(2f);
     }
 }
index 56be197e1df4dac779b4a4ae09e8f3ad03391564..2ea40308b9448dbc4e5b17f8aada16007fa04f2e 100644 (file)
@@ -312,6 +312,7 @@ public abstract class SharedSingularitySystem : EntitySystem
 
         comp.FalloffPower = newFalloffPower;
         comp.Intensity = newIntensity;
+        Dirty(uid, comp);
     }
 
     /// <summary>