PolygonEntity

abstract class PolygonEntity(node: PolygonNode) : PolygonNode, Entity

The base of a game entity whose body is a polygon: a PolygonNode subclass, so the entity is its node — geometry, style, and tags — plus whatever facts the game class adds.

An entity is a value like any node: it moves by rebinding (ball *= motion replaces the variable with the moved entity), and every shape-preserving operation returns through copy, which this class re-abstracts — the compiler forces each entity class to say how it is rebuilt, carrying its facts across (Ball(PolygonNode(polygon, style, tags)).also { it.velocity = velocity }). Facts a subclass adds (a velocity, a charge) are plain mutable properties; the inherited identity stays structural and fact-exclusive — an entity that needs fact-sensitive equality folds its facts in locally over super.equals.

Parameters

node

The node value the entity starts as.

Constructors

Link copied to clipboard
constructor(node: PolygonNode)

Roots the entity at node's geometry, style, and tags.

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override var style: ShapeStyle
Link copied to clipboard
open override var tags: Set<String>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
override val x: Double

The entity's position on x: the x coordinate of its polygon's centroid.

Link copied to clipboard
override val y: Double

The entity's position on y: the y coordinate of its polygon's centroid.

Functions

Link copied to clipboard
abstract override fun copy(polygon: Polygon): PolygonEntity

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

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
open override fun toString(): String
Link copied to clipboard