Skip to content

Game.Prefabs.ServiceData

Assembly:
Game assembly (Assembly-CSharp)

Namespace:
Game.Prefabs

Type:
struct

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

Summary:
ServiceData is a small ECS component used by the game's prefab systems to identify which city service a prefab belongs to and whether that prefab's budget is adjustable by the player. It is a plain, blittable struct suitable for use with Unity.Entities queries and component storage.


Fields

  • public CityService m_Service
    Specifies the service type for the prefab (for example: police, fire, health, etc.). CityService is defined in Game.City and is typically an enum or similar identifier used across the game's systems to route service-specific logic.

  • public bool m_BudgetAdjustable
    A flag indicating whether this prefab's budget can be adjusted (true) or is fixed/immutable in the budget UI (false). Systems and UI code can check this field to determine if budget controls should be shown or applied.

Properties

  • None (no properties are declared in the struct).
    This component exposes raw public fields rather than properties to keep it blittable and efficient for ECS usage.

Constructors

  • public ServiceData()
    The struct has no explicit constructors in source; the default parameterless (value-type) constructor is available. You can initialize instances using object initializer syntax:
var sd = new ServiceData { m_Service = CityService.Police, m_BudgetAdjustable = true };

If desired, you may add a convenience constructor in your mod code, but note that adding instance methods or non-blittable fields will affect its suitability as an IComponentData.

Methods

  • None (no methods are declared on this struct).

Usage Example

// Creating an entity with ServiceData via EntityManager
var em = Unity.Entities.World.DefaultGameObjectInjectionWorld.EntityManager;
var archetype = em.CreateArchetype(typeof(Game.Prefabs.ServiceData));
var entity = em.CreateEntity(archetype);

// Set component data
em.SetComponentData(entity, new Game.Prefabs.ServiceData {
    m_Service = Game.City.CityService.Police,
    m_BudgetAdjustable = true
});

// Querying in a SystemBase
public class ExampleSystem : Unity.Entities.SystemBase
{
    protected override void OnUpdate()
    {
        Entities.ForEach((ref Game.Prefabs.ServiceData sd) =>
        {
            if (sd.m_BudgetAdjustable)
            {
                // apply budget-related logic
            }
        }).ScheduleParallel();
    }
}

Notes: - Because ServiceData implements IComponentData, it is intended for use with Unity ECS (Entities). Keep the struct blittable (primitive fields or unmanaged types) to avoid performance penalties. - Implementing IQueryTypeParameter allows this type to be used in certain generic query scenarios provided by the game's ECS utilities.