mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-01-04 20:38:24 -05:00
This commit imports the C# engine code and game files, excluding C++ source code. [Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
64 lines
1.3 KiB
C#
64 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" );
|
|
|
|
LineMaterial = Material.Load( "materials/gizmo/line.vmat" );
|
|
}
|
|
|
|
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--;
|
|
}
|
|
|
|
Scene.SceneWorld.DeletePendingObjects();
|
|
}
|
|
|
|
void StartUpdate()
|
|
{
|
|
RemoveExpired();
|
|
RemoveSingleFrame( false );
|
|
}
|
|
|
|
void StartFixedUpdate()
|
|
{
|
|
RemoveSingleFrame( true );
|
|
inFixedUpdate = true;
|
|
}
|
|
|
|
void EndFixedUpdate()
|
|
{
|
|
inFixedUpdate = false;
|
|
}
|
|
}
|