Files
sbox-public/engine/Sandbox.Engine/Scene/GameObjectSystems/DecalGameSystem.cs
s&box team 71f266059a Open source release
This commit imports the C# engine code and game files, excluding C++ source code.

[Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
2025-11-24 09:05:18 +00:00

53 lines
968 B
C#

namespace Sandbox;
public sealed class DecalGameSystem : GameObjectSystem<DecalGameSystem>
{
[ConVar( "maxdecals" )]
public static int MaxDecals { get; internal set; } = 1000;
/// <summary>
/// A list of decals that can be destroyed after a certain time.
/// </summary>
LinkedList<Decal> _transients = new();
public DecalGameSystem( Scene scene ) : base( scene )
{
}
public void ClearDecals()
{
while ( _transients.Count > 0 )
{
var first = _transients.First;
first.Value.Destroy();
_transients.Remove( first );
}
}
internal void AddTransient( Decal decal )
{
if ( decal is null || !decal.IsValid() )
return;
_transients.AddLast( decal );
int max = MaxDecals;
while ( _transients.Count > max )
{
var first = _transients.First;
first.Value.Destroy();
_transients.Remove( first );
}
}
internal void RemoveTransient( Decal decal )
{
if ( decal is null ) return;
_transients.Remove( decal );
}
}