/// <summary> /// Loads inventory from byte array. /// </summary> /// <param name="data"> /// Byte array containing inventory items. /// </param> /// <param name="offset"> /// Position of inventory. /// </param> public Backpack(byte[] data, int offset) { for(int i = 0; i < 24; i++) { inventory[i] = new ItemStack(data, offset+i*6); } }
/// <summary> /// Loads inventory from byte array. /// </summary> /// <param name="data"> /// Byte array containing inventory items. /// </param> /// <param name="offset"> /// Position of inventory. /// </param> public Equipment(byte[] data, int offset) { Neck = new ItemStack(data, offset); Head = new ItemStack(data, offset+6); Tail = new ItemStack(data, offset+12); RightHand = new ItemStack(data, offset+18); Chest = new ItemStack(data, offset+24); LeftHand = new ItemStack(data, offset+30); RightFinger = new ItemStack(data, offset+36); Feet = new ItemStack(data, offset+42); LeftFinger = new ItemStack(data, offset+48); }
/// <summary> /// Removes all items from inventory. /// </summary> public override void Clear() { Neck = default(ItemStack); Head = default(ItemStack); Tail = default(ItemStack); RightHand = default(ItemStack); Chest = default(ItemStack); LeftHand = default(ItemStack); RightFinger = default(ItemStack); Feet = default(ItemStack); LeftFinger = default(ItemStack); }
/// <summary> /// Accesses item using item <paramref name="index"/>. /// </summary> /// <param name="index"> /// Item index in range from 0 to 8. /// </param> public override ItemStack this[int index] { get{ switch(index) { case 0: return Neck; case 1: return Head; case 2: return Tail; case 3: return RightHand; case 4: return Chest; case 5: return LeftHand; case 6: return RightFinger; case 7: return Feet; case 8: return LeftFinger; default: throw new ArgumentOutOfRangeException("index"); } } set{ switch(index) { case 0: Neck = value; break; case 1: Head = value; break; case 2: Tail = value; break; case 3: RightHand = value; break; case 4: Chest = value; break; case 5: LeftHand = value; break; case 6: RightFinger = value; break; case 7: Feet = value; break; case 8: LeftFinger = value; break; default: throw new ArgumentOutOfRangeException("index"); } } }
/// <summary> /// Compares two item stacks. /// </summary> public bool Equals(ItemStack stack) { return this.Count == stack.Count && this.Charges == stack.Charges && this.NumRecharged == stack.NumRecharged && this.Flags == stack.Flags && this.Type == stack.Type; }