Game.Prefabs.ObjectSubNets
Assembly: Assembly-CSharp
Namespace: Game.Prefabs
Type: class
Base: ComponentBase
Summary:
Component used on building (and building extension) prefabs to declare one or more "sub-net" prefabs that should be associated with the object. Typically used to attach small network pieces (for example service or connection decorations) to a building. The ComponentMenu attribute registers this component for BuildingPrefab and BuildingExtensionPrefab. The component:
- exposes an array of ObjectSubNetInfo entries (m_SubNets) that reference net prefabs,
- provides an inversion mode (m_InvertWhen) to control net flipping behavior,
- marks itself as ignoring unlock dependencies,
- contributes ECS component types required to represent SubNet data on entities.
Fields
-
public NetInvertMode m_InvertWhen
Controls how/when the associated sub-nets should be inverted (flipped) relative to the parent object's orientation. The enum guides placement orientation logic for the sub-nets when the prefab is instantiated. -
public ObjectSubNetInfo[] m_SubNets
Array of sub-net descriptors. Each ObjectSubNetInfo should reference a net prefab (m_NetPrefab) and any per-subnet placement settings. GetDependencies iterates this array to collect referenced net prefabs.
Properties
public override bool ignoreUnlockDependencies => true
This override makes the component ignore unlock/DLC dependency checks when determining if the prefab can be used. The property always returns true in this implementation.
Constructors
public ObjectSubNets()
Default parameterless constructor (implicit). The class does not define custom construction logic.
Methods
-
public override void GetDependencies(List<PrefabBase> prefabs)
Adds referenced net prefabs from m_SubNets to the provided prefabs list. Performs a null-check on m_SubNets and iterates the array, calling prefabs.Add(m_SubNets[i].m_NetPrefab) for each entry. This ensures the net prefabs are loaded/registered as dependencies of the building prefab. -
public override void GetPrefabComponents(HashSet<ComponentType> components)
Adds the runtime component type ComponentType.ReadWrite() to the provided set. This indicates that entity instances of this prefab will need a SubNet component at the prefab/component level. -
public override void GetArchetypeComponents(HashSet<ComponentType> components)
Adds the archetype-level component type ComponentType.ReadWrite() to the provided set. This ensures the ECS archetype for entities created from this prefab includes storage for the Game.Net.SubNet component.
Usage Example
// Example: create and configure an ObjectSubNets component on a prefab instance
var subNetsComp = new ObjectSubNets();
subNetsComp.m_InvertWhen = NetInvertMode.None;
subNetsComp.m_SubNets = new[]
{
new ObjectSubNetInfo { m_NetPrefab = someNetPrefabA },
new ObjectSubNetInfo { m_NetPrefab = someNetPrefabB }
};
// When the prefab system calls GetDependencies(prefabs), the referenced net prefabs will be added:
// subNetsComp.GetDependencies(prefabsList);