Skip to content

Commit 09a3bfb

Browse files
committed
chore: Bump idofront, gradle 9.0.0
feat: Entity infoReader class to provide info about prefabs to other modules chore: Provide info about the entity that ran an erroring passive action
1 parent cbbffcd commit 09a3bfb

11 files changed

Lines changed: 39 additions & 9 deletions

File tree

addons/geary-actions/src/com/mineinabyss/geary/actions/event_binds/Passive.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ fun Geary.parsePassive() = observe<OnSet>()
4949
runCatching {
5050
val context = ActionGroupContext(entity)
5151
systemBind.run.execute(context)
52-
}.onFailure { it.printStackTrace() }
52+
}.onFailure {
53+
logger.e { "Error while executing passive system on entity $entity:" }
54+
it.printStackTrace()
55+
}
5356
}
5457
}
5558
}

addons/geary-actions/src/com/mineinabyss/geary/actions/expressions/EntityExpression.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ value class EntityExpression(
1111
val expression: String,
1212
) : Expression<GearyEntity> {
1313
override fun evaluate(context: ActionGroupContext): GearyEntity {
14-
return if (expression == "parent") context.entity?.parent!!
14+
return if (expression == "parent") context.entity?.parent ?: error("No parent entity in environment")
1515
else Expression.Variable<GearyEntity>(expression).evaluate(context)
1616
}
1717
}

addons/geary-prefabs/src/com/mineinabyss/geary/prefabs/PrefabsModule.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ val Prefabs = createAddon<PrefabSources, PrefabsModule>("Prefabs", {
3333
PrefabSources()
3434
}) {
3535
val formats = geary.getAddon(SerializableComponents).formats
36+
geary.infoReader.addInfoLine("prefabs") { entity ->
37+
entity.prefabs.mapNotNull { it.get<PrefabKey>().toString() }.joinToString()
38+
}
3639
val module = PrefabsModule(PrefabManager(), PrefabLoader(configuration, geary, formats, logger))
3740

3841
systems {

build.gradle.kts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
22

33
plugins {
44
alias(idofrontLibs.plugins.kotlin.multiplatform)
5-
alias(idofrontLibs.plugins.dokka)
65
alias(idofrontLibs.plugins.mia.autoversion)
76
alias(idofrontLibs.plugins.dependencyversions)
87
alias(idofrontLibs.plugins.version.catalog.update)
@@ -20,12 +19,9 @@ allprojects {
2019
}
2120

2221
allprojects {
23-
apply(plugin = "org.jetbrains.dokka")
24-
2522
pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
2623
kotlin {
2724
jvm {
28-
withJava()
2925
testRuns["test"].executionTask.configure {
3026
useJUnitPlatform()
3127
}

geary-core/src/com/mineinabyss/geary/datatypes/Entity.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,9 @@ class Entity(val id: EntityId, val world: Geary) {
372372
"This entity is in ${world.stringify()}, while the other is in ${other.world.stringify()}"
373373
}
374374

375-
override fun toString(): String = "Entity($id, world=${world.stringify()})"
375+
override fun toString(): String {
376+
return "$id(${world.infoReader.readEntityInfo(this)})"
377+
}
376378

377379
override fun equals(other: Any?): Boolean {
378380
if (this === other) return true
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.mineinabyss.geary.engine
2+
3+
import com.mineinabyss.geary.datatypes.Entity
4+
5+
/**
6+
* Allow addons to provide extra information about an entity.
7+
*
8+
* Used when calling [Entity.toString]
9+
*/
10+
class EntityInfoReader {
11+
private val lines = mutableMapOf<String, (Entity) -> String?>()
12+
13+
fun addInfoLine(name: String, eval: (Entity) -> String?) {
14+
lines[name] = eval
15+
}
16+
17+
fun readEntityInfo(entity: Entity): String {
18+
return lines.mapNotNull {
19+
val value = it.value(entity) ?: return@mapNotNull null
20+
"${it.key}=$value"
21+
}.joinToString(", ")
22+
}
23+
}

geary-core/src/com/mineinabyss/geary/modules/ArchetypeEngineModule.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ internal object ArchetypesModules {
5757
includes(components)
5858
singleOf(::ArchetypeReadOperations) { bind<EntityReadOperations>() }
5959
singleOf(::PipelineImpl) { bind<Pipeline>() }
60+
singleOf(::EntityInfoReader)
6061
}
6162

6263
val engine get() = module {

geary-core/src/com/mineinabyss/geary/modules/Geary.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ interface Geary : KoinComponent {
4646
// access where the engine isn't expected to be reloaded (ex. like it might be in tests)
4747
val eventRunner: EventRunner get() = get()
4848
val read: EntityReadOperations get() = get()
49+
val infoReader: EntityInfoReader get() = get()
4950
val write: EntityMutateOperations get() = get()
5051
val queryManager: QueryManager get() = get()
5152
val pipeline: Pipeline get() = get()
@@ -123,6 +124,7 @@ interface Geary : KoinComponent {
123124
override val logger: Logger = logger ?: super.logger
124125
override val eventRunner: EventRunner by inject()
125126
override val read: EntityReadOperations by inject()
127+
override val infoReader: EntityInfoReader by inject()
126128
override val write: EntityMutateOperations by inject()
127129
override val queryManager: QueryManager by inject()
128130
override val pipeline: Pipeline by inject()

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ group=com.mineinabyss
22
version=0.27
33
# Workaround for dokka builds failing on CI, see https://github.com/Kotlin/dokka/issues/1405
44
#org.gradle.jvmargs=-XX:MaxMetaspaceSize=512m
5-
idofrontVersion=0.26.0-dev.2
5+
idofrontVersion=1.0.0
66
kotlin.native.ignoreDisabledTargets=true

gradle/wrapper/gradle-wrapper.jar

1.83 KB
Binary file not shown.

0 commit comments

Comments
 (0)