Skip to content

Game.Prefabs.Locked

Assembly:
Game (game-specific assembly containing prefab-related components)

Namespace:
Game.Prefabs

Type:
struct

Base:
System.ValueType
Implements: IComponentData, IQueryTypeParameter, IEnableableComponent, IEmptySerializable

Summary:
A small marker (empty) ECS component used to mark prefabs or entities as "locked". It contains no payload data and exists solely as a tag. The struct is annotated with StructLayout(LayoutKind.Sequential, Size = 1) to ensure a non-zero, predictable size for native/serialization code. Implements IEnableableComponent so the tag can be enabled or disabled on an entity, IQueryTypeParameter so it can be used in ECS queries, and IEmptySerializable to participate correctly in the game's/custom serialization systems.


Fields

  • This struct has no instance fields; it is intentionally empty (marker component).
    The StructLayout(Size = 1) attribute guarantees a size of 1 byte for interoperability and serialization despite being empty.

Properties

  • None. This is an empty marker component and exposes no properties.

Constructors

  • public Locked()
    The default parameterless constructor is provided implicitly for the value type. No initialization is required because the component carries no state.

Methods

  • None. The type provides no methods; behavior is driven by presence/absence (and enabled state) of the component on entities.

Usage Example

// Add the marker to an entity:
entityManager.AddComponent<Locked>(entity);

// Remove the marker:
entityManager.RemoveComponent<Locked>(entity);

// Enable or disable the marker (IEnableableComponent support):
entityManager.SetComponentEnabled<Locked>(entity, true);  // enable
entityManager.SetComponentEnabled<Locked>(entity, false); // disable

// Query for entities that have the Locked tag:
var query = entityManager.CreateEntityQuery(typeof(Locked));
// or using a query builder in a SystemBase:
Entities.WithAll<Locked>().ForEach((Entity e) => { /* ... */ }).Schedule();

Additional notes: - Because Locked implements IEmptySerializable, it is compatible with the game's serialization systems for prefabs and entities, allowing empty/tag components to be saved/loaded correctly. - Treat this component as a marker only; any "locked" semantics (e.g., preventing edits, UI changes) must be enforced by game logic that checks for the presence or enabled state of this component.