Static helper in the RoleplayFramework that reports what the current process is doing (offline, dedicated server, listen host or client) by reading Networking.IsActive and Networking.IsHost. Also exposes IsAuthority and HasLocalPlayer derived from that role, plus a describe string.
namespace RoleplayFramework.Core;
/// <summary>What this process is right now. Changes over a session (menu → hosting → disconnected), so always read it live.</summary>
public enum ProcessRole
{
/// <summary>Not in a networked session (main menu, or offline in the editor).</summary>
Offline,
/// <summary>Headless dedicated server: server realm only, no local player.</summary>
DedicatedServer,
/// <summary>Listen/local server: this process is the server and also has a local player (server + client realms).</summary>
ListenHost,
/// <summary>Connected to someone else's server: client realm only.</summary>
Client,
}
public static class RealmInfo
{
public static ProcessRole Role
{
get
{
if ( Application.IsDedicatedServer ) return ProcessRole.DedicatedServer;
if ( !Networking.IsActive ) return ProcessRole.Offline;
return Networking.IsHost ? ProcessRole.ListenHost : ProcessRole.Client;
}
}
/// <summary>True when this process owns authoritative gameplay state (dedicated server, listen host, or offline).</summary>
public static bool IsAuthority => Role != ProcessRole.Client;
/// <summary>True when this process renders UI for a local player.</summary>
public static bool HasLocalPlayer => Role != ProcessRole.DedicatedServer;
public static string Describe() => Role switch
{
ProcessRole.Offline => "offline",
ProcessRole.DedicatedServer => "dedicated server",
ProcessRole.ListenHost => "listen host",
_ => "client",
};
}