/// <summary> /// Copies the column values into the given Dictionary using the database column name /// with a prefixed @ as the key. The keys must already exist in the Dictionary; /// this method will not create them if they are missing. /// </summary> /// <param name="source">The object to copy the values from.</param> /// <param name="dic">The Dictionary to copy the values into.</param> public static void CopyValues(IItemTable source, IDictionary <String, Object> dic) { dic["action_display_id"] = source.ActionDisplayID; dic["amount"] = source.Amount; dic["description"] = source.Description; dic["equipped_body"] = source.EquippedBody; dic["graphic"] = source.Graphic; dic["height"] = source.Height; dic["hp"] = source.HP; dic["id"] = source.ID; dic["item_template_id"] = source.ItemTemplateID; dic["mp"] = source.MP; dic["name"] = source.Name; dic["range"] = source.Range; dic["stat_agi"] = (Int16)source.GetStat(StatType.Agi); dic["stat_defence"] = (Int16)source.GetStat(StatType.Defence); dic["stat_int"] = (Int16)source.GetStat(StatType.Int); dic["stat_maxhit"] = (Int16)source.GetStat(StatType.MaxHit); dic["stat_maxhp"] = (Int16)source.GetStat(StatType.MaxHP); dic["stat_maxmp"] = (Int16)source.GetStat(StatType.MaxMP); dic["stat_minhit"] = (Int16)source.GetStat(StatType.MinHit); dic["stat_req_agi"] = (Int16)source.GetReqStat(StatType.Agi); dic["stat_req_int"] = (Int16)source.GetReqStat(StatType.Int); dic["stat_req_str"] = (Int16)source.GetReqStat(StatType.Str); dic["stat_str"] = (Int16)source.GetStat(StatType.Str); dic["type"] = source.Type; dic["value"] = source.Value; dic["weapon_type"] = source.WeaponType; dic["width"] = source.Width; }
/// <summary> /// Copies the values from the given <paramref name="source"/> into this ItemTable. /// </summary> /// <param name="source">The IItemTable to copy the values from.</param> public void CopyValuesFrom(IItemTable source) { this.ActionDisplayID = (System.Nullable <NetGore.Features.ActionDisplays.ActionDisplayID>)source.ActionDisplayID; this.Amount = (System.Byte)source.Amount; this.Description = (System.String)source.Description; this.EquippedBody = (System.String)source.EquippedBody; this.Graphic = (NetGore.GrhIndex)source.Graphic; this.Height = (System.Byte)source.Height; this.HP = (DemoGame.SPValueType)source.HP; this.ID = (DemoGame.ItemID)source.ID; this.ItemTemplateID = (System.Nullable <DemoGame.ItemTemplateID>)source.ItemTemplateID; this.MP = (DemoGame.SPValueType)source.MP; this.Name = (System.String)source.Name; this.Range = (System.UInt16)source.Range; this.SetStat((DemoGame.StatType)DemoGame.StatType.Agi, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.Agi)); this.SetStat((DemoGame.StatType)DemoGame.StatType.Defence, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.Defence)); this.SetStat((DemoGame.StatType)DemoGame.StatType.Int, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.Int)); this.SetStat((DemoGame.StatType)DemoGame.StatType.MaxHit, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxHit)); this.SetStat((DemoGame.StatType)DemoGame.StatType.MaxHP, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxHP)); this.SetStat((DemoGame.StatType)DemoGame.StatType.MaxMP, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxMP)); this.SetStat((DemoGame.StatType)DemoGame.StatType.MinHit, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.MinHit)); this.SetReqStat((DemoGame.StatType)DemoGame.StatType.Agi, (System.Int32)source.GetReqStat((DemoGame.StatType)DemoGame.StatType.Agi)); this.SetReqStat((DemoGame.StatType)DemoGame.StatType.Int, (System.Int32)source.GetReqStat((DemoGame.StatType)DemoGame.StatType.Int)); this.SetReqStat((DemoGame.StatType)DemoGame.StatType.Str, (System.Int32)source.GetReqStat((DemoGame.StatType)DemoGame.StatType.Str)); this.SetStat((DemoGame.StatType)DemoGame.StatType.Str, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.Str)); this.Type = (DemoGame.ItemType)source.Type; this.Value = (System.Int32)source.Value; this.WeaponType = (DemoGame.WeaponType)source.WeaponType; this.Width = (System.Byte)source.Width; }
/// <summary> /// Copies the values from the given <paramref name="source"/> into this ItemTable. /// </summary> /// <param name="source">The IItemTable to copy the values from.</param> public void CopyValuesFrom(IItemTable source) { ActionDisplayID = source.ActionDisplayID; Amount = source.Amount; Description = source.Description; EquippedBody = source.EquippedBody; Graphic = source.Graphic; Height = source.Height; HP = source.HP; ID = source.ID; ItemTemplateID = source.ItemTemplateID; MP = source.MP; Name = source.Name; Range = source.Range; SetStat(StatType.Agi, source.GetStat(StatType.Agi)); SetStat(StatType.Defence, source.GetStat(StatType.Defence)); SetStat(StatType.Int, source.GetStat(StatType.Int)); SetStat(StatType.MaxHit, source.GetStat(StatType.MaxHit)); SetStat(StatType.MaxHP, source.GetStat(StatType.MaxHP)); SetStat(StatType.MaxMP, source.GetStat(StatType.MaxMP)); SetStat(StatType.MinHit, source.GetStat(StatType.MinHit)); SetReqStat(StatType.Agi, source.GetReqStat(StatType.Agi)); SetReqStat(StatType.Int, source.GetReqStat(StatType.Int)); SetReqStat(StatType.Str, source.GetReqStat(StatType.Str)); SetStat(StatType.Str, source.GetStat(StatType.Str)); Type = source.Type; Value = source.Value; WeaponType = source.WeaponType; Width = source.Width; }
/// <summary> /// Checks if this <see cref="IItemTable"/> contains the same values as another <see cref="IItemTable"/>. /// </summary> /// <param name="source">The source <see cref="IItemTable"/>.</param> /// <param name="otherItem">The <see cref="IItemTable"/> to compare the values to.</param> /// <returns> /// True if this <see cref="IItemTable"/> contains the same values as the <paramref name="otherItem"/>; otherwise false. /// </returns> public static System.Boolean HasSameValues(this IItemTable source, IItemTable otherItem) { return(Equals(source.ActionDisplayID, otherItem.ActionDisplayID) && Equals(source.Amount, otherItem.Amount) && Equals(source.Description, otherItem.Description) && Equals(source.EquippedBody, otherItem.EquippedBody) && Equals(source.Graphic, otherItem.Graphic) && Equals(source.Height, otherItem.Height) && Equals(source.HP, otherItem.HP) && Equals(source.ID, otherItem.ID) && Equals(source.ItemTemplateID, otherItem.ItemTemplateID) && Equals(source.MP, otherItem.MP) && Equals(source.Name, otherItem.Name) && Equals(source.Range, otherItem.Range) && Equals(source.SkillID, otherItem.SkillID) && Equals(source.GetStat((DemoGame.StatType)DemoGame.StatType.Agi), otherItem.GetStat((DemoGame.StatType)DemoGame.StatType.Agi)) && Equals(source.GetStat((DemoGame.StatType)DemoGame.StatType.Defence), otherItem.GetStat((DemoGame.StatType)DemoGame.StatType.Defence)) && Equals(source.GetStat((DemoGame.StatType)DemoGame.StatType.Int), otherItem.GetStat((DemoGame.StatType)DemoGame.StatType.Int)) && Equals(source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxHit), otherItem.GetStat((DemoGame.StatType)DemoGame.StatType.MaxHit)) && Equals(source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxHP), otherItem.GetStat((DemoGame.StatType)DemoGame.StatType.MaxHP)) && Equals(source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxMP), otherItem.GetStat((DemoGame.StatType)DemoGame.StatType.MaxMP)) && Equals(source.GetStat((DemoGame.StatType)DemoGame.StatType.MinHit), otherItem.GetStat((DemoGame.StatType)DemoGame.StatType.MinHit)) && Equals(source.GetReqStat((DemoGame.StatType)DemoGame.StatType.Agi), otherItem.GetReqStat((DemoGame.StatType)DemoGame.StatType.Agi)) && Equals(source.GetReqStat((DemoGame.StatType)DemoGame.StatType.Int), otherItem.GetReqStat((DemoGame.StatType)DemoGame.StatType.Int)) && Equals(source.GetReqStat((DemoGame.StatType)DemoGame.StatType.Str), otherItem.GetReqStat((DemoGame.StatType)DemoGame.StatType.Str)) && Equals(source.GetStat((DemoGame.StatType)DemoGame.StatType.Str), otherItem.GetStat((DemoGame.StatType)DemoGame.StatType.Str)) && Equals(source.Type, otherItem.Type) && Equals(source.Value, otherItem.Value) && Equals(source.WeaponType, otherItem.WeaponType) && Equals(source.Width, otherItem.Width)); }
/// <summary> /// Copies the column values into the given Dictionary using the database column name /// with a prefixed @ as the key. The keys must already exist in the Dictionary; /// this method will not create them if they are missing. /// </summary> /// <param name="source">The object to copy the values from.</param> /// <param name="dic">The Dictionary to copy the values into.</param> public static void CopyValues(IItemTable source, System.Collections.Generic.IDictionary <System.String, System.Object> dic) { dic["action_display_id"] = (System.Nullable <NetGore.Features.ActionDisplays.ActionDisplayID>)source.ActionDisplayID; dic["amount"] = (System.Byte)source.Amount; dic["description"] = (System.String)source.Description; dic["equipped_body"] = (System.String)source.EquippedBody; dic["graphic"] = (NetGore.GrhIndex)source.Graphic; dic["height"] = (System.Byte)source.Height; dic["hp"] = (DemoGame.SPValueType)source.HP; dic["id"] = (DemoGame.ItemID)source.ID; dic["item_template_id"] = (System.Nullable <DemoGame.ItemTemplateID>)source.ItemTemplateID; dic["mp"] = (DemoGame.SPValueType)source.MP; dic["name"] = (System.String)source.Name; dic["range"] = (System.UInt16)source.Range; dic["stat_agi"] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.Agi); dic["stat_defence"] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.Defence); dic["stat_int"] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.Int); dic["stat_maxhit"] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxHit); dic["stat_maxhp"] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxHP); dic["stat_maxmp"] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxMP); dic["stat_minhit"] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.MinHit); dic["stat_req_agi"] = (System.Int16)source.GetReqStat((DemoGame.StatType)DemoGame.StatType.Agi); dic["stat_req_int"] = (System.Int16)source.GetReqStat((DemoGame.StatType)DemoGame.StatType.Int); dic["stat_req_str"] = (System.Int16)source.GetReqStat((DemoGame.StatType)DemoGame.StatType.Str); dic["stat_str"] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.Str); dic["type"] = (DemoGame.ItemType)source.Type; dic["value"] = (System.Int32)source.Value; dic["weapon_type"] = (DemoGame.WeaponType)source.WeaponType; dic["width"] = (System.Byte)source.Width; }
/// <summary> /// Copies the column values into the given DbParameterValues using the database column name /// with a prefixed @ as the key. The keys must already exist in the DbParameterValues; /// this method will not create them if they are missing. /// </summary> /// <param name="source">The object to copy the values from.</param> /// <param name="paramValues">The DbParameterValues to copy the values into.</param> public static void CopyValues(this IItemTable source, DbParameterValues paramValues) { paramValues["action_display_id"] = (ushort?)source.ActionDisplayID; paramValues["amount"] = source.Amount; paramValues["description"] = source.Description; paramValues["equipped_body"] = source.EquippedBody; paramValues["graphic"] = (UInt16)source.Graphic; paramValues["height"] = source.Height; paramValues["hp"] = (Int16)source.HP; paramValues["id"] = (Int32)source.ID; paramValues["item_template_id"] = (ushort?)source.ItemTemplateID; paramValues["mp"] = (Int16)source.MP; paramValues["name"] = source.Name; paramValues["range"] = source.Range; paramValues["stat_agi"] = (Int16)source.GetStat(StatType.Agi); paramValues["stat_defence"] = (Int16)source.GetStat(StatType.Defence); paramValues["stat_int"] = (Int16)source.GetStat(StatType.Int); paramValues["stat_maxhit"] = (Int16)source.GetStat(StatType.MaxHit); paramValues["stat_maxhp"] = (Int16)source.GetStat(StatType.MaxHP); paramValues["stat_maxmp"] = (Int16)source.GetStat(StatType.MaxMP); paramValues["stat_minhit"] = (Int16)source.GetStat(StatType.MinHit); paramValues["stat_req_agi"] = (Int16)source.GetReqStat(StatType.Agi); paramValues["stat_req_int"] = (Int16)source.GetReqStat(StatType.Int); paramValues["stat_req_str"] = (Int16)source.GetReqStat(StatType.Str); paramValues["stat_str"] = (Int16)source.GetStat(StatType.Str); paramValues["type"] = (Byte)source.Type; paramValues["value"] = source.Value; paramValues["weapon_type"] = (Byte)source.WeaponType; paramValues["width"] = source.Width; }
/// <summary> /// Handles when the ItemInfo for the given slot has been received. /// </summary> /// <param name="slot">The slot.</param> /// <param name="itemInfo">The item info. Can be null, which will be equivilant to saying that the /// item has no information or does not exist.</param> public void ReceiveInfo(T slot, IItemTable itemInfo) { if (_slot.Equals(slot)) { _itemInfo = itemInfo; _isItemInfoSet = true; } }
/// <summary> /// Unsets the current <see cref="IItemTable"/>, forcing the data to be reacquired. /// </summary> public void Unset() { _slot = default(T); _itemInfo = null; _slotObj = null; _needToRequest = true; _isItemInfoSet = false; }
/// <summary> /// Initializes a new instance of the <see cref="ItemEntity"/> class. /// </summary> /// <param name="iv">The item values.</param> public ItemEntity(IItemTable iv) : this( Vector2.Zero, new Vector2(iv.Width, iv.Height), iv.ItemTemplateID, iv.Name, iv.Description, iv.Type, iv.WeaponType, iv.Range, iv.Graphic, iv.Value, iv.Amount, iv.HP, iv.MP, iv.EquippedBody, iv.ActionDisplayID, iv.Stats.Select(x => (Stat <StatType>)x), iv.ReqStats.Select(x => (Stat <StatType>)x)) { _id = iv.ID; }
/// <summary> /// Creates the <see cref="StyledText"/> lines needed to display the information for an item. /// </summary> /// <param name="itemInfo">The item information to create the <see cref="StyledText"/> lines for.</param> /// <returns>The <see cref="StyledText"/> lines needed to display the information for the <paramref name="itemInfo"/>.</returns> public static StyledText[] GetStyledText(IItemTable itemInfo) { if (itemInfo == null) { return(StyledText.EmptyArray); } return(GetStyledText(itemInfo.Name, itemInfo.Description, itemInfo.Value, itemInfo.HP, itemInfo.MP, itemInfo.Stats, itemInfo.ReqStats)); }
/// <summary> /// Handles when the ItemInfo for the given slot has been received. /// </summary> /// <param name="slot">The slot.</param> /// <param name="reader">The <see cref="IValueReader"/> to read the <see cref="IItemTable"/> from. An internal /// <see cref="IItemTable"/> instance will be used for containing the data. Must not be null.</param> public void ReceiveInfo(T slot, IValueReader reader) { _reusableItemInfo.ReadState(reader); if (_slot.Equals(slot)) { _itemInfo = _reusableItemInfo; _isItemInfoSet = true; } }
/// <summary> /// Initializes a new instance of the <see cref="ItemEntity"/> class. /// </summary> /// <param name="iv">The item values.</param> public ItemEntity(IItemTable iv) : base(Vector2.Zero, new Vector2(iv.Width, iv.Height)) { _id = iv.ID; _templateID = iv.ItemTemplateID; _name = iv.Name; _description = iv.Description; _graphicIndex = iv.Graphic; _value = iv.Value; _amount = iv.Amount; _type = iv.Type; _weaponType = iv.WeaponType; _range = iv.Range; _equippedBody = iv.EquippedBody; _baseStats = NewItemStats(iv.Stats.Select(x => (Stat <StatType>)x), StatCollectionType.Base); _reqStats = NewItemStats(iv.ReqStats.Select(x => (Stat <StatType>)x), StatCollectionType.Requirement); Resized += ItemEntity_Resized; }
/// <summary> /// Notifies this object when an item has been added into an <see cref="EquipmentSlot"/>. /// </summary> /// <param name="slot">The <see cref="EquipmentSlot"/> the item was added to.</param> /// <param name="item">The item.</param> public void NotifyAdded(EquipmentSlot slot, IItemTable item) { // Get the ID of the slot var slotID = slot.GetValue(); // Check if there is a paper-doll item in the slot already. If so, remove it. if (_bodies[slotID] != null) { NotifyRemoved(slot); } // Check that the new item has a paper-doll value if (string.IsNullOrEmpty(item.EquippedBody)) { return; } // The new item has a paper-doll value, so add it and synchronize _bodies[slotID] = item.EquippedBody; SynchronizeBodyLayers(); }
/// <summary> /// Checks if this <see cref="IItemTable"/> contains the same values as another <see cref="IItemTable"/>. /// </summary> /// <param name="source">The source <see cref="IItemTable"/>.</param> /// <param name="otherItem">The <see cref="IItemTable"/> to compare the values to.</param> /// <returns> /// True if this <see cref="IItemTable"/> contains the same values as the <paramref name="otherItem"/>; otherwise false. /// </returns> public static Boolean HasSameValues(this IItemTable source, IItemTable otherItem) { return Equals(source.ActionDisplayID, otherItem.ActionDisplayID) && Equals(source.Amount, otherItem.Amount) && Equals(source.Description, otherItem.Description) && Equals(source.EquippedBody, otherItem.EquippedBody) && Equals(source.Graphic, otherItem.Graphic) && Equals(source.Height, otherItem.Height) && Equals(source.HP, otherItem.HP) && Equals(source.ID, otherItem.ID) && Equals(source.ItemTemplateID, otherItem.ItemTemplateID) && Equals(source.MP, otherItem.MP) && Equals(source.Name, otherItem.Name) && Equals(source.Range, otherItem.Range) && Equals(source.GetStat(StatType.Agi), otherItem.GetStat(StatType.Agi)) && Equals(source.GetStat(StatType.Defence), otherItem.GetStat(StatType.Defence)) && Equals(source.GetStat(StatType.Int), otherItem.GetStat(StatType.Int)) && Equals(source.GetStat(StatType.MaxHit), otherItem.GetStat(StatType.MaxHit)) && Equals(source.GetStat(StatType.MaxHP), otherItem.GetStat(StatType.MaxHP)) && Equals(source.GetStat(StatType.MaxMP), otherItem.GetStat(StatType.MaxMP)) && Equals(source.GetStat(StatType.MinHit), otherItem.GetStat(StatType.MinHit)) && Equals(source.GetReqStat(StatType.Agi), otherItem.GetReqStat(StatType.Agi)) && Equals(source.GetReqStat(StatType.Int), otherItem.GetReqStat(StatType.Int)) && Equals(source.GetReqStat(StatType.Str), otherItem.GetReqStat(StatType.Str)) && Equals(source.GetStat(StatType.Str), otherItem.GetStat(StatType.Str)) && Equals(source.Type, otherItem.Type) && Equals(source.Value, otherItem.Value) && Equals(source.WeaponType, otherItem.WeaponType) && Equals(source.Width, otherItem.Width); }
/// <summary> /// Gets the <see cref="IItemTable"/> for the item in the given <paramref name="slot"/>. /// </summary> /// <param name="slot">The slot of the item to get the info for.</param> /// <param name="itemInfo">When this method returns true, contains the <see cref="IItemTable"/> for the /// item at the given <paramref name="slot"/>.</param> /// <returns>The <see cref="IItemTable"/> of the item for the given <paramref name="slot"/>, or null if /// the given <paramref name="slot"/> contained no item.</returns> public bool TryGetInfo(T slot, out IItemTable itemInfo) { // If the item in the slot is null, don't even bother - just return a null IItemTable if (IsSlotNull(slot)) { itemInfo = null; return(true); } // Check if the slot to get the information has changed, or if the item in the slot is different var currSlotObj = GetSlotObject(slot); if (!_slot.Equals(slot) || (_slotObj != GetSlotObject(slot))) { _slot = slot; _needToRequest = true; _isItemInfoSet = false; _slotObj = currSlotObj; } // Send the request for the slot if it hasn't been made yet if (_needToRequest) { // Send a request to the server for the information on the item in the slot using (var pw = GetRequest(_slot)) { Socket.Send(pw, ClientMessageType.GUIItemInfoRequest); } _needToRequest = false; itemInfo = null; return(false); } itemInfo = _itemInfo; return(_isItemInfoSet); }
/// <summary> /// Copies the values from the given <paramref name="source"/> into this ItemTable. /// </summary> /// <param name="source">The IItemTable to copy the values from.</param> public void CopyValuesFrom(IItemTable source) { this.ActionDisplayID = (System.Nullable<NetGore.Features.ActionDisplays.ActionDisplayID>)source.ActionDisplayID; this.Amount = (System.Byte)source.Amount; this.Description = (System.String)source.Description; this.EquippedBody = (System.String)source.EquippedBody; this.Graphic = (NetGore.GrhIndex)source.Graphic; this.Height = (System.Byte)source.Height; this.HP = (DemoGame.SPValueType)source.HP; this.ID = (DemoGame.ItemID)source.ID; this.ItemTemplateID = (System.Nullable<DemoGame.ItemTemplateID>)source.ItemTemplateID; this.MP = (DemoGame.SPValueType)source.MP; this.Name = (System.String)source.Name; this.Range = (System.UInt16)source.Range; this.SkillID = (System.Nullable<DemoGame.SkillType>)source.SkillID; this.SetStat((DemoGame.StatType)DemoGame.StatType.Agi, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.Agi)); this.SetStat((DemoGame.StatType)DemoGame.StatType.Defence, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.Defence)); this.SetStat((DemoGame.StatType)DemoGame.StatType.Int, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.Int)); this.SetStat((DemoGame.StatType)DemoGame.StatType.MaxHit, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxHit)); this.SetStat((DemoGame.StatType)DemoGame.StatType.MaxHP, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxHP)); this.SetStat((DemoGame.StatType)DemoGame.StatType.MaxMP, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxMP)); this.SetStat((DemoGame.StatType)DemoGame.StatType.MinHit, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.MinHit)); this.SetReqStat((DemoGame.StatType)DemoGame.StatType.Agi, (System.Int32)source.GetReqStat((DemoGame.StatType)DemoGame.StatType.Agi)); this.SetReqStat((DemoGame.StatType)DemoGame.StatType.Int, (System.Int32)source.GetReqStat((DemoGame.StatType)DemoGame.StatType.Int)); this.SetReqStat((DemoGame.StatType)DemoGame.StatType.Str, (System.Int32)source.GetReqStat((DemoGame.StatType)DemoGame.StatType.Str)); this.SetStat((DemoGame.StatType)DemoGame.StatType.Str, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.Str)); this.Type = (DemoGame.ItemType)source.Type; this.Value = (System.Int32)source.Value; this.WeaponType = (DemoGame.WeaponType)source.WeaponType; this.Width = (System.Byte)source.Width; }
/// <summary> /// Initializes a new instance of the <see cref="ItemEntity"/> class. /// </summary> /// <param name="iv">The item values.</param> public ItemEntity(IItemTable iv) : base(Vector2.Zero, new Vector2(iv.Width, iv.Height)) { _id = iv.ID; _templateID = iv.ItemTemplateID; _name = iv.Name; _description = iv.Description; _graphicIndex = iv.Graphic; _value = iv.Value; _amount = iv.Amount; _type = iv.Type; _weaponType = iv.WeaponType; _range = iv.Range; _equippedBody = iv.EquippedBody; _baseStats = NewItemStats(iv.Stats.Select(x => (Stat<StatType>)x), StatCollectionType.Base); _reqStats = NewItemStats(iv.ReqStats.Select(x => (Stat<StatType>)x), StatCollectionType.Requirement); Resized += ItemEntity_Resized; }
/// <summary> /// Initializes a new instance of the <see cref="ItemTable"/> class. /// </summary> /// <param name="source">IItemTable to copy the initial values from.</param> public ItemTable(IItemTable source) { CopyValuesFrom(source); }
/// <summary> /// Copies the column values into the given Dictionary using the database column name /// with a prefixed @ as the key. The keys must already exist in the Dictionary; /// this method will not create them if they are missing. /// </summary> /// <param name="source">The object to copy the values from.</param> /// <param name="dic">The Dictionary to copy the values into.</param> public static void CopyValues(IItemTable source, IDictionary<String, Object> dic) { dic["action_display_id"] = source.ActionDisplayID; dic["amount"] = source.Amount; dic["description"] = source.Description; dic["equipped_body"] = source.EquippedBody; dic["graphic"] = source.Graphic; dic["height"] = source.Height; dic["hp"] = source.HP; dic["id"] = source.ID; dic["item_template_id"] = source.ItemTemplateID; dic["mp"] = source.MP; dic["name"] = source.Name; dic["range"] = source.Range; dic["stat_agi"] = (Int16)source.GetStat(StatType.Agi); dic["stat_defence"] = (Int16)source.GetStat(StatType.Defence); dic["stat_int"] = (Int16)source.GetStat(StatType.Int); dic["stat_maxhit"] = (Int16)source.GetStat(StatType.MaxHit); dic["stat_maxhp"] = (Int16)source.GetStat(StatType.MaxHP); dic["stat_maxmp"] = (Int16)source.GetStat(StatType.MaxMP); dic["stat_minhit"] = (Int16)source.GetStat(StatType.MinHit); dic["stat_req_agi"] = (Int16)source.GetReqStat(StatType.Agi); dic["stat_req_int"] = (Int16)source.GetReqStat(StatType.Int); dic["stat_req_str"] = (Int16)source.GetReqStat(StatType.Str); dic["stat_str"] = (Int16)source.GetStat(StatType.Str); dic["type"] = source.Type; dic["value"] = source.Value; dic["weapon_type"] = source.WeaponType; dic["width"] = source.Width; }
/// <summary> /// Creates the <see cref="StyledText"/> lines needed to display the information for an item. /// </summary> /// <param name="itemInfo">The item information to create the <see cref="StyledText"/> lines for.</param> /// <returns>The <see cref="StyledText"/> lines needed to display the information for the <paramref name="itemInfo"/>.</returns> public static StyledText[] GetStyledText(IItemTable itemInfo) { if (itemInfo == null) return StyledText.EmptyArray; return GetStyledText(itemInfo.Name, itemInfo.Description, itemInfo.Value, itemInfo.HP, itemInfo.MP, itemInfo.Stats, itemInfo.ReqStats); }
/// <summary> /// Copies the column values into the given DbParameterValues using the database column name /// with a prefixed @ as the key. The key must already exist in the DbParameterValues /// for the value to be copied over. If any of the keys in the DbParameterValues do not /// match one of the column names, or if there is no field for a key, then it will be /// ignored. Because of this, it is important to be careful when using this method /// since columns or keys can be skipped without any indication. /// </summary> /// <param name="source">The object to copy the values from.</param> /// <param name="paramValues">The DbParameterValues to copy the values into.</param> public static void TryCopyValues(this IItemTable source, DbParameterValues paramValues) { for (var i = 0; i < paramValues.Count; i++) { switch (paramValues.GetParameterName(i)) { case "action_display_id": paramValues[i] = (ushort?)source.ActionDisplayID; break; case "amount": paramValues[i] = source.Amount; break; case "description": paramValues[i] = source.Description; break; case "equipped_body": paramValues[i] = source.EquippedBody; break; case "graphic": paramValues[i] = (UInt16)source.Graphic; break; case "height": paramValues[i] = source.Height; break; case "hp": paramValues[i] = (Int16)source.HP; break; case "id": paramValues[i] = (Int32)source.ID; break; case "item_template_id": paramValues[i] = (ushort?)source.ItemTemplateID; break; case "mp": paramValues[i] = (Int16)source.MP; break; case "name": paramValues[i] = source.Name; break; case "range": paramValues[i] = source.Range; break; case "stat_agi": paramValues[i] = (Int16)source.GetStat(StatType.Agi); break; case "stat_defence": paramValues[i] = (Int16)source.GetStat(StatType.Defence); break; case "stat_int": paramValues[i] = (Int16)source.GetStat(StatType.Int); break; case "stat_maxhit": paramValues[i] = (Int16)source.GetStat(StatType.MaxHit); break; case "stat_maxhp": paramValues[i] = (Int16)source.GetStat(StatType.MaxHP); break; case "stat_maxmp": paramValues[i] = (Int16)source.GetStat(StatType.MaxMP); break; case "stat_minhit": paramValues[i] = (Int16)source.GetStat(StatType.MinHit); break; case "stat_req_agi": paramValues[i] = (Int16)source.GetReqStat(StatType.Agi); break; case "stat_req_int": paramValues[i] = (Int16)source.GetReqStat(StatType.Int); break; case "stat_req_str": paramValues[i] = (Int16)source.GetReqStat(StatType.Str); break; case "stat_str": paramValues[i] = (Int16)source.GetStat(StatType.Str); break; case "type": paramValues[i] = (Byte)source.Type; break; case "value": paramValues[i] = source.Value; break; case "weapon_type": paramValues[i] = (Byte)source.WeaponType; break; case "width": paramValues[i] = source.Width; break; } } }
/// <summary> /// Copies the column values into the given Dictionary using the database column name /// with a prefixed @ as the key. The keys must already exist in the Dictionary; /// this method will not create them if they are missing. /// </summary> /// <param name="source">The object to copy the values from.</param> /// <param name="dic">The Dictionary to copy the values into.</param> public static void CopyValues(IItemTable source, System.Collections.Generic.IDictionary<System.String,System.Object> dic) { dic["action_display_id"] = (System.Nullable<NetGore.Features.ActionDisplays.ActionDisplayID>)source.ActionDisplayID; dic["amount"] = (System.Byte)source.Amount; dic["description"] = (System.String)source.Description; dic["equipped_body"] = (System.String)source.EquippedBody; dic["graphic"] = (NetGore.GrhIndex)source.Graphic; dic["height"] = (System.Byte)source.Height; dic["hp"] = (DemoGame.SPValueType)source.HP; dic["id"] = (DemoGame.ItemID)source.ID; dic["item_template_id"] = (System.Nullable<DemoGame.ItemTemplateID>)source.ItemTemplateID; dic["mp"] = (DemoGame.SPValueType)source.MP; dic["name"] = (System.String)source.Name; dic["range"] = (System.UInt16)source.Range; dic["skill_id"] = (System.Nullable<DemoGame.SkillType>)source.SkillID; dic["stat_agi"] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.Agi); dic["stat_defence"] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.Defence); dic["stat_int"] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.Int); dic["stat_maxhit"] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxHit); dic["stat_maxhp"] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxHP); dic["stat_maxmp"] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxMP); dic["stat_minhit"] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.MinHit); dic["stat_req_agi"] = (System.Int16)source.GetReqStat((DemoGame.StatType)DemoGame.StatType.Agi); dic["stat_req_int"] = (System.Int16)source.GetReqStat((DemoGame.StatType)DemoGame.StatType.Int); dic["stat_req_str"] = (System.Int16)source.GetReqStat((DemoGame.StatType)DemoGame.StatType.Str); dic["stat_str"] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.Str); dic["type"] = (DemoGame.ItemType)source.Type; dic["value"] = (System.Int32)source.Value; dic["weapon_type"] = (DemoGame.WeaponType)source.WeaponType; dic["width"] = (System.Byte)source.Width; }
/// <summary> /// Initializes a new instance of the <see cref="ItemEntity"/> class. /// </summary> /// <param name="iv">The item values.</param> public ItemEntity(IItemTable iv) : this( Vector2.Zero, new Vector2(iv.Width, iv.Height), iv.ItemTemplateID, iv.Name, iv.Description, iv.Type, iv.WeaponType, iv.Range, iv.Graphic, iv.Value, iv.Amount, iv.HP, iv.MP, iv.EquippedBody, iv.ActionDisplayID, iv.Stats.Select(x => (Stat<StatType>)x), iv.ReqStats.Select(x => (Stat<StatType>)x)) { _id = iv.ID; }
/// <summary> /// Handles attacking with a melee weapon. /// </summary> /// <param name="weapon">The weapon to attack with. Cannot be null.</param> /// <param name="target">The target to attack. Can be null.</param> void AttackMelee(IItemTable weapon, Character target) { if (weapon == null) { Debug.Fail("Weapon should not be null..."); return; } OnAttacked(); if (Attacked != null) Attacked.Raise(this, EventArgs.Empty); // If melee and no target was defined, try to find one automatically if (target == null) { var hitArea = GameData.GetMeleeAttackArea(this, weapon.Range); target = Map.Spatial.Get<Character>(hitArea, x => x != this && x.IsAlive && Alliance.CanAttack(x.Alliance)); } // Display the attack var targetID = (target != null ? target.MapEntityIndex : (MapEntityIndex?)null); using (var charAttack = ServerPacket.CharAttack(MapEntityIndex, targetID, weapon.ActionDisplayID)) { Map.SendToArea(this, charAttack, ServerMessageType.MapEffect); } // Check that we managed to find a target if (target == null) return; // We found a target, so attack it AttackApplyReal(target); }