From 64f825465de9fa30c4dfe2707067efdb96110db8 Mon Sep 17 00:00:00 2001 From: Elizabeth Hunt Date: Thu, 23 Oct 2025 21:59:37 -0700 Subject: Init --- .../src/commonMain/kotlin/coffee/liz/ecs/World.kt | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 composeApp/src/commonMain/kotlin/coffee/liz/ecs/World.kt (limited to 'composeApp/src/commonMain/kotlin/coffee/liz/ecs/World.kt') diff --git a/composeApp/src/commonMain/kotlin/coffee/liz/ecs/World.kt b/composeApp/src/commonMain/kotlin/coffee/liz/ecs/World.kt new file mode 100644 index 0000000..fd3b6df --- /dev/null +++ b/composeApp/src/commonMain/kotlin/coffee/liz/ecs/World.kt @@ -0,0 +1,42 @@ +package coffee.liz.ecs + +import kotlin.jvm.JvmName +import kotlin.reflect.KClass + +/** + * The World manages entities and systems. + */ +interface World { + /** + * Create a new entity with a unique ID. + */ + fun createEntity(): Entity + + /** + * Destroy an entity and remove it from all caches. + */ + fun destroyEntity(entity: Entity) + + /** + * Get all entities that have all the specified component types. + */ + fun query(vararg componentTypes: KClass): Set + + /** + * Update all systems in dependency order. + * @param deltaTime Time elapsed since last update in seconds + */ + fun update(deltaTime: Float) +} + +// Convenience extension for queries +@JvmName("query1") +inline fun World.query(): Set = query(T::class) + +@JvmName("query2") +inline fun World.query(): Set = + query(T1::class, T2::class) + +@JvmName("query3") +inline fun World.query(): Set = + query(T1::class, T2::class, T3::class) -- cgit v1.2.3-70-g09d2