コード例 #1
0
ファイル: ItemDragInfo.cs プロジェクト: Knopy/TQVaultAE
        /// <summary>
        /// Marks the item as placed removing it from the original container.
        /// </summary>
        /// <param name="slot">slot if an equipment placement.</param>
        public void MarkPlaced(int slot)
        {
            // Remove the item from the old sack
            if (this.IsModifiedItem)
            {
                // modified items do not have a source sack.
                // so no one needs to be notified of the placement.
            }
            else
            {
                if (this.sack.SackType == SackType.Equipment && slot != -1)
                {
                    // Remove the item out of the equipment slot
                    this.sack.RemoveAtItem(slot);

                    // Put a dummy item in it's place
                    Item newItem = this.item.MakeEmptyItem();
                    newItem.PositionX = SackCollection.GetEquipmentLocationOffset(slot).X;
                    newItem.PositionY = SackCollection.GetEquipmentLocationOffset(slot).Y;
                    this.sack.InsertItem(slot, newItem);
                }
                else
                {
                    this.sack.RemoveItem(this.item);
                }
            }

            // finally clear things out
            this.item             = null;
            this.sack             = null;
            this.sackPanel        = null;
            this.original         = null;
            this.autoMove         = AutoMoveLocation.NotSet;
            this.isBeingCancelled = false;
        }
コード例 #2
0
ファイル: ItemDragInfo.cs プロジェクト: tnm-l/TQVaultAE
        /// <summary>
        /// Marks the item as placed removing it from the original container.
        /// </summary>
        /// <param name="slot">slot if an equipment placement.</param>
        public void MarkPlaced()
        {
            int slot = -1;

            // modified items do not have a source sack.
            // so no one needs to be notified of the placement.
            if (!this.IsModifiedItem)
            {
                // Check to see if the dragged item is from one of the equipped slots.
                if (this.sack.SackType == SackType.Equipment)
                {
                    slot = EquipmentPanel.FindEquipmentSlot(this.sack, this.item);
                }

                if (slot != -1)
                {
                    // Remove the item out of the equipment slot
                    this.sack.RemoveAtItem(slot);

                    // Put a dummy item in it's place
                    Item newItem = this.item.MakeEmptyItem();
                    newItem.PositionX = SackCollection.GetEquipmentLocationOffset(slot).X;
                    newItem.PositionY = SackCollection.GetEquipmentLocationOffset(slot).Y;
                    this.sack.InsertItem(slot, newItem);
                }
                else
                {
                    // Remove the item from the old sack
                    this.sack.RemoveItem(this.item);
                }

                BagButtonTooltip.InvalidateCache(this.Sack, this.Original?.Sack);
            }

            // finally clear things out
            this.item             = null;
            this.sack             = null;
            this.sackPanel        = null;
            this.original         = null;
            this.AutoMove         = AutoMoveLocation.NotSet;
            this.IsBeingCancelled = false;
        }
コード例 #3
0
        /// <summary>
        /// Parses the binary sack data to internal data
        /// </summary>
        /// <param name="reader">BinaryReader instance</param>
        public void Parse(SackCollection sc, BinaryReader reader)
        {
            try
            {
                sc.isModified = false;

                if (sc.sackType == SackType.Stash)
                {
                    // IL decided to use a different format for the stash files.
                    TQData.ValidateNextString("numItems", reader);
                    sc.size = reader.ReadInt32();
                }
                else if (sc.sackType == SackType.Equipment)
                {
                    if (sc.isImmortalThrone)
                    {
                        sc.size  = 12;
                        sc.slots = 12;
                    }
                    else
                    {
                        sc.size  = 11;
                        sc.slots = 11;
                    }
                }
                else
                {
                    // sc is just a regular sack.
                    TQData.ValidateNextString("begin_block", reader);                     // make sure we just read a new block
                    sc.beginBlockCrap = reader.ReadInt32();

                    TQData.ValidateNextString("tempBool", reader);
                    sc.tempBool = reader.ReadInt32();

                    TQData.ValidateNextString("size", reader);
                    sc.size = reader.ReadInt32();
                }

                sc.items = new List <Item>(sc.size);

                Item prevItem = null;
                for (int i = 0; i < sc.size; ++i)
                {
                    // Additional logic to decode the weapon slots in the equipment section
                    if (sc.sackType == SackType.Equipment && (i == 7 || i == 9))
                    {
                        TQData.ValidateNextString("begin_block", reader);
                        sc.beginBlockCrap = reader.ReadInt32();

                        // Eat the alternate tag and flag
                        TQData.ValidateNextString("alternate", reader);

                        // Skip over the alternateCrap
                        reader.ReadInt32();
                    }

                    Item item = new Item();
                    item.ContainerType = sc.sackType;
                    ItemProvider.Parse(item, reader);

                    // Stack sc item with the previous item if necessary
                    if ((prevItem != null) && item.DoesStack && (item.PositionX == -1) && (item.PositionY == -1))
                    {
                        prevItem.StackSize++;
                    }
                    else
                    {
                        prevItem = item;
                        sc.items.Add(item);
                        if (sc.sackType == SackType.Equipment)
                        {
                            // Get the item location from the table
                            item.PositionX = SackCollection.GetEquipmentLocationOffset(i).X;
                            item.PositionY = SackCollection.GetEquipmentLocationOffset(i).Y;

                            // Eat the itemAttached tag and flag
                            TQData.ValidateNextString("itemAttached", reader);

                            // Skip over the itemAttachedCrap
                            reader.ReadInt32();
                        }
                    }

                    // Additional logic to decode the weapon slots in the equipment section
                    if (sc.sackType == SackType.Equipment && (i == 8 || i == 10))
                    {
                        TQData.ValidateNextString("end_block", reader);
                        sc.endBlockCrap = reader.ReadInt32();
                    }
                }

                TQData.ValidateNextString("end_block", reader);
                sc.endBlockCrap = reader.ReadInt32();
            }
            catch (ArgumentException ex)
            {
                // The ValidateNextString Method can throw an ArgumentException.
                // We just pass it along at sc point.
                Log.LogDebug(ex, "ValidateNextString fail !");
                throw;
            }
        }