Skip to content

Commit ff7dbc2

Browse files
committed
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
1 parent 0e330d7 commit ff7dbc2

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

Assets/FluidBehaviorTree/Runtime/Tasks/Actions/ActionGeneric.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ protected override void OnStart () {
2020
}
2121

2222
protected override void OnExit () {
23-
initLogic?.Invoke();
23+
exitLogic?.Invoke();
2424
}
2525

2626
protected override void OnInit () {
27-
exitLogic?.Invoke();
27+
initLogic?.Invoke();
2828
}
2929
}
30-
}
30+
}

Assets/FluidBehaviorTree/Tests/Editor/Tasks/Actions/ActionGenericTest.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,19 @@ public void It_should_execute_a_init_hook () {
4444
Assert.AreEqual(1, test);
4545
}
4646

47+
[Test]
48+
public void It_should_execute_init_hook_on_continue () {
49+
var test = 0;
50+
var task = new ActionGeneric {
51+
initLogic = () => { test++; },
52+
updateLogic = () => TaskStatus.Continue,
53+
};
54+
55+
task.Update();
56+
57+
Assert.AreEqual(1, test);
58+
}
59+
4760
[Test]
4861
public void It_should_execute_a_exit_hook () {
4962
var test = 0;
@@ -57,4 +70,4 @@ public void It_should_execute_a_exit_hook () {
5770
}
5871
}
5972
}
60-
}
73+
}

0 commit comments

Comments
 (0)