Game.CharacterGroupData
Assembly:
Assembly-CSharp (typical Unity/City Skylines 2 mod assembly; actual assembly name may vary)
Namespace:
Game.Prefabs
Type:
struct
Base:
System.ValueType
Implements: Unity.Entities.IComponentData, Unity.Entities.IQueryTypeParameter
Summary:
A zero-data/tag component used with Unity's DOTS/ECS to mark or identify entities that belong to a "character group" concept in the game. The struct is empty by design and is annotated with [StructLayout(LayoutKind.Sequential, Size = 1)] so it has a defined 1-byte size (useful for being stored in archetypes/arrays and ensuring blittability). Implementing IComponentData makes it a component that can be attached to entities; implementing IQueryTypeParameter enables its use as a query type parameter in entity queries and ForEach-style APIs.
Fields
- This struct defines no instance fields.
The type is intentionally empty (a tag component). The StructLayout attribute forces a 1-byte size even though there are no managed fields, which is important for stable layout and memory usage in DOTS/ECS.
Properties
- This struct exposes no properties. It is a plain marker/tag component.
Constructors
public CharacterGroupData()
(implicit default)
As an empty value type, it has the implicit parameterless default constructor provided by .NET. There is typically no need to construct or store data on this component—adding or removing the component on an entity is the usual usage.
Methods
- This type declares no methods. It only serves as a marker implementing IComponentData and IQueryTypeParameter.
Usage Example
// Add the tag component to an entity
entityManager.AddComponent<CharacterGroupData>(entity);
// Create an archetype that includes the tag
var archetype = entityManager.CreateArchetype(typeof(CharacterGroupData), typeof(Translation));
// Use in a query / ForEach to operate only on entities with the tag
Entities
.WithAll<CharacterGroupData>()
.ForEach((ref Translation tr) =>
{
// operate on entities that are part of a character group
})
.Schedule();
// Alternatively, using the tag as a parameter in a ForEach
Entities.ForEach((in CharacterGroupData tag, ref SomeOtherComponent comp) =>
{
// This will run for entities that include CharacterGroupData
}).Schedule();
Notes: - Because the struct is empty it is best used as a tag (presence/absence) rather than to store data. - The explicit 1-byte size via StructLayout ensures a consistent, non-zero size for the type when used in archetypes or component arrays, and helps with blittability needed by some DOTS operations.