tirbofish/dropbear · commit
5ada4cc1db17a9975889909200c193ab01e41ea9
merge fixes
Signature present but could not be verified.
Unverified
@@ -53,6 +53,8 @@ Cargo.lock .idea/ +.env + libs/ .env @@ -53,7 +53,7 @@ kotlin { println("Local library exists") // "${project.rootDir}/libs/$libName" } else { - throw GradleException("libeucalyptus_core.so does not exist. This is a local build, so most likely you haven't built the rust library yet. \n" + + println("libeucalyptus_core.so does not exist. This is a local build, so most likely you haven't built the rust library yet. \n" + "Try running cargo build") } @@ -1,21 +0,0 @@ -import com.dropbear.DropbearEngine -import com.dropbear.EntityId -import com.dropbear.System -import com.dropbear.ProjectScriptingMetadata -import com.dropbear.Runnable -import com.dropbear.ScriptRegistration - -@Runnable(["player"]) -class Player: System { - override fun load(engine: DropbearEngine) { - TODO("Not yet implemented") - } - - override fun update(engine: DropbearEngine, deltaTime: Float) { - TODO("Not yet implemented") - } - - override fun destroy(engine: DropbearEngine) { - TODO("Not yet implemented") - } -} @@ -1,47 +0,0 @@ -package com.dropbear.input - -import com.dropbear.ffi.NativeEngine - -/** - * High-level input management wrapper for accessing input state - * from Kotlin scripts. - */ -object Input { - /** - * Check if a specific key is currently pressed - * - * @param keyCode The key to check (use KeyCode constants) - * @return true if the key is pressed, false otherwise - * - * @example - * ```kotlin - * if (Input.isKeyPressed(KeyCode.W)) { - * // Move forward - * } - * ``` - */ - fun isKeyPressed(keyCode: Long): Boolean { - return NativeEngine.isKeyPressed(keyCode) - } - - /** - * Get the current mouse X position - */ - fun getMouseX(): Double { - return NativeEngine.getMouseX() - } - - /** - * Get the current mouse Y position - */ - fun getMouseY(): Double { - return NativeEngine.getMouseY() - } - - /** - * Get the mouse position as a pair - */ - fun getMousePosition(): Pair<Double, Double> { - return Pair(getMouseX(), getMouseY()) - } -} @@ -1,47 +0,0 @@ -package com.dropbear.input - -/** - * Key codes that match the Rust KeyCode enum. - * These are used with NativeEngine.isKeyPressed() - */ -object KeyCode { - // Letters - const val A = 65L - const val B = 66L - const val C = 67L - const val D = 68L - const val E = 69L - const val F = 70L - const val G = 71L - const val H = 72L - const val I = 73L - const val J = 74L - const val K = 75L - const val L = 76L - const val M = 77L - const val N = 78L - const val O = 79L - const val P = 80L - const val Q = 81L - const val R = 82L - const val S = 83L - const val T = 84L - const val U = 85L - const val V = 86L - const val W = 87L - const val X = 88L - const val Y = 89L - const val Z = 90L - - // Arrow keys - const val ARROW_LEFT = 37L - const val ARROW_UP = 38L - const val ARROW_RIGHT = 39L - const val ARROW_DOWN = 40L - - // Special keys - const val SPACE = 32L - const val SHIFT = 16L - const val CONTROL = 17L - const val ESCAPE = 27L -} @@ -1,72 +0,0 @@ -// File to get an idea of what is generated -@file:OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class) -import com.dropbear.DropbearEngine -import com.dropbear.EntityId -import com.dropbear.EntityRef -import com.dropbear.ProjectScriptingMetadata -import com.dropbear.ScriptRegistration -import com.dropbear.ffi.NativeEngine -import kotlinx.cinterop.COpaquePointer -import kotlinx.cinterop.ExperimentalForeignApi -import kotlin.experimental.ExperimentalNativeApi -import kotlin.native.CName - -// import /* CLASS */ - -private val scriptInstances: List<ScriptRegistration> by lazy { - Metadata().getScripts() -} - -class Metadata: ProjectScriptingMetadata { - override fun getScripts(): List<ScriptRegistration> { - return listOf( - ScriptRegistration( - tags = listOf("player"), - script = Player() - ), - -// ScriptRegistration( -// tags = /* TAGS */, -// script = /* CLASS NAME */ -// ), - - ) - } -} - -fun getDropbearEngine(worldPointer: COpaquePointer?, currentEntity: Long?): DropbearEngine { - val nativeEngine = NativeEngine() - nativeEngine.init(worldPointer) - val dropbearEngine = DropbearEngine(nativeEngine, if (currentEntity == null) null else EntityRef(EntityId(currentEntity.toULong()))) - return dropbearEngine -} - -@CName("dropbear_load") -fun loadScriptByTag(worldPointer: COpaquePointer?, currentEntity: Long?, tag: String?) { - if (tag == null) return - val scripts = scriptInstances.filter { it.tags.contains(tag) } - val engine = getDropbearEngine(worldPointer, currentEntity) - for (script in scripts) { - script.script.load(engine) - } -} - -@CName("dropbear_update") -fun updateScriptByTag(worldPointer: COpaquePointer?, currentEntity: Long?, tag: String?, deltaTime: Double) { - if (tag == null) return - val scripts = scriptInstances.filter { it.tags.contains(tag) } - val engine = getDropbearEngine(worldPointer, currentEntity) - for (script in scripts) { - script.script.update(engine, deltaTime.toFloat()) - } -} - -@CName("dropbear_destroy") -fun destroyScriptByTag(worldPointer: COpaquePointer?, currentEntity: Long?, tag: String?) { - if (tag == null) return - val scripts = scriptInstances.filter { it.tags.contains(tag) } - val engine = getDropbearEngine(worldPointer, currentEntity) - for (script in scripts) { - script.script.destroy(engine) - } -}