using System; using System.Collections.Generic; using Continentis.MainGame.Character; using SLSFramework.General; using Sirenix.OdinInspector; using SLSFramework.UModAssistance; using UnityEngine; using UnityEngine.Serialization; namespace Continentis.MainGame.Card { public enum CardType { Attack = 0, Skill = 10, Power = 20, Status = 30, Curse = 40, Item = 50, } // ───────────────────────────────────────────────────────────────────────── // CardData — ScriptableObject 数据定义 // ───────────────────────────────────────────────────────────────────────── [CreateAssetMenu(menuName = "Continentis/MainGame/Card/CardData", fileName = "CardData")] public partial class CardData : ScriptableObject { // ── Fundamental ─────────────────────────────────────────────────────── [BoxGroup("Fundamental"), PropertyOrder(0)] [ValueDropdown("@CardData.GetCardLogicDropdownItems()", AppendNextDrawer = true, DisableGUIInAppendedDrawer = true)] [LabelText("逻辑类名"), OnValueChanged("OnCardLogicClassSelected")] public string className; [BoxGroup("Fundamental"), PropertyOrder(1)] [ReadOnly, LabelText("Mod 名称")] public string modName; [BoxGroup("Fundamental"), PropertyOrder(2)] [ReadOnly, LabelText("分类名称")] public string categoryName; [BoxGroup("Fundamental"), PropertyOrder(3)] [ReadOnly, LabelText("显示名称 Key")] public string displayName; [BoxGroup("Fundamental"), PropertyOrder(4)] [LabelText("稀有度")] public Rarity cardRarity; [BoxGroup("Fundamental"), PropertyOrder(5)] [LabelText("卡牌类型")] public CardType cardType; [BoxGroup("Fundamental"), PropertyOrder(6)] [ListDrawerSettings(ShowIndexLabels = false, DraggableItems = true)] [ValueDropdown("GetAvailableKeywords", AppendNextDrawer = true)] [LabelText("关键词")] public List keywords; // ── Display ─────────────────────────────────────────────────────────── [BoxGroup("Display"), PropertyOrder(7)] [PreviewField(80, ObjectFieldAlignment.Left)] [LabelText("卡牌图片")] public Sprite cardSprite; [BoxGroup("Display"), PropertyOrder(8)] [LabelText("功能文本 Key")] public string functionText; [FormerlySerializedAs("cardDescription")] [BoxGroup("Display"), PropertyOrder(9)] [LabelText("卡牌描述 Key")] public string descriptionText; [BoxGroup("Display"), PropertyOrder(10)] [ListDrawerSettings(ShowIndexLabels = false), LabelText("布局标签")] public List cardLayoutTags; // ── Attributes ──────────────────────────────────────────────────────── [TabGroup("Data", "属性"), PropertyOrder(20)] [DictionaryDrawerSettings(KeyLabel = "属性名", ValueLabel = "属性值")] [Tooltip("可变属性:自动设置 BaseAttr → Original,设置 Attr / BaseAttrOffset=0 / DisplayAttr → Current")] [LabelText("可变属性 (Variable)")] public SerializableDictionary variableAttributes = new SerializableDictionary(); [TabGroup("Data", "属性"), PropertyOrder(21)] [DictionaryDrawerSettings(KeyLabel = "属性名", ValueLabel = "属性值")] [Tooltip("基础属性,运行时不会改变,通常不直接使用。")] [LabelText("基础属性 (Original)")] public SerializableDictionary originalAttributes = new SerializableDictionary(); [TabGroup("Data", "属性"), PropertyOrder(22)] [DictionaryDrawerSettings(KeyLabel = "属性名", ValueLabel = "初始值表达式")] [FormerlySerializedAs("endowingCurrentAttributes")] [Tooltip("运行时当前属性:Value 填写对应 OriginalAttributes 的 Key 名,或直接填浮点数,留空则默认为 0。")] [LabelText("运行时当前属性 (Runtime Current)")] public SerializableDictionary runtimeCurrentAttributes = new SerializableDictionary(); // ── Upgrade ─────────────────────────────────────────────────────────── [TabGroup("Data", "升级"), PropertyOrder(40)] [HideLabel] public CardUpgradeNode upgradeNode; // ── References ──────────────────────────────────────────────────────── [TabGroup("Data", "引用"), PropertyOrder(50)] [ListDrawerSettings(ShowIndexLabels = false, DraggableItems = false)] [ValueDropdown("GetAvailablePrefabs", AppendNextDrawer = true)] [LabelText("Prefab 引用")] public List prefabRefs = new List(); [TabGroup("Data", "引用"), PropertyOrder(51)] [ListDrawerSettings(ShowIndexLabels = false, DraggableItems = false)] [ValueDropdown("GetAvailableCardData", AppendNextDrawer = true)] [LabelText("衍生卡牌数据引用")] public List derivativeCardDataRefs = new List(); [TabGroup("Data", "引用"), PropertyOrder(52)] [ListDrawerSettings(ShowIndexLabels = false, DraggableItems = false)] [ValueDropdown("GetAvailableCharacterData", AppendNextDrawer = true)] [LabelText("衍生角色数据引用")] public List derivativeCharacterDataRefs = new List(); // ── Intention ──────────────────────────────────────────────────────── [TabGroup("Data", "意图"), PropertyOrder(60)] [ListDrawerSettings(ShowIndexLabels = false)] [ValueDropdown("GetAvailableIntentionIcons", AppendNextDrawer = true)] [LabelText("意图图标 Keys")] public List intentionIconKeys; [TabGroup("Data", "意图"), PropertyOrder(61)] [ListDrawerSettings(ShowIndexLabels = false)] [ValueDropdown("GetVariableAttributeKeys", AppendNextDrawer = true)] [LabelText("意图数值名")] public List intentionValueNames; [TabGroup("Data", "意图"), PropertyOrder(62)] [LabelText("意图文本覆盖")] public string intentionTextOverride; [FormerlySerializedAs("baseWeight")] [TabGroup("Data", "意图"), PropertyOrder(63)] [LabelText("基础权重"), Range(0f, 100f)] public float intentionBaseWeight = 0f; } // ───────────────────────────────────────────────────────────────────────── // Runtime: 关键词查询 // ───────────────────────────────────────────────────────────────────────── public partial class CardData { /// /// 检查此卡牌是否包含指定关键词。 /// public bool HasKeyword(string keyword) { return keywords.Contains(keyword); } } // ───────────────────────────────────────────────────────────────────────── // Runtime: 数据库查询 // ───────────────────────────────────────────────────────────────────────── public partial class CardData { /// /// 通过 DataID 从 ModManager 数据库查找 CardData。 /// public static CardData Get(string dataID) { return ModManager.GetData(dataID); } } // ───────────────────────────────────────────────────────────────────────── // Runtime: 衍生数据访问 // ───────────────────────────────────────────────────────────────────────── public partial class CardData { /// /// 通过索引获取衍生卡牌数据。 /// public CardData GetDerivativeCardData(int index) { return ModManager.GetData(derivativeCardDataRefs[index]); } /// /// 通过索引获取衍生角色数据。 /// public CharacterData GetDerivativeCharacterData(int index) { return ModManager.GetData(derivativeCharacterDataRefs[index]); } } }