@using Sandbox @using Sandbox.UI @inherits PanelComponent @namespace Sandbox @CurrentAmmo / @TotalInInventory @* (@MaxAmmo - вместимость магазина) *@ @if ( IsReloading ) { } @code { private int CurrentAmmo { get; set; } = 0; private int MaxAmmo { get; set; } = 0; private bool IsReloading { get; set; } = false; private float ReloadProgress { get; set; } = 0f; private int TotalInInventory { get; set; } = 0; private bool HasWeapon { get; set; } = false; protected override void OnUpdate() { if ( Dedugan.Local == null ) return; var ammoInfo = Dedugan.Local.GetAmmoInfo(); CurrentAmmo = ammoInfo.current; MaxAmmo = ammoInfo.max; TotalInInventory = ammoInfo.totalInInventory; ReloadProgress = Dedugan.Local.GetReloadProgress(); IsReloading = ReloadProgress < 1f; // Проверяем, есть ли оружие в руках (если MaxAmmo > 0, значит есть оружие) HasWeapon = MaxAmmo > 0; } protected override int BuildHash() { if ( Dedugan.Local == null || !HasWeapon ) return -1; var hash = new System.HashCode(); hash.Add( CurrentAmmo ); hash.Add( MaxAmmo ); hash.Add( TotalInInventory ); hash.Add( IsReloading ); hash.Add( ReloadProgress ); hash.Add( HasWeapon ); return hash.ToHashCode(); } }