Skip to content

Game.Prefabs.CreatureSpawnData

Assembly: Assembly-CSharp (typical Unity runtime/user scripts assembly)
Namespace: Game.Prefabs

Type: struct

Base: System.ValueType
Implements: Unity.Entities.IComponentData, Unity.Entities.IQueryTypeParameter

Summary:
CreatureSpawnData is a lightweight ECS component data struct used to store configuration for creature spawning, specifically the maximum number of creatures in a spawn group. It is a pure data container (IComponentData) and can be used as a query parameter marker (IQueryTypeParameter) within Unity DOTS/Entities systems.


Fields

  • public int m_MaxGroupCount
    Holds the maximum number of creatures allowed in a single spawn group. Default value for the field is 0 when the struct is default-initialized. Modders should set this to a positive integer to control group sizes for spawn logic.

  • private System.Diagnostics.Stopwatch m_Stopwatch
    Not present in this type. (This placeholder from the template is not applicable; CreatureSpawnData defines only m_MaxGroupCount.)

  • private Unity.Jobs.JobHandle <producerHandle>k__BackingField
    Not present in this type. (This placeholder from the template is not applicable to CreatureSpawnData.)

Properties

  • This type has no properties. It exposes a single public field (m_MaxGroupCount).

Constructors

  • public CreatureSpawnData() (implicit default)
    Structs have an implicit parameterless constructor that zero-initializes fields; m_MaxGroupCount will be 0 until explicitly set. To create an instance with a specific value, use an object initializer: new CreatureSpawnData { m_MaxGroupCount = 5 }

Methods

  • This struct declares no methods. It is a plain data container implementing IComponentData and IQueryTypeParameter; behavior should be implemented in systems that read or write this component.

Usage Example

using Unity.Entities;
using Game.Prefabs;

// Add component to an existing entity
var spawnData = new CreatureSpawnData { m_MaxGroupCount = 6 };
entityManager.AddComponentData(entity, spawnData);

// Querying in a system (Entities.ForEach or SystemBase)
Entities
    .ForEach((ref CreatureSpawnData spawn) =>
    {
        if (spawn.m_MaxGroupCount <= 0)
        {
            // handle default/disabled spawn group
        }
        else
        {
            // spawn logic using spawn.m_MaxGroupCount
        }
    }).Schedule();

Additional notes: - Because this is an IComponentData struct, it should be used with the Entities API (EntityManager, SystemBase, ISystem) to read and write spawn configuration on entities. - Consider using a descriptive field name or adding XML comments in source if you extend the struct for clarity (e.g., distinguishing per-entity vs. prototype/group values).