|
@@ -5,6 +5,8 @@
|
|
|
|
|
|
#include "AITestsCommon.h"
|
|
|
#include "EzAbility.h"
|
|
|
+#include "EzAbilityCompiler.h"
|
|
|
+#include "EzAbilityCompilerLog.h"
|
|
|
#include "EzAbilityComponent.h"
|
|
|
#include "EzAbilityEditorData.h"
|
|
|
#include "EzAblityTestTypes.h"
|
|
@@ -35,6 +37,44 @@ struct FEzAbilityTest_MakeAndBakeEzAbility : FAITestBase
|
|
|
{
|
|
|
virtual bool InstantTest() override
|
|
|
{
|
|
|
+ UEzAbility& EzAbility = UE::EzAbility::Tests::NewAbility(&GetWorld());
|
|
|
+ UEzAbilityEditorData& EditorData = *Cast<UEzAbilityEditorData>(EzAbility.EditorData);
|
|
|
+
|
|
|
+ UEzAbilityState& Root = EditorData.AddSubTree(FName(TEXT("Root")));
|
|
|
+ UEzAbilityState& StateA = Root.AddChildState(FName(TEXT("A")));
|
|
|
+ UEzAbilityState& StateB = Root.AddChildState(FName(TEXT("B")));
|
|
|
+
|
|
|
+ // Root
|
|
|
+ auto& EvalA = EditorData.AddEvaluator<FTestEval_A>();
|
|
|
+
|
|
|
+ // State A
|
|
|
+ auto& TaskB1 = StateA.AddTask<FTestTask_B>();
|
|
|
+ EditorData.AddPropertyBinding(EvalA, TEXT("IntA"), TaskB1, TEXT("IntB"));
|
|
|
+
|
|
|
+ // auto& IntCond = StateA.AddEnterCondition<FEzAbilityCompareIntCondition>(EGenericAICheck::Less);
|
|
|
+ // IntCond.GetInstanceData().Right = 2;
|
|
|
+ //
|
|
|
+ // EditorData.AddPropertyBinding(EvalA, TEXT("IntA"), IntCond, TEXT("Left"));
|
|
|
+
|
|
|
+ StateA.AddTransition(EEzAbilityTransitionTrigger::OnStateCompleted, EEzAbilityTransitionType::GotoState, &StateB);
|
|
|
+
|
|
|
+ // State B
|
|
|
+ auto& TaskB2 = StateB.AddTask<FTestTask_B>();
|
|
|
+ EditorData.AddPropertyBinding(EvalA, TEXT("bBoolA"), TaskB2, TEXT("bBoolB"));
|
|
|
+
|
|
|
+ FEzAbilityTransition& Trans = StateB.AddTransition({}, EEzAbilityTransitionType::GotoState, &Root);
|
|
|
+ // auto& TransFloatCond = Trans.AddCondition<FEzAbilityCompareFloatCondition>(EGenericAICheck::Less);
|
|
|
+ // TransFloatCond.GetInstanceData().Right = 13.0f;
|
|
|
+ //EditorData.AddPropertyBinding(EvalA, TEXT("FloatA"), TransFloatCond, TEXT("Left"));
|
|
|
+
|
|
|
+ StateB.AddTransition(EEzAbilityTransitionTrigger::OnStateCompleted, EEzAbilityTransitionType::Succeeded);
|
|
|
+
|
|
|
+ FEzAbilityCompilerLog Log;
|
|
|
+ FEzAbilityCompiler Compiler(Log);
|
|
|
+ const bool bResult = Compiler.Compile(EzAbility);
|
|
|
+
|
|
|
+ AITEST_TRUE("EzAbility should get compiled", bResult);
|
|
|
+ AITEST_TRUE("EzAbility should be ready to run", EzAbility.IsReadyToRun());
|
|
|
return true;
|
|
|
}
|
|
|
};
|
|
@@ -53,12 +93,12 @@ struct FEzAbilityTest_EmptyAbility : FAITestBase
|
|
|
UEzAbilityState& Root = EditorData.AddSubTree(FName(TEXT("Root")));
|
|
|
Root.AddTransition(EEzAbilityTransitionTrigger::OnStateCompleted, EEzAbilityTransitionType::Succeeded);
|
|
|
|
|
|
- // FEzAbilityCompilerLog Log;
|
|
|
- // FEzAbilityCompiler Compiler(Log);
|
|
|
- // const bool bResult = Compiler.Compile(EzAbility);
|
|
|
- //
|
|
|
- // AITEST_TRUE("EzAbility should get compiled", bResult);
|
|
|
- //
|
|
|
+ FEzAbilityCompilerLog Log;
|
|
|
+ FEzAbilityCompiler Compiler(Log);
|
|
|
+ const bool bResult = Compiler.Compile(Ability);
|
|
|
+
|
|
|
+ AITEST_TRUE("EzAbility should get compiled", bResult);
|
|
|
+
|
|
|
EAbilityRunStatus Status = EAbilityRunStatus::Unset;
|
|
|
FEzAbilityInstanceData InstanceData;
|
|
|
FTestEzAbilityExecutionContext Exec(Ability, Ability, InstanceData);
|