mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-08-01 16:28:36 -04:00
* Move all unit tests to Engine/Tests * Fix Margin.EdgeSubtract * Fix Capsule.Contains * EnvironmentVariables.Remove if it's null * Fixed ray trace never returning startedsolid * Fix HistoryList.Navigate on empty list * Fix GameObject.WorldPosition accepting NaNs * Fix flex: initial expanding to the wrong grow/shrink * Translation.TryConvert shouldn't throw on invalid enum strings * Skip sound file tests on machines with no audio device
66 lines
1.3 KiB
C#
66 lines
1.3 KiB
C#
namespace Sandbox;
|
|
|
|
public sealed partial class DebugOverlaySystem : GameObjectSystem<DebugOverlaySystem>
|
|
{
|
|
bool inFixedUpdate;
|
|
|
|
public DebugOverlaySystem( Scene scene ) : base( scene )
|
|
{
|
|
Listen( Stage.StartUpdate, -10000, StartUpdate, "BuildDebugOverlays" );
|
|
Listen( Stage.StartFixedUpdate, -10000, StartFixedUpdate, "BuildDebugOverlays" );
|
|
Listen( Stage.FinishFixedUpdate, 10000, EndFixedUpdate, "BuildDebugOverlays" );
|
|
}
|
|
|
|
void RemoveExpired()
|
|
{
|
|
for ( int i = 0; i < entries.Count; i++ )
|
|
{
|
|
if ( entries[i].SingleFrame ) continue;
|
|
entries[i].life -= Time.Delta;
|
|
|
|
if ( entries[i].life < 0 )
|
|
{
|
|
entries[i].Dispose();
|
|
entries.RemoveAt( i ); // move to end and remove?
|
|
i--;
|
|
}
|
|
}
|
|
}
|
|
|
|
void RemoveSingleFrame( bool createdDuringFixed )
|
|
{
|
|
for ( int i = 0; i < entries.Count; i++ )
|
|
{
|
|
if ( !entries[i].SingleFrame ) continue;
|
|
if ( entries[i].CreatedDuringFixed != createdDuringFixed ) continue;
|
|
|
|
entries[i].Dispose();
|
|
entries.RemoveAt( i );
|
|
i--;
|
|
}
|
|
|
|
// don't force the scene world to exist just to flush deletes
|
|
if ( Scene.HasSceneWorld )
|
|
{
|
|
Scene.SceneWorld.DeletePendingObjects();
|
|
}
|
|
}
|
|
|
|
void StartUpdate()
|
|
{
|
|
RemoveExpired();
|
|
RemoveSingleFrame( false );
|
|
}
|
|
|
|
void StartFixedUpdate()
|
|
{
|
|
RemoveSingleFrame( true );
|
|
inFixedUpdate = true;
|
|
}
|
|
|
|
void EndFixedUpdate()
|
|
{
|
|
inFixedUpdate = false;
|
|
}
|
|
}
|