Skip to content

Commit

Permalink
fixed behavior editor for multiple KoolBehaviors on a single entity
Browse files Browse the repository at this point in the history
  • Loading branch information
fabmax committed Jul 2, 2024
1 parent d04fd10 commit b8ec0a0
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,6 @@ abstract class KoolContext {

companion object {
// automatically updated by gradle script on build
const val KOOL_VERSION = "0.16.0-SNAPSHOT"
const val KOOL_VERSION = "0.15.1"
}
}
1 change: 0 additions & 1 deletion kool-editor-model/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
plugins {
id("kool.androidlib-conventions")
id("kool.lib-conventions")
id("kool.publish-conventions")
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,13 @@ class GameEntityEditor(ui: EditorUi) :
is MeshComponent -> componentEditor(objects) { MeshEditor() }
is SceneComponent -> componentEditor(objects) { ScenePropertiesEditor() }
is SceneBackgroundComponent -> componentEditor(objects) { SceneBackgroundEditor() }
is BehaviorComponent -> componentEditor(objects) { BehaviorEditor() }
is ShadowMapComponent -> componentEditor(objects) { ShadowMapEditor() }
is SsaoComponent -> componentEditor(objects) { SsaoEditor() }
is TransformComponent -> componentEditor(objects) { TransformEditor() }
is PhysicsWorldComponent -> componentEditor(objects) { PhysicsWorldEditor() }
is RigidActorComponent -> componentEditor(objects) { RigidActorEditor() }
is CharacterControllerComponent -> componentEditor(objects) { CharacterControllerEditor() }
is BehaviorComponent -> behaviorComponentEditor(objects, component.data.behaviorClassName)
}
}
}
Expand All @@ -193,6 +193,18 @@ class GameEntityEditor(ui: EditorUi) :
}
}

private fun UiScope.behaviorComponentEditor(gameEntities: List<GameEntity>, behaviorClassName: String) {
val components = gameEntities.map {
it.getComponents<BehaviorComponent>().first { c -> c.data.behaviorClassName == behaviorClassName }
}
Box(width = Grow.Std, scopeName = components[0].componentType) {
val editor = remember { BehaviorEditor() }
editor.components = components
editor.entityEditor = this@GameEntityEditor
editor()
}
}

private fun UiScope.addComponentSelector(objects: List<GameEntity>) {
val popup = remember { ContextPopupMenu<List<GameEntity>>("add-component") }
var popupPos by remember(Vec2f.ZERO)
Expand Down

0 comments on commit b8ec0a0

Please sign in to comment.