s&box docs
API ReferenceSandbox.Clutter

public abstract class Sandbox.Clutter.Scatterer

Base class to override if you want to create custom scatterer logic. Provides utility methods for entry selection and common operations.

Broader workflow and conceptual references connected to this API.

Constructors

Showing 1 constructors

Methods

Showing 7 methods

protected int CalculatePointCount(BBox bounds, float density, int maxPoints = 10000)

Calculates the number of points to scatter based on density and area. Caps at maxPoints to prevent engine freezing.

Parameters

  • bounds: Bounds to scatter in
  • density: Points per square meter
  • maxPoints: Maximum points to cap at (default 10000) Default: 10000

Returns

Number of points to generate

protected virtual System.Collections.Generic.List`1<Sandbox.Clutter.ClutterInstance> Generate(BBox bounds, Sandbox.Clutter.ClutterDefinition clutter, Sandbox.Scene scene = null)

Generates clutter instances for the given bounds. The Random property is initialized before this is called.

Parameters

  • bounds: World-space bounds to scatter within
  • clutter: The clutter containing objects to scatter
  • scene: Scene to use for tracing (null falls back to Game.ActiveScene) Default: null

Returns

Collection of clutter instances to spawn

public static int GenerateSeed(int baseSeed, int x, int y)

Generates a deterministic seed from tile coordinates and base seed. Use this to create unique seeds for different tiles.

protected static Rotation GetAlignedRotation(Vector3 normal, float yawDegrees)

Creates a rotation aligned to a surface normal with random yaw.

protected Sandbox.Clutter.ClutterEntry GetRandomEntry(Sandbox.Clutter.ClutterDefinition clutter)

Selects a random entry from the clutter based on weights. Returns null if no valid entries exist.

public System.Collections.Generic.List`1<Sandbox.Clutter.ClutterInstance> Scatter(BBox bounds, Sandbox.Clutter.ClutterDefinition clutter, int seed, Sandbox.Scene scene = null)

Public entry point for scattering. Creates Random from seed and calls Generate().

Parameters

  • bounds: World-space bounds to scatter within
  • clutter: The clutter containing objects to scatter
  • seed: Seed for deterministic random generation
  • scene: Scene to use for tracing (required in editor mode) Default: null

Returns

Collection of clutter instances to spawn

Properties

Showing 1 properties

protected System.Random Sandbox.Clutter.Scatterer.Random { get; set; }

Metadata

FieldValue
NamespaceSandbox.Clutter
Typeclass
AssemblySandbox.Engine
Doc IDT:Sandbox.Clutter.Scatterer

On this page