Beispiel #1
0
        public void DumpToPlayer()
        {
            for (int i = _currentAmount - 1; i > -1; i--)
            {
#if SUBNAUTICA
                var itemSize = CraftData.GetItemSize(TechType.GasPod);
#elif BELOWZERO
                var itemSize = TechData.GetItemSize(techType);
#endif
                if (Inventory.main.HasRoomFor(itemSize.x, itemSize.y))
                {
                    if (_currentAmount > 0)
                    {
                        _currentAmount -= 1;
                        var pickup = CraftData.InstantiateFromPrefab(TechType.GasPod).GetComponent <Pickupable>();
                        Inventory.main.Pickup(pickup);
                    }
                }
                else
                {
                    break;
                }

                OnAmountChanged?.Invoke(_currentAmount);
            }
        }
Beispiel #2
0
        public void SetAmount(byte amount)
        {
            var oldAmount = Amount;

            Amount = Math.Min((byte)100, amount);

            OnAmountChanged?.Invoke(this, oldAmount);
        }
        private async Task CheckChanges()
        {
            var client = new QBitNinjaClient(settings.ApiUrl, Network.Main);

            OnNewCheckCycleStarted?.Invoke(this, EventArgs.Empty);

            foreach (var monitoringElement in monitoringList.ToList())
            {
                var from  = new BlockFeature(SpecialFeature.Last);
                var until = new BlockFeature(monitoringElement.Until.BlockHeight);

                var balance =
                    await client.GetBalanceBetween(new BalanceSelector(monitoringElement.Address), from, until).ConfigureAwait(false);

                if (balance == null)
                {
                    throw new PaymentMonitorException($"Can't get {monitoringElement.Address} balance");
                }


                var monitorUntilTxid   = monitoringElement.Until.TransactionId;
                var oldToNewOperations = balance.Operations.Where(t => t.ReceivedCoins != null).ToList();

                if (oldToNewOperations.Count == 0)
                {
                    continue;
                }

                oldToNewOperations.Reverse();
                if (monitorUntilTxid != uint256.Zero && oldToNewOperations.Exists(x => x.TransactionId == monitorUntilTxid))
                {
                    oldToNewOperations = oldToNewOperations.SkipWhile(x => x.TransactionId != monitorUntilTxid).ToList();
                    oldToNewOperations.RemoveAll(x => x.TransactionId == monitorUntilTxid);
                }

                foreach (var operation in oldToNewOperations)
                {
                    if (operation.Confirmations < settings.MinConfirmations)
                    {
                        continue;
                    }

                    var lku = new TransactionIdentity
                    {
                        BlockHeight   = operation.Height,
                        TransactionId = operation.TransactionId,
                    };


                    var info = new MoneyEventInfo(monitoringElement.Address, lku,
                                                  operation.ReceivedCoins.Cast <Coin>().Select(x => x.Amount).ToList());

                    OnAmountChanged?.Invoke(this, info);
                    UpdateElementIdentity(monitoringElement, lku);
                }
            }
        }
Beispiel #4
0
        internal void AddGaspod(Collider collider)
        {
            if (_currentAmount < _storageLimit)
            {
                _currentAmount += 1;
            }

            Destroy(collider.gameObject);

            OnAmountChanged?.Invoke(_currentAmount);
            OnGaspodCollected?.Invoke();
        }
Beispiel #5
0
        /// <summary>
        /// Checks if the amount entered in the input field is valid and updates the amount changed listeners.
        /// </summary>
        private void CheckIfValidAmount()
        {
            bool emptyField = string.IsNullOrEmpty(amountInputField.Text);

            amountInputField.Error = emptyField || SendableAmount == 0 || SendableAmount > MaxSendableAmount;

            if (!emptyField)
            {
                amountInputField.errorMessage.text = SendableAmount == 0 ? "Invalid amount" : "Exceeds " + tradableTokenSymbol + " balance";
            }

            OnAmountChanged?.Invoke();
        }
        private void CostCenterFlatStructures_OnItemPropertyChanged(object sender, object item, System.ComponentModel.PropertyChangedEventArgs e)
        {
            CostCenterFlatStructures.OnItemPropertyChanged -=
                CostCenterFlatStructures_OnItemPropertyChanged;

            CostCenterFlatStructure costCenter = (CostCenterFlatStructure)item;

            foreach (CostCenterFlatStructure CostCenterFlatStructure in CostCenterFlatStructures)
            {
                if (CostCenterFlatStructure.ParentKey == costCenter.Key && costCenter.IsActive)
                {
                    CostCenterFlatStructure.IsActive = true;
                }
                else if (CostCenterFlatStructure.ParentKey == costCenter.Key && costCenter.IsActive == false)
                {
                    CostCenterFlatStructure.IsActive = false;
                }
            }

            if (costCenter.IsActive)
            {
                int parentKey = costCenter.ParentKey;
                do
                {
                    CostCenterFlatStructure parentCategory =
                        CostCenterFlatStructures.SingleOrDefault(x => x.Key == parentKey);
                    if (parentCategory != null)
                    {
                        parentCategory.IsActive = true;
                        parentKey = parentCategory.ParentKey;
                    }
                    else
                    {
                        parentKey = 0;
                    }
                } while (parentKey != 0);
            }

            CostCenterFlatStructures.OnItemPropertyChanged +=
                CostCenterFlatStructures_OnItemPropertyChanged;
            RaisePropertyChanged("CostCenterFlatStructures");
            OnAmountChanged?.Invoke();
        }
Beispiel #7
0
        internal void RemoveGaspod()
        {
#if SUBNAUTICA
            var itemSize = CraftData.GetItemSize(TechType.GasPod);
#elif BELOWZERO
            var itemSize = TechData.GetItemSize(TechType.GasPod);
#endif
            if (Inventory.main.HasRoomFor(itemSize.x, itemSize.y))
            {
                if (_currentAmount > 0)
                {
                    _currentAmount -= 1;
                    var pickup = CraftData.InstantiateFromPrefab(TechType.GasPod).GetComponent <Pickupable>();
                    Inventory.main.Pickup(pickup);
                }
            }


            OnAmountChanged?.Invoke(_currentAmount);
        }
Beispiel #8
0
 private void ModifyAmount(float value)
 {
     Amount = Mathf.Clamp(Amount + value, 0f, _stats.MaxDuration);
     OnAmountChanged?.Invoke();
 }