Add new HasAnyTag and HasAllTags overrides (#22577)
* Add new HasAnyTag and HasAllTags overrides * Add missing overrides
This commit is contained in:
@@ -188,6 +188,17 @@ public sealed class TagSystem : EntitySystem
|
|||||||
HasTag(component, id);
|
HasTag(component, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks if all of the given tags have been added to an entity.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity">The entity to check.</param>
|
||||||
|
/// <param name="id">The tags to check for.</param>
|
||||||
|
/// <returns>true if they all exist, false otherwise.</returns>
|
||||||
|
/// <exception cref="UnknownPrototypeException">
|
||||||
|
/// Thrown if one of the ids represents an unregistered <see cref="TagPrototype"/>.
|
||||||
|
/// </exception>
|
||||||
|
public bool HasAllTags(EntityUid entity, string id) => HasTag(entity, id);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Checks if all of the given tags have been added to an entity.
|
/// Checks if all of the given tags have been added to an entity.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -197,7 +208,7 @@ public sealed class TagSystem : EntitySystem
|
|||||||
/// <exception cref="UnknownPrototypeException">
|
/// <exception cref="UnknownPrototypeException">
|
||||||
/// Thrown if one of the ids represents an unregistered <see cref="TagPrototype"/>.
|
/// Thrown if one of the ids represents an unregistered <see cref="TagPrototype"/>.
|
||||||
/// </exception>
|
/// </exception>
|
||||||
public bool HasAllTags(EntityUid entity, params string[] ids)
|
public bool HasAllTags(EntityUid entity, List<string> ids)
|
||||||
{
|
{
|
||||||
return TryComp<TagComponent>(entity, out var component) &&
|
return TryComp<TagComponent>(entity, out var component) &&
|
||||||
HasAllTags(component, ids);
|
HasAllTags(component, ids);
|
||||||
@@ -233,6 +244,32 @@ public sealed class TagSystem : EntitySystem
|
|||||||
HasAnyTag(component, ids);
|
HasAnyTag(component, ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks if all of the given tags have been added to an entity.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity">The entity to check.</param>
|
||||||
|
/// <param name="id">The tag to check for.</param>
|
||||||
|
/// <returns>true if any of them exist, false otherwise.</returns>
|
||||||
|
/// <exception cref="UnknownPrototypeException">
|
||||||
|
/// Thrown if one of the ids represents an unregistered <see cref="TagPrototype"/>.
|
||||||
|
/// </exception>
|
||||||
|
public bool HasAnyTag(EntityUid entity, string id) => HasTag(entity, id);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks if all of the given tags have been added to an entity.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity">The entity to check.</param>
|
||||||
|
/// <param name="ids">The tags to check for.</param>
|
||||||
|
/// <returns>true if any of them exist, false otherwise.</returns>
|
||||||
|
/// <exception cref="UnknownPrototypeException">
|
||||||
|
/// Thrown if one of the ids represents an unregistered <see cref="TagPrototype"/>.
|
||||||
|
/// </exception>
|
||||||
|
public bool HasAnyTag(EntityUid entity, List<string> ids)
|
||||||
|
{
|
||||||
|
return TryComp<TagComponent>(entity, out var component) &&
|
||||||
|
HasAnyTag(component, ids);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Checks if all of the given tags have been added to an entity.
|
/// Checks if all of the given tags have been added to an entity.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -388,6 +425,37 @@ public sealed class TagSystem : EntitySystem
|
|||||||
return HasAllTags(component, ids.AsEnumerable());
|
return HasAllTags(component, ids.AsEnumerable());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks if all of the given tags have been added.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">The tag to check for.</param>
|
||||||
|
/// <returns>true if they all exist, false otherwise.</returns>
|
||||||
|
/// <exception cref="UnknownPrototypeException">
|
||||||
|
/// Thrown if one of the ids represents an unregistered <see cref="TagPrototype"/>.
|
||||||
|
/// </exception>
|
||||||
|
public bool HasAllTags(TagComponent component, string id) => HasTag(component, id);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks if all of the given tags have been added.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ids">The tags to check for.</param>
|
||||||
|
/// <returns>true if they all exist, false otherwise.</returns>
|
||||||
|
/// <exception cref="UnknownPrototypeException">
|
||||||
|
/// Thrown if one of the ids represents an unregistered <see cref="TagPrototype"/>.
|
||||||
|
/// </exception>
|
||||||
|
public bool HasAllTags(TagComponent component, List<string> ids)
|
||||||
|
{
|
||||||
|
foreach (var id in ids)
|
||||||
|
{
|
||||||
|
AssertValidTag(id);
|
||||||
|
|
||||||
|
if (!component.Tags.Contains(id))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Checks if all of the given tags have been added.
|
/// Checks if all of the given tags have been added.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -423,6 +491,40 @@ public sealed class TagSystem : EntitySystem
|
|||||||
return HasAnyTag(component, ids.AsEnumerable());
|
return HasAnyTag(component, ids.AsEnumerable());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks if any of the given tags have been added.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">The tag to check for.</param>
|
||||||
|
/// <returns>true if any of them exist, false otherwise.</returns>
|
||||||
|
/// <exception cref="UnknownPrototypeException">
|
||||||
|
/// Thrown if one of the ids represents an unregistered <see cref="TagPrototype"/>.
|
||||||
|
/// </exception>
|
||||||
|
public bool HasAnyTag(TagComponent component, string id) => HasTag(component, id);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks if any of the given tags have been added.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ids">The tags to check for.</param>
|
||||||
|
/// <returns>true if any of them exist, false otherwise.</returns>
|
||||||
|
/// <exception cref="UnknownPrototypeException">
|
||||||
|
/// Thrown if one of the ids represents an unregistered <see cref="TagPrototype"/>.
|
||||||
|
/// </exception>
|
||||||
|
public bool HasAnyTag(TagComponent component, List<string> ids)
|
||||||
|
{
|
||||||
|
foreach (var id in ids)
|
||||||
|
{
|
||||||
|
AssertValidTag(id);
|
||||||
|
|
||||||
|
if (component.Tags.Contains(id))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Checks if any of the given tags have been added.
|
/// Checks if any of the given tags have been added.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user