Game.Prefabs.TelecomPrefab
Assembly:
Assembly not specified in source (likely Assembly-CSharp or a game-specific assembly for Cities: Skylines 2).
{{ This class is part of the game's prefab system and will typically be compiled into the game's main assembly. }}
Namespace:
Game.Prefabs
{{ Declared at the top of the source file as "namespace Game.Prefabs". }}
Type:
class
{{ Public class used as a Unity/Entities prefab definition. }}
Base:
PrefabBase
{{ TelecomPrefab inherits from PrefabBase and extends prefab behaviour for telecom-related prefabs. }}
Summary:
{{ TelecomPrefab is a prefab definition that exposes a reference to another prefab representing the telecom service. It ensures entities created from this prefab include a TelecomParameterData component and, during late initialization, fills that component with an Entity reference to the configured telecom service prefab via the PrefabSystem. The class is annotated with [ComponentMenu("Settings/", ...)] so it appears under the Settings menu in the Unity component menu. }}
Fields
public PrefabBase m_TelecomServicePrefab
{{ Public inspector-exposed reference to another PrefabBase that represents the telecom service. This is intended to be assigned in the editor (or by code) and is resolved to an ECS Entity during LateInitialize via PrefabSystem.GetEntity(m_TelecomServicePrefab). If left null, the resolved Entity may be Entity.Null. }}
Properties
- (none)
{{ This class does not declare properties. It uses the public field above and overrides methods from PrefabBase. }}
Constructors
public TelecomPrefab()
{{ No explicit constructor is defined in the source; the default parameterless constructor is used. }}
Methods
-
public override void GetPrefabComponents(HashSet<ComponentType> components) : System.Void
{{ Calls base.GetPrefabComponents(components) and then adds ComponentType.ReadWrite() to the provided set. This ensures that entities created from this prefab will have the TelecomParameterData component available for read/write. }} -
public override void GetArchetypeComponents(HashSet<ComponentType> components) : System.Void
{{ Overrides the base method but currently only calls the base implementation. It is left as a placeholder for adding archetype-specific component types if needed in future. }} -
public override void LateInitialize(EntityManager entityManager, Entity entity) : System.Void
{{ Called after the prefab has been created as an ECS entity. This implementation: - Calls base.LateInitialize(entityManager, entity).
- Obtains the PrefabSystem instance for the current World using entityManager.World.GetOrCreateSystemManaged
(). - Resolves the inspector-assigned PrefabBase (m_TelecomServicePrefab) to an Entity with PrefabSystem.GetEntity(...) and writes that into the entity's TelecomParameterData component via entityManager.SetComponentData. This step links the in-editor prefab reference to an actual ECS Entity reference so runtime systems can use the referenced telecom service entity. Be aware that m_TelecomServicePrefab may be null, in which case the resolved entity will typically be Entity.Null. }}
Usage Example
// Example: typical workflow — assign m_TelecomServicePrefab in the inspector for this prefab.
// At runtime the prefab system will call LateInitialize and populate the entity's TelecomParameterData.
public class ExampleUsage
{
// Suppose prefabAsset is an instance of TelecomPrefab configured in the editor,
// and the game's prefab system instantiates it into an Entity.
// The following shows the same logic performed in LateInitialize (already implemented in TelecomPrefab).
public void ManualLateInitialize(EntityManager entityManager, Entity entity, TelecomPrefab prefab)
{
var prefabSystem = entityManager.World.GetOrCreateSystemManaged<PrefabSystem>();
entityManager.SetComponentData(entity, new TelecomParameterData
{
m_TelecomServicePrefab = prefabSystem.GetEntity(prefab.m_TelecomServicePrefab)
});
}
}
{{ Notes: - Ensure TelecomParameterData is defined in the ECS codebase and contains a field m_TelecomServicePrefab of type Entity (or compatible). - This prefab relies on PrefabSystem to resolve PrefabBase -> Entity. If PrefabSystem cannot resolve the referenced prefab, the component will receive Entity.Null. - The class has the attribute [ComponentMenu("Settings/", new Type[] { })], so it will be available under the Settings menu when adding components/prefabs in the Unity editor. }}