/// <summary>
 /// Handles fetching of a value in the IntValues Dictionary
 /// </summary>
 /// <param name="defaultValue">Default Value to use if value is not found in the Settings Dictionary</param>
 /// <param name="name">Compiler Generated Name of Property</param>
 /// <returns>Int Value for the dictionary</returns>
 public int GetInt(int?defaultValue = null, [CallerMemberName] string name = null)
 {
     if (name == null)
     {
         return(0);
     }
     return(IntValues.ContainsKey(name) ? IntValues[name] : defaultValue ?? 0);
 }
 /// <summary>
 /// Handles setting of a value in the IntValues Dictionary
 /// </summary>
 /// <param name="value">Value to Set</param>
 /// <param name="name">Compiler Generated Name of the Property</param>
 public void SetInt(int value, [CallerMemberName] string name = null)
 {
     if (name == null)
     {
         return;
     }
     if (IntValues.ContainsKey(name))
     {
         IntValues[name] = value;
     }
     else
     {
         IntValues.Add(name, value);
     }
 }
예제 #3
0
        /// <summary>
        /// This will init ItemSetID and CachedSpells.
        /// </summary>
        public void BuiltItemSearchCache()
        {
            ItemSetId = IntValues.ContainsKey(265) ? IntValues[265] : 0;

            foreach (var spellId in Spells)
            {
                try
                {
                    Spell spell = SpellTools.GetSpell(spellId);
                    cachedSpells.Add(spell);
                }
                catch (ArgumentException)
                {
                    MessageBox.Show("Unable to cache spell id: " + spellId + " on item: " + Name + ". Spell ID not found in the master table.");
                }
            }
        }
예제 #4
0
        public ExecutionState LoadData(ByteReader br)
        {
            while (br.Avaliable > 0)
            {
                var Name = br.ReadString();
                if (!Name)
                {
                    return(ExecutionState.Failed());
                }
                var Type = br.ReadByte();
                if (!Type)
                {
                    return(ExecutionState.Failed());
                }
                if (!DataTypeHelper.TryParse(Type.Result, out DataType TypeResult))
                {
                    return(ExecutionState.Failed());
                }
                switch (TypeResult)
                {
                case DataType.type_byte:
                    var ValueByte = br.ReadByte();
                    if (!ValueByte)
                    {
                        return(ExecutionState.Failed());
                    }
                    if (ByteValues.ContainsKey(Name.Result))
                    {
                        return(ExecutionState.Failed());
                    }
                    ByteValues.Add(Name.Result, ValueByte.Result);
                    break;

                case DataType.type_sbyte:
                    var ValueSByte = br.ReadSByte();
                    if (!ValueSByte)
                    {
                        return(ExecutionState.Failed());
                    }
                    if (SByteValues.ContainsKey(Name.Result))
                    {
                        return(ExecutionState.Failed());
                    }
                    SByteValues.Add(Name.Result, ValueSByte.Result);
                    break;

                case DataType.type_short:
                    var ValueShort = br.ReadShort();
                    if (!ValueShort)
                    {
                        return(ExecutionState.Failed());
                    }
                    if (ShortValues.ContainsKey(Name.Result))
                    {
                        return(ExecutionState.Failed());
                    }
                    ShortValues.Add(Name.Result, ValueShort.Result);
                    break;

                case DataType.type_ushort:
                    var ValueUShort = br.ReadUShort();
                    if (!ValueUShort)
                    {
                        return(ExecutionState.Failed());
                    }
                    if (UShortValues.ContainsKey(Name.Result))
                    {
                        return(ExecutionState.Failed());
                    }
                    UShortValues.Add(Name.Result, ValueUShort.Result);
                    break;

                case DataType.type_int:
                    var ValueInt = br.ReadInt();
                    if (!ValueInt)
                    {
                        return(ExecutionState.Failed());
                    }
                    if (IntValues.ContainsKey(Name.Result))
                    {
                        return(ExecutionState.Failed());
                    }
                    IntValues.Add(Name.Result, ValueInt.Result);
                    break;

                case DataType.type_uint:
                    var ValueUInt = br.ReadUInt();
                    if (!ValueUInt)
                    {
                        return(ExecutionState.Failed());
                    }
                    if (UIntValues.ContainsKey(Name.Result))
                    {
                        return(ExecutionState.Failed());
                    }
                    UIntValues.Add(Name.Result, ValueUInt.Result);
                    break;

                case DataType.type_long:
                    var ValueLong = br.ReadLong();
                    if (!ValueLong)
                    {
                        return(ExecutionState.Failed());
                    }
                    if (LongValues.ContainsKey(Name.Result))
                    {
                        return(ExecutionState.Failed());
                    }
                    LongValues.Add(Name.Result, ValueLong.Result);
                    break;

                case DataType.type_ulong:
                    var ValueULong = br.ReadULong();
                    if (!ValueULong)
                    {
                        return(ExecutionState.Failed());
                    }
                    if (ULongValues.ContainsKey(Name.Result))
                    {
                        return(ExecutionState.Failed());
                    }
                    ULongValues.Add(Name.Result, ValueULong.Result);
                    break;

                case DataType.type_single:
                    var ValueSingle = br.ReadSingle();
                    if (!ValueSingle)
                    {
                        return(ExecutionState.Failed());
                    }
                    if (SingleValues.ContainsKey(Name.Result))
                    {
                        return(ExecutionState.Failed());
                    }
                    SingleValues.Add(Name.Result, ValueSingle.Result);
                    break;

                case DataType.type_double:
                    var ValueDobule = br.ReadDouble();
                    if (!ValueDobule)
                    {
                        return(ExecutionState.Failed());
                    }
                    if (DoubleValues.ContainsKey(Name.Result))
                    {
                        return(ExecutionState.Failed());
                    }
                    DoubleValues.Add(Name.Result, ValueDobule.Result);
                    break;

                case DataType.type_string:
                    var ValueString = br.ReadString();
                    if (!ValueString)
                    {
                        return(ExecutionState.Failed());
                    }
                    if (StringValues.ContainsKey(Name.Result))
                    {
                        return(ExecutionState.Failed());
                    }
                    StringValues.Add(Name.Result, ValueString.Result);
                    break;
                }
            }

            return(ExecutionState.Succeeded());
        }