58 lines
1.6 KiB
C#
58 lines
1.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Sirenix.OdinInspector;
|
|
using UnityEngine;
|
|
|
|
namespace DDD
|
|
{
|
|
[Serializable]
|
|
public class TestInventoryEditorTool
|
|
{
|
|
[ValueDropdown(nameof(GetItemIds))]
|
|
public string SelectedItemId;
|
|
|
|
[MinValue(1)]
|
|
public int Quantity = 1;
|
|
|
|
[Button("아이템 추가")]
|
|
private void AddItem()
|
|
{
|
|
if (!Application.isPlaying)
|
|
{
|
|
Debug.LogWarning("플레이 중에만 아이템 추가가 가능합니다.");
|
|
return;
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(SelectedItemId))
|
|
{
|
|
InventoryManager.Instance.AddItem(SelectedItemId, Quantity);
|
|
}
|
|
}
|
|
|
|
[Button("아이템 제거")]
|
|
private void RemoveItem()
|
|
{
|
|
if (!Application.isPlaying)
|
|
{
|
|
Debug.LogWarning("플레이 중에만 아이템 제거가 가능합니다.");
|
|
return;
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(SelectedItemId))
|
|
{
|
|
InventoryManager.Instance.RemoveItem(SelectedItemId, Quantity);
|
|
}
|
|
}
|
|
|
|
private IEnumerable<string> GetItemIds()
|
|
{
|
|
if (!Application.isPlaying || DataManager.Instance?.GetDataSo<ItemDataSo>() == null)
|
|
return Enumerable.Empty<string>();
|
|
|
|
return DataManager.Instance.GetDataSo<ItemDataSo>().GetDataList()
|
|
.Select(data => data.Id)
|
|
.Where(id => !string.IsNullOrEmpty(id));
|
|
}
|
|
}
|
|
} |