public IMineDepositResult TryMine(IPropDepositModule deposit)
        {
            if (deposit is null)
            {
                throw new ArgumentNullException(nameof(deposit));
            }

            var requiredToolTags = deposit.GetToolTags();
            var hasAllTags       = EquipmentHelper.HasAllTags(_tool.Scheme.Tags, requiredToolTags);

            if (!hasAllTags)
            {
                throw new InvalidOperationException("Попытка выполнить добычу ресурса не подходящим инструментом.");
            }

            var isSuccessfulMining = _mineDepositMethodRandomSource.RollSuccess(deposit.Difficulty);

            if (isSuccessfulMining)
            {
                deposit.Mine();

                return(new SuccessMineDepositResult());
            }
            else
            {
                return(new FailureMineDepositResult());
            }
        }
        public void TakeDamage(int damageValue)
        {
            if (_mineDamageCounter <= 0)
            {
                throw new InvalidOperationException("Попытка нанести урон залежам с нулевым счётчиком.");
            }

            _mineDamageCounter -= damageValue;
            if (_mineDamageCounter <= 0)
            {
                _propDepositModule.Mine();

                if (Value > 0)
                {
                    _mineDamageCounter = _damagePerMineUnit;
                }
                else
                {
                    if (!_lifetimeModule.IsParentStaticObjectDestroyed)
                    {
                        _lifetimeModule.Destroy();
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public IMineDepositResult TryMine(IPropDepositModule deposit)
        {
            if (deposit is null)
            {
                throw new ArgumentNullException(nameof(deposit));
            }

            if (deposit.GetToolTags().Any())
            {
                throw new InvalidOperationException("Попытка выполнить добычу ресурса не подходящим инструментом.");
            }

            var isSuccessfulMining = _mineDepositMethodRandomSource.RollSuccess(deposit.Difficulty);

            if (isSuccessfulMining)
            {
                deposit.Mine();

                return(new SuccessMineDepositResult());
            }

            return(new FailureMineDepositResult());
        }