GroupEntity

abstract class GroupEntity<E : Node>(val children: List<E>, bounds: SceneBounds? = null) : GroupNode

The base of a game entity whose body is a group of nodes: a GroupNode subclass, so the entity is its sub-tree — the typed children in draw order — plus whatever facts the game class adds.

The group analog of PolygonEntity: the entity is a value that moves by rebinding (wall *= motion replaces the variable with the moved entity), and every group-preserving operation returns through the typed copy hook, which the compiler forces each entity class to implement — rebuilding its own class around the replacement children and carrying its facts across. children covariantly narrows GroupNode.children, so the group's entities read back typed, cast-free. Facts a subclass adds are plain mutable properties; the inherited identity stays structural and fact-exclusive.

Type Parameters

E

The children's type.

Constructors

Link copied to clipboard
constructor(children: List<E>, bounds: SceneBounds? = null)

Roots the entity at its children, in draw order, with optional bounds.

Properties

Link copied to clipboard
Link copied to clipboard
override val children: List<E>

The group's entities in draw order — the typed narrowing of GroupNode.children.

Functions

Link copied to clipboard
abstract fun copy(children: List<E>): GroupEntity<E>

Returns this entity rebuilt around children — the hook every group-preserving operation returns through, re-abstracted with typed children so each entity class must implement it.

override fun copy(children: List<Node>, bounds: SceneBounds?): GroupEntity<E>

Returns this entity rebuilt around children through the typed hook; bounds is not consulted — the rebuilt entity carries whatever bounds its own class sets.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
inline fun <E : Node> GroupEntity<E>.forEach(action: (E) -> Unit)

Runs action on each child, in draw order.

Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
operator fun <E : Node> GroupEntity<E>.iterator(): Iterator<E>

Returns an iterator over the children, in draw order.

Link copied to clipboard
open override fun toString(): String