// -------------------------------------------------------------------------------------------------------------------- // // Copyright (c) VRMADA, All rights reserved. // // -------------------------------------------------------------------------------------------------------------------- using System; using UltimateXR.Core.Components; using UltimateXR.Manipulation; using UnityEngine; namespace UltimateXR.Mechanics.Weapons { /// /// A magazine that contains ammo for a . Magazines can be attached to firearms using /// functionality. /// public partial class UxrFirearmMag : UxrComponent { #region Inspector Properties/Serialized Fields [SerializeField] private int _rounds; [SerializeField] private int _capacity; #endregion #region Public Types & Data /// /// Total ammo capacity. /// public int Capacity => _capacity; /// /// Remaining ammo. /// public int Rounds { get => Mathf.Clamp(_rounds, 0, _capacity); set { _rounds = Mathf.Clamp(value, 0, _capacity); RoundsChanged?.Invoke(); } } /// /// Event called whenever the number of rounds changed. /// public Action RoundsChanged; #endregion } }