Game.Tools.CreationDefinition
Assembly: Game (assembly containing Game.Tools)
Namespace: Game.Tools
Type: struct
Base: System.ValueType, Unity.Entities.IComponentData, Unity.Entities.IQueryTypeParameter
Summary:
CreationDefinition is an ECS component (IComponentData) used to describe parameters for creating or instantiating entities in the game's tool/creation systems. It holds references to prefab entities (primary and sub), the original source entity, ownership/attachment relationships, creation flags that alter behavior, and a random seed for deterministic/randomized creation behavior.
Fields
-
public Unity.Entities.Entity m_Prefab
The primary prefab Entity to instantiate/construct. -
public Unity.Entities.Entity m_SubPrefab
An optional sub-prefab Entity associated with the creation (e.g., a secondary/mirrored part). -
public Unity.Entities.Entity m_Original
Reference to the original/source Entity this creation is derived from (if any). -
public Unity.Entities.Entity m_Owner
Entity that should be considered the owner of the created entity (used for linking or permission logic). -
public Unity.Entities.Entity m_Attached
Entity to which the created entity should be attached (parent/slot linking). -
public CreationFlags m_Flags
Flags (enum/bitmask) that control creation behavior/options. Controls special-case behavior for the creation process (see CreationFlags definition in codebase). -
public int m_RandomSeed
Integer seed used to drive deterministic/randomized aspects of the creation (so results can be replicated if needed).
Properties
This type defines no properties. It is a plain data-oriented struct exposing public fields for ECS usage.
Constructors
public CreationDefinition()
Structs have an implicit parameterless constructor; all fields default to their default values (Entity.Null for Entity fields, zero for integers, default enum value for CreationFlags).
Methods
This type declares no methods. It is a POD (plain-old-data) ECS component used for passing creation parameters via the EntityManager / component queries.
Usage Example
using Unity.Entities;
using Unity.Mathematics;
using Game.Tools; // for CreationDefinition and CreationFlags
// Example: assign a CreationDefinition to an existing entity
void AssignCreationDefinition(EntityManager entityManager, Entity targetEntity, Entity prefabEntity, Entity owner)
{
var def = new CreationDefinition
{
m_Prefab = prefabEntity,
m_SubPrefab = Entity.Null,
m_Original = Entity.Null,
m_Owner = owner,
m_Attached = Entity.Null,
m_Flags = CreationFlags.None, // adjust as appropriate
m_RandomSeed = new Unity.Mathematics.Random((uint)System.DateTime.Now.Ticks).NextInt()
};
// Add or set the component on the target entity
if (!entityManager.HasComponent<CreationDefinition>(targetEntity))
entityManager.AddComponentData(targetEntity, def);
else
entityManager.SetComponentData(targetEntity, def);
}
Notes: - Because CreationDefinition implements IComponentData and IQueryTypeParameter, it is intended to be used with the Unity DOTS ECS (EntityManager, queries, systems). - CreationFlags is referenced here as an enum/bitmask in the codebase — consult its declaration for available options and intended semantics.