]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Replace all T : Component constraints with T : IComponent (#21073)
authorDrSmugleaf <DrSmugleaf@users.noreply.github.com>
Wed, 18 Oct 2023 02:42:47 +0000 (19:42 -0700)
committerGitHub <noreply@github.com>
Wed, 18 Oct 2023 02:42:47 +0000 (19:42 -0700)
Content.Client/Antag/AntagStatusIconSystem.cs
Content.IntegrationTests/PoolManager.cs
Content.Server/GameTicking/Rules/GameRuleSystem.cs
Content.Server/ParticleAccelerator/EntitySystems/ParticleAcceleratorSystem.Parts.cs
Content.Server/StationEvents/Events/StationEventSystem.cs
Content.Shared/Body/Systems/SharedBodySystem.Organs.cs
Content.Shared/Body/Systems/SharedBodySystem.Parts.cs
Content.Shared/Mind/SharedMindSystem.cs
Content.Shared/Roles/SharedRoleSystem.cs
Content.Shared/StatusEffect/StatusEffectsSystem.cs

index 3c1c72d03b9de5720c651d28a83dce2e14f92a3d..bf3955b49ab1edfe3eb0cbb40f5a7b5432c5ae2a 100644 (file)
@@ -1,8 +1,8 @@
+using Content.Shared.Ghost;
 using Content.Shared.StatusIcon;
 using Content.Shared.StatusIcon.Components;
-using Robust.Shared.Prototypes;
-using Content.Shared.Ghost;
 using Robust.Client.Player;
+using Robust.Shared.Prototypes;
 
 namespace Content.Client.Antag;
 
@@ -10,7 +10,7 @@ namespace Content.Client.Antag;
 /// Used for assigning specified icons for antags.
 /// </summary>
 public abstract class AntagStatusIconSystem<T> : SharedStatusIconSystem
-    where T : Component
+    where T : IComponent
 {
     [Dependency] private readonly IPrototypeManager _prototype = default!;
     [Dependency] private readonly IPlayerManager _player = default!;
index 3f8d261e8dda80ab2388c754a30407256164e961..a2015f3fdba20af11b68cd218f2d67fe46c00da9 100644 (file)
@@ -428,7 +428,7 @@ we are just going to end this here to save a lot of time. This is the exception
     /// <summary>
     ///     Helper method that retrieves all entity prototypes that have some component.
     /// </summary>
-    public static List<EntityPrototype> GetPrototypesWithComponent<T>(RobustIntegrationTest.IntegrationInstance instance) where T : Component
+    public static List<EntityPrototype> GetPrototypesWithComponent<T>(RobustIntegrationTest.IntegrationInstance instance) where T : IComponent
     {
         var protoMan = instance.ResolveDependency<IPrototypeManager>();
         var compFact = instance.ResolveDependency<IComponentFactory>();
index b13f00f36383a3345c35ed322c8e2e744fb82253..ba781e32e298dc12a097f52e778e83bd72825fa4 100644 (file)
@@ -3,7 +3,7 @@ using Content.Server.GameTicking.Rules.Components;
 
 namespace Content.Server.GameTicking.Rules;
 
-public abstract partial class GameRuleSystem<T> : EntitySystem where T : Component
+public abstract partial class GameRuleSystem<T> : EntitySystem where T : IComponent
 {
     [Dependency] protected readonly IChatManager ChatManager = default!;
     [Dependency] protected readonly GameTicker GameTicker = default!;
index 860fbdcefe3bdcbed9374b5397837325e34ed742..e76d85781023b0893729163a34d4d64c4b833b93 100644 (file)
@@ -1,10 +1,10 @@
+using System.Diagnostics.CodeAnalysis;
+using System.Numerics;
 using Content.Server.ParticleAccelerator.Components;
 using JetBrains.Annotations;
 using Robust.Server.Player;
 using Robust.Shared.Map.Components;
 using Robust.Shared.Physics.Events;
-using System.Diagnostics.CodeAnalysis;
-using System.Numerics;
 
 namespace Content.Server.ParticleAccelerator.EntitySystems;
 
@@ -127,12 +127,12 @@ public sealed partial class ParticleAcceleratorSystem
     }
 
     private bool ScanPart<T>(EntityUid uid, Vector2i coordinates, Angle? rotation, [NotNullWhen(true)] out EntityUid? part, [NotNullWhen(true)] out T? comp, MapGridComponent? grid = null)
-        where T : Component
+        where T : IComponent
     {
         if (!Resolve(uid, ref grid))
         {
             part = null;
-            comp = null;
+            comp = default;
             return false;
         }
 
index 97b96ff7b0bdc251d32780fc495bc6958af4e9d3..41a7b153f58c0c21eb122c539cd8fb781eaf759f 100644 (file)
@@ -1,5 +1,4 @@
 using System.Diagnostics.CodeAnalysis;
-using System.Linq;
 using Content.Server.Administration.Logs;
 using Content.Server.Atmos.EntitySystems;
 using Content.Server.Chat.Systems;
@@ -22,7 +21,7 @@ namespace Content.Server.StationEvents.Events;
 /// <summary>
 ///     An abstract entity system inherited by all station events for their behavior.
 /// </summary>
-public abstract partial class StationEventSystem<T> : GameRuleSystem<T> where T : Component
+public abstract partial class StationEventSystem<T> : GameRuleSystem<T> where T : IComponent
 {
     [Dependency] protected readonly IAdminLogManager AdminLogManager = default!;
     [Dependency] private readonly IGameTiming _timing = default!;
index d2a7b7256ae85bd16a7b0e252c453e654b0922f7..6e392b9892c25d7b3899735a2640249c3c7f019e 100644 (file)
@@ -151,7 +151,7 @@ public partial class SharedBodySystem
     public List<(T Comp, OrganComponent Organ)> GetBodyOrganComponents<T>(
         EntityUid uid,
         BodyComponent? body = null)
-        where T : Component
+        where T : IComponent
     {
         if (!Resolve(uid, ref body))
             return new List<(T Comp, OrganComponent Organ)>();
@@ -180,7 +180,7 @@ public partial class SharedBodySystem
         EntityUid uid,
         [NotNullWhen(true)] out List<(T Comp, OrganComponent Organ)>? comps,
         BodyComponent? body = null)
-        where T : Component
+        where T : IComponent
     {
         if (!Resolve(uid, ref body))
         {
index 66397017e14fcac3745fc149454d34fad85feb25..463a4b7661a9253faed81ba6c3cd3a9e61adad9f 100644 (file)
@@ -679,7 +679,7 @@ public partial class SharedBodySystem
     public List<(T Comp, OrganComponent Organ)> GetBodyPartOrganComponents<T>(
         EntityUid uid,
         BodyPartComponent? part = null)
-        where T : Component
+        where T : IComponent
     {
         if (!Resolve(uid, ref part))
             return new List<(T Comp, OrganComponent Organ)>();
@@ -709,7 +709,7 @@ public partial class SharedBodySystem
         EntityUid uid,
         [NotNullWhen(true)] out List<(T Comp, OrganComponent Organ)>? comps,
         BodyPartComponent? part = null)
-        where T : Component
+        where T : IComponent
     {
         if (!Resolve(uid, ref part))
         {
@@ -751,7 +751,7 @@ public partial class SharedBodySystem
     public IEnumerable<(EntityUid AdjacentId, T Component)> GetBodyPartAdjacentPartsComponents<T>(
         EntityUid partId,
         BodyPartComponent? part = null)
-        where T : Component
+        where T : IComponent
     {
         if (!Resolve(partId, ref part, false))
             yield break;
@@ -768,7 +768,7 @@ public partial class SharedBodySystem
         EntityUid partId,
         [NotNullWhen(true)] out List<(EntityUid AdjacentId, T Component)>? comps,
         BodyPartComponent? part = null)
-        where T : Component
+        where T : IComponent
     {
         if (!Resolve(partId, ref part, false))
         {
index be11d8a2ad4c85b18978631745274f98cf2ab40d..cc4ac4af23675c5ff2ed38b689d6de3df9c86bb1 100644 (file)
@@ -292,7 +292,7 @@ public abstract class SharedMindSystem : EntitySystem
         return true;
     }
 
-    public bool TryGetObjectiveComp<T>(EntityUid uid, [NotNullWhen(true)] out T? objective) where T : Component
+    public bool TryGetObjectiveComp<T>(EntityUid uid, [NotNullWhen(true)] out T? objective) where T : IComponent
     {
         if (TryGetMind(uid, out var mindId, out var mind) && TryGetObjectiveComp(mindId, out objective, mind))
         {
@@ -302,7 +302,7 @@ public abstract class SharedMindSystem : EntitySystem
         return false;
     }
 
-    public bool TryGetObjectiveComp<T>(EntityUid mindId, [NotNullWhen(true)] out T? objective, MindComponent? mind = null) where T : Component
+    public bool TryGetObjectiveComp<T>(EntityUid mindId, [NotNullWhen(true)] out T? objective, MindComponent? mind = null) where T : IComponent
     {
         if (Resolve(mindId, ref mind))
         {
@@ -382,9 +382,9 @@ public abstract class SharedMindSystem : EntitySystem
     /// Gets a role component from a player's mind.
     /// </summary>
     /// <returns>Whether a role was found</returns>
-    public bool TryGetRole<T>(EntityUid user, [NotNullWhen(true)] out T? role) where T : Component
+    public bool TryGetRole<T>(EntityUid user, [NotNullWhen(true)] out T? role) where T : IComponent
     {
-        role = null;
+        role = default;
         if (!TryComp<MindContainerComponent>(user, out var mindContainer) || mindContainer.Mind == null)
             return false;
 
index 75296b96f4a5a6db1bcc0916e2dcd8a82b8aeb62..ebd6730bbe47e27bc8b92c602581dad943bc7f67 100644 (file)
@@ -65,7 +65,7 @@ public abstract class SharedRoleSystem : EntitySystem
     /// <exception cref="ArgumentException">
     ///     Thrown if we already have a role with this type.
     /// </exception>
-    public void MindAddRole<T>(EntityUid mindId, T component, MindComponent? mind = null, bool silent = false) where T : Component, new()
+    public void MindAddRole<T>(EntityUid mindId, T component, MindComponent? mind = null, bool silent = false) where T : IComponent, new()
     {
         if (!Resolve(mindId, ref mind))
             return;
@@ -99,7 +99,7 @@ public abstract class SharedRoleSystem : EntitySystem
     /// <exception cref="ArgumentException">
     ///     Thrown if we do not have this role.
     /// </exception>
-    public void MindRemoveRole<T>(EntityUid mindId) where T : Component
+    public void MindRemoveRole<T>(EntityUid mindId) where T : IComponent
     {
         if (!RemComp<T>(mindId))
         {
@@ -118,7 +118,7 @@ public abstract class SharedRoleSystem : EntitySystem
             $"'Role {typeof(T).Name}' removed from mind of {_minds.MindOwnerLoggingString(mind)}");
     }
 
-    public bool MindTryRemoveRole<T>(EntityUid mindId) where T : Component
+    public bool MindTryRemoveRole<T>(EntityUid mindId) where T : IComponent
     {
         if (!MindHasRole<T>(mindId))
             return false;
@@ -127,7 +127,7 @@ public abstract class SharedRoleSystem : EntitySystem
         return true;
     }
 
-    public bool MindHasRole<T>(EntityUid mindId) where T : Component
+    public bool MindHasRole<T>(EntityUid mindId) where T : IComponent
     {
         return HasComp<T>(mindId);
     }
index bedc5a824ce2eaf4be1fc74e5316d5006c60ef71..17b886449301f1916b3bcc373171f8631d6e619d 100644 (file)
@@ -1,8 +1,5 @@
 using System.Diagnostics.CodeAnalysis;
 using Content.Shared.Alert;
-using Content.Shared.Mobs;
-using Content.Shared.Mobs.Components;
-using Content.Shared.Mobs.Systems;
 using Content.Shared.Rejuvenate;
 using Robust.Shared.GameStates;
 using Robust.Shared.Prototypes;
@@ -107,7 +104,7 @@ namespace Content.Shared.StatusEffect
         /// <typeparam name="T">The component type to add and remove from the entity.</typeparam>
         public bool TryAddStatusEffect<T>(EntityUid uid, string key, TimeSpan time, bool refresh,
             StatusEffectsComponent? status = null)
-            where T : Component, new()
+            where T : IComponent, new()
         {
             if (!Resolve(uid, ref status, false))
                 return false;