View source

abstract flaxen.EntityRef(Either<Entity, String>)

import flaxen.Flaxen;

Available on all platforms

In many methods where an Entity is expected you can instead pass a String that is the name of an Entity in Ash. EntityRef is an abstract type that could be referring to either an Entity or a String. A class may use ref.toEntity() to validate the reference and return a full Entity instance.

Class Fields

function fromEntity(e:Entity):EntityRef

function fromString(str:String):EntityRef

Instance Fields

var type:Either<Entity, String>

function get_type():Either<Entity, String>

function toEntity(f:Flaxen, ?compulsory:Bool = true):Entity

Converts the EntityRef into an Entity. If the EntityRef references an Entity, does not do a lookup to verify the entity exists in the Ash engine (i.e., it may be a free entity).

f

The Flaxen object

compulsory

If true, throws exception instead of returning null

returns

The Entity object, or null if string lookup fails or ref was null

function toString():String

Returns the name of this entity. May return null if the ref is null.

returns

The entity's name