Game.Prefabs.AuxiliaryNets
Assembly: Assembly-CSharp
Namespace: Game.Prefabs
Type: class
Base: ComponentBase
Summary:
Component used by net prefabs to declare "auxiliary" nets that are associated with a primary net prefab. This component exposes a flag controlling link end offsets and an array of AuxiliaryNetInfo entries that reference other net prefabs. It overrides prefab dependency and component registration hooks so that referenced auxiliary prefabs are included in the prefab dependency list and required ECS component types are added to prefabs/archetypes.
Additional notes: - Marked with [ComponentMenu("Net/", typeof(NetPrefab))], so it appears under Net/ when creating components for Net prefabs. - Designed to be placed on Net/NetPrefab-derived prefabs to inform the game about related nets (for example, sidewalks, markings, or variant meshes that should be packaged together).
Fields
-
public System.Boolean m_LinkEndOffsets
Controls whether link end offsets are applied for the auxiliary nets. Default true in source. When true, end offsets on links can be used (behavior depends on net systems reading this flag). -
public Game.Net.AuxiliaryNetInfo[] m_AuxiliaryNets
Array of AuxiliaryNetInfo entries. Each entry typically contains a reference to another net prefab (m_Prefab) and configuration for how the auxiliary net is applied. The component's GetDependencies implementation iterates this array and adds each referenced prefab to the dependency list.
Properties
public override System.Boolean ignoreUnlockDependencies => true
Indicates that this component ignores unlock dependencies. Returning true means the prefab system will not attempt to enforce unlock dependency checks for this component. This is an override of a ComponentBase property.
Constructors
public AuxiliaryNets()
Default parameterless constructor (no explicit initialization beyond field defaults in the source). Fields should typically be set in the prefab asset/inspector rather than at runtime.
Methods
public override void GetDependencies(System.Collections.Generic.List<PrefabBase> prefabs)
Adds referenced auxiliary prefabs to the provided prefabs list. Implementation:- Calls base.GetDependencies(prefabs).
- Iterates m_AuxiliaryNets and for each entry adds m_AuxiliaryNets[i].m_Prefab to prefabs.
-
Note: the implementation assumes m_AuxiliaryNets is non-null; if it's null calling this will throw a NullReferenceException.
-
public override void GetPrefabComponents(System.Collections.Generic.HashSet<Unity.Entities.ComponentType> components)
Registers required prefab-level component types. This component adds: - ComponentType.ReadWrite
() -
ComponentType.ReadWrite
() These indicate that prefabs using this component will require those component types on spawned entities. -
public override void GetArchetypeComponents(System.Collections.Generic.HashSet<Unity.Entities.ComponentType> components)
Registers required archetype-level component types. This component adds: - ComponentType.ReadWrite
() This ensures the SubNet component is present in the entity archetype built for these prefabs.
Usage Example
// Example: a NetPrefab-derived prefab that includes AuxiliaryNets in the inspector
[ComponentMenu("Net/", typeof(NetPrefab))]
public class MyCustomNetPrefab : NetPrefab
{
// In the Unity editor, attach an AuxiliaryNets component and populate m_AuxiliaryNets
public AuxiliaryNets auxiliaryNets;
public override void GetDependencies(List<PrefabBase> prefabs)
{
base.GetDependencies(prefabs);
// Delegate dependency collection to the AuxiliaryNets component so referenced
// auxiliary net prefabs are included in the final dependency list.
if (auxiliaryNets != null)
{
auxiliaryNets.GetDependencies(prefabs);
}
}
}
{{ - If you are creating or modifying net prefabs for Cities: Skylines 2 modding, set up m_AuxiliaryNets in the prefab inspector to point to auxiliary net prefabs (e.g., markings, attachments). - Be careful: GetDependencies in this component does not null-check m_AuxiliaryNets in the original source — ensure the array is initialized to avoid runtime exceptions. - The component works together with PlaceableNetData, AuxiliaryNet and Game.Net.SubNet ECS components; ensure those components exist and are understood when authoring nets. }}