/// <summary>
        /// Warning !! this method is experimental, there is known issues dues to architectural problems:
        /// the Item wont be initialize by ItemGenerationProvider.
        /// </summary>
        /// <param name="character"></param>
        /// <param name="item"></param>
        /// <param name="quantity"></param>
        public static void AddQuietCharacterItem(CharacterRecord character, CharacterItemRecord item)
        {
            lock (CharactersItems)
            {
                bool isOnline = WorldServer.Instance.IsOnline(character.Id);

                if (isOnline)
                {
                    Logger.Write <CharacterItemRecord>("Cannot attribute " + item.Template.Name + " to " + character.Name + " , the character is online!", ConsoleColor.Red);
                }
                else
                {
                    item.CharacterId = character.Id;
                    var items = CharacterItemRecord.GetCharacterItems(character.Id);
                    var same  = items.FirstOrDefault(x => x.GId == item.GId && x.PositionEnum == CharacterInventoryPositionEnum.INVENTORY_POSITION_NOT_EQUIPED && Inventory.SameEffects(x.Effects, item.Effects));

                    if (same != null)
                    {
                        same.Quantity += item.Quantity;
                        same.UpdateElement();
                    }
                    else
                    {
                        item.UId = ItemUIdPopper.PopUID();
                        item.AddElement();
                    }
                }
            }
        }
Beispiel #2
0
 /// <summary>
 /// Lorsque plusieurs objects sont ajoutés
 /// </summary>
 /// <param name="obj"></param>
 void Inventory_OnItemsAdded(IEnumerable <CharacterItemRecord> obj)
 {
     foreach (var item in obj)
     {
         item.UId = ItemUIdPopper.PopUID();
         item.AddElement();
     }
     Character.Client.Send(new ObjectsAddedMessage(Array.ConvertAll(obj.ToArray(), x => x.GetObjectItem())));
     RefreshWeight();
 }
 public override AbstractItem CloneWithoutUID()
 {
     return(new BidShopItemRecord(this.BidShopId,
                                  this.AccountId,
                                  this.Price,
                                  ItemUIdPopper.PopUID(),
                                  this.GId,
                                  this.Position,
                                  this.Quantity,
                                  new List <Effect>(this.Effects),
                                  this.AppearanceId));
 }
        /// <summary>
        /// Lorsqu'un objet est ajouté
        /// </summary>
        /// <param name="obj"></param>
        void Inventory_OnItemAdded(CharacterItemRecord obj)
        {
            obj.UId = ItemUIdPopper.PopUID();

            if (ItemGenerationProvider.IsHandled(obj.Template.TypeEnum))
            {
                ItemGenerationProvider.InitItem(obj, Character);
            }

            obj.AddElement();
            Character.Client.Send(new ObjectAddedMessage(obj.GetObjectItem()));
            RefreshWeight();
        }
 public override AbstractItem CloneWithoutUID()
 {
     return(new CharacterItemRecord(CharacterId, ItemUIdPopper.PopUID(), GId, Position, Quantity, new List <Effect>(Effects), AppearanceId));
 }
 public BidShopItemRecord ToBidShopItemRecord(int bidshopId, int accountId, uint price)
 {
     return(new BidShopItemRecord(bidshopId, accountId, price, ItemUIdPopper.PopUID(), GId, Position, Quantity, new List <Effect>(Effects), AppearanceId));
 }
 public override AbstractItem CloneWithoutUID()
 {
     return(new BidShopItemRecord(BidShopId, AccountId,
                                  Price, ItemUIdPopper.PopUID(), GId, Position, Quantity, new List <Effect>(Effects), AppearanceId));
 }
Beispiel #8
0
 public override AbstractItem CloneWithoutUID()
 {
     return(new BankItemRecord(this.AccountId, ItemUIdPopper.PopUID(), this.GId, this.Position, this.Quantity, this.Effects, this.AppearanceId));
 }