API ReferenceSandbox.Clutter

Scattererclass

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

objectScatterer
Namespace
Sandbox.Clutter
Assembly
Sandbox.Engine
Declaration
public abstract class Sandbox.Clutter.Scatterer

Constructors1

Showing 1 constructors

Methods7

Showing 7 methods

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

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

ParameterTypeDescription
boundsBBoxBounds to scatter in
densityfloatPoints per square meter
maxPoints = 10000intMaximum points to cap at (default 10000)
Returns:intNumber 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)PROTECTEDVIRTUAL

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

ParameterTypeDescription
boundsBBoxWorld-space bounds to scatter within
clutterClutterDefinitionThe clutter containing objects to scatter
scene = nullSceneScene to use for tracing (null falls back to Game.ActiveScene)
Returns:List<ClutterInstance>Collection of clutter instances to spawn

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

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

ParameterTypeDescription
baseSeedint
xint
yint
Returns:int

protected static Rotation GetAlignedRotation(Vector3 normal, float yawDegrees)PROTECTEDSTATIC

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

ParameterTypeDescription
normalVector3
yawDegreesfloat
Returns:Rotation

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

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

ParameterTypeDescription
boundsBBoxWorld-space bounds to scatter within
clutterClutterDefinitionThe clutter containing objects to scatter
seedintSeed for deterministic random generation
scene = nullSceneScene to use for tracing (required in editor mode)
Returns:List<ClutterInstance>Collection of clutter instances to spawn

Properties1

Showing 1 properties

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

Returns:Random

On this page