sasalka/Code/Inventory/Definitions/BaseItemDefinition.cs
2025-06-28 22:26:47 +03:00

84 lines
2.0 KiB
C#

namespace Sasalka;
public enum ItemCategory
{
Weapon,
Clothing,
Ammo,
Consumable,
Tool,
Misc
}
public enum ItemRarity
{
Common,
Uncommon,
Rare,
Epic,
Legendary
}
[GameResource( "Base Item Definition", "inv", "", Category = "Sasalka", Icon = "inventory_2" )]
public class BaseItemDefinition : GameResource
{
[Property, Title( "Basic Info" )] public string Name { get; set; } = "Unknown Item";
[Property] public string Description { get; set; } = "";
[Property, Category( "Visual" )]
[ResourceType( "prefab" )]
public GameObject Prefab { get; set; } = GameObject.GetPrefab( "prefabs/item_parcel.prefab" );
[Property, Category( "Visual" )] public Texture ImageTexture { get; set; }
[Property, Category( "Visual" )] public string ImageUrl { get; set; }
[Property, Category( "Properties" )]
[Range( 1, 1000 )]
public int MaxCount { get; set; } = 1;
[Property, Category( "Properties" )] public virtual ItemCategory Category { get; set; } = ItemCategory.Misc;
[Property, Category( "Properties" )] public ItemRarity Rarity { get; set; } = ItemRarity.Common;
[Property, Category( "Properties" )] public float Weight { get; set; } = 1.0f;
[Property, Category( "Properties" )] public bool IsStackable = false;
[Property, Category( "Properties" )] public bool IsEquipable => this is IEquipable;
public virtual Inventar.InventorySlot? GetSlot() => null;
public virtual bool CanUse() => false;
public virtual void OnUse( InventoryItem item ) { }
public string GetRarityColor()
{
return Rarity switch
{
ItemRarity.Common => "#ffffff",
ItemRarity.Uncommon => "#1eff00",
ItemRarity.Rare => "#0070dd",
ItemRarity.Epic => "#a335ee",
ItemRarity.Legendary => "#ff8000",
_ => "#ffffff"
};
}
public string GetCategoryIcon()
{
return Category switch
{
ItemCategory.Weapon => "🔫",
ItemCategory.Clothing => "👕",
ItemCategory.Ammo => "💥",
ItemCategory.Consumable => "🍖",
ItemCategory.Tool => "🔧",
ItemCategory.Misc => "📦",
_ => "📦"
};
}
}