keyword + animation

This commit is contained in:
SoulliesOfficial
2025-10-27 07:04:34 -04:00
parent c3c4a17440
commit 2906206f0c
40 changed files with 512 additions and 384 deletions

Binary file not shown.

View File

@@ -17,8 +17,10 @@ MonoBehaviour:
displayName: Card_Basic_DualStrike_DisplayName
cardRarity: 10
cardType: 0
tags: []
keywords:
- Strike
cardSprite: {fileID: 21300000, guid: b5ebf255ba7f19543b7faea59e86ea77, type: 3}
cardLayoutTags: []
functionText: Card_Basic_DualStrike_FunctionText
cardDescription: '$Keyword("Strike"), deal $Attribute("Damage") damage twice. '
baseWeight: 1

View File

@@ -17,10 +17,11 @@ MonoBehaviour:
displayName: Card_Basic_Strike_DisplayName
cardRarity: 10
cardType: 0
tags:
keywords:
- Strike
- TargetEnemies
- Physics
cardSprite: {fileID: 21300000, guid: 54336fab907a76a4095ff5607e0b86c8, type: 3}
cardLayoutTags: []
functionText: Card_Basic_Strike_FunctionText
cardDescription: Card_Basic_Strike_Description
baseWeight: 1

View File

@@ -17,8 +17,9 @@ MonoBehaviour:
displayName: Card_Basic_HiddenBlade_DisplayName
cardRarity: 0
cardType: 50
tags: []
keywords: []
cardSprite: {fileID: 21300000, guid: 8be7e5378b35956469dceadef0180595, type: 3}
cardLayoutTags: []
functionText: Card_Basic_HiddenBlade_FunctionText
cardDescription: $Keyword("Retain"), $Keyword("Exhaust"), $Keyword("Prick"), deal
$Attribute("Damage") damage.

View File

@@ -44,6 +44,5 @@ MonoBehaviour:
upgradeCards: []
customDescriptions: []
prefabRefs: []
derivativeCardDataRefs:
- CardData_Basic_HolyWaterPreparation
derivativeCardDataRefs: []
derivativeCharacterDataRefs: []

View File

@@ -35,6 +35,7 @@ namespace Continentis.Mods.Basic.Cards
private void SelectEffect(CardInstance card)
{
card.cardLogic.ModifyAttribute("StaminaCost", -1);
card.cardLogic.contentSubmodule.keywords.Add("Retain");
card.cardLogic.contentSubmodule.originalFunctionText += " + $Keyword(\"Retain\")";
CardTextInterpreter.InterpretText(card.cardLogic, true);
card.handCardView.Setup();

View File

@@ -34,7 +34,7 @@ namespace Continentis.Mods.Basic.Cards
private bool CardFilter(CardData cardData)
{
return cardData.cardType == CardType.Attack && cardData.HasTag("Physics");
return cardData.cardType == CardType.Attack && cardData.HasKeyword("Physics");
}
}
}

View File

@@ -24,7 +24,7 @@ namespace Continentis.Mods.Basic.Cards
mainGroup.AddCommand(new Cmd_PlayAnimation(user.characterView, "Skill"));
mainGroup.AddCommand(new Cmd_Function(() =>
{
CardData holyWaterCardData = LogicComponent<CardLogicComponent_GenerateCards>().GetDerivativeCardData(0);
CardData holyWaterCardData = GetDerivativeCardData(0);
CardInstance.GenerateCardInstance(holyWaterCardData, user.team, "Hand");
}));

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using Continentis.MainGame.Card;
using Continentis.MainGame.Character;
using Continentis.MainGame.Commands;
@@ -14,18 +15,22 @@ namespace Continentis.Mods.Basic.Cards
{
AddLogicComponent<CardLogicComponent_Attack>();
}
protected override CommandBase PlayEffect(List<CharacterBase> targetList)
{
CommandGroup mainGroup = TargetListCommandGroup(targetList,
new Cmd_PlayAnimation(user.characterView, "Attack"),
new Cmd_PlaySFX("SFX_Basic_SwordStrike"),
new Cmd_SpawnVFX("VFX_Basic_RedImpact"),
new Cmd_ParamFunction<CharacterBase>(target => user.Attack(target, GetFinalDamage(target))));
new Cmd_SpawnVFX("VFX_Basic_RedImpact"));
foreach (Cmd_PlayAnimation cmd in mainGroup.GetAllCommands<Cmd_PlayAnimation>())
{
cmd.AddAction<CharacterBase>(0.7f, "Target", target => user.Attack(target, GetFinalDamage(target)));
}
return mainGroup;
}
public override void ApplyAttributeChangesByCard()
{
LogicComponent<CardLogicComponent_Attack>().SetDamage_Strike();

View File

@@ -17,27 +17,6 @@ AnimationClip:
m_PositionCurves: []
m_ScaleCurves: []
m_FloatCurves:
- serializedVersion: 2
curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: Infinity
outSlope: Infinity
tangentMode: 103
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_IsActive
path: Body/Firearm
classID: 1
script: {fileID: 0}
flags: 16
- serializedVersion: 2
curve:
serializedVersion: 2
@@ -103,15 +82,6 @@ AnimationClip:
m_Extent: {x: 0, y: 0, z: 0}
m_ClipBindingConstant:
genericBindings:
- serializedVersion: 2
path: 539894089
attribute: 2086281974
script: {fileID: 0}
typeID: 1
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 2073732236
attribute: 3843704414
@@ -143,27 +113,6 @@ AnimationClip:
m_HeightFromFeet: 0
m_Mirror: 0
m_EditorCurves:
- serializedVersion: 2
curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: Infinity
outSlope: Infinity
tangentMode: 103
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_IsActive
path: Body/Firearm
classID: 1
script: {fileID: 0}
flags: 16
- serializedVersion: 2
curve:
serializedVersion: 2

View File

@@ -7,7 +7,7 @@ AnimationClip:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Idle
serializedVersion: 6
serializedVersion: 7
m_Legacy: 0
m_Compressed: 0
m_UseHighQualityCurve: 1
@@ -17,26 +17,8 @@ AnimationClip:
m_PositionCurves: []
m_ScaleCurves: []
m_FloatCurves:
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: Infinity
outSlope: Infinity
tangentMode: 103
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_IsActive
path: Body/Firearm
classID: 1
script: {fileID: 0}
- curve:
- serializedVersion: 2
curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
@@ -73,6 +55,7 @@ AnimationClip:
path: Body
classID: 114
script: {fileID: 11500000, guid: ed8b1ae4e4e52b34ea557c1c11e076fc, type: 3}
flags: 16
m_PPtrCurves: []
m_SampleRate: 60
m_WrapMode: 0
@@ -81,13 +64,6 @@ AnimationClip:
m_Extent: {x: 0, y: 0, z: 0}
m_ClipBindingConstant:
genericBindings:
- serializedVersion: 2
path: 713069421
attribute: 2086281974
script: {fileID: 0}
typeID: 1
customType: 0
isPPtrCurve: 0
- serializedVersion: 2
path: 2073732236
attribute: 1181594048
@@ -95,6 +71,8 @@ AnimationClip:
typeID: 114
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
pptrCurveMapping: []
m_AnimationClipSettings:
serializedVersion: 2
@@ -117,26 +95,8 @@ AnimationClip:
m_HeightFromFeet: 0
m_Mirror: 0
m_EditorCurves:
- curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: Infinity
outSlope: Infinity
tangentMode: 103
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_IsActive
path: Body/Firearm
classID: 1
script: {fileID: 0}
- curve:
- serializedVersion: 2
curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
@@ -173,6 +133,7 @@ AnimationClip:
path: Body
classID: 114
script: {fileID: 11500000, guid: ed8b1ae4e4e52b34ea557c1c11e076fc, type: 3}
flags: 16
m_EulerEditorCurves: []
m_HasGenericRootTransform: 0
m_HasMotionFloatCurves: 0

View File

@@ -17,27 +17,6 @@ AnimationClip:
m_PositionCurves: []
m_ScaleCurves: []
m_FloatCurves:
- serializedVersion: 2
curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: Infinity
outSlope: Infinity
tangentMode: 103
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_IsActive
path: Body/Firearm
classID: 1
script: {fileID: 0}
flags: 16
- serializedVersion: 2
curve:
serializedVersion: 2
@@ -94,15 +73,6 @@ AnimationClip:
m_Extent: {x: 0, y: 0, z: 0}
m_ClipBindingConstant:
genericBindings:
- serializedVersion: 2
path: 539894089
attribute: 2086281974
script: {fileID: 0}
typeID: 1
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 2073732236
attribute: 1181594048
@@ -134,27 +104,6 @@ AnimationClip:
m_HeightFromFeet: 0
m_Mirror: 0
m_EditorCurves:
- serializedVersion: 2
curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: Infinity
outSlope: Infinity
tangentMode: 103
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_IsActive
path: Body/Firearm
classID: 1
script: {fileID: 0}
flags: 16
- serializedVersion: 2
curve:
serializedVersion: 2

View File

@@ -455,7 +455,7 @@ SpriteRenderer:
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_Sprite: {fileID: 6991849013916550155, guid: 671c5c2c0a10455c9c046b8e8e5011a7, type: 3}
m_Sprite: {fileID: 4723107735738678597, guid: 671c5c2c0a10455c9c046b8e8e5011a7, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
@@ -495,7 +495,7 @@ MonoBehaviour:
m_CategoryHash: 9.365925e-16
m_labelHash: 0.00000040954276
m_SpriteKey: 8.913528e-15
m_SpriteHash: 673223268
m_SpriteHash: 288431053
--- !u!1 &4492774868295366629
GameObject:
m_ObjectHideFlags: 0

View File

@@ -423,7 +423,7 @@ AnimatorStateMachine:
m_StateMachineTransitions: {}
m_StateMachineBehaviours: []
m_AnyStatePosition: {x: 0, y: 250, z: 0}
m_EntryPosition: {x: 0, y: -140, z: 0}
m_EntryPosition: {x: -120, y: -140, z: 0}
m_ExitPosition: {x: 0, y: 290, z: 0}
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
m_DefaultState: {fileID: 6342953676309033787}

View File

@@ -25,7 +25,7 @@ namespace Continentis.Mods.Basic.Buffs
.AddParameterGetter("Target", () => target.data.displayName);//TODO: 以后增加角色的ContentSubmodule
this.iconSubmodule = new IconSubmodule(this).SetTextFunctions("Count");
this.combatRoundTimeSubmodule = new CountSubmodule(this, actionCount);
this.eventSubmodule = new EventSubmodule(this);

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 3da21070bbc4b3142a117111283c301f
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,93 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 634ae9a7ace35674aac295f34a73f088, type: 3}
m_Name: Basic_EditKeywordsReference
m_EditorClassIdentifier: GameAPI::Continentis.Mods.EditKeywordsReference
keywordRefs:
dictionaryList:
- Key: TargetSelf
Value:
index: 0
isKeyDuplicated: 0
- Key: TargetEnemies
Value:
index: 1
isKeyDuplicated: 0
- Key: TargetAllies
Value:
index: 2
isKeyDuplicated: 0
- Key: TargetAll
Value:
index: 3
isKeyDuplicated: 0
- Key: Strike
Value:
index: 4
isKeyDuplicated: 0
- Key: Prick
Value:
index: 5
isKeyDuplicated: 0
- Key: Slash
Value:
index: 6
isKeyDuplicated: 0
- Key: Arcane
Value:
index: 7
isKeyDuplicated: 0
- Key: Sorcery
Value:
index: 8
isKeyDuplicated: 0
- Key: Swiftness
Value:
index: 9
isKeyDuplicated: 0
- Key: Fortitude
Value:
index: 10
isKeyDuplicated: 0
- Key: Prediction
Value:
index: 11
isKeyDuplicated: 0
- Key: Exhaust
Value:
index: 12
isKeyDuplicated: 0
- Key: Instant
Value:
index: 13
isKeyDuplicated: 0
- Key: Unplayable
Value:
index: 14
isKeyDuplicated: 0
- Key: Innate
Value:
index: 15
isKeyDuplicated: 0
- Key: Tardy
Value:
index: 16
isKeyDuplicated: 0
- Key: Retain
Value:
index: 17
isKeyDuplicated: 0
- Key: Ethereal
Value:
index: 18
isKeyDuplicated: 0
dividerPosProp: 0.3

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: af4030fdce3a4774b90f808d1a3bced8
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,15 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: afb8fcbb8d897e449a135120c7516dbd, type: 3}
m_Name: Basic_ModEditReference
m_EditorClassIdentifier: GameAPI::Continentis.Mods.ModEditReference
cardKeywordsReference: {fileID: 11400000, guid: af4030fdce3a4774b90f808d1a3bced8, type: 2}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: eca19f3199465f448830fa0e3ff71dc6
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -13,12 +13,7 @@ namespace Continentis.MainGame
static BuffTextInterpreter()
{
TextInterpreter = new Interpreter();
TextInterpreter.SetFunction("Value", new Func<float, string>((cv) => DynamicTextInterpreter.GetValue(cv, false)));
TextInterpreter.SetFunction("Value", new Func<float, float, string>((cv, bv) => DynamicTextInterpreter.GetValue(cv, bv, true, false)));
TextInterpreter.SetFunction("Value",
new Func<float, float, bool, string>((cv, bv, high) => DynamicTextInterpreter.GetValue(cv, bv, high, false)));
TextInterpreter.SetFunction("Value",
new Func<float, float, bool, bool, string>((cv, bv, high, percent) => DynamicTextInterpreter.GetValue(cv, bv, high, percent)));
DynamicTextInterpreter.InitializeInterpreter(ref TextInterpreter);
foreach (KeyValuePair<string, InterpretedKeyword> keyword in MainGameManager.Instance.keywordData.interpretedKeywords)
{
@@ -34,7 +29,7 @@ namespace Continentis.MainGame
TextInterpreter.SetFunction("ParameterFloat", new Func<string, string>((paramName) => GetParameterFloat(buff, paramName)));
TextInterpreter.SetFunction("ParameterString", new Func<string, string>((paramName) => GetParameterString(buff, paramName)));
string descriptionToParse = buff.contentSubmodule.originalFunctionText;
string result = DynamicTextInterpreter.Parse(TextInterpreter, descriptionToParse, new List<string>(), new List<string>());
string result = DynamicTextInterpreter.Parse(TextInterpreter, descriptionToParse);
buff.contentSubmodule.interpretedFunctionText = result;
}
}

View File

@@ -13,11 +13,7 @@ namespace Continentis.MainGame
static CardTextInterpreter()
{
TextInterpreter = new Interpreter();
TextInterpreter.SetFunction("Value", new Func<float, string>((cv) => DynamicTextInterpreter.GetValue(cv, false)));
TextInterpreter.SetFunction("Value", new Func<float, float, string>((cv, bv) => DynamicTextInterpreter.GetValue(cv, bv, true, false)));
TextInterpreter.SetFunction("Value", new Func<float, float, bool, string>((cv, bv, high) => DynamicTextInterpreter.GetValue(cv, bv, high, false)));
TextInterpreter.SetFunction("Value", new Func<float, float, bool, bool, string>((cv, bv, high, percent) => DynamicTextInterpreter.GetValue(cv, bv, high, percent)));
DynamicTextInterpreter.InitializeInterpreter(ref TextInterpreter);
foreach (KeyValuePair<string, InterpretedKeyword> keyword in MainGameManager.Instance.keywordData.interpretedKeywords)
{
@@ -27,7 +23,7 @@ namespace Continentis.MainGame
public static void InterpretText(CardLogicBase card, bool overrideDescription = false)
{
card.contentSubmodule.keywords.Clear();
//card.contentSubmodule.keywords.Clear();
foreach (KeyValuePair<string, float> attribute in card.attributeSubmodule.attributeGroup.current)
{
@@ -40,7 +36,7 @@ namespace Continentis.MainGame
TextInterpreter.SetFunction("Attribute", new Func<string, bool, bool, string>((name, high, percent) => GetAttribute(card, name, high, percent)));
string descriptionToParse = card.contentSubmodule.originalFunctionText;
string result = DynamicTextInterpreter.Parse(TextInterpreter, descriptionToParse, card.contentSubmodule.keywords, card.contentSubmodule.hintKeywords);
string result = DynamicTextInterpreter.Parse(TextInterpreter, descriptionToParse);
card.contentSubmodule.interpretedFunctionText = result;

View File

@@ -9,19 +9,34 @@ namespace Continentis.MainGame
{
public partial class DynamicTextInterpreter
{
public static string Parse(Interpreter interpreter, string template, List<string> keywords, List<string> hintKeywords)
public static void InitializeInterpreter(ref Interpreter interpreter)
{
interpreter.UnsetFunction("Keyword");
interpreter.SetFunction("Keyword", new Func<string, string>(kw => SetKeyword(ref keywords, kw, "#FFA500")));
interpreter.UnsetFunction("HintKeyword");
interpreter.SetFunction("HintKeyword", new Func<string, string>(kw => SetKeyword(ref hintKeywords, kw, "#FFA500")));
interpreter.SetFunction("HintKeyword", new Func<string, string, string>((kw, colorHex) => SetKeyword(ref hintKeywords, kw, colorHex)));
interpreter.UnsetFunction("DescKeyword");
interpreter.SetFunction("Keyword", new Func<string, string>(kw => SetKeyword(kw, "#FFA500")));
interpreter.SetFunction("HintKeyword", new Func<string, string>(kw => SetKeyword(kw, "#FFA500")));
interpreter.SetFunction("HintKeyword", new Func<string, string, string>(SetKeyword));
interpreter.SetFunction("DescKeyword", new Func<string, string>(kw =>DescKeyword(kw, "#FFA500")));
interpreter.SetFunction("DescKeyword", new Func<string, string, string>(DescKeyword));
interpreter.UnsetFunction("ColorText");
interpreter.SetFunction("ColorText", new Func<string, string, string>(ColorText));
interpreter.SetFunction("Value", new Func<float, string>((cv) => GetValue(cv, false)));
interpreter.SetFunction("Value", new Func<float, float, string>((cv, bv) => GetValue(cv, bv, true, false)));
interpreter.SetFunction("Value", new Func<float, float, bool, string>((cv, bv, high) => GetValue(cv, bv, high, false)));
interpreter.SetFunction("Value", new Func<float, float, bool, bool, string>((cv, bv, high, percent) => GetValue(cv, bv, high, percent)));
//本地函数,用于添加关键词到集合中并返回格式化后的关键词字符串
string SetKeyword(string keyword, string colorHex)
{
if (!string.IsNullOrEmpty(keyword))
{
return Keyword(keyword, colorHex);
}
return string.Empty;
}
}
public static string Parse(Interpreter interpreter, string template)
{
try
{
while (template.Contains("$"))
@@ -49,17 +64,6 @@ namespace Continentis.MainGame
}
return template;
//本地函数,用于添加关键词到集合中并返回格式化后的关键词字符串
string SetKeyword(ref List<string> collection, string keyword, string colorHex)
{
if (!string.IsNullOrEmpty(keyword) && !collection.Contains(keyword))
{
collection.Add(keyword);
}
return Keyword(keyword, colorHex);
}
}
private static int FindMatchingClosingParenthesis(string text, int startIndex)

View File

@@ -13,15 +13,10 @@ namespace Continentis.MainGame.Card
#region Fundamental
public partial class CardLogicBase
{
public bool HasTag(string tag)
public List<string> GetElementalKeywords(List<string> overrideKeywords = null)
{
return tags.Contains(tag);
}
public List<string> GetElementTags(List<string> tags = null)
{
tags ??= this.tags;
return tags.Filtered((tag) => MainGameManager.Instance.elementTags.Contains(tag));
overrideKeywords ??= contentSubmodule.keywords;
return overrideKeywords.Filtered(kw => MainGameManager.Instance.elementTags.Contains(kw));
}
public bool HasKeyword(string keyword)
@@ -95,15 +90,22 @@ namespace Continentis.MainGame.Card
{
CommandBase clone = template.Clone();
List<CommandBase> allCommands = new List<CommandBase>();
if (clone is CommandGroup group)
{
foreach (CommandBase cmd in group.commands)
{
cmd.selfContext.context["Target"] = target;
}
}//TODO: 变成递归
allCommands.AddRange(group.GetAllCommands(true));
}
else
{
allCommands.Add(clone);
}
foreach (CommandBase cmd in allCommands)
{
cmd.selfContext.context["Target"] = target;
}
clone.selfContext.context["Target"] = target;
singleGroup.AddCommand(clone);
}
@@ -132,17 +134,17 @@ namespace Continentis.MainGame.Card
protected virtual int GetFinalDamage(CharacterBase target, List<string> elementalTags,
out float baseDamageAfterOffset, out float elementalMultiplier, out float magicMultiplier, out float finalMultiplier)
{
elementalTags ??= GetElementTags();
elementalTags ??= GetElementalKeywords();
//----计算基础伤害增量----
int physicsOffset = 0;
if (HasTag("Physics") || HasKeyword("Slash") || HasKeyword("Prick") || HasKeyword("Strike"))
if (HasKeyword("Physics") || HasKeyword("Slash") || HasKeyword("Prick") || HasKeyword("Strike"))
{
physicsOffset = user.GetAttribute("PhysicsDamageDealtOffset"); //物理伤害基础增量
}
int magicOffset = 0;
if (HasTag("Magic") || HasKeyword("Arcane") || HasKeyword("Sorcery"))
if (HasKeyword("Magic") || HasKeyword("Arcane") || HasKeyword("Sorcery"))
{
magicOffset = user.GetAttribute("MagicDamageDealtOffset"); //魔法伤害基础增量
}
@@ -159,7 +161,7 @@ namespace Continentis.MainGame.Card
//计算通用的魔法伤害加成
magicMultiplier = 1;
if (HasTag("Magic") || HasKeyword("Arcane") || HasKeyword("Sorcery"))
if (HasKeyword("Magic") || HasKeyword("Arcane") || HasKeyword("Sorcery"))
{
magicMultiplier = user.GetRawAttribute("MagicDamageDealtMultiplier", 1) *
target.GetRawAttribute("MagicDamageGainMultiplier", 1);

View File

@@ -24,55 +24,47 @@ namespace Continentis.MainGame.Card
Curse = 40,
Item = 50,
}
[CreateAssetMenu(menuName = "Continentis/MainGame/Card/CardData", fileName = "CardData")]
public partial class CardData : ScriptableObject
{
[Header("Fundamental")]
public string modName;
[Header("Fundamental")] public string modName;
public string className;
public string displayName;
public Rarity cardRarity;
public CardType cardType;
public List<string> tags;
public List<string> keywords;
public Sprite cardSprite;
public List<string> cardLayoutTags;
public string functionText;
public string cardDescription;
[Header("Intention")]
public float baseWeight = 1f;
[Header("Attributes")]
[Tooltip("可变属性这个属性会自动设置BaseAttr进入Original设置AttrBaseAttrOffset=0以及DisplayAttr进入Current")]
[Header("Intention")] public float baseWeight = 1f;
[Header("Attributes")] [Tooltip("可变属性这个属性会自动设置BaseAttr进入Original设置AttrBaseAttrOffset=0以及DisplayAttr进入Current")]
public SerializableDictionary<string, float> variableAttributes = new SerializableDictionary<string, float>();
[Tooltip("基础属性,不会改变,通常情况下不会直接使用")]
public SerializableDictionary<string, float> originalAttributes = new SerializableDictionary<string, float>();
[FormerlySerializedAs("endowingCurrentAttributes")] [Tooltip("初始化时赋予给CurrentAttributes的属性第一栏是属性名第二栏是初始化时使用对应名称的OriginalAttributes的留空则默认为0如果是float数字则直接使用该数字")]
[FormerlySerializedAs("endowingCurrentAttributes")]
[Tooltip("初始化时赋予给CurrentAttributes的属性第一栏是属性名第二栏是初始化时使用对应名称的OriginalAttributes的留空则默认为0如果是float数字则直接使用该数字")]
public SerializableDictionary<string, string> runtimeCurrentAttributes = new SerializableDictionary<string, string>();
[Header("Upgrade")]
public CardUpgradeNode upgradeNode;
[Header("References")]
public List<string> prefabRefs = new List<string>();
[Header("Upgrade")] public CardUpgradeNode upgradeNode;
[Header("References")] public List<string> prefabRefs = new List<string>();
public List<string> derivativeCardDataRefs = new List<string>();
public List<string> derivativeCharacterDataRefs = new List<string>();
}
public partial class CardData
{
public bool HasTag(string tag)
{
return tags.Contains(tag);
}
public bool HasKeyword(string keyword)
{
return functionText.Contains($"$Keyword(\"{keyword}\")");
return keywords.Contains(keyword);
}
}
@@ -83,10 +75,10 @@ namespace Continentis.MainGame.Card
return ModManager.GetData<CardData>(dataID);
}
}
public partial class CardData
{
/// <summary>
/// 通过索引获取衍生卡牌数据
/// </summary>
@@ -94,7 +86,7 @@ namespace Continentis.MainGame.Card
{
return ModManager.GetData<CardData>(derivativeCardDataRefs[index]);
}
/// <summary>
/// 通过索引获取衍生角色数据
/// </summary>
@@ -105,109 +97,4 @@ namespace Continentis.MainGame.Card
return ModManager.GetData<CharacterData>(derivativeCharacterDataRefs[index]);
}
}
#if UNITY_EDITOR
public partial class CardData
{/*
private void SetCardIdentifier()
{
cardIdentifier = cardClass.Name;
int underscoreIndex = cardClass.Name.IndexOf('_');
string cardNamePart = cardClass.Name.Substring(underscoreIndex + 1);
string result = Regex.Replace(cardNamePart, "([a-z])([A-Z])", "$1 $2");
cardName = result;
}
private void CreateUpgradeNode()
{
upgradeNode = new CardUpgradeNode(this);
}
private IEnumerable<ValueDropdownItem<Type>> GetLogicTypes()
{
IEnumerable<Type> types = AppDomain.CurrentDomain.GetAssemblies()
.SelectMany(assembly => assembly.GetTypes())
.Where(t => typeof(CardLogicBase).IsAssignableFrom(t) && !t.IsAbstract && !t.IsInterface);
// 我们将从命名空间中移除这个公共前缀,让路径更简洁
string commonNamespacePrefix = "Continentis.Mods";
foreach (var type in types)
{
string path = "Uncategorized/" + type.Name; // 默认路径
if (type.Namespace != null && type.Namespace.StartsWith(commonNamespacePrefix))
{
// 1. 移除公共前缀
string formattedNamespace = type.Namespace.Substring(commonNamespacePrefix.Length);
// 2. 移除特定的子命名空间部分(例如 "Cards"
formattedNamespace = formattedNamespace.Replace(".Cards", "");
// 3. 将点 '.' 替换为斜杠 '/' 来创建分组
formattedNamespace = formattedNamespace.Replace('.', '/');
// 4. 组合成最终的路径
path = formattedNamespace + "/" + type.Name;
}
yield return new ValueDropdownItem<Type>(path, type);
}
}
[FoldoutGroup("Functions")]
[Button("从所有的DefaultCollection中粘贴默认属性")]
public void PasteDefaultAttributes()
{
List<CardAttributesDefaultCollection> targetCollections = new List<CardAttributesDefaultCollection>();
string[] guids = AssetDatabase.FindAssets("t:CardAttributesDefaultCollection");
foreach (string guid in guids)
{
// 将GUID转换为资产的路径
string path = AssetDatabase.GUIDToAssetPath(guid);
// 2. 验证每个资产的路径是否完全符合您指定的结构
// 使用 Path.GetDirectoryName 获取文件所在的目录
// 并统一使用'/'作为路径分隔符,以兼容不同操作系统
string directory = Path.GetDirectoryName(path)?.Replace('\\', '/');
Debug.Log($"Checking asset at path: {path}, directory: {directory}");
// 加载资产以检查其命名空间
ScriptableObject collection = AssetDatabase.LoadAssetAtPath<ScriptableObject>(path);
Type assetType = collection.GetType();
string assetNamespace = assetType.Namespace;
// 检查目录是否有效,是否在"Assets/Mods/"下,并且是否以"/Characters/DefaultCollections"结尾
if (!string.IsNullOrEmpty(directory) &&
assetNamespace == typeof(CardAttributesDefaultCollection).Namespace &&
directory.StartsWith("Assets/Mods/") &&
directory.EndsWith("/Cards/DefaultCollections"))
{
// 3. 如果路径和命名空间都符合要求,则将该资产添加到目标列表中
CardAttributesDefaultCollection defaultList = collection as CardAttributesDefaultCollection;
targetCollections.Add(defaultList);
Debug.Log($"Loaded DefaultStringList from: {path}");
}
}
Dictionary<string, float> variableAttributes = new Dictionary<string, float>();
Dictionary<string, float> originalAttributes = new Dictionary<string, float>();
Dictionary<string, string> endowingCurrentAttributes = new Dictionary<string, string>();
foreach (CardAttributesDefaultCollection collection in targetCollections)
{
collection.variableAttributes.PasteDictionary(variableAttributes);
collection.originalAttributes.PasteDictionary(originalAttributes);
collection.endowingCurrentAttributes.PasteDictionary(endowingCurrentAttributes);
}
variableAttributes.PasteDictionary(this.variableAttributes);
originalAttributes.PasteDictionary(this.originalAttributes);
endowingCurrentAttributes.PasteDictionary(this.endowingCurrentAttributes);
Debug.Log($"Pasted default attributes to file {this.name}");
}*/
}
#endif
}

View File

@@ -23,7 +23,6 @@ namespace Continentis.MainGame.Card
[Header("Card Base Info")]
public Guid cardID;
public List<string> tags;
public int upgradeLevel;
[Header("Submodules")]
@@ -63,8 +62,7 @@ namespace Continentis.MainGame.Card
public void Setup()
{
this.cardID = Guid.NewGuid();
this.tags = new List<string>(cardData.tags);
this.attributeSubmodule = new AttributeSubmodule(this);
this.weightSubmodule = new WeightSubmodule(this);
this.eventSubmodule = new EventSubmodule(this);
@@ -140,6 +138,14 @@ namespace Continentis.MainGame.Card
}
}
/// <summary>
/// 获取衍生卡牌数据
/// </summary>
public CardData GetDerivativeCardData(int index)
{
return ModManager.GetData<CardData>(cardData.derivativeCardDataRefs[index]);
}
}
/// <summary>

View File

@@ -74,13 +74,13 @@ namespace Continentis.MainGame.Card
return;
}
if (targetCount == 0 || cardData.tags.Contains("TargetSelf")) // 卡牌目标为自身
if (targetCount == 0 || HasKeyword("TargetSelf")) // 卡牌目标为自身
{
valid.Add(user);
invalid.AddRange(characters);
invalid.Remove(user);
}
else if (cardData.tags.Contains("TargetAllies")) // 卡牌目标为友方单位
else if (HasKeyword("TargetAllies")) // 卡牌目标为友方单位
{
if(user.fraction is Fraction.Ally or Fraction.Player)
{
@@ -111,7 +111,7 @@ namespace Continentis.MainGame.Card
}
}
}
else if (cardData.tags.Contains("TargetEnemies")) // 卡牌目标为敌人
else if (HasKeyword("TargetEnemies")) // 卡牌目标为敌人
{
if (user.fraction is Fraction.Ally or Fraction.Player)
{
@@ -155,12 +155,13 @@ namespace Continentis.MainGame.Card
}
}
}
else if(cardData.tags.Contains("TargetAll")) // 卡牌目标为全体
else if(HasKeyword("TargetAll")) // 卡牌目标为全体
{
valid.AddRange(characters);
}
else
{
valid.AddRange(characters);// 默认卡牌目标为所有单位
Debug.Log("No valid target found");
}
}

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using SLSFramework.General;
using UnityEngine;
@@ -7,7 +8,6 @@ namespace Continentis.MainGame.Card
public class ContentSubmodule : SubmoduleBase<CardLogicBase>
{
public List<string> keywords;
public List<string> hintKeywords;
public string cardName;
public Sprite cardSprite;
@@ -18,8 +18,7 @@ namespace Continentis.MainGame.Card
public ContentSubmodule(CardLogicBase card) : base(card)
{
keywords = new List<string>();
hintKeywords = new List<string>();
keywords = card.cardData.keywords;
cardName = card.cardData.displayName.Localize();
cardSprite = card.cardData.cardSprite;
originalFunctionText = card.cardData.functionText.Localize();

View File

@@ -59,7 +59,6 @@ namespace Continentis.MainGame.Card
List<string> allKeywords = new List<string>();
allKeywords.AddRange(cardLogic.contentSubmodule.keywords);
allKeywords.AddRange(cardLogic.contentSubmodule.hintKeywords);
keywordList.Enable(allKeywords);
}
@@ -99,10 +98,11 @@ namespace Continentis.MainGame.Card
if (string.IsNullOrEmpty(collectionName)) collectionName = "Basic";
CardViewCollection collection = MainGameManager.Instance.basePrefabs.cardViewCollections[collectionName];
List<string> elementTags = cardLogic.GetElementTags();
string firstElementTag = elementTags.Count > 0 ? elementTags[0] : "Default";
if (!collection.cardViews.ContainsKey(firstElementTag)) firstElementTag = "Default";
cardBackground.sprite = collection.cardViews[firstElementTag].background;
List<string> layoutTags = cardLogic.cardData.cardLayoutTags; //TODO后续可扩展为动态布局标签
string firstLayoutTag = layoutTags.Count > 0 ? layoutTags[0] : "Default";
if (!collection.cardViews.ContainsKey(firstLayoutTag)) firstLayoutTag = "Default";
cardBackground.sprite = collection.cardViews[firstLayoutTag].background;
cardTypeText.text = cardLogic.contentSubmodule.cardType.ToString();

View File

@@ -248,7 +248,7 @@ namespace Continentis.MainGame.Card
return;
}
if (!cardLogic.HasTag("TargetSelf"))
if (!cardLogic.HasKeyword("TargetSelf"))
{
if (!validTargets.Contains(hoveringCharacter))
{

View File

@@ -1,14 +1,17 @@
#if UNITY_EDITOR
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEngine;
using SLSFramework.UModAssistance;
using Continentis.MainGame.Character;
using Continentis.Mods;
namespace Continentis.MainGame.Card
{
[CustomEditor(typeof(CardData))]
public class CardDataEditor : DataEditor
public partial class CardDataEditor : DataEditor
{
// 存储我们需要自定义绘制的属性的引用
private SerializedProperty modNameProp;
@@ -16,9 +19,10 @@ namespace Continentis.MainGame.Card
private SerializedProperty displayNameProp;
private SerializedProperty cardRarityProp;
private SerializedProperty cardTypeProp;
private SerializedProperty tagsProp;
private SerializedProperty keywordsProp;
private SerializedProperty cardSpriteProp;
private SerializedProperty cardLayoutTagsProp;
private SerializedProperty functionTextProp;
private SerializedProperty cardDescriptionProp;
@@ -33,19 +37,22 @@ namespace Continentis.MainGame.Card
private SerializedProperty prefabsProp;
private SerializedProperty derivativeCardsProp;
private SerializedProperty derivativeCharactersProp;
protected override void OnEnable()
{
base.OnEnable();
LoadAllKeywordsFromEditRefs();
// 在启用时根据我们修改后的字段名找到对应的SerializedProperty
modNameProp = serializedObject.FindProperty("modName");
classNameProp = serializedObject.FindProperty("className");
displayNameProp = serializedObject.FindProperty("displayName");
cardRarityProp = serializedObject.FindProperty("cardRarity");
cardTypeProp = serializedObject.FindProperty("cardType");
tagsProp = serializedObject.FindProperty("tags");
keywordsProp = serializedObject.FindProperty("keywords");
cardSpriteProp = serializedObject.FindProperty("cardSprite");
cardLayoutTagsProp = serializedObject.FindProperty("cardLayoutTags");
functionTextProp = serializedObject.FindProperty("functionText");
cardDescriptionProp = serializedObject.FindProperty("cardDescription");
baseWeightProp = serializedObject.FindProperty("baseWeight");
@@ -86,8 +93,14 @@ namespace Continentis.MainGame.Card
EditorGUILayout.PropertyField(cardRarityProp);
EditorGUILayout.PropertyField(cardTypeProp);
EditorGUILayout.PropertyField(tagsProp, true);
EditorGUILayout.PropertyField(keywordsProp, true);
if (keywordsProp.isExpanded)
{
DrawKeywordSelector();
}
EditorGUILayout.PropertyField(cardSpriteProp);
EditorGUILayout.PropertyField(cardLayoutTagsProp, true);
EditorGUILayout.PropertyField(functionTextProp);
EditorGUILayout.PropertyField(cardDescriptionProp);
@@ -114,5 +127,106 @@ namespace Continentis.MainGame.Card
serializedObject.ApplyModifiedProperties();
}
}
public partial class CardDataEditor
{
private List<string> allAvailableKeywords;
/// <summary>
/// 使用 AssetDatabase 查找项目中的所有 KeywordDatabase 并合并它们的列表
/// </summary>
private void LoadAllKeywordsFromEditRefs()
{
// 使用 HashSet 来自动处理重复的关键词
HashSet<string> allKeywordsSet = new HashSet<string>();
// 1. 查找项目中所有类型为 "KeywordDatabase" 的
// "t:KeywordDatabase" 是一个搜索过滤器t: 表示按类型搜索
string[] guids = AssetDatabase.FindAssets("t:ModEditReference");
foreach (string guid in guids)
{
// 2. 将 GUID 转换为资产路径
string assetPath = AssetDatabase.GUIDToAssetPath(guid);
// 3. 加载该路径下的 ScriptableObject
ModEditReference editRef = AssetDatabase.LoadAssetAtPath<ModEditReference>(assetPath);
EditKeywordsReference cardKeywordsRef = editRef.cardKeywordsReference;
if (cardKeywordsRef != null && cardKeywordsRef.keywordRefs != null)
{
// 4. 将词库中的所有词添加到 Set 中
foreach (string keyword in cardKeywordsRef.keywordRefs.Keys)
{
if (!string.IsNullOrEmpty(keyword))
{
allKeywordsSet.Add(keyword);
}
}
}
}
// 5. 将 Set 转换为 List 并排序,以便在菜单中清晰显示
allAvailableKeywords = allKeywordsSet.ToList();
allAvailableKeywords.Sort();
}
private void DrawKeywordSelector()
{
// 1. 检查是否找到了任何关键词
if (allAvailableKeywords == null || allAvailableKeywords.Count == 0)
{
EditorGUILayout.HelpBox("在项目中没有找到任何 KeywordDatabase或者词库为空。", MessageType.Warning);
// 显示一个刷新按钮,以防用户刚刚创建了词库
if (GUILayout.Button("Refresh Keyword Edit References"))
{
LoadAllKeywordsFromEditRefs();
}
return;
}
List<string> currentKeywords = (target as CardData)!.keywords;
// 2. 找出尚未添加的关键词
List<string> keywordsToAdd = allAvailableKeywords.Except(currentKeywords).ToList();
// 3. 如果所有关键词都添加了,显示提示
if (keywordsToAdd.Count == 0)
{
EditorGUILayout.HelpBox("所有可用的关键词都已添加。", MessageType.Info);
}
else
{
// 4. 绘制 "Add Keyword" 按钮
if (GUILayout.Button("Add Keyword from Edit Refs..."))
{
GenericMenu menu = new GenericMenu();
foreach (string keyword in keywordsToAdd)
{
menu.AddItem(new GUIContent(keyword), false, () => {
AddKeywordToList(keyword);
});
}
menu.ShowAsContext();
}
}
// 5. (可选) 添加一个手动刷新按钮
// 因为 AssetDatabase.FindAssets() 速度很快所以我们也可以在每次GUI绘制时都调用
// 但如果词库很多,使用按钮刷新更好。
/*if (GUILayout.Button("Refresh Keyword Databases"))
{
LoadAllKeywordsFromEditRefs();
}*/
}
private void AddKeywordToList(string keyword)
{
keywordsProp.InsertArrayElementAtIndex(keywordsProp.arraySize);
SerializedProperty newElement = keywordsProp.GetArrayElementAtIndex(keywordsProp.arraySize - 1);
newElement.stringValue = keyword;
serializedObject.ApplyModifiedProperties();
}
}
}
#endif

View File

@@ -15,7 +15,7 @@ namespace Continentis.Mods.Basic.Cards
public override void Initialize(CardLogicBase card)
{
base.Initialize(card);
cardFilter = cardData => !cardData.HasTag("Unobtainable");
cardFilter = cardData => !cardData.HasKeyword("Unobtainable");
}
/// <summary>
@@ -24,18 +24,10 @@ namespace Continentis.Mods.Basic.Cards
public void SetFilter(Func<CardData, bool> filter)
{
List<Func<CardData, bool>> originalFilters = new List<Func<CardData, bool>>();
originalFilters.Add(cardData => !cardData.HasTag("Unobtainable"));
originalFilters.Add(cardData => !cardData.HasKeyword("Unobtainable"));
if (filter != null) originalFilters.Add(filter);
this.cardFilter = cardData => originalFilters.All(f => f(cardData));
}
/// <summary>
/// 获取衍生卡牌数据
/// </summary>
public CardData GetDerivativeCardData(int index)
{
return card.cardData.GetDerivativeCardData(index);
}
/// <summary>
/// 从指定的cardDataID中根据needFilter决定是否进行过滤获取符合条件的卡牌数据列表

View File

@@ -1,8 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Continentis.MainGame.Character;
using SLSFramework.General;
using UniRx;
using UnityEngine;
using UnityEngine.Events;
namespace Continentis.MainGame.Commands
{
@@ -14,6 +17,11 @@ namespace Continentis.MainGame.Commands
private float overrideDuration;
private string stateName;
private int layer;
//在动画的normalizedTime执行函数
private AnimationClip clip;
private float clipScaledLength => clip.length / animator.speed;
private Dictionary<float, Action> animationActions;
public Cmd_PlayAnimation(CombatCharacterViewBase characterView, string stateName,
bool waitForFinish = false, float overrideDuration = -1, int layer = 0) : base(null)
@@ -21,9 +29,36 @@ namespace Continentis.MainGame.Commands
this.characterView = characterView;
this.animator = characterView.animator;
this.stateName = stateName;
this.clip = characterView.animationClips[stateName];
this.waitForFinish = waitForFinish;
this.overrideDuration = overrideDuration;
this.layer = layer;
this.animationActions = new Dictionary<float, Action>();
}
public Cmd_PlayAnimation AddAction(float normalizedDuration, Action action)
{
animationActions[normalizedDuration] = action;
return this;
}
public Cmd_PlayAnimation AddAction(int frame, Action action)
{
float normalizedDuration = frame / (clip.frameRate * clip.length);
return AddAction(normalizedDuration, action);
}
public Cmd_PlayAnimation AddAction<T>(float normalizedDuration, string selfContextKey, Action<T> action)
{
T param = selfContext.GetInfo<T>(selfContextKey);
animationActions[normalizedDuration] = () => action(param);
return this;
}
public Cmd_PlayAnimation AddAction<T>(int frame, string selfContextKey, Action<T> action)
{
float normalizedDuration = frame / (clip.frameRate * clip.length);
return AddAction(normalizedDuration, selfContextKey, action);
}
protected override IObservable<Unit> OnExecute(CommandContext outerContext)
@@ -47,6 +82,24 @@ namespace Continentis.MainGame.Commands
}
animator.CrossFade(stateName, 0f, layer, 0f);
//监听动画进度以执行函数独立Observable
if (animationActions.Count > 0)
{
Observable.EveryUpdate().TakeUntil(Observable.Timer(TimeSpan.FromSeconds(clipScaledLength))).Subscribe(_ =>
{
float normalizedTime = animator.GetCurrentAnimatorStateInfo(layer).normalizedTime % 1f;
foreach (var kvp in animationActions.ToList())
{
if (normalizedTime >= kvp.Key)
{
kvp.Value?.Invoke();
animationActions.Remove(kvp.Key); //确保只执行一次
}
}
});
}
if (waitForFinish)
{
float animationDuration = overrideDuration >= 0 ? overrideDuration : characterView.animationClips[stateName].length;

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 9510942ad8df1f7418b4474e196ce728
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,12 @@
using SLSFramework.General;
using UnityEngine;
namespace Continentis.Mods
{
[CreateAssetMenu(fileName = "EditKeywordsReference", menuName = "Continentis/Mod/Edit/Keywords Reference", order = 3)]
public class EditKeywordsReference : ScriptableObject
{
[KeyWidth(0.3f)]
public SerializableDictionary<string, string> keywordRefs;
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 634ae9a7ace35674aac295f34a73f088

View File

@@ -0,0 +1,12 @@
using SLSFramework.General;
using UnityEngine;
using UnityEngine.Serialization;
namespace Continentis.Mods
{
[CreateAssetMenu(fileName = "ModEditReference", menuName = "Continentis/Mod/Edit Reference", order = 2)]
public class ModEditReference : ScriptableObject
{
[FormerlySerializedAs("keywordsReference")] public EditKeywordsReference cardKeywordsReference;
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: afb8fcbb8d897e449a135120c7516dbd

View File

@@ -47,6 +47,46 @@ namespace SLSFramework.General
commands.Add(command);
return this;
}
/// <summary>
/// 获取所有子指令,包含嵌套的指令组中的指令。
/// </summary>
/// <param name="alsoIncludeGroups">是否也包含CommandGroupfalse则不会将CommandGroup返回</param>
/// <returns></returns>
public List<CommandBase> GetAllCommands(bool alsoIncludeGroups = false)
{
//CommandBase可能也是CommandGroup,需要递归获取
List<CommandBase> allCommands = new List<CommandBase>();
if (alsoIncludeGroups)
{
allCommands.Add(this);
}
foreach (CommandBase cmd in commands)
{
if (cmd is CommandGroup group)
{
if (alsoIncludeGroups)
{
allCommands.Add(group);
}
allCommands.AddRange(group.GetAllCommands(alsoIncludeGroups));
}
else
{
allCommands.Add(cmd);
}
}
return allCommands;
}
public List<T> GetAllCommands<T>() where T : CommandBase
{
return GetAllCommands(true).OfType<T>().ToList();
}
protected override IObservable<Unit> OnExecute(CommandContext outerContext)
{