Skip to content

Game.Prefabs.SubObjectFlags

Assembly:
Assembly-CSharp (game assembly)

Namespace:
Game.Prefabs

Type:
public enum SubObjectFlags (has [Flags] attribute)

Base:
System.Enum

Summary:
A bitmask enum used by the game's prefab/subobject system to control placement rules and behavior for subobjects (props/attachments placed along segments, edges, medians, etc.). The [Flags] attribute allows multiple options to be combined with bitwise operations. Modders use these flags to declare where a subobject may be placed (edge, middle, start/end), what conditions are required (elevated, dead-end, water crossing), and placement behaviors (fixed placement, even spacing, combining, flipping, preserving shape).


Fields

  • AnchorTop = 1
    Anchors the subobject to the top (typically top edge or top alignment) when placed.

  • AnchorCenter = 2
    Anchors the subobject to the center alignment of the placement reference.

  • RequireElevated = 0x10
    Subobject only allowed when the target is elevated (e.g., elevated segment/structure).

  • RequireOutsideConnection = 0x20
    Requires an outside connection (used when placement depends on an outside network connection).

  • RequireDeadEnd = 0x40
    Placement restricted to dead-end segments/nodes.

  • RequireOrphan = 0x80
    Requires orphan placement conditions (no clear connection or isolated placement).

  • OnGround = 0x100
    Indicates placement on ground level (not elevated, not underground).

  • WaterwayCrossing = 0x200
    Marked for placements that cross waterways (e.g., bridges or crossings).

  • NotWaterwayCrossing = 0x400
    Placement prohibited on waterway crossings.

  • EdgePlacement = 0x1000
    Subobject is intended for edge placement (edge of the road/segment).

  • MiddlePlacement = 0x2000
    Subobject is intended for middle/center placement (e.g., median).

  • AllowCombine = 0x4000
    Allows this subobject to be combined with other subobjects (merge or stack).

  • CoursePlacement = 0x8000
    Indicates placement following the course/path of the segment (used when subobject should align to the road course).

  • FlipInverted = 0x10000
    Allows flipping or inverted placement variants when mirroring.

  • StartPlacement = 0x20000
    Allowed at the start of a segment (start anchor).

  • EndPlacement = 0x40000
    Allowed at the end of a segment (end anchor).

  • MakeOwner = 0x100000
    Mark the subobject as the owner of a created entity (semantics depend on engine usage).

  • OnMedian = 0x200000
    Specifically intended for placement on medians/dividers.

  • FixedPlacement = 0x400000
    Placement is fixed; the subobject should not be freely moved/adjusted by spacing algorithms.

  • PreserveShape = 0x800000
    Preserve the original shape of the subobject when the parent is transformed or scaled.

  • EvenSpacing = 0x1000000
    Enforce even spacing between repeated subobjects along a course.

  • SpacingOverride = 0x2000000
    Allow overriding the default spacing (take precedence over typical spacing rules).

Properties

  • This enum type does not define properties. It is a plain flags enum used as a bitmask.

Constructors

  • Enums do not have user-visible constructors. Values are compiled constants; instantiate/assign by name or numeric value.

Methods

  • The enum type does not define methods. Typical operations are bitwise checks and combinations (|, &, ~) or using Enum.HasFlag.

Usage Example

// Combine flags when defining a subobject's placement rules:
SubObjectFlags flags = SubObjectFlags.EdgePlacement | SubObjectFlags.AnchorTop | SubObjectFlags.AllowCombine;

// Check flags:
bool isEdge = (flags & SubObjectFlags.EdgePlacement) != 0;
// or using HasFlag (boxed check, slightly slower):
bool requiresElevated = flags.HasFlag(SubObjectFlags.RequireElevated);

// Add/remove a flag:
flags |= SubObjectFlags.EvenSpacing;      // add
flags &= ~SubObjectFlags.AllowCombine;    // remove

// Typical usage in a placement routine:
void PlaceSubObject(SubObjectFlags flags, PlacementContext ctx) {
    if ((flags & SubObjectFlags.RequireElevated) != 0 && !ctx.IsElevated) return;
    if ((flags & SubObjectFlags.NotWaterwayCrossing) != 0 && ctx.IsWaterwayCrossing) return;
    // ... apply anchor, spacing, flipping, etc.
}

Notes for modders: - Because this is a [Flags] enum, combine multiple behaviors with bitwise OR. - Prefer bitwise (&) checks in performance-sensitive code over Enum.HasFlag to avoid boxing. - Use flags like FixedPlacement, PreserveShape, EvenSpacing and SpacingOverride to fine-tune automatic placement systems (spacing, combining, mirroring, and when the engine should or should not alter a subobject).