From e5a264a1f89902810d0dd4d428865f5e95d94f3c Mon Sep 17 00:00:00 2001 From: Ash Blue Date: Tue, 23 Mar 2021 19:08:09 -0600 Subject: [PATCH] fix(actions): generic action had exit and init reversed Didn't seem to cause any problems. But would have definitely caused issues with extending the ActionGeneric class. #35 --- Runtime/Tasks/Actions/ActionGeneric.cs | 6 +++--- Tests/Editor/Tasks/Actions/ActionGenericTest.cs | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Runtime/Tasks/Actions/ActionGeneric.cs b/Runtime/Tasks/Actions/ActionGeneric.cs index ccb036d4..4ebe5028 100644 --- a/Runtime/Tasks/Actions/ActionGeneric.cs +++ b/Runtime/Tasks/Actions/ActionGeneric.cs @@ -20,11 +20,11 @@ protected override void OnStart () { } protected override void OnExit () { - initLogic?.Invoke(); + exitLogic?.Invoke(); } protected override void OnInit () { - exitLogic?.Invoke(); + initLogic?.Invoke(); } } -} \ No newline at end of file +} diff --git a/Tests/Editor/Tasks/Actions/ActionGenericTest.cs b/Tests/Editor/Tasks/Actions/ActionGenericTest.cs index 4c453774..ab15916d 100644 --- a/Tests/Editor/Tasks/Actions/ActionGenericTest.cs +++ b/Tests/Editor/Tasks/Actions/ActionGenericTest.cs @@ -44,6 +44,19 @@ public void It_should_execute_a_init_hook () { Assert.AreEqual(1, test); } + [Test] + public void It_should_execute_init_hook_on_continue () { + var test = 0; + var task = new ActionGeneric { + initLogic = () => { test++; }, + updateLogic = () => TaskStatus.Continue, + }; + + task.Update(); + + Assert.AreEqual(1, test); + } + [Test] public void It_should_execute_a_exit_hook () { var test = 0; @@ -57,4 +70,4 @@ public void It_should_execute_a_exit_hook () { } } } -} \ No newline at end of file +}