Files
Continentis/Assets/Scripts/MainGame/Character/CharacterData/CharacterData.cs

147 lines
7.8 KiB
C#
Raw Normal View History

2025-10-03 00:02:43 -04:00
using System.Collections.Generic;
using Continentis.MainGame.Card;
using Continentis.MainGame.UI;
2025-10-23 00:49:44 -04:00
using SLSFramework.General;
2026-03-20 11:56:50 -04:00
using Sirenix.OdinInspector;
2025-10-23 00:49:44 -04:00
using SLSFramework.UModAssistance;
2026-03-20 11:56:50 -04:00
using SLSUtilities.General;
2025-10-03 00:02:43 -04:00
using UnityEngine;
using UnityEngine.Serialization;
namespace Continentis.MainGame.Character
{
2026-03-20 11:56:50 -04:00
// ─────────────────────────────────────────────────────────────────────────
// CharacterData — ScriptableObject 数据定义
// ─────────────────────────────────────────────────────────────────────────
2025-10-03 00:02:43 -04:00
[CreateAssetMenu(menuName = "Continentis/MainGame/Character/CharacterData", fileName = "CharacterData")]
2025-10-23 00:49:44 -04:00
public partial class CharacterData : ScriptableObject
2025-10-03 00:02:43 -04:00
{
2026-03-20 11:56:50 -04:00
// ── Fundamental ───────────────────────────────────────────────────────
[BoxGroup("Fundamental"), PropertyOrder(0)]
[LabelText("使用自定义逻辑类")]
[Tooltip("勾选后可通过下拉菜单选择一个 CharacterLogicBase 子类,并自动填充 modName / className。")]
2025-10-23 00:49:44 -04:00
public bool haveCustomClass;
2026-03-20 11:56:50 -04:00
// haveCustomClass = true 时:逻辑类选择器(替代旧 DrawSearchableTypeSelector
[BoxGroup("Fundamental"), PropertyOrder(1)]
[ShowIf("haveCustomClass")]
[InfoBox("请通过下拉菜单选择角色逻辑类Mod 名 / 类名将自动填充。", InfoMessageType.None)]
[ValueDropdown("@CharacterData.GetCharacterLogicDropdownItems()", AppendNextDrawer = true, DisableGUIInAppendedDrawer = true)]
[LabelText("逻辑类全名"), OnValueChanged("OnCharacterLogicClassSelected")]
2025-10-23 00:49:44 -04:00
public string classFullName;
2026-03-20 11:56:50 -04:00
// haveCustomClass = false 时:手动填写 modName / className
[BoxGroup("Fundamental"), PropertyOrder(2)]
[HideIf("haveCustomClass")]
[LabelText("Mod 名称")]
2025-10-23 00:49:44 -04:00
public string modName;
2026-03-20 11:56:50 -04:00
[BoxGroup("Fundamental"), PropertyOrder(3)]
[HideIf("haveCustomClass")]
[LabelText("类名称")]
2025-10-23 00:49:44 -04:00
public string className;
2026-03-20 11:56:50 -04:00
[BoxGroup("Fundamental"), PropertyOrder(4)]
[LabelText("显示名称 Key")]
2025-10-23 00:49:44 -04:00
public string displayName;
2026-03-20 11:56:50 -04:00
[BoxGroup("Fundamental"), PropertyOrder(5)]
[ListDrawerSettings(ShowIndexLabels = false, DraggableItems = true)]
[LabelText("标签")]
2025-10-23 00:49:44 -04:00
public List<string> tags;
2026-03-20 11:56:50 -04:00
// ── 立绘与描述 ────────────────────────────────────────────────────────
[BoxGroup("Visuals"), PropertyOrder(6)]
[PreviewField(80, ObjectFieldAlignment.Left), LabelText("头像 (Avatar)")]
2025-10-23 00:49:44 -04:00
public Sprite avatar;
2026-03-20 11:56:50 -04:00
[BoxGroup("Visuals"), PropertyOrder(7)]
[PreviewField(120, ObjectFieldAlignment.Left), LabelText("立绘 (Portrait)")]
2025-10-23 00:49:44 -04:00
public Sprite portrait;
2026-03-20 11:56:50 -04:00
[BoxGroup("Visuals"), PropertyOrder(8)]
[LabelText("角色描述 Key")]
2025-10-23 00:49:44 -04:00
public string characterDescription;
2026-03-20 11:56:50 -04:00
[BoxGroup("Visuals"), PropertyOrder(9)]
[LabelText("角色故事 Key")]
2025-10-23 00:49:44 -04:00
public string characterStory;
2026-03-20 11:56:50 -04:00
// ── Attributes ────────────────────────────────────────────────────────
[TabGroup("Data", "属性"), PropertyOrder(20)]
2026-04-08 04:48:35 -04:00
[Tooltip("角色的属性:支持智能下拉菜单")]
2026-03-20 11:56:50 -04:00
public SerializedDictionary<string, float, CharacterAttributePair> generalAttributes = new SerializedDictionary<string, float, CharacterAttributePair>();
[TabGroup("Data", "属性"), PropertyOrder(22)]
[DictionaryDrawerSettings(KeyLabel = "运行时状态槽 (如 Health)", ValueLabel = "绑定的最大值标记 (如 MaximumHealth)")]
[Tooltip("初始化时赋予给 CurrentGeneralAttributes 的属性Value 填写对应 GeneralAttributes 的 Key 名,或直接填浮点数,留空默认为 0。")]
public SerializedDictionary<string, string> runtimeGeneralAttributes = new SerializedDictionary<string, string>();
// ── View ──────────────────────────────────────────────────────────────
[TabGroup("Data", "视图"), PropertyOrder(30)]
[LabelText("战斗位置顺序")]
[MinValue(0)]
2025-10-23 00:49:44 -04:00
public int combatPositionOrder;
2026-03-20 11:56:50 -04:00
[TabGroup("Data", "视图"), PropertyOrder(31)]
[LabelText("战斗角色视图 Prefab")]
2025-10-23 00:49:44 -04:00
public GameObject combatCharacterView;
2026-03-20 11:56:50 -04:00
[TabGroup("Data", "视图"), PropertyOrder(32)]
[DictionaryDrawerSettings(KeyLabel = "动画名称", ValueLabel = "AnimationClip")]
[LabelText("动画映射")]
2025-12-10 18:22:26 -05:00
public SerializableDictionary<string, AnimationClip> animations;
2026-03-20 11:56:50 -04:00
// ── References ────────────────────────────────────────────────────────
[TabGroup("Data", "引用"), PropertyOrder(40)]
[ListDrawerSettings(ShowIndexLabels = false, DraggableItems = false)]
[ValueDropdown("GetAvailablePrefabs", AppendNextDrawer = true)]
[LabelText("Prefab 引用")]
2025-10-23 00:49:44 -04:00
public List<string> prefabRefs = new List<string>();
2026-03-20 11:56:50 -04:00
[TabGroup("Data", "引用"), PropertyOrder(41)]
[ListDrawerSettings(ShowIndexLabels = false, DraggableItems = false)]
[ValueDropdown("GetAvailableCardData", AppendNextDrawer = true)]
[LabelText("衍生卡牌数据引用")]
2025-10-23 00:49:44 -04:00
public List<string> derivativeCardDataRefs = new List<string>();
2026-03-20 11:56:50 -04:00
[TabGroup("Data", "引用"), PropertyOrder(42)]
[ListDrawerSettings(ShowIndexLabels = false, DraggableItems = false)]
[ValueDropdown("GetAvailableCharacterData", AppendNextDrawer = true)]
[LabelText("衍生角色数据引用")]
2025-10-23 00:49:44 -04:00
public List<string> derivativeCharacterDataRefs = new List<string>();
2026-03-20 11:56:50 -04:00
[TabGroup("Data", "引用"), PropertyOrder(43)]
[ListDrawerSettings(ShowIndexLabels = false, DraggableItems = false)]
[ValueDropdown("GetAvailableCardData", AppendNextDrawer = true)]
2025-10-23 00:49:44 -04:00
[Tooltip("初始卡组引用列表")]
2026-03-20 11:56:50 -04:00
[LabelText("初始卡组引用")]
2025-10-23 00:49:44 -04:00
public List<string> initialDeckRef;
2026-03-20 11:56:50 -04:00
[TabGroup("Data", "引用"), PropertyOrder(44)]
[ListDrawerSettings(ShowIndexLabels = false, DraggableItems = false)]
[ValueDropdown("GetAvailableHUDData", AppendNextDrawer = true)]
[Tooltip("HUD 信息引用列表")]
[LabelText("HUD 数据引用")]
2025-10-23 00:49:44 -04:00
public List<string> hudDataRefs;
}
2026-03-20 11:56:50 -04:00
// ─────────────────────────────────────────────────────────────────────────
// Runtime: 数据库查询
// ─────────────────────────────────────────────────────────────────────────
2025-10-23 00:49:44 -04:00
public partial class CharacterData
{
2026-03-20 11:56:50 -04:00
/// <summary>
/// 通过 DataID 从 ModManager 数据库查找 CharacterData。
/// </summary>
2025-10-23 00:49:44 -04:00
public static CharacterData Get(string dataID)
{
return ModManager.GetData<CharacterData>(dataID);
}
2025-10-03 00:02:43 -04:00
}
}