Aura.Channel.World.Inventory.BankInventory.GetTransferTime C# (CSharp) Method

GetTransferTime() public static method

Returns the time it takes to transfer an item from one bank to the other in milliseconds.
Unofficial, but works well.
public static GetTransferTime ( string fromBankId, string toBankId ) : int
fromBankId string The id of the bank the item is at.
toBankId string The id of the bank the item is transferred to.
return int
		public static int GetTransferTime(string fromBankId, string toBankId)
		{
			if (fromBankId == "Global" || toBankId == "Global")
				return 0;

			var data1 = AuraData.BankDb.Find(fromBankId);
			var data2 = AuraData.BankDb.Find(toBankId);

			if (data1 == null || data2 == null)
			{
				Log.Warning("BankInventory.GetTransferTime: Unknown bank, returning 0 time. ({0} -> {1})", fromBankId, toBankId);
				return 0;
			}

			var pos1 = new Position(data1.X, data1.Y);
			var pos2 = new Position(data2.X, data2.Y);
			var distance = pos1.GetDistance(pos2);

			return distance * 5000;
		}

Usage Example

Beispiel #1
0
        /// <summary>
        /// Attempts to start a transfer of the given item to the bank the
        /// creature is currently using.
        /// </summary>
        /// <param name="creature"></param>
        /// <param name="itemEntityId"></param>
        /// <param name="instantTransfer"></param>
        /// <returns></returns>
        public bool Transfer(Creature creature, long itemEntityId, bool instantTransfer)
        {
            // Check bank
            var currentBank = creature.Temp.CurrentBankId;

            if (string.IsNullOrWhiteSpace(currentBank))
            {
                Log.Warning("BankTransferRequest: Player '0x{0:X16}' (Account: '{1}') tried to transfer item while not being in a bank.", creature.EntityId, creature.Client.Account.Id);
                return(false);
            }

            // Get item and tab
            Item   item    = null;
            string tabName = null;

            foreach (var tab in this.Tabs.Values)
            {
                item = tab.GetItem(itemEntityId);
                if (item != null)
                {
                    tabName = tab.Name;
                    break;
                }
            }

            if (item == null)
            {
                Log.Warning("BankTransferRequest: Player '0x{0:X16}' (Account: '{1}') tried to transfer a non-existing or in-transit item.", creature.EntityId, creature.Client.Account.Id);
                return(false);
            }

            // Get fee and time
            var fee  = BankInventory.GetTransferFee(item, item.Bank, currentBank);
            var time = BankInventory.GetTransferTime(item.Bank, currentBank);

            // Incrase fee for instant transfer.
            if (instantTransfer)
            {
                // Don't change, hardcoded in the client.
                fee  = 100 + (fee * 5);
                time = 0;
            }

            // Check gold
            if (this.Gold < fee)
            {
                Send.MsgBox(creature, Localization.Get("Unable to pay the fee, Insufficient balance."));
                return(false);
            }

            // Transfer
            item.Bank = currentBank;
            item.BankTransferStart    = DateTime.Now;
            item.BankTransferDuration = time;

            this.RemoveGold(creature, fee);

            Send.BankTransferInfo(creature, tabName, item);

            return(true);
        }