mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-04-20 14:28:17 -04:00
https://files.facepunch.com/antopilo/1b0311b1/sbox-dev_Ghn3TRf8eM.mp4 https://files.facepunch.com/antopilo/1b0311b1/sbox-dev_yALD2nMaPw.mp4
49 lines
1.1 KiB
C#
49 lines
1.1 KiB
C#
namespace Sandbox.Clutter;
|
|
|
|
/// <summary>
|
|
/// Represents a single tile in the clutter spatial grid.
|
|
/// Tracks spawned objects for cleanup when the tile is no longer needed.
|
|
/// </summary>
|
|
class ClutterTile
|
|
{
|
|
/// <summary>
|
|
/// Grid coordinates of this tile.
|
|
/// </summary>
|
|
public Vector2Int Coordinates { get; set; }
|
|
|
|
/// <summary>
|
|
/// World-space bounds of this tile.
|
|
/// </summary>
|
|
public BBox Bounds { get; set; }
|
|
|
|
/// <summary>
|
|
/// Random seed offset for deterministic generation.
|
|
/// </summary>
|
|
public int SeedOffset { get; set; }
|
|
|
|
/// <summary>
|
|
/// Whether this tile has been populated with clutter instances.
|
|
/// </summary>
|
|
public bool IsPopulated { get; internal set; }
|
|
|
|
/// <summary>
|
|
/// GameObjects spawned from prefab entries.
|
|
/// </summary>
|
|
internal List<GameObject> SpawnedObjects { get; } = [];
|
|
|
|
internal void AddObject( GameObject obj )
|
|
{
|
|
if ( obj.IsValid() )
|
|
SpawnedObjects.Add( obj );
|
|
}
|
|
|
|
internal void Destroy()
|
|
{
|
|
foreach ( var obj in SpawnedObjects )
|
|
if ( obj.IsValid() ) obj.Destroy();
|
|
|
|
SpawnedObjects.Clear();
|
|
IsPopulated = false;
|
|
}
|
|
}
|