mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-01-15 09:49:23 -05:00
This commit imports the C# engine code and game files, excluding C++ source code. [Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
31 lines
725 B
C#
31 lines
725 B
C#
namespace Sandbox;
|
|
|
|
partial class Compiler
|
|
{
|
|
private List<FileWatch> sourceWatchers = new();
|
|
|
|
/// <summary>
|
|
/// Watch the filesystem for changes to our c# files, and trigger a recompile if they change.
|
|
/// </summary>
|
|
public void WatchForChanges()
|
|
{
|
|
foreach ( var fs in SourceLocations )
|
|
{
|
|
var watcher = fs.Watch( "*.*" );
|
|
watcher.OnChangedFile += OnFileChanged;
|
|
sourceWatchers.Add( watcher );
|
|
}
|
|
}
|
|
|
|
private void OnFileChanged( string file )
|
|
{
|
|
if ( !file.EndsWith( ".cs", StringComparison.OrdinalIgnoreCase ) && !file.EndsWith( ".razor", StringComparison.OrdinalIgnoreCase ) )
|
|
return;
|
|
|
|
if ( file.Contains( "/obj/", StringComparison.OrdinalIgnoreCase ) )
|
|
return;
|
|
|
|
MarkForRecompile();
|
|
}
|
|
}
|