Skip to content

Commit 896b759

Browse files
committed
docs: Add CHANGELOG, update Geary -> WorldScoped in examples
1 parent f41c802 commit 896b759

8 files changed

Lines changed: 47 additions & 31 deletions

File tree

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Changelog
2+
3+
All notable changes to this project between Minecraft versions will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). We currently do not follow semver while
6+
MAJOR is set to zero.
7+
8+
## [Unreleased]
9+
10+
### Added
11+
12+
- `geary-examples` module with some basic engine setup examples
13+
14+
### Changed
15+
16+
- Switched to our own small DI library for internal module and for addons
17+
- `WorldScoped` is now the preferred receiver when writing extension functions. `WorldScoped.newScope()` can be used to
18+
register systems, observers, etc... and automatically unregister them when calling `close` on the returned scope

README.md

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Read our [Quickstart guide](https://docs.mineinabyss.com/geary/quickstart/) to s
3030
data class Position(var x: Double, var y: Double)
3131
data class Velocity(var x: Double, var y: Double)
3232

33-
fun Geary.updatePositionSystem() = system(query<Position, Velocity>())
33+
fun WorldScoped.updatePositionSystem() = system(query<Position, Velocity>())
3434
.every(interval = 20.milliseconds)
3535
.exec { (position, velocity) ->
3636
// We can access our components like regular variables!
@@ -41,22 +41,27 @@ fun Geary.updatePositionSystem() = system(query<Position, Velocity>())
4141

4242
fun main() {
4343
// Set up geary
44-
geary(ArchetypeEngineModule) {
44+
val world = geary(ArchetypeEngineModule()) {
4545
// example engine configuration
4646
install(Prefabs)
4747
}
4848

49-
val posSystem = geary.updatePositionSystem()
49+
with(world) {
50+
// Create our system
51+
val posSystem = updatePositionSystem()
5052

51-
// Create an entity the system can run on
52-
entity {
53-
setAll(Position(0.0, 0.0), Velocity(1.0, 0.0))
53+
// Create an entity the system can run on
54+
entity {
55+
setAll(Position(0.0, 0.0), Velocity(1.0, 0.0))
56+
}
57+
58+
posSystem.tick() // exec just this system
59+
tick() // exec all registered repeating systems, interval used to calculate every n ticks to run
60+
61+
val positions: List<Position> = posSystem.map { (pos) -> pos }
5462
}
55-
56-
posSystem.tick() // exec just this system
57-
geary.engine.tick() // exec all registered repeating systems, interval used to calculate every n ticks to run
58-
59-
val positions: List<Position> = posSystem.map { (pos) -> pos }
63+
64+
world.close() // Use world.newScope(), then close to separate groups of systems into modules
6065
}
6166

6267
```

addons/geary-actions/test/com/mineinabyss/geary/actions/ConfigEntityObserversTests.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class ConfigEntityObserversTests : GearyTest() {
3232
class MyComp()
3333

3434
override fun setupGeary() = geary(TestEngineModule) {
35-
load(GearyActions)
35+
install(GearyActions)
3636

3737
serialization {
3838
withCommonComponentNames()

addons/geary-actions/test/com/mineinabyss/geary/actions/ExpressionDecodingTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ class ExpressionDecodingTest : GearyTest() {
2727
override fun setupGeary() = geary(TestEngineModule) {
2828
serialization {
2929
registerComponentSerializers(
30-
TestFunction.serializer()
30+
TestFunction::class to TestFunction.serializer()
3131
)
3232
format("yml", ::YamlFormat)
3333
}
3434
}
3535

36-
val format get() = getAddon(SerializableComponents).formats["yml"] as YamlFormat
36+
val format get() = getAddon(SerializableComponents).formats.getFormat("yml") as YamlFormat
3737
// @org.junit.jupiter.api.Test
3838
// fun `should correctly decode json`() {
3939
// val input = """

addons/geary-serialization/src/com/mineinabyss/geary/serialization/helpers/Component.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ package com.mineinabyss.geary.serialization.helpers
22

33
import com.mineinabyss.geary.datatypes.ComponentId
44
import com.mineinabyss.geary.helpers.componentId
5-
import com.mineinabyss.geary.modules.Geary
5+
import com.mineinabyss.geary.modules.WorldScoped
66
import com.mineinabyss.geary.serialization.SerializableComponents
77

88
/**
99
* Gets the id of a component by its serial name.
1010
* Throws an error if the component name does not exist.
1111
*/
12-
fun Geary.componentId(serialName: String): ComponentId =
12+
fun WorldScoped.componentId(serialName: String): ComponentId =
1313
componentId(getAddon(SerializableComponents).serializers.getClassFor(serialName))
Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
package com.mineinabyss.geary.benchmarks.unpacking
22

33
import com.mineinabyss.geary.benchmarks.helpers.*
4-
import com.mineinabyss.geary.modules.Geary
5-
import com.mineinabyss.geary.systems.query.GearyQuery
4+
import com.mineinabyss.geary.modules.WorldScoped
65
import com.mineinabyss.geary.systems.query.query
76

8-
fun Geary.systemOf1() = cache(query<Comp1>())
9-
fun Geary.systemOf1OrNull() = cache(query<Comp1?>())
10-
fun Geary.systemOf2() = cache(query<Comp1, Comp2>())
11-
fun Geary.systemOf6() = cache(query<Comp1, Comp2, Comp3, Comp4, Comp5, Comp6>())
7+
fun WorldScoped.systemOf1() = cache(query<Comp1>())
8+
fun WorldScoped.systemOf1OrNull() = cache(query<Comp1?>())
9+
fun WorldScoped.systemOf2() = cache(query<Comp1, Comp2>())
10+
fun WorldScoped.systemOf6() = cache(query<Comp1, Comp2, Comp3, Comp4, Comp5, Comp6>())

gradle.properties

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
group=com.mineinabyss
2-
version=0.28
2+
version=0.29
33
# Workaround for dokka builds failing on CI, see https://github.com/Kotlin/dokka/issues/1405
44
#org.gradle.jvmargs=-XX:MaxMetaspaceSize=512m
55
idofrontVersion=2.0.0-dev.7
66
kotlin.native.ignoreDisabledTargets=true
7+
org.gradle.configuration-cache=true
8+
org.gradle.caching=true

gradle/libs.versions.toml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,12 @@
22
androidxCollection = "1.4.0"
33
atomicfu = "0.24.0"
44
kotlinxBenchmarkRuntime = "0.4.10"
5-
okio = "3.9.0"
65
roaringbitmap = "1.0.6"
76
statelyConcurrency = "2.0.7"
8-
koin = "4.1.0"
9-
junitJupiter = "5.8.1"
10-
kodein = "7.30.0"
117

128
[libraries]
139
androidx-collection = { module = "androidx.collection:collection", version.ref = "androidxCollection" }
1410
atomicfu = { module = "org.jetbrains.kotlinx:atomicfu", version.ref = "atomicfu" }
1511
kotlinx-benchmark-runtime = { module = "org.jetbrains.kotlinx:kotlinx-benchmark-runtime", version.ref = "kotlinxBenchmarkRuntime" }
16-
okio = { module = "com.squareup.okio:okio", version.ref = "okio" }
1712
roaringbitmap = { module = "org.roaringbitmap:RoaringBitmap", version.ref = "roaringbitmap" }
1813
stately-concurrency = { module = "co.touchlab:stately-concurrency", version.ref = "statelyConcurrency" }
19-
koin-test = { module = "io.insert-koin:koin-test", version.ref = "koin" }
20-
junit-jupiter = { group = "org.junit.jupiter", name = "junit-jupiter", version.ref = "junitJupiter" }
21-
kodein-di = { module = "org.kodein.di:kodein-di", version.ref = "kodein" }

0 commit comments

Comments
 (0)