Game.Prefabs.EditorContainer
Assembly:
Namespace: Game.Prefabs
Type: class
Base: ComponentBase
Summary:
EditorContainer is a prefab component helper used to register editor-related ECS component types on prefabs. It ensures that editor/state data required by in-game editing tools is present on created archetypes. Depending on what primary component types are already present on the prefab (Edge, Node, or Game.Objects.Object), it adds the appropriate additional editor/tooling components (such as editor container data, culling info, curve/sub-lane data, etc.). This class is intended for use by the game's prefab creation pipeline and by mods that need to add editor/tooling support to custom prefabs.
Fields
- This type declares no explicit instance fields.
Properties
- This type declares no public properties.
Constructors
public EditorContainer()
Default parameterless constructor (implicit if not declared). No special initialization is performed by this class itself.
Methods
public override void GetPrefabComponents(HashSet<ComponentType> components)
Examines the provided set of component types and adds the base editor container data component required by editor tooling:- Adds
ComponentType.ReadWrite<EditorContainerData>()
. -
This method is called during prefab component collection to ensure editor data is present on the prefab.
-
public override void GetArchetypeComponents(HashSet<ComponentType> components)
Conditionally augments the archetype component set based on the presence of specific primary components: - If the archetype already contains
Edge
:- Adds
Game.Tools.EditorContainer
- Adds
Game.Net.SubLane
- Adds
Curve
- Adds
CullingInfo
- Adds
PseudoRandomSeed
- Adds
- Else if the archetype contains
Node
:- Adds
Game.Tools.EditorContainer
- Adds
CullingInfo
- Adds
- Else if the archetype contains
Game.Objects.Object
:- Adds
Game.Tools.EditorContainer
- Adds
Game.Objects.SubObject
- Adds
Static
- Adds
CullingInfo
- Adds
- This method tailors the final ECS archetype components to include the editor/tool data needed by edges, nodes, and placed objects.
Notes for modders: - The class does not itself define the data components (e.g., EditorContainerData, Game.Tools.EditorContainer, SubLane, Curve). It only registers those component types onto prefabs/archetypes. - Use this when you want your custom prefabs to participate in the game's editor tooling (selection, editing, culling, curve/sub-lane data, pseudo-random seeds for variation). - Adding EditorContainer ensures editor UI and tool systems have the data layout they expect.
Usage Example
// Ensure your custom prefab includes the editor components from EditorContainer.
// Example: forwarding the editor component registration from a custom prefab type.
public class MyCustomPrefab : NetPrefab
{
private readonly EditorContainer m_editorContainer = new EditorContainer();
public override void GetPrefabComponents(HashSet<ComponentType> components)
{
base.GetPrefabComponents(components);
// Add the base editor container data component
m_editorContainer.GetPrefabComponents(components);
}
public override void GetArchetypeComponents(HashSet<ComponentType> components)
{
base.GetArchetypeComponents(components);
// Add appropriate editor/tooling components depending on whether this prefab is an Edge/Node/Object
m_editorContainer.GetArchetypeComponents(components);
}
}