Replace all T : Component constraints with T : IComponent (#21073)

This commit is contained in:
DrSmugleaf
2023-10-17 19:42:47 -07:00
committed by GitHub
parent a136616531
commit 5934c6728f
10 changed files with 25 additions and 29 deletions

View 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!;

View 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>();

View 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!;

View 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;
}

View 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!;

View 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))
{

View 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))
{

View 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;

View 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);
}

View 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;