-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework state4k to have enter commands (#57)
* upgrade versions data4k - rename content() to unwrap() data4k - add ability to set raw child data nodes * upgrade dependencies new version of state4k which defines commands that are triggered on entering a state * Release 2.15.0.0
- Loading branch information
1 parent
34d7c1f
commit dce4560
Showing
17 changed files
with
136 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 0 additions & 22 deletions
22
state4k/src/main/kotlin/dev/forkhandles/state4k/EntityStateLens.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
state4k/src/main/kotlin/dev/forkhandles/state4k/StateIdLens.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package dev.forkhandles.state4k | ||
|
||
/** | ||
* Responsible for retrieving and setting the state on an entity | ||
*/ | ||
interface StateIdLens<Entity, StateId> { | ||
operator fun invoke(entity: Entity): StateId | ||
operator fun invoke(entity: Entity, newState: StateId): Entity | ||
|
||
companion object { | ||
/** | ||
* Convenience function for creating an EntityStateLens | ||
*/ | ||
operator fun <Entity, StateId> invoke( | ||
get: (Entity) -> StateId, | ||
set: (Entity, StateId) -> Entity, | ||
) = object : StateIdLens<Entity, StateId> { | ||
override fun invoke(entity: Entity) = get(entity) | ||
override fun invoke(entity: Entity, newState: StateId) = set(entity, newState) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
state4k/src/main/kotlin/dev/forkhandles/state4k/StateMachineRenderer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
package dev.forkhandles.state4k | ||
|
||
fun interface StateMachineRenderer { | ||
operator fun invoke(transitions: List<StateTransition<*, *, *, *>>): String | ||
operator fun invoke(states: List<State<*, *, *>>): String | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.