TimedDestroy.cs
// Copyright (c) 2026 SubZero Studios LLC. All rights reserved.
using System;
using Sandbox;
namespace SubZero.SubTerrain;
/// <summary>
/// Destroys this GameObject after a delay. Used by debris prefabs.
/// </summary>
[Title( "Timed Destroy" )]
[Category( "SubTerrain" )]
[Icon( "timer" )]
public sealed class TimedDestroy : Component
{
[Property] public float Seconds { get; set; } = 12f;
TimeSince _alive;
protected override void OnStart()
{
_alive = 0;
}
protected override void OnUpdate()
{
if ( _alive >= Seconds )
GameObject.Destroy();
}
}