Skip to content

Game.Common.Applied

Assembly: (not specified in source)

Namespace: Game.Common

Type: struct

Base: System.ValueType

Summary:
Applied is an empty (tag) ECS component used to mark or flag entities. It implements IComponentData so it can be attached to Unity.Entities entities and IQueryTypeParameter to allow use in query-type parameters. The StructLayout attribute with Size = 1 makes the struct occupy at least one byte (avoiding being treated as an "empty" type by native interop/layout), which is a common pattern for marker components in DOTS-based code.


Fields

  • This struct declares no instance fields; it is an empty/tag component used purely for marking entities.
  • Rationale: empty tag components are lightweight markers used for filtering or signaling state without storing data.

Properties

  • None.
  • Rationale: the component carries no data or properties — presence/absence of the component is the data.

Constructors

  • Implicit public parameterless constructor (provided by C# for structs).
  • Usage: you can create the default value with new Applied() or simply attach the component type to an entity via the ECS API.

Methods

  • None.
  • Rationale: behaviour is implemented by systems that query for this component; the component itself contains no logic.

Usage Example

using Unity.Entities;
using Game.Common;

public partial class ExampleApplySystem : SystemBase
{
    protected override void OnUpdate()
    {
        var em = EntityManager;

        // Create a new entity that has the Applied tag
        Entity e = em.CreateEntity(typeof(Applied));

        // Alternatively add the tag to an existing entity
        // em.AddComponent<Applied>(existingEntity);

        // Check for the tag
        if (em.HasComponent<Applied>(e))
        {
            // Do something for entities that are "Applied"
        }

        // Query over all entities that have the Applied tag
        Entities
            .WithAll<Applied>()
            .ForEach((Entity entity) =>
            {
                // Process tagged entities here
            })
            .Schedule();
    }
}

Notes and tips: - Because Applied is a tag component, prefer query-based processing (WithAll/WithAny) rather than reading fields from the component. - The small explicit size (StructLayout(Size = 1)) ensures the type is non-empty for native interop and consistent layout expectations when used with low-level APIs.