2025-05-01 10:04:15 +02:00
|
|
|
|
using Cirno.Scripts.Interactables;
|
|
|
|
|
|
using Cirno.Scripts.Resources.ItemEffects;
|
2025-03-17 16:20:22 +01:00
|
|
|
|
using Godot;
|
2025-01-28 14:05:38 +01:00
|
|
|
|
|
|
|
|
|
|
namespace Cirno.Scripts.Resources;
|
|
|
|
|
|
|
|
|
|
|
|
[GlobalClass]
|
2025-04-28 10:52:50 +02:00
|
|
|
|
[Tool]
|
2025-01-28 14:05:38 +01:00
|
|
|
|
public partial class LootItem : Resource
|
|
|
|
|
|
{
|
2025-03-13 13:29:13 +01:00
|
|
|
|
[Export] public StringName ItemName { get; set; }
|
2025-03-28 10:29:04 +01:00
|
|
|
|
[Export] public StringName ShortName { get; set; }
|
2025-03-13 13:29:13 +01:00
|
|
|
|
[Export] public StringName ItemDescription { get; set; }
|
|
|
|
|
|
[Export] public StringName ItemKey { get; set; }
|
2025-01-28 14:05:38 +01:00
|
|
|
|
[Export] public ItemTypes Item;
|
2025-05-01 11:10:36 +02:00
|
|
|
|
[Export] public int Tier { get; set; } = 0;
|
2025-04-25 11:29:21 +02:00
|
|
|
|
[Export] public int Price { get; set; }
|
2025-03-17 16:20:22 +01:00
|
|
|
|
[Export] public ItemEffectResource ItemEffect { get; private set; }
|
2025-02-11 11:50:45 +01:00
|
|
|
|
[Export] public WeaponResource WeaponData { get; set; }
|
2025-01-28 14:05:38 +01:00
|
|
|
|
[Export] public int Amount;
|
2025-01-30 17:24:40 +01:00
|
|
|
|
[Export] public int Max;
|
2025-01-31 13:03:38 +01:00
|
|
|
|
[Export] public bool PickupIfMaxed;
|
|
|
|
|
|
[Export] public bool ConsumeOnUse;
|
2025-02-10 17:29:14 +01:00
|
|
|
|
[Export] public UiItemType UiType;
|
2025-02-25 18:11:57 +01:00
|
|
|
|
[Export] public bool Selectable;
|
2025-03-28 15:38:55 +01:00
|
|
|
|
[Export] public bool AutoPickup { get; private set; } = false;
|
2025-02-16 17:36:33 +01:00
|
|
|
|
[Export] public Texture2D InventorySprite;
|
2025-03-28 10:29:04 +01:00
|
|
|
|
//[Export] public SpriteFrames WorldSprite;
|
|
|
|
|
|
//[Export] public PackedScene HudItemScene;
|
2025-03-04 09:43:05 +01:00
|
|
|
|
[Export(PropertyHint.File)] public StringName DropScenePath { get; private set; } // Has to be a string path to avoid recursion issues
|
2025-05-01 10:04:15 +02:00
|
|
|
|
|
|
|
|
|
|
public ItemPickup Spawn(Node2D parent)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(DropScenePath)) return null;
|
|
|
|
|
|
var itemScene = GD.Load<PackedScene>(DropScenePath);
|
|
|
|
|
|
var spawnedItem = parent.CreateSibling<ItemPickup>(itemScene);
|
|
|
|
|
|
|
|
|
|
|
|
spawnedItem.Name = this.ItemKey;
|
|
|
|
|
|
|
|
|
|
|
|
spawnedItem.LootTable.Add(this);
|
|
|
|
|
|
spawnedItem.SetSprite(InventorySprite);
|
|
|
|
|
|
|
|
|
|
|
|
return spawnedItem;
|
|
|
|
|
|
}
|
2025-02-10 17:29:14 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public enum UiItemType
|
|
|
|
|
|
{
|
|
|
|
|
|
NoUI,
|
|
|
|
|
|
Icon,
|
|
|
|
|
|
IconText
|
2025-01-28 14:05:38 +01:00
|
|
|
|
}
|