Replace all T : Component constraints with T : IComponent (#21073)
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
|
using Content.Shared.Ghost;
|
||||||
using Content.Shared.StatusIcon;
|
using Content.Shared.StatusIcon;
|
||||||
using Content.Shared.StatusIcon.Components;
|
using Content.Shared.StatusIcon.Components;
|
||||||
using Robust.Shared.Prototypes;
|
|
||||||
using Content.Shared.Ghost;
|
|
||||||
using Robust.Client.Player;
|
using Robust.Client.Player;
|
||||||
|
using Robust.Shared.Prototypes;
|
||||||
|
|
||||||
namespace Content.Client.Antag;
|
namespace Content.Client.Antag;
|
||||||
|
|
||||||
@@ -10,7 +10,7 @@ namespace Content.Client.Antag;
|
|||||||
/// Used for assigning specified icons for antags.
|
/// Used for assigning specified icons for antags.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class AntagStatusIconSystem<T> : SharedStatusIconSystem
|
public abstract class AntagStatusIconSystem<T> : SharedStatusIconSystem
|
||||||
where T : Component
|
where T : IComponent
|
||||||
{
|
{
|
||||||
[Dependency] private readonly IPrototypeManager _prototype = default!;
|
[Dependency] private readonly IPrototypeManager _prototype = default!;
|
||||||
[Dependency] private readonly IPlayerManager _player = default!;
|
[Dependency] private readonly IPlayerManager _player = default!;
|
||||||
|
|||||||
@@ -428,7 +428,7 @@ we are just going to end this here to save a lot of time. This is the exception
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Helper method that retrieves all entity prototypes that have some component.
|
/// Helper method that retrieves all entity prototypes that have some component.
|
||||||
/// </summary>
|
/// </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 protoMan = instance.ResolveDependency<IPrototypeManager>();
|
||||||
var compFact = instance.ResolveDependency<IComponentFactory>();
|
var compFact = instance.ResolveDependency<IComponentFactory>();
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ using Content.Server.GameTicking.Rules.Components;
|
|||||||
|
|
||||||
namespace Content.Server.GameTicking.Rules;
|
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 IChatManager ChatManager = default!;
|
||||||
[Dependency] protected readonly GameTicker GameTicker = default!;
|
[Dependency] protected readonly GameTicker GameTicker = default!;
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
using System.Numerics;
|
||||||
using Content.Server.ParticleAccelerator.Components;
|
using Content.Server.ParticleAccelerator.Components;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Server.Player;
|
using Robust.Server.Player;
|
||||||
using Robust.Shared.Map.Components;
|
using Robust.Shared.Map.Components;
|
||||||
using Robust.Shared.Physics.Events;
|
using Robust.Shared.Physics.Events;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
|
||||||
using System.Numerics;
|
|
||||||
|
|
||||||
namespace Content.Server.ParticleAccelerator.EntitySystems;
|
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)
|
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))
|
if (!Resolve(uid, ref grid))
|
||||||
{
|
{
|
||||||
part = null;
|
part = null;
|
||||||
comp = null;
|
comp = default;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Linq;
|
|
||||||
using Content.Server.Administration.Logs;
|
using Content.Server.Administration.Logs;
|
||||||
using Content.Server.Atmos.EntitySystems;
|
using Content.Server.Atmos.EntitySystems;
|
||||||
using Content.Server.Chat.Systems;
|
using Content.Server.Chat.Systems;
|
||||||
@@ -22,7 +21,7 @@ namespace Content.Server.StationEvents.Events;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// An abstract entity system inherited by all station events for their behavior.
|
/// An abstract entity system inherited by all station events for their behavior.
|
||||||
/// </summary>
|
/// </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] protected readonly IAdminLogManager AdminLogManager = default!;
|
||||||
[Dependency] private readonly IGameTiming _timing = default!;
|
[Dependency] private readonly IGameTiming _timing = default!;
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ public partial class SharedBodySystem
|
|||||||
public List<(T Comp, OrganComponent Organ)> GetBodyOrganComponents<T>(
|
public List<(T Comp, OrganComponent Organ)> GetBodyOrganComponents<T>(
|
||||||
EntityUid uid,
|
EntityUid uid,
|
||||||
BodyComponent? body = null)
|
BodyComponent? body = null)
|
||||||
where T : Component
|
where T : IComponent
|
||||||
{
|
{
|
||||||
if (!Resolve(uid, ref body))
|
if (!Resolve(uid, ref body))
|
||||||
return new List<(T Comp, OrganComponent Organ)>();
|
return new List<(T Comp, OrganComponent Organ)>();
|
||||||
@@ -180,7 +180,7 @@ public partial class SharedBodySystem
|
|||||||
EntityUid uid,
|
EntityUid uid,
|
||||||
[NotNullWhen(true)] out List<(T Comp, OrganComponent Organ)>? comps,
|
[NotNullWhen(true)] out List<(T Comp, OrganComponent Organ)>? comps,
|
||||||
BodyComponent? body = null)
|
BodyComponent? body = null)
|
||||||
where T : Component
|
where T : IComponent
|
||||||
{
|
{
|
||||||
if (!Resolve(uid, ref body))
|
if (!Resolve(uid, ref body))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -679,7 +679,7 @@ public partial class SharedBodySystem
|
|||||||
public List<(T Comp, OrganComponent Organ)> GetBodyPartOrganComponents<T>(
|
public List<(T Comp, OrganComponent Organ)> GetBodyPartOrganComponents<T>(
|
||||||
EntityUid uid,
|
EntityUid uid,
|
||||||
BodyPartComponent? part = null)
|
BodyPartComponent? part = null)
|
||||||
where T : Component
|
where T : IComponent
|
||||||
{
|
{
|
||||||
if (!Resolve(uid, ref part))
|
if (!Resolve(uid, ref part))
|
||||||
return new List<(T Comp, OrganComponent Organ)>();
|
return new List<(T Comp, OrganComponent Organ)>();
|
||||||
@@ -709,7 +709,7 @@ public partial class SharedBodySystem
|
|||||||
EntityUid uid,
|
EntityUid uid,
|
||||||
[NotNullWhen(true)] out List<(T Comp, OrganComponent Organ)>? comps,
|
[NotNullWhen(true)] out List<(T Comp, OrganComponent Organ)>? comps,
|
||||||
BodyPartComponent? part = null)
|
BodyPartComponent? part = null)
|
||||||
where T : Component
|
where T : IComponent
|
||||||
{
|
{
|
||||||
if (!Resolve(uid, ref part))
|
if (!Resolve(uid, ref part))
|
||||||
{
|
{
|
||||||
@@ -751,7 +751,7 @@ public partial class SharedBodySystem
|
|||||||
public IEnumerable<(EntityUid AdjacentId, T Component)> GetBodyPartAdjacentPartsComponents<T>(
|
public IEnumerable<(EntityUid AdjacentId, T Component)> GetBodyPartAdjacentPartsComponents<T>(
|
||||||
EntityUid partId,
|
EntityUid partId,
|
||||||
BodyPartComponent? part = null)
|
BodyPartComponent? part = null)
|
||||||
where T : Component
|
where T : IComponent
|
||||||
{
|
{
|
||||||
if (!Resolve(partId, ref part, false))
|
if (!Resolve(partId, ref part, false))
|
||||||
yield break;
|
yield break;
|
||||||
@@ -768,7 +768,7 @@ public partial class SharedBodySystem
|
|||||||
EntityUid partId,
|
EntityUid partId,
|
||||||
[NotNullWhen(true)] out List<(EntityUid AdjacentId, T Component)>? comps,
|
[NotNullWhen(true)] out List<(EntityUid AdjacentId, T Component)>? comps,
|
||||||
BodyPartComponent? part = null)
|
BodyPartComponent? part = null)
|
||||||
where T : Component
|
where T : IComponent
|
||||||
{
|
{
|
||||||
if (!Resolve(partId, ref part, false))
|
if (!Resolve(partId, ref part, false))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -292,7 +292,7 @@ public abstract class SharedMindSystem : EntitySystem
|
|||||||
return true;
|
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))
|
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;
|
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))
|
if (Resolve(mindId, ref mind))
|
||||||
{
|
{
|
||||||
@@ -382,9 +382,9 @@ public abstract class SharedMindSystem : EntitySystem
|
|||||||
/// Gets a role component from a player's mind.
|
/// Gets a role component from a player's mind.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Whether a role was found</returns>
|
/// <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)
|
if (!TryComp<MindContainerComponent>(user, out var mindContainer) || mindContainer.Mind == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ public abstract class SharedRoleSystem : EntitySystem
|
|||||||
/// <exception cref="ArgumentException">
|
/// <exception cref="ArgumentException">
|
||||||
/// Thrown if we already have a role with this type.
|
/// Thrown if we already have a role with this type.
|
||||||
/// </exception>
|
/// </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))
|
if (!Resolve(mindId, ref mind))
|
||||||
return;
|
return;
|
||||||
@@ -99,7 +99,7 @@ public abstract class SharedRoleSystem : EntitySystem
|
|||||||
/// <exception cref="ArgumentException">
|
/// <exception cref="ArgumentException">
|
||||||
/// Thrown if we do not have this role.
|
/// Thrown if we do not have this role.
|
||||||
/// </exception>
|
/// </exception>
|
||||||
public void MindRemoveRole<T>(EntityUid mindId) where T : Component
|
public void MindRemoveRole<T>(EntityUid mindId) where T : IComponent
|
||||||
{
|
{
|
||||||
if (!RemComp<T>(mindId))
|
if (!RemComp<T>(mindId))
|
||||||
{
|
{
|
||||||
@@ -118,7 +118,7 @@ public abstract class SharedRoleSystem : EntitySystem
|
|||||||
$"'Role {typeof(T).Name}' removed from mind of {_minds.MindOwnerLoggingString(mind)}");
|
$"'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))
|
if (!MindHasRole<T>(mindId))
|
||||||
return false;
|
return false;
|
||||||
@@ -127,7 +127,7 @@ public abstract class SharedRoleSystem : EntitySystem
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool MindHasRole<T>(EntityUid mindId) where T : Component
|
public bool MindHasRole<T>(EntityUid mindId) where T : IComponent
|
||||||
{
|
{
|
||||||
return HasComp<T>(mindId);
|
return HasComp<T>(mindId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using Content.Shared.Alert;
|
using Content.Shared.Alert;
|
||||||
using Content.Shared.Mobs;
|
|
||||||
using Content.Shared.Mobs.Components;
|
|
||||||
using Content.Shared.Mobs.Systems;
|
|
||||||
using Content.Shared.Rejuvenate;
|
using Content.Shared.Rejuvenate;
|
||||||
using Robust.Shared.GameStates;
|
using Robust.Shared.GameStates;
|
||||||
using Robust.Shared.Prototypes;
|
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>
|
/// <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,
|
public bool TryAddStatusEffect<T>(EntityUid uid, string key, TimeSpan time, bool refresh,
|
||||||
StatusEffectsComponent? status = null)
|
StatusEffectsComponent? status = null)
|
||||||
where T : Component, new()
|
where T : IComponent, new()
|
||||||
{
|
{
|
||||||
if (!Resolve(uid, ref status, false))
|
if (!Resolve(uid, ref status, false))
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user