/// <summary>
 /// Creates from a serialized item.
 /// </summary>
 void FromItemData(ItemData_v1 data)
 {
     uid = data.uid;
     shortName = data.shortName;
     nativeMaterialValue = data.nativeMaterialValue;
     dyeColor = data.dyeColor;
     weightInKg = data.weightInKg;
     drawOrder = data.drawOrder;
     value1 = data.value1;
     value2 = data.value2;
     hits1 = data.hits1;
     hits2 = data.hits2;
     hits3 = data.hits3;
     stackCount = data.stackCount;
     enchantmentPoints = data.enchantmentPoints;
     message = data.message;
     legacyMagic = data.legacyMagic;
     playerTextureArchive = data.playerTextureArchive;
     playerTextureRecord = data.playerTextureRecord;
     worldTextureArchive = data.worldTextureArchive;
     worldTextureRecord = data.worldTextureRecord;
     itemGroup = data.itemGroup;
     groupIndex = data.groupIndex;
     currentVariant = data.currentVariant;
 }
        /// <summary>
        /// Gets item data for serialization.
        /// </summary>
        /// <returns>ItemData_v1.</returns>
        public ItemData_v1 GetSaveData()
        {
            ItemData_v1 data = new ItemData_v1();
            data.uid = uid;
            data.shortName = shortName;
            data.nativeMaterialValue = nativeMaterialValue;
            data.dyeColor = dyeColor;
            data.weightInKg = weightInKg;
            data.drawOrder = drawOrder;
            data.value1 = value1;
            data.value2 = value2;
            data.hits1 = hits1;
            data.hits2 = hits2;
            data.hits3 = hits3;
            data.stackCount = stackCount;
            data.enchantmentPoints = enchantmentPoints;
            data.message = message;
            data.legacyMagic = legacyMagic;
            data.playerTextureArchive = playerTextureArchive;
            data.playerTextureRecord = playerTextureRecord;
            data.worldTextureArchive = worldTextureArchive;
            data.worldTextureRecord = worldTextureRecord;
            data.itemGroup = itemGroup;
            data.groupIndex = groupIndex;
            data.currentVariant = currentVariant;

            return data;
        }
        /// <summary>
        /// Serialize items from this collection.
        /// </summary>
        /// <returns>ItemData_v1 array.</returns>
        public ItemData_v1[] SerializeItems()
        {
            ItemData_v1[] itemArray = new ItemData_v1[Count];

            int index = 0;
            foreach(DaggerfallUnityItem item in items.Values)
            {
                itemArray[index++] = item.GetSaveData();
            }

            return itemArray;
        }
 /// <summary>
 /// Construct item from serialized data.
 /// Used serialized UID.
 /// </summary>
 /// <param name="itemData">Item data to restore.</param>
 public DaggerfallUnityItem(ItemData_v1 itemData)
 {
     FromItemData(itemData);
 }
        /// <summary>
        /// Deserialize items into this collection.
        /// Existing items will be destroyed.
        /// </summary>
        /// <param name="itemArray">ItemData_v1 array.</param>
        public void DeserializeItems(ItemData_v1[] itemArray)
        {
            // Clear existing items
            Clear();

            // Nothing more to do if no items in source array
            if (itemArray == null || itemArray.Length == 0)
                return;

            // Add items to this collection
            for(int i = 0; i < itemArray.Length; i++)
            {
                DaggerfallUnityItem item = new DaggerfallUnityItem(itemArray[i]);
                AddItem(item);
            }
        }