Player/Car/AI/BotBrain.cs

Abstract BotBrain component for AI-driven cars. Provides ConVars to enable/disable boost and drift, exposes the Car component reference, and requires subclasses to implement Tick() to produce CarInputData. Also has an optional OnRespawned hook.

namespace Machines.Player;

/// <summary>
/// Abstract base for bot AI; subclass and override Tick() to produce input for a bot-driven car
/// </summary>
public abstract class BotBrain : Component
{
	/// <summary>
	/// When false, bots will never use boost.
	/// </summary>
	[ConVar( "bot_enable_boost" )]
	public static bool EnableBoost { get; set; } = true;

	/// <summary>
	/// When false, bots will never initiate drifts.
	/// </summary>
	[ConVar( "bot_enable_drift" )]
	public static bool EnableDrift { get; set; } = true;

	public Car Car => GetComponent<Car>();

	/// <summary>
	/// Produce input for this frame. Called by CarInput when the car owner is a bot.
	/// </summary>
	public abstract CarInputData Tick();

	/// <summary>
	/// Called after respawn/teleport so the brain can re-sync; override as needed
	/// </summary>
	public virtual void OnRespawned() { }
}