Files
Continentis/Assets/Scripts/MainGame/Card/CardData/CardData.cs
SoulliesOfficial c3b1561375 更新
2026-04-01 12:23:27 -04:00

202 lines
9.9 KiB
C#
Raw 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 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<string> 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<string> cardLayoutTags;
// ── Attributes ────────────────────────────────────────────────────────
[TabGroup("Data", "属性"), PropertyOrder(20)]
[DictionaryDrawerSettings(KeyLabel = "属性名", ValueLabel = "属性值")]
[Tooltip("可变属性:自动设置 BaseAttr → Original设置 Attr / BaseAttrOffset=0 / DisplayAttr → Current")]
[LabelText("可变属性 (Variable)")]
public SerializableDictionary<string, float> variableAttributes = new SerializableDictionary<string, float>();
[TabGroup("Data", "属性"), PropertyOrder(21)]
[DictionaryDrawerSettings(KeyLabel = "属性名", ValueLabel = "属性值")]
[Tooltip("基础属性,运行时不会改变,通常不直接使用。")]
[LabelText("基础属性 (Original)")]
public SerializableDictionary<string, float> originalAttributes = new SerializableDictionary<string, float>();
[TabGroup("Data", "属性"), PropertyOrder(22)]
[DictionaryDrawerSettings(KeyLabel = "属性名", ValueLabel = "初始值表达式")]
[FormerlySerializedAs("endowingCurrentAttributes")]
[Tooltip("运行时当前属性Value 填写对应 OriginalAttributes 的 Key 名,或直接填浮点数,留空则默认为 0。")]
[LabelText("运行时当前属性 (Runtime Current)")]
public SerializableDictionary<string, string> runtimeCurrentAttributes = new SerializableDictionary<string, string>();
// ── 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<string> prefabRefs = new List<string>();
[TabGroup("Data", "引用"), PropertyOrder(51)]
[ListDrawerSettings(ShowIndexLabels = false, DraggableItems = false)]
[ValueDropdown("GetAvailableCardData", AppendNextDrawer = true)]
[LabelText("衍生卡牌数据引用")]
public List<string> derivativeCardDataRefs = new List<string>();
[TabGroup("Data", "引用"), PropertyOrder(52)]
[ListDrawerSettings(ShowIndexLabels = false, DraggableItems = false)]
[ValueDropdown("GetAvailableCharacterData", AppendNextDrawer = true)]
[LabelText("衍生角色数据引用")]
public List<string> derivativeCharacterDataRefs = new List<string>();
// ── Intention ────────────────────────────────────────────────────────
[TabGroup("Data", "意图"), PropertyOrder(60)]
[ListDrawerSettings(ShowIndexLabels = false)]
[ValueDropdown("GetAvailableIntentionIcons", AppendNextDrawer = true)]
[LabelText("意图图标 Keys")]
public List<string> intentionIconKeys;
[TabGroup("Data", "意图"), PropertyOrder(61)]
[ListDrawerSettings(ShowIndexLabels = false)]
[ValueDropdown("GetVariableAttributeKeys", AppendNextDrawer = true)]
[LabelText("意图数值名")]
public List<string> 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
{
/// <summary>
/// 检查此卡牌是否包含指定关键词。
/// </summary>
public bool HasKeyword(string keyword)
{
return keywords.Contains(keyword);
}
}
// ─────────────────────────────────────────────────────────────────────────
// Runtime: 数据库查询
// ─────────────────────────────────────────────────────────────────────────
public partial class CardData
{
/// <summary>
/// 通过 DataID 从 ModManager 数据库查找 CardData。
/// </summary>
public static CardData Get(string dataID)
{
return ModManager.GetData<CardData>(dataID);
}
}
// ─────────────────────────────────────────────────────────────────────────
// Runtime: 衍生数据访问
// ─────────────────────────────────────────────────────────────────────────
public partial class CardData
{
/// <summary>
/// 通过索引获取衍生卡牌数据。
/// </summary>
public CardData GetDerivativeCardData(int index)
{
return ModManager.GetData<CardData>(derivativeCardDataRefs[index]);
}
/// <summary>
/// 通过索引获取衍生角色数据。
/// </summary>
public CharacterData GetDerivativeCharacterData(int index)
{
return ModManager.GetData<CharacterData>(derivativeCharacterDataRefs[index]);
}
}
}