Files
Continentis/docs/References/AttributeCollection.cs
SoulliesOfficial d09b58fd80 架构大更
2026-03-20 11:56:50 -04:00

64 lines
2.3 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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<string, float, CharacterAttributePair> originalAttributes;
[Tooltip("初始化时赋予给CurrentAttributes的属性\n" +
"第一栏是属性名第二栏是初始化时使用对应名称的originalAttributes的数据留空则默认为0如果是float数字则直接使用该数字")]
public SerializedDictionary<string, string> runtimeAttributes;
}
[Serializable]
public struct CharacterAttributePair : ISerializedPair<string, float>
{
[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;
}
}
}