Code/InventoryItem.cs
using Sandbox;
[AssetType( Extension = "item" )]
public class InventoryItem : GameResource
{
[Property] public string ItemName { get; set; } = "Unnamed Item";
[Property, TextArea] public string Description { get; set; } = "";
[Property] public Texture Icon { get; set; }
[Property, Range( 1, 999 )] public int MaxStack { get; set; } = 1;
[Property] public float Weight { get; set; } = 0f;
[Property] public ItemCategory Category { get; set; } = ItemCategory.Misc;
[Property] public ItemRarity Rarity { get; set; } = ItemRarity.Common;
[Property] public int MaxDurability { get; set; } = 0;
[Property] public bool IsUsable { get; set; } = false;
/// <summary>
/// The world prefab to spawn when this item is dropped.
/// Should contain an ItemPickup component to make it pickable.
/// If not set, a simple box will be used as fallback.
/// </summary>
[Property] public GameObject WorldPrefab { get; set; }
[Property] public EquipSlot EquipSlot { get; set; } = EquipSlot.None;
[Property] public StatModifier[] StatModifiers { get; set; } = new StatModifier[0];
}
public enum ItemCategory
{
Misc,
Weapon,
Armor,
Consumable,
Material,
Tool,
Key,
Ammo,
Quest
}
public enum ItemRarity
{
Common,
Uncommon,
Rare,
Epic,
Legendary
}
public enum StatType
{
MaxHealth,
Attack,
Defense,
Speed,
MagicPower,
MagicDefense,
}
public struct StatModifier
{
[Property] public StatType Type { get; set; }
[Property] public float Value { get; set; }
}
public enum EquipSlot
{
None,
Head,
Chest,
Legs,
Feet,
Hands,
WeaponMain,
WeaponOffhand,
Accessory1,
Accessory2,
}