UI/SpawnMenu/AiSettingsPage.razor
@using Sandbox;
@using Sandbox.UI;
@using Sandbox.Npcs;
@inherits UtilityPage
@namespace Sandbox
@attribute [Icon( "🤖" )]
@attribute [Title( "#spawnmenu.utility.npcs" )]
@attribute [Group( "#spawnmenu.utility.group.world" )]
@attribute [Order( 1 )]
<root class="page" style="flex-direction: column;">
@if ( Connection.Local.HasPermission( "admin" ) )
{
<div class="control-row" Tooltip=@EnabledDescription>
<div class="left"><label>#spawnmenu.utility.ai_enabled</label></div>
<div style="flex-grow: 1;"></div>
<SwitchControl Value="@NpcConVars.Enabled" OnValueChanged=@( (bool value) => SetAiEnabled( value ) ) />
</div>
<div class="control-row" Tooltip=@NoTargetDescription>
<div class="left"><label>#spawnmenu.utility.no_target</label></div>
<div style="flex-grow: 1;"></div>
<SwitchControl Value="@NpcConVars.NoTarget" OnValueChanged=@( (bool value) => SetNoTarget( value ) ) />
</div>
}
else
{
<div class="control-row">
<div class="left"><label>⚠️ </label><label>#spawnmenu.common.host_only</label></div>
</div>
}
</root>
@code
{
public override bool IsPageVisible() => Connection.Local.HasPermission( "admin" );
static readonly string EnabledDescription = "#spawnmenu.utility.ai_enabled_description";
static readonly string NoTargetDescription = "#spawnmenu.utility.no_target_description";
void SetAiEnabled( bool enabled ) => GameManager.SetConVar( "sandbox.ai.enabled", enabled );
void SetNoTarget( bool noTarget ) => GameManager.SetConVar( "sandbox.ai.notarget", noTarget );
}