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());
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="propDepositModule"> Prop Deposit module from static object. </param>
 /// <param name="lifetimeModule"> Lifetime module from static object. </param>
 /// <param name="damagePerMineUnit"> Required damage to mine one time. Example, if this value is 10 and actor hit multiple times sum on 10, this be like one mine action. </param>
 public DepositDurabilityModule(IPropDepositModule propDepositModule, ILifetimeModule lifetimeModule, int damagePerMineUnit)
 {
     IsActive           = true;
     _propDepositModule = propDepositModule;
     _lifetimeModule    = lifetimeModule;
     _damagePerMineUnit = damagePerMineUnit;
     _mineDamageCounter = _damagePerMineUnit;
 }
Ejemplo n.º 3
0
        public DepositLifetimeModule(IStaticObjectManager staticObjectManager, IStaticObject parentStaticObject)
        {
            _staticObjectManager = staticObjectManager ?? throw new ArgumentNullException(nameof(staticObjectManager));
            _parentStaticObject  = parentStaticObject ?? throw new ArgumentNullException(nameof(parentStaticObject));

            _depositModule   = _parentStaticObject.GetModule <IPropDepositModule>();
            _containerModule = _parentStaticObject.GetModule <IPropContainer>();

            _depositModule.Mined          += DepositModule_Mined;
            _containerModule.ItemsRemoved += ContainerModule_ItemsRemoved;
        }
Ejemplo n.º 4
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());
        }