CreateStructureInstance¶
Vanilla Assets.Scripts.Networking.CreateStructureInstance. Plain managed class used as the in-process placement-intent payload for Constructor.SpawnConstruct and as the constructor source for ConstructionCreationMessage. Carries the prefab reference, target grid cell, target Quaternion, owner ID, and optional custom color index.
Class layout¶
public class CreateStructureInstance
{
public Grid3 LocalGrid;
public Quaternion LocalRotation;
public Structure Prefab;
public GridController GridController;
public int CustomColor = -1;
public ulong OwnerClientId;
public Vector3 WorldPosition => GridController.LocalToWorld(LocalGrid);
public Quaternion WorldRotation => LocalRotation;
public CreateStructureInstance(Structure prefabToCreate, Structure oldPrefab)
{
Prefab = prefabToCreate;
LocalGrid = oldPrefab.GridController.WorldToLocal(oldPrefab.ThingTransformPosition);
LocalRotation = oldPrefab.ThingTransformLocalRotation;
GridController = oldPrefab.GridController;
OwnerClientId = oldPrefab.OwnerClientId;
CustomColor = ((oldPrefab.CustomColor != null) ? oldPrefab.CustomColor.Index : 0);
}
public CreateStructureInstance(Structure prefabToCreate, Grid3 localGrid, Quaternion worldRotation, ulong ownerClientId, int colorIndex = -1)
{
Prefab = prefabToCreate;
GridController = GridController.World;
LocalGrid = localGrid;
LocalRotation = worldRotation;
OwnerClientId = ownerClientId;
CustomColor = colorIndex;
}
}
Notes¶
WorldRotationis a getter aliased toLocalRotation- they are NOT separate channels in this struct. A Quaternion passed to either constructor lands inLocalRotationand surfaces unchanged on theWorldRotationgetter. TheConstructionCreationMessagelater writes both fields as the same value.WorldPositionis computed from the grid byGridController.LocalToWorld(LocalGrid)at access time, not stored. MutatingLocalGridafter construction shifts the world position.- The "old prefab" constructor is used by routines that respawn / replace an existing structure (e.g. swapping a placed prefab for a variant), reading the existing object's transform rather than fresh placement input.
Verification history¶
- 2026-04-25: page created during the placement-pipeline decompile pass.
Open questions¶
None.