public bool TryStack(PlayerItem pi) { Contract.Requires(pi != null); if (this.IsEmpty() || pi.IsEmpty()) { return false; } return (this.RInventoryItem.TryStack(pi.RInventoryItem) != InventoryItem.MergeResult.Failed); }
/// <summary> /// Adds an Item to the inventory. /// </summary> /// <param name="item"></param> /// <param name="i"></param> public void AddItem(PlayerItem item, int i = 1) { _inv.AddItemAmount(item.RInventoryItem.datablock, i); }
/// <summary> /// Drops the specific item. /// </summary> /// <param name="pi"></param> public void DropItem(PlayerItem pi) { DropHelper.DropItem(this.InternalInventory, pi.Slot); }
public void RemoveItem(PlayerItem pi) { Contract.Requires(pi != null); foreach (PlayerItem item in this.Items) { if (item == pi) { this._inv.RemoveItem(pi.RInventoryItem); return; } } foreach (PlayerItem item2 in this.ArmorItems) { if (item2 == pi) { this._inv.RemoveItem(pi.RInventoryItem); return; } } foreach (PlayerItem item3 in this.BarItems) { if (item3 == pi) { this._inv.RemoveItem(pi.RInventoryItem); break; } } }
public void DropItem(PlayerItem pi) { Contract.Requires(pi != null); DropHelper.DropItem(this.InternalInventory, pi.Slot); }
public static Data.Entities.StoreItem GetStoreItem(Data.Entities.User user, Fougerite.PlayerItem item, int price = 1) { if (item.Name != "" && item.Quantity != -1 && item != null) { IInventoryItem itemdata = item.RInventoryItem; string category = item.RInventoryItem.datablock.category.ToString(); int internalID = 1; if (StoreItems.Count > 0) { Data.Entities.StoreItem lastItem = StoreItems.Last <Data.Entities.StoreItem>(); if (lastItem != null) { internalID = lastItem.InternalID + 1; } } Data.Entities.StoreItem newItem = new Data.Entities.StoreItem { InternalID = internalID, UserID = user.ID, Price = price, Date = DateTime.Now.ToString(), ItemName = item.Name, ItemCategory = GetCategoryNumber(category), ItemQuantity = item.Quantity, ItemCondition = itemdata.condition, Item = item, }; if (user.Player != null) { newItem.Player = user.Player; } else { return(null); } if (item.isWeapon) { newItem.ItemWeaponBullets = itemdata.uses; ItemModDataBlock mod1 = item.getModSlot(0); ItemModDataBlock mod2 = item.getModSlot(1); ItemModDataBlock mod3 = item.getModSlot(2); ItemModDataBlock mod4 = item.getModSlot(3); ItemModDataBlock mod5 = item.getModSlot(4); newItem.ItemWeaponSlots = item.getModSlotsCount; if (mod1 != null) { newItem.ItemWeaponSlot1 = mod1.name; } if (mod2 != null) { newItem.ItemWeaponSlot2 = mod2.name; } if (mod3 != null) { newItem.ItemWeaponSlot3 = mod3.name; } if (mod4 != null) { newItem.ItemWeaponSlot4 = mod4.name; } if (mod5 != null) { newItem.ItemWeaponSlot5 = mod5.name; } } return(newItem); } return(null); }