Backpack playerBackpack = new Backpack(); playerBackpack.AddItem("Sword"); playerBackpack.AddItem("Potion"); playerBackpack.RemoveItem("Sword"); if(playerBackpack.HasItem("Potion")){ Console.WriteLine("Player has potion"); }
Backpack playerBackpack = new Backpack(); Item sword = new Item("Sword"); sword.AddAttribute("Damage", 10); playerBackpack.AddItem(sword); if(playerBackpack.GetItem("Sword").GetAttribute("Damage") == 10){ Console.WriteLine("Sword has correct damage attribute"); }This example demonstrates how to add attributes to an item and get them from the Backpack. It creates a new Backpack instance, creates a new Item instance with a custom attribute "Damage" and a value of 10, adds the sword to the Backpack, and then checks that the attribute value is correct. Package Library: The Server.Items Backpack is a part of the Server library in C#.