Passion & UI

This commit is contained in:
SoulliesOfficial
2026-06-12 17:11:39 -04:00
parent 7bc1e1722c
commit 6d7ebc5825
3444 changed files with 865284 additions and 463132 deletions

View File

@@ -40,6 +40,28 @@ namespace Cielonos.MainGame.Characters
public partial class BackpackSubmodule
{
public bool HaveItem(string itemClass)
{
Type type = Type.GetType($"Cielonos.MainGame.Inventory.Collections.{itemClass}");
if (type == null)
{
Debug.LogError($"[Backpack] 无法找到道具类类型:'{itemClass}'。确保它在命名空间 Cielonos.MainGame.Inventory.Collections 中。");
return false;
}
if (typeof(MainWeaponBase).IsAssignableFrom(type))
return mainWeapons.Exists(item => item.GetType() == type);
if (typeof(SupportEquipmentBase).IsAssignableFrom(type))
return supportEquipments.Exists(item => item.GetType() == type);
if (typeof(PassiveEquipmentBase).IsAssignableFrom(type))
return passiveEquipments.Exists(item => item.GetType() == type);
if (typeof(ConsumableBase).IsAssignableFrom(type))
return consumables.Exists(item => item.GetType() == type);
Debug.LogError($"[Backpack] 类型 '{itemClass}' 不属于任何已知的道具基类。");
return false;
}
/// <summary>
/// 通过 Resources 加载 Prefab实例化到对应的 Container 下,然后加入背包。
/// 若为消耗品且背包中已存在同类型实例,则直接堆叠,不再重复生成。