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()); } }
/// <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; }
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; }
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()); }