Exemple #1
0
        /// <summary>
        /// Read ItemStatCost data
        /// </summary>
        private static void ReadItemStatCost()
        {
            List <ItemStatCost> statCosts = ItemStatCost.Read(Resources.Instance.OpenResourceText("ItemStatCost.txt"));

            itemStatCostsByName = statCosts.ToDictionary(v => v.Stat, v => v);
            itemStatCostsById   = statCosts.ToDictionary(v => v.ID, v => v);
        }
        /// <summary>
        /// Reads property data for a specified ID from BitReader
        /// </summary>
        /// <param name="propertyList">List of properties to add data to</param>
        /// <param name="currentPropertyID">ID of property to read from BitReader</param>
        /// <param name="isAdditional">Property to read has no header. Found in damage type properties</param>
        private void ReadPropertyData(List <PropertyInfo> propertyList, int currentPropertyID, bool isAdditional = false)
        {
            //ItemStatCost statCost = null;
            //if (ItemDefs.ItemStatCostsById.ContainsKey(currentPropertyID))
            ItemStatCost statCost = ItemDefs.ItemStatCostsById[currentPropertyID];

            if (statCost == null)
            {
                return;
            }

            PropertyInfo currentPropertyInfo = new PropertyInfo();

            currentPropertyInfo.IsAdditionalProperty = isAdditional;
            currentPropertyInfo.ID    = currentPropertyID;
            currentPropertyInfo.Value = (int)bs.ReadReversed(statCost.SaveBits) - statCost.SaveAdd;

            if (statCost.SaveParamBits > 0)
            {
                currentPropertyInfo.ParamValue = (int)bs.ReadReversed(statCost.SaveParamBits);
            }

            propertyList.Add(currentPropertyInfo);

            switch (statCost.Stat)
            {
            case "item_maxdamage_percent":
                ReadPropertyData(propertyList, ItemDefs.ItemStatCostsByName["item_mindamage_percent"].ID, true);
                break;

            case "firemindam":
                ReadPropertyData(propertyList, ItemDefs.ItemStatCostsByName["firemaxdam"].ID, true);
                break;

            case "lightmindam":
                ReadPropertyData(propertyList, ItemDefs.ItemStatCostsByName["lightmaxdam"].ID, true);
                break;

            case "magicmindam":
                ReadPropertyData(propertyList, ItemDefs.ItemStatCostsByName["magicmaxdam"].ID, true);
                break;

            case "coldmindam":
                ReadPropertyData(propertyList, ItemDefs.ItemStatCostsByName["coldmaxdam"].ID, true);
                ReadPropertyData(propertyList, ItemDefs.ItemStatCostsByName["coldlength"].ID, true);
                break;

            case "poisonmindam":
                ReadPropertyData(propertyList, ItemDefs.ItemStatCostsByName["poisonmaxdam"].ID, true);
                ReadPropertyData(propertyList, ItemDefs.ItemStatCostsByName["poisonlength"].ID, true);
                break;

            default:
                break;
            }
        }
Exemple #3
0
        /// <summary>
        /// Writes an item property to the BitStream
        /// </summary>
        /// <param name="bs">Bitstream to write property to</param>
        /// <param name="property">Property to write</param>
        private void WriteItemProperty(BitStream bs, PropertyInfo property)
        {
            if (property.ID == 0x1ff)
            {
                bs.WriteReversed(property.ID, 9);
                return;
            }

            ItemStatCost statCost = ItemDefs.ItemStatCostsById[property.ID];

            int fixedValue = property.Value + statCost.SaveAdd;

            if (!property.IsAdditionalProperty)
            {
                bs.WriteReversed(property.ID, 9);
            }

            bs.WriteReversed(fixedValue, statCost.SaveBits);

            if (statCost.SaveParamBits > 0)
            {
                bs.WriteReversed(property.ParamValue, statCost.SaveParamBits);
            }
        }