Console command bindings for host-side weapon settings. Provides two concommands, swb_host_customization and swb_host_autoreload, which set WeaponSettings.Instance.Customization and AutoReload after ensuring the caller is the host (or running singleplayer/editor where networking is inactive).
namespace SWB.Base;
/// <summary>
/// SWB's host-side weapon settings.
///
/// ⚠️ MODIFIED FROM UPSTREAM — the only file in swb_base that was. It used
/// `PlayerBase.Local.IsHost` from SWB's own `swb_player` module, which this
/// project does NOT vendor: we have NZPlayer, and pulling in a second player
/// controller to satisfy one boolean would mean two player systems fighting
/// over the same GameObject.
///
/// `Networking.IsHost` answers the same question without the dependency.
///
/// ⚠️ Keep this note if SWB is ever updated — the upstream version of this file
/// will not compile here, and the reason is not obvious from the error.
/// </summary>
public class Commands
{
[ConCmd( "swb_host_customization", Help = "Enable the weapon customization menu (Q)" )]
public static void SetWeaponCustomization( int enable )
{
// ⚠️ Solo in the editor there is no active networking, and IsHost is
// false — which would make every one of these commands silently do
// nothing in exactly the situation they get used in. Not networked
// means you ARE the host.
if ( Networking.IsActive && !Networking.IsHost ) return;
WeaponSettings.Instance.Customization = enable != 0;
}
[ConCmd( "swb_host_autoreload", Help = "Reload weapons automatically while shooting if clip is empty" )]
public static void SetWeaponAutoReload( int enable )
{
if ( Networking.IsActive && !Networking.IsHost ) return;
WeaponSettings.Instance.AutoReload = enable != 0;
}
}