Files
godot-------/Script/Item/BagItem.cs
m0_75251201 7700703099 初次提交
2025-07-12 11:30:22 +08:00

45 lines
893 B
C#

using Godot;
using System;
using System.Collections.Generic;
public partial class BagItem
{
public ItemResource itemResource;
public int amount;
public string ItemName
{
get
{
return itemResource?.ItemName ?? "Unknown"; // 防止空引用
}
}
public string Description
{
get
{
return itemResource?.Description ?? "No description"; // 防止空引用
}
}
public void AddAmount(int value)
{
if (value < 0)
{
GD.PrintErr("Cannot add negative amount to BagItem.");
return;
}
amount += value;
}
public void RemoveAmount(int value)
{
if (value < 0 || value > amount)
{
GD.PrintErr("Invalid amount to remove from BagItem.");
return;
}
amount -= value;
}
}