Exemplo n.º 1
0
        public static void StorageObjectUpdateMessageTreatment(Message message, byte[] packetDatas, AccountUC account)
        {
            StorageObjectUpdateMessage storageObjectUpdateMessage = (StorageObjectUpdateMessage)message;

            using (BigEndianReader reader = new BigEndianReader(packetDatas))
            {
                storageObjectUpdateMessage.Deserialize(reader);
            }
            bool exists = false;

            for (int index = 0; index < account.SafeItems.Count; index++)
            {
                if (account.SafeItems[index].ObjectUID ==
                    storageObjectUpdateMessage.Object.ObjectUID)
                {
                    account.SafeItems[index].Quantity +=
                        storageObjectUpdateMessage.Object.Quantity;
                    exists = true;
                }
            }
            if (!exists)
            {
                account.SafeItems.Add(storageObjectUpdateMessage.Object);
            }
        }
Exemplo n.º 2
0
        public void Update(StorageObjectUpdateMessage message)
        {
            var obj = Objects.FirstOrDefault(f => f.UID == message.Object.ObjectUID);

            // Needs to be added
            if (obj == null)
            {
                Objects.Add(new ObjectEntry(message.Object, DataManager.Get <Items>((int)message.Object.ObjectGID)));
            }
            // Needs to be updated
            else
            {
                obj.Update(message.Object);
            }

            StorageUpdated?.Invoke();
        }
Exemplo n.º 3
0
 public static Task HandleStorageObjectUpdateMessage(Account account, StorageObjectUpdateMessage message)
 => Task.Run(() => account.Game.Storage.Update(message));