EntityFactory

Stores definitions of entities to allow for easy creation/cloning

Constructor

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(item) → {Item}

Clone an existing item. Resulting item 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 item.hydrate(state)

Parameters:
Name Type Description
item Item
Returns:
Item

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