Skip to content

Commit

Permalink
Rename bukkitEntityAssociations
Browse files Browse the repository at this point in the history
  • Loading branch information
0ffz committed Jan 28, 2022
1 parent 73f5fe0 commit 70b76a1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public open class GearyMCKoinComponent : GearyKoinComponent(), GearyScope {
public override val bukkitEntity2Geary: BukkitEntity2Geary by inject()

public val geary: GearyPlugin by inject()
public val bukkitAssociations: BukkitEntity2Geary by inject()
public val bukkit2Geary: BukkitEntity2Geary by inject()

public val uuid2entity: UUID2GearyMap by inject()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ import com.mineinabyss.geary.ecs.api.engine.entity
import com.mineinabyss.geary.ecs.api.entities.GearyEntity
import com.mineinabyss.geary.papermc.GearyMCKoinComponent
import com.mineinabyss.idofront.typealiases.BukkitEntity
import org.bukkit.entity.Entity

public fun BukkitEntity.toGeary(): GearyEntity = GearyMCKoinComponent {
bukkitAssociations[entityId] ?: entity { set<BukkitEntity>(this@toGeary) }
bukkit2Geary[entityId] ?: entity { set<BukkitEntity>(this@toGeary) }
}

// Separate function because inline `run` cannot be nullable
Expand All @@ -16,7 +15,7 @@ public inline fun BukkitEntity.toGeary(init: GearyEntity.() -> Unit): GearyEntit
toGeary().apply { init() }

public fun BukkitEntity.toGearyOrNull(): GearyEntity? = GearyMCKoinComponent().run {
bukkitAssociations[entityId]
bukkit2Geary[entityId]
}

public fun GearyEntity.toBukkit(): BukkitEntity? = get()

0 comments on commit 70b76a1

Please sign in to comment.