parentOrNull
Returns the parent of child, or null if it has none or is not alive.
Samples
val world = World()
val ship = world.create()
val leftGun = world.create()
val rightGun = world.create()
world.setParent(leftGun, ship)
world.setParent(rightGun, ship)
assertPrints(world.parentOrNull(leftGun), "Entity(0:0)")
assertPrints(world.childrenOf(ship), "[Entity(1:0), Entity(2:0)]")
world.removeParent(leftGun)
assertPrints(world.parentOrNull(leftGun), "null")
assertPrints(world.childrenOf(ship), "[Entity(2:0)]")
// A parent cannot become a child of its own descendant.
assertFailsWith<IllegalArgumentException> { world.setParent(ship, rightGun) }Content copied to clipboard