Advertisement
SleepyMode

Untitled

Mar 17th, 2023
720
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.79 KB | None | 0 0
  1.  
  2. public partial class BaseInventory
  3. {
  4.     /// <summary>
  5.     /// The type of the inventory in question, such as player, container, et cetera.
  6.     /// </summary>
  7.     [Net] public string Type { get; set; }
  8.  
  9.     /// <summary>
  10.     /// The unique identifier of the inventory in the database.
  11.     /// </summary>
  12.     [Net] public long UniqueId { get; set; }
  13.    
  14.     /// <summary>
  15.     /// The items contained by this inventory.
  16.     /// </summary>
  17.     [Net] public IList<ItemInstance> Items { get; set; }
  18.  
  19.     /// <summary>
  20.     /// Returns the list of items contained within this inventory of the given type.
  21.     /// </summary>
  22.     /// <param name="type">The type of the item.</param>
  23.     /// <returns>The items contained in the inventory with of given type.</returns>
  24.     public IEnumerable<ItemInstance> GetItemsOfType( string type )
  25.     {
  26.         return Items.Where( item => item.Type == type );
  27.     }
  28.  
  29.     /// <summary>
  30.     /// Returns the list of items contained within this inventory which pass the given filter.
  31.     /// </summary>
  32.     /// <param name="filter">The filter that defines which items will be returned.</param>
  33.     /// <returns>The items contained in the inventory which pass the given filter.</returns>
  34.     public IEnumerable<ItemInstance> FilterItems( Func<ItemInstance, bool> filter )
  35.     {
  36.         return Items.Where( filter );
  37.     }
  38.  
  39.     /// <summary>
  40.     /// Checks whether or not the inventory contains an item of the given type.
  41.     /// </summary>
  42.     /// <param name="type">The type to look for.</param>
  43.     /// <returns>The item if found, otherwise null.</returns>
  44.     public ItemInstance HasItem( string type )
  45.     {
  46.         return GetItemsOfType( type ).FirstOrDefault();
  47.     }
  48.  
  49.     /// <summary>
  50.     /// Checks whether or not the inventory contains an item.
  51.     /// </summary>
  52.     /// <param name="item">The item to look for.</param>
  53.     /// <returns>The item if found, otherwise null</returns>
  54.     public ItemInstance HasItem( ItemInstance item )
  55.     {
  56.         return FilterItems( inventoryItem => inventoryItem.UniqueId == item.UniqueId ).FirstOrDefault();
  57.     }
  58.  
  59.     /// <summary>
  60.     /// Adds an item of the given type to the inventory.
  61.     /// </summary>
  62.     /// <param name="type">The item type to add to the inventory.</param>
  63.     /// <returns>The created instance.</returns>
  64.     public Task<ItemInstance> AddItem( string type )
  65.     {
  66.         throw new NotImplementedException();
  67.     }
  68.  
  69.     /// <summary>
  70.     /// Adds an item to the inventory.
  71.     /// </summary>
  72.     /// <param name="item">The item to add.</param>
  73.     /// <returns>The created instance.</returns>
  74.     public bool AddItem( ItemInstance item )
  75.     {
  76.         throw new NotImplementedException();
  77.     }
  78.  
  79.     /// <summary>
  80.     /// Removes an item from the inventory.
  81.     /// </summary>
  82.     /// <param name="type">The type of the item to remove</param>
  83.     /// <param name="item">The removed item instance.</param>
  84.     /// <returns>True if the item was successfully removed, false otherwise.</returns>
  85.     public bool RemoveItem( string type, out ItemInstance item )
  86.     {
  87.         throw new NotImplementedException();
  88.     }
  89.  
  90.     /// <summary>
  91.     /// Removes an item from the inventory.
  92.     /// </summary>
  93.     /// <param name="item">The item to remove.</param>
  94.     /// <returns>True if the item was successfully removed, false otherwise.</returns>
  95.     public bool RemoveItem( ItemInstance item )
  96.     {
  97.         throw new NotImplementedException();
  98.     }
  99.  
  100.     /// <summary>
  101.     /// Deletes an item from the inventory.
  102.     /// </summary>
  103.     /// <param name="type">The type of the item to delete.</param>
  104.     /// <returns>True if the item was successfully deleted, false otherwise.</returns>
  105.     public bool DeleteItem( string type )
  106.     {
  107.         throw new NotImplementedException();
  108.     }
  109.  
  110.     /// <summary>
  111.     /// Deletes an item from the inventory.
  112.     /// </summary>
  113.     /// <param name="item">The item to delete.</param>
  114.     /// <returns>True if the item was successfully deleted, false otherwise.</returns>
  115.     public bool DeleteItem( ItemInstance item )
  116.     {
  117.         throw new NotImplementedException();
  118.     }
  119. }
  120.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement