using System;
using Sirenix.OdinInspector;
using SLSUtilities.General;
using UnityEngine;
namespace Continentis.MainGame.Character
{
///
/// 使用新版 SerializedDictionary 和 CharacterAttributePair 的全新配置集合类。
/// (目前不替换旧的 CharacterAttributesDefaultCollection,请按需测试本版本)
///
[CreateAssetMenu(fileName = "CharacterAttributeCollection",
menuName = "Continentis/MainGame/Character/CharacterAttributeCollection", order = 1)]
public class CharacterAttributeCollection : ScriptableObject
{
[Title("Attributes(新特性架构测试版)")] [Tooltip("角色的通常属性:支持下拉菜单/手写自由切换的优雅 UI 交互!")]
public SerializedDictionary originalAttributes;
[Tooltip("初始化时赋予给CurrentAttributes的属性:\n" +
"留空则默认为0,填数字则使用数字。")]
public SerializedDictionary runtimeAttributes;
}
///
/// 自定义的带有极简美学 UI 的字典序列化结构体。
/// 可以同时包含“下拉菜单安全输入”以及“纯手写高级输入”两种状态。
///
[Serializable]
public struct CharacterAttributePair : ISerializedPair
{
[SerializeField] [HideInInspector] public string attributeKey;
[SerializeField] [HideInInspector] private bool useManualInput;
[ShowInInspector]
[PropertyOrder(0)]
[HideIf("useManualInput")]
[HorizontalGroup("H")]
[HideLabel]
[ValueDropdown("@Continentis.MainGame.Base.EditorBaseCollection.GetCharacterAttributesDropdown($property)",
IsUniqueList = true, DropdownHeight = 400)]
[InlineButton("ToggleMode", Icon = SdfIconType.ListUl, Label = "")]
public string DropdownKey
{
get => attributeKey;
set => attributeKey = value;
}
[ShowInInspector]
[PropertyOrder(0)]
[ShowIf("useManualInput")]
[HorizontalGroup("H")]
[HideLabel]
[InlineButton("ToggleMode", Icon = SdfIconType.PencilSquare, Label = "")]
public string ManualKey
{
get => attributeKey;
set => attributeKey = value;
}
[PropertyOrder(10)] [HorizontalGroup("H", MarginLeft = 10, Width = 100)] [HideLabel]
public float attributeValue;
// 供 SLSUtilities.General 的接口实现
public string Key
{
get => attributeKey;
set => attributeKey = value;
}
public float Value
{
get => attributeValue;
set => attributeValue = value;
}
private void ToggleMode()
{
useManualInput = !useManualInput;
}
}
}