Skip to content

Game.Prefabs.ResourceConnectionData

Assembly: Assembly-CSharp
Namespace: Game.Prefabs

Type: struct

Base: IComponentData, IQueryTypeParameter

Summary:
ECS component that attaches resource connection information to a prefab/entity. It stores which in-game resource the connection refers to and an Entity reference used for a connection-warning notification (for example when a connection is missing or broken). This component is intended for use by systems that manage resource connections and notifications in the Cities: Skylines 2 game world. It is a plain data container (blittable) suitable for use in Jobs and entity queries.


Fields

  • public Resource m_Resource
    Holds the resource identifier/details from Game.Economy that this connection represents (e.g., water, electricity, goods). The exact shape of Resource is defined in Game.Economy; this field lets systems know which commodity or service the connection relates to.

  • public Entity m_ConnectionWarningNotification
    An Entity reference used to track an in-world or UI notification object representing a connection warning for this resource (e.g., an icon or effect shown when a connection is missing). Typically Entity.Null when no notification is currently present. Systems can set this to the spawned notification entity to avoid creating duplicates.

Properties

  • This struct exposes no properties; it uses public fields for direct, efficient access within ECS systems and jobs.

Constructors

  • public ResourceConnectionData()
    No explicit constructors are defined. The default constructor zero-initializes the fields (m_Resource set to default Resource, m_ConnectionWarningNotification set to Entity.Null). Initialize values explicitly when creating instances to avoid relying on defaults.

Methods

  • This struct defines no methods. It is a pure data container intended for use with EntityManager and job-friendly systems.

Usage Example

using Game.Economy;
using Game.Prefabs;
using Unity.Entities;

// Create and attach the component to an existing entity:
var resource = /* obtain or create a Resource instance representing the resource */;
Entity somePrefabEntity = /* an existing entity for the prefab */;

var connectionData = new ResourceConnectionData
{
    m_Resource = resource,
    m_ConnectionWarningNotification = Entity.Null
};

var em = World.DefaultGameObjectInjectionWorld.EntityManager;
em.AddComponentData(somePrefabEntity, connectionData);

// Example: system processing - spawn a warning if missing
Entities.ForEach((ref ResourceConnectionData rcd, in Entity e) =>
{
    if (rcd.m_ConnectionWarningNotification == Entity.Null)
    {
        // Spawn notification entity and store it in m_ConnectionWarningNotification
        // rcd.m_ConnectionWarningNotification = spawnedNotificationEntity;
    }
}).Schedule();