Skip to content

Commit b8ec0a0

Browse files
committed
fixed behavior editor for multiple KoolBehaviors on a single entity
1 parent d04fd10 commit b8ec0a0

4 files changed

Lines changed: 14 additions & 38 deletions

File tree

kool-core/src/commonMain/kotlin/de/fabmax/kool/KoolContext.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,6 @@ abstract class KoolContext {
140140

141141
companion object {
142142
// automatically updated by gradle script on build
143-
const val KOOL_VERSION = "0.16.0-SNAPSHOT"
143+
const val KOOL_VERSION = "0.15.1"
144144
}
145145
}

kool-editor-model/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
plugins {
2-
id("kool.androidlib-conventions")
32
id("kool.lib-conventions")
43
id("kool.publish-conventions")
54
}

kool-editor-model/src/androidMain/kotlin/de/fabmax/kool/editor/api/BehaviorLoader.android.kt

Lines changed: 0 additions & 35 deletions
This file was deleted.

kool-editor/src/commonMain/kotlin/de/fabmax/kool/editor/ui/GameEntityEditor.kt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,13 +173,13 @@ class GameEntityEditor(ui: EditorUi) :
173173
is MeshComponent -> componentEditor(objects) { MeshEditor() }
174174
is SceneComponent -> componentEditor(objects) { ScenePropertiesEditor() }
175175
is SceneBackgroundComponent -> componentEditor(objects) { SceneBackgroundEditor() }
176-
is BehaviorComponent -> componentEditor(objects) { BehaviorEditor() }
177176
is ShadowMapComponent -> componentEditor(objects) { ShadowMapEditor() }
178177
is SsaoComponent -> componentEditor(objects) { SsaoEditor() }
179178
is TransformComponent -> componentEditor(objects) { TransformEditor() }
180179
is PhysicsWorldComponent -> componentEditor(objects) { PhysicsWorldEditor() }
181180
is RigidActorComponent -> componentEditor(objects) { RigidActorEditor() }
182181
is CharacterControllerComponent -> componentEditor(objects) { CharacterControllerEditor() }
182+
is BehaviorComponent -> behaviorComponentEditor(objects, component.data.behaviorClassName)
183183
}
184184
}
185185
}
@@ -193,6 +193,18 @@ class GameEntityEditor(ui: EditorUi) :
193193
}
194194
}
195195

196+
private fun UiScope.behaviorComponentEditor(gameEntities: List<GameEntity>, behaviorClassName: String) {
197+
val components = gameEntities.map {
198+
it.getComponents<BehaviorComponent>().first { c -> c.data.behaviorClassName == behaviorClassName }
199+
}
200+
Box(width = Grow.Std, scopeName = components[0].componentType) {
201+
val editor = remember { BehaviorEditor() }
202+
editor.components = components
203+
editor.entityEditor = this@GameEntityEditor
204+
editor()
205+
}
206+
}
207+
196208
private fun UiScope.addComponentSelector(objects: List<GameEntity>) {
197209
val popup = remember { ContextPopupMenu<List<GameEntity>>("add-component") }
198210
var popupPos by remember(Vec2f.ZERO)

0 commit comments

Comments
 (0)