using System; using System.Collections.Generic; using Sirenix.OdinInspector; using SLSUtilities.General; using UnityEngine; namespace Cielonos.MainGame.Characters { [CreateAssetMenu(fileName = "AttributeCollection", menuName = "Cielonos/Characters/AttributeCollection", order = 1)] public class AttributeCollection : SerializedScriptableObject { [Title("Attributes")] [Tooltip("角色的通常属性:第一栏是属性名,第二栏是属性值")] public SerializedDictionary originalAttributes; [Tooltip("初始化时赋予给CurrentAttributes的属性:\n" + "第一栏是属性名,第二栏是初始化时使用对应名称的originalAttributes的数据,留空则默认为0,如果是float数字则直接使用该数字")] public SerializedDictionary runtimeAttributes; } [Serializable] public struct CharacterAttributePair : ISerializedPair { [SerializeField, HideInInspector] public string attributeKey; [SerializeField, HideInInspector] private bool useManualInput; // 记录当前是否处于手动输入模式 [ShowInInspector] [PropertyOrder(0)] [HideIf("useManualInput")] [HorizontalGroup("H")] [HideLabel] [ValueDropdown("@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; public string Key => attributeKey; public float Value => attributeValue; private void ToggleMode() { useManualInput = !useManualInput; } } }