-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #94 from MineInAbyss/develop
Benchmarks, performance improvements
- Loading branch information
Showing
125 changed files
with
2,055 additions
and
1,492 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 11 additions & 6 deletions
17
...on-features/src/main/kotlin/com/mineinabyss/geary/game/systems/ExpiringComponentSystem.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,24 @@ | ||
package com.mineinabyss.geary.game.systems | ||
|
||
import com.mineinabyss.geary.annotations.optin.UnsafeAccessors | ||
import com.mineinabyss.geary.game.components.Expiry | ||
import com.mineinabyss.geary.systems.RepeatingSystem | ||
import com.mineinabyss.geary.systems.accessors.TargetScope | ||
import com.mineinabyss.geary.systems.accessors.Pointer | ||
|
||
|
||
/** | ||
* Handles removing components when an [Expiry] relation exists with another component. | ||
*/ | ||
class ExpiringComponentSystem : RepeatingSystem() { | ||
private val TargetScope.expiry by getRelations<Expiry, Any?>() | ||
private val Pointer.expiry by getRelationsWithData<Expiry, Any?>() | ||
|
||
override fun TargetScope.tick() { | ||
if (expiry.data.timeOver()) { | ||
entity.remove(expiry.kind.id) | ||
entity.remove(expiry.relation.id) | ||
@OptIn(UnsafeAccessors::class) | ||
override fun Pointer.tick() { | ||
expiry.forEach { | ||
if (it.data.timeOver()) { | ||
entity.remove(it.kind.id) | ||
entity.remove(it.relation.id) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 15 additions & 14 deletions
29
...mmonMain/kotlin/com/mineinabyss/geary/prefabs/configuration/systems/ParseChildOnPrefab.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,44 @@ | ||
package com.mineinabyss.geary.prefabs.configuration.systems | ||
|
||
import com.mineinabyss.geary.annotations.Handler | ||
import com.mineinabyss.geary.components.EntityName | ||
import com.mineinabyss.geary.components.relations.NoInherit | ||
import com.mineinabyss.geary.annotations.optin.UnsafeAccessors | ||
import com.mineinabyss.geary.helpers.addParent | ||
import com.mineinabyss.geary.helpers.entity | ||
import com.mineinabyss.geary.prefabs.configuration.components.ChildOnPrefab | ||
import com.mineinabyss.geary.prefabs.configuration.components.ChildrenOnPrefab | ||
import com.mineinabyss.geary.prefabs.configuration.components.Prefab | ||
import com.mineinabyss.geary.systems.Listener | ||
import com.mineinabyss.geary.systems.accessors.TargetScope | ||
import com.mineinabyss.geary.systems.accessors.Pointers | ||
|
||
|
||
class ParseChildOnPrefab : Listener() { | ||
private val TargetScope.child by onSet<ChildOnPrefab>().onTarget() | ||
private var Pointers.child by get<ChildOnPrefab>().removable().whenSetOnTarget() | ||
|
||
@Handler | ||
private fun TargetScope.convertToRelation() { | ||
@OptIn(UnsafeAccessors::class) | ||
override fun Pointers.handle() { | ||
entity { | ||
addParent(entity) | ||
setAll(child.components) | ||
addParent(target.entity) | ||
setAll(child!!.components) | ||
} | ||
entity.remove<ChildOnPrefab>() | ||
child = null | ||
} | ||
} | ||
|
||
class ParseChildrenOnPrefab : Listener() { | ||
private val TargetScope.children by onSet<ChildrenOnPrefab>().onTarget() | ||
private var Pointers.children by get<ChildrenOnPrefab>().removable().whenSetOnTarget() | ||
|
||
@Handler | ||
private fun TargetScope.convertToRelation() { | ||
children.nameToComponents.forEach { (name, components) -> | ||
@OptIn(UnsafeAccessors::class) | ||
override fun Pointers.handle() { | ||
children!!.nameToComponents.forEach { (name, components) -> | ||
entity { | ||
set(EntityName(name)) | ||
set(Prefab()) | ||
addParent(entity) | ||
addParent(target.entity) | ||
addRelation<NoInherit, Prefab>() | ||
setAll(components) | ||
} | ||
} | ||
entity.remove<ChildrenOnPrefab>() | ||
children = null | ||
} | ||
} |
13 changes: 6 additions & 7 deletions
13
...nMain/kotlin/com/mineinabyss/geary/prefabs/configuration/systems/ParseRelationOnPrefab.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 8 additions & 5 deletions
13
...kotlin/com/mineinabyss/geary/prefabs/configuration/systems/ParseRelationWithDataSystem.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 7 additions & 7 deletions
14
...efabs/src/commonMain/kotlin/com/mineinabyss/geary/prefabs/systems/InheritPrefabsOnLoad.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
package com.mineinabyss.geary.prefabs.systems | ||
|
||
import com.mineinabyss.geary.annotations.Handler | ||
import com.mineinabyss.geary.annotations.optin.UnsafeAccessors | ||
import com.mineinabyss.geary.datatypes.family.family | ||
import com.mineinabyss.geary.prefabs.events.PrefabLoaded | ||
import com.mineinabyss.geary.prefabs.helpers.inheritPrefabs | ||
import com.mineinabyss.geary.systems.Listener | ||
import com.mineinabyss.geary.systems.accessors.EventScope | ||
import com.mineinabyss.geary.systems.accessors.TargetScope | ||
import com.mineinabyss.geary.systems.accessors.Pointers | ||
|
||
|
||
class InheritPrefabsOnLoad : Listener() { | ||
private val EventScope.loaded by family { has<PrefabLoaded>() }.onEvent() | ||
private val Pointers.loaded by family { has<PrefabLoaded>() }.on(event) | ||
|
||
@Handler | ||
private fun TargetScope.inheritOnLoad() { | ||
entity.inheritPrefabs() | ||
@OptIn(UnsafeAccessors::class) | ||
override fun Pointers.handle() { | ||
target.entity.inheritPrefabs() | ||
} | ||
} | ||
|
16 changes: 9 additions & 7 deletions
16
...bs/src/commonMain/kotlin/com/mineinabyss/geary/prefabs/systems/TrackPrefabsByKeySystem.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,20 @@ | ||
package com.mineinabyss.geary.prefabs.systems | ||
|
||
import com.mineinabyss.geary.annotations.Handler | ||
import com.mineinabyss.geary.components.relations.NoInherit | ||
import com.mineinabyss.geary.datatypes.Records | ||
import com.mineinabyss.geary.annotations.optin.UnsafeAccessors | ||
import com.mineinabyss.geary.prefabs.PrefabKey | ||
import com.mineinabyss.geary.prefabs.prefabs | ||
import com.mineinabyss.geary.systems.Listener | ||
import com.mineinabyss.geary.systems.accessors.TargetScope | ||
import com.mineinabyss.geary.systems.accessors.Pointers | ||
|
||
|
||
class TrackPrefabsByKeySystem : Listener() { | ||
private val TargetScope.key by onSet<PrefabKey>().onTarget() | ||
private val Records.key by get<PrefabKey>().whenSetOnTarget() | ||
|
||
@Handler | ||
private fun TargetScope.registerOnSet() { | ||
prefabs.manager.registerPrefab(key, entity) | ||
entity.addRelation<NoInherit, PrefabKey>() | ||
@OptIn(UnsafeAccessors::class) | ||
override fun Pointers.handle() { | ||
prefabs.manager.registerPrefab(key, target.entity) | ||
target.entity.addRelation<NoInherit, PrefabKey>() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 6 additions & 7 deletions
13
...eary-uuid/src/commonMain/kotlin/com/mineinabyss/geary/uuid/systems/UnTrackUuidOnRemove.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,19 @@ | ||
package com.mineinabyss.geary.uuid.systems | ||
|
||
import com.benasher44.uuid.Uuid | ||
import com.mineinabyss.geary.annotations.Handler | ||
import com.mineinabyss.geary.components.events.EntityRemoved | ||
import com.mineinabyss.geary.datatypes.Records | ||
import com.mineinabyss.geary.datatypes.family.family | ||
import com.mineinabyss.geary.systems.GearyListener | ||
import com.mineinabyss.geary.systems.accessors.EventScope | ||
import com.mineinabyss.geary.systems.accessors.TargetScope | ||
import com.mineinabyss.geary.systems.accessors.Pointers | ||
|
||
import com.mineinabyss.geary.uuid.uuid2Geary | ||
|
||
class UnTrackUuidOnRemove : GearyListener() { | ||
private val TargetScope.uuid by get<Uuid>().onTarget() | ||
private val EventScope.removed by family { has<EntityRemoved>() }.onEvent() | ||
private val Pointers.uuid by get<Uuid>().on(target) | ||
private val Pointers.removed by family { has<EntityRemoved>() }.on(event) | ||
|
||
@Handler | ||
private fun TargetScope.untrack() { | ||
override fun Pointers.handle() { | ||
uuid2Geary.remove(uuid) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.