Table of Contents

Interface ITagCapability

Namespace
KeenEyes.Capabilities
Assembly
KeenEyes.Abstractions.dll

Capability interface for string-based entity tagging.

public interface ITagCapability

Examples

public void Install(IPluginContext context)
{
    if (context.TryGetCapability<ITagCapability>(out var tags))
    {
        // Add tags to entities
        tags.AddTag(entity, "Enemy");
        tags.AddTag(entity, "Boss");

        // Query by tag
        foreach (var enemy in tags.QueryByTag("Enemy"))
        {
            // Process enemies
        }
    }
}

Remarks

This capability provides runtime-flexible tagging for scenarios like designer-driven content tagging, serialization, and editor tooling. Unlike type-safe tag components, string tags can be assigned dynamically without compile-time type definitions.

Plugins that need to work with string tags should request this capability via GetCapability<T>() rather than casting to the concrete World type.

Methods

AddTag(Entity, string)

Adds a string tag to an entity.

bool AddTag(Entity entity, string tag)

Parameters

entity Entity

The entity to add the tag to.

tag string

The tag to add. Cannot be null, empty, or whitespace.

Returns

bool

True if the tag was added; false if the entity already had the tag.

Exceptions

InvalidOperationException

Thrown when the entity is not alive.

ArgumentNullException

Thrown when tag is null.

ArgumentException

Thrown when tag is empty or whitespace.

GetTags(Entity)

Gets all string tags on an entity.

IReadOnlyCollection<string> GetTags(Entity entity)

Parameters

entity Entity

The entity to get tags for.

Returns

IReadOnlyCollection<string>

A read-only collection of tags on the entity. Returns an empty collection if the entity is not alive or has no tags.

HasTag(Entity, string)

Checks if an entity has a specific string tag.

bool HasTag(Entity entity, string tag)

Parameters

entity Entity

The entity to check.

tag string

The tag to check for. Cannot be null, empty, or whitespace.

Returns

bool

True if the entity is alive and has the specified tag.

Exceptions

ArgumentNullException

Thrown when tag is null.

ArgumentException

Thrown when tag is empty or whitespace.

QueryByTag(string)

Gets all entities that have a specific string tag.

IEnumerable<Entity> QueryByTag(string tag)

Parameters

tag string

The tag to query for. Cannot be null, empty, or whitespace.

Returns

IEnumerable<Entity>

An enumerable of entities that have the specified tag.

Exceptions

ArgumentNullException

Thrown when tag is null.

ArgumentException

Thrown when tag is empty or whitespace.

RemoveTag(Entity, string)

Removes a string tag from an entity.

bool RemoveTag(Entity entity, string tag)

Parameters

entity Entity

The entity to remove the tag from.

tag string

The tag to remove. Cannot be null, empty, or whitespace.

Returns

bool

True if the tag was removed; false if the entity didn't have the tag.

Exceptions

InvalidOperationException

Thrown when the entity is not alive.

ArgumentNullException

Thrown when tag is null.

ArgumentException

Thrown when tag is empty or whitespace.