EntityFactory()

Stores definitions of entities to allow for easy creation/cloning

new EntityFactory()

Methods

addScriptListener(entityRef, event, listener)

Add an event listener from a script to a specific item

Parameters:
Name Type Description
entityRef string
event string
listener function
See:
  • BehaviorManager::addListener

clone(entity) → {Item|Npc|Room|Area}

Clone an existing entity.

Parameters:
Name Type Description
entity Item | Npc | Room | Area
Returns:
Item | Npc | Room | Area

createByType(area, entityRef, Type) → {type}

Create a new instance of a given npc definition. Resulting npc will not be held or equipped and will not have its default contents. If you want it to also populate its default contents you must manually call npc.hydrate(state)

Parameters:
Name Type Description
area Area
entityRef string
Type Class

Type of entity to instantiate

Returns:
type

createEntityRef(areaName, id) → {string}

Create the key used by the entities and scripts maps

Parameters:
Name Type Description
areaName string
id number
Returns:
string

getDefinition(entityRef) → {Object}

Parameters:
Name Type Description
entityRef string
Returns:
Object

setDefinition(entityRef, def)

Parameters:
Name Type Description
entityRef string
def Object