SboxSuperuser/Engine/Compatibility/ProbeRuntime.cs

Small compatibility helper that checks whether the current runtime should allow a particular probe or operation. IsSupported returns true when this instance is the network host and either is a dedicated server or is running in the editor with an opt-in flag. Describe returns a short diagnostic string with mode, engine version and bool flags.

Networking
using Sandbox;

namespace SboxSuperuser.Engine.Compatibility;

internal static class ProbeRuntime
{
	internal static bool IsSupported( bool allowEditorTesting )
	{
		return Networking.IsHost
			&& (Application.IsDedicatedServer || (Game.IsEditor && allowEditorTesting));
	}

	internal static string Describe( bool allowEditorTesting )
	{
		var mode = Application.IsDedicatedServer ? "DedicatedServer" : "EditorTest";
		if ( !IsSupported( allowEditorTesting ) )
		{
			mode = "Unsupported";
		}

		return $"mode={mode}; engine={Application.Version}; "
			+ $"dedicated={Application.IsDedicatedServer}; editor={Game.IsEditor}; "
			+ $"host={Networking.IsHost}; editorOptIn={allowEditorTesting}";
	}
}