GameLoop/GameManager.Bots.cs
public sealed partial class GameManager
{
private static int BotIdCounter = 0;
[ConCmd( "bot_add", ConVarFlags.Cheat )]
public static void SpawnBot( int count )
{
if ( !Networking.IsHost ) return;
for ( int i = 0; i < count; i++ )
{
int botId = BotIdCounter++;
string name = $"Bot - {botId}";
var go = new GameObject( true, $"PlayerInfo - {name}" );
var data = go.AddComponent<PlayerData>();
data.PlayerId = Guid.NewGuid();
data.DisplayName = name;
data.BotId = botId;
go.NetworkSpawn( null );
go.Network.SetOwnerTransfer( OwnerTransfer.Fixed );
Current.SpawnPlayer( data );
}
}
}