A group of Entitys and the Processors that are used to process them in different phases.

Constructor

new ()

Variables

entities:Array<Entity>

The entities that belong to this universe

phases:Array<Phase>

The processor phases that belong to this universe

Methods

createEntity (?components:Array<Component>):Entity

Construct a new entity

Parameters:

components

An optional list of starting components

Returns:

Entity

createPhase ():Phase

Construct a phase, adding it to this Universe

Returns:

Phase

destroyAllEntities ():Void

Unmatch and delete all entities from this universe

destroyEntity (entity:Entity):Void

Destroys an entity, removing it entirely from this Universe

Parameters:

entity

The entity to destroy

getResource<T> (type:ResourceTypeID):Null<T>

Get a resource / global component from the Universe. If an instance has not yet been set using setResource, this will return null

Parameters:

type

the ID of the resource to retrieve: {ResourceClass}.HashCode()

Returns:

Null

loadEntities (buf:String):LoadResult

Load the entities saved by saveEntities, deleting any currently existing ones

Note: the function will

Parameters:

buf

The state generated by saveEntities

Returns:

LoadResult

saveEntities ():String

Serialize the entities / state into a string using the Haxe serializer

Note: the git version is stored alongside the serialized data to ensure proper entity matching!

Returns:

String

setResource (resource:Resource):Void

Store a resource / global component in the Universe

Parameters:

resource

the resource with type to set