Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/kotlin/com/tpcly/behaviourtree/node/Action.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import com.tpcly.behaviourtree.TreeNodeResult
class Action<S>(
override val name: String,
val func: (state: S?) -> Status
) : TreeNode<S> {
) : Leaf<S> {
override fun execute(state: S?): TreeNodeResult<S> {
return TreeNodeResult(this, func(state))
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/com/tpcly/behaviourtree/node/Condition.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import com.tpcly.behaviourtree.TreeNodeResult
class Condition<S>(
override val name: String,
val predicate: (state: S?) -> Boolean
) : TreeNode<S> {
) : Leaf<S> {
override fun execute(state: S?): TreeNodeResult<S> {
val status = when (predicate(state)) {
true -> Status.SUCCESS
Expand Down
3 changes: 3 additions & 0 deletions src/main/kotlin/com/tpcly/behaviourtree/node/Leaf.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.tpcly.behaviourtree.node

sealed interface Leaf<S> : TreeNode<S>
2 changes: 1 addition & 1 deletion src/main/kotlin/com/tpcly/behaviourtree/node/Perform.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import com.tpcly.behaviourtree.TreeNodeResult
class Perform<S>(
override val name: String,
val func: (state: S?) -> Unit
) : TreeNode<S> {
) : Leaf<S> {
override fun execute(state: S?): TreeNodeResult<S> {
func(state)
return TreeNodeResult.success(this)
Expand Down