Skip to content

Game.Prefabs.NetUpgrade

Assembly: Assembly-CSharp.dll
Namespace: Game.Prefabs

Type: class

Base: ComponentBase

Summary:
NetUpgrade is a ComponentBase-derived prefab component used by net (road/rail/etc.) prefabs to describe upgrade behavior and required pieces when an upgrade is applied or removed. It contains arrays describing the requirements for setting and unsetting the upgrade, and flags to control whether the upgrade can exist standalone or represents an underground variant. The component also contributes required runtime component types to prefabs and to entity archetypes used by the DOTS conversion pipeline.


Fields

  • public NetPieceRequirements[] m_SetState
    Array of NetPieceRequirements that describe which net pieces and resources are required/applied when this upgrade is set (activated). Typical use: the parts that should be added to the base net when the upgrade is applied.

  • public NetPieceRequirements[] m_UnsetState
    Array of NetPieceRequirements that describe which net pieces and resources are required/removed when this upgrade is unset (deactivated). Typical use: the parts that should be restored/removed when the upgrade is rolled back.

  • public bool m_Standalone
    Flag indicating whether this upgrade can exist as a standalone prefab (not attached to an existing net). True if the upgrade can be placed independently; false if it only exists as an upgrade to another net.

  • public bool m_Underground
    Flag indicating whether this upgrade represents an underground variant of the net. Used to distinguish surface vs underground upgrade behavior.

Properties

  • None declared on this component.

Constructors

  • public NetUpgrade()
    Default constructor. No custom initialization logic is present in the source; behavior is driven by serialized fields assigned in the prefab asset.

Methods

  • public override void GetDependencies(List<PrefabBase> prefabs)
    Overrides ComponentBase.GetDependencies. Current implementation simply calls base.GetDependencies(prefabs). Intended extension point for the component to add any prefab dependencies required by its Set/Unset states, but the shipped implementation does not add additional dependencies.

  • public override void GetPrefabComponents(HashSet<ComponentType> components)
    Adds runtime component types required on the converted prefab entity:

  • Adds PlaceableNetData (read/write)
  • Adds PlaceableInfoviewItem (read/write)
    These indicate that prefabs containing this component will require placeable net-related data and an infoview item component on the entity at conversion/creation time.

  • public override void GetArchetypeComponents(HashSet<ComponentType> components)
    Checks whether the archetype components already include NetCompositionData; if so, adds PlaceableNetComposition (read/write). This ensures that when a net composition is present in the archetype, the placeable net composition component is included so that runtime systems that rely on net composition can read/write it.

Usage Example

// This component is normally placed on net prefabs in the editor.
// Example: ensure converted entities for a net upgrade include expected components.
public class ExamplePrefabProcessor
{
    public void CollectComponents(Game.Prefabs.NetUpgrade upgrade, HashSet<ComponentType> components)
    {
        // Simulate what GetPrefabComponents does:
        upgrade.GetPrefabComponents(components);

        // components will now contain:
        // - ComponentType.ReadWrite<PlaceableNetData>()
        // - ComponentType.ReadWrite<PlaceableInfoviewItem>()
    }
}

{{ Additional notes: - NetPieceRequirements is a project-specific type describing the pieces/resources required for net state transitions; inspect its definition to understand fields like piece IDs, costs, or placement rules. - This component is purely data/configuration; runtime behavior that applies upgrades is handled by separate systems that read these Placeable* components and NetCompositionData. - When modding, add or modify NetUpgrade components on net prefabs to change how upgrades behave (e.g., toggle m_Underground or provide custom m_SetState entries). }}