Skip to content

Commit

Permalink
add custom deserializer parameter to prefab loading
Browse files Browse the repository at this point in the history
  • Loading branch information
minecrawler committed Dec 1, 2020
1 parent 3954768 commit e99bc4a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/world.spec.ts
Expand Up @@ -77,7 +77,7 @@ export interface IPartialWorld {
* Load entities with components from a prefab file
* @param rawPrefab
*/
loadPrefab(rawPrefab: TPrefab): TPrefabHandle
loadPrefab(rawPrefab: TPrefab, customDeserializer?: TDeserializer): TPrefabHandle

/**
* Re-calculate all entity, component and system dependencies and connections
Expand Down
4 changes: 2 additions & 2 deletions src/world.ts
Expand Up @@ -237,7 +237,7 @@ export class World implements IWorld {
return this.resources.get(type) as T;
}

loadPrefab(rawPrefab: TPrefab): TPrefabHandle {
loadPrefab(rawPrefab: TPrefab, customDeserializer?: TDeserializer): TPrefabHandle {
const entities = [];
const saveFormat = this.saveFormat ?? new SaveFormat();

Expand All @@ -247,7 +247,7 @@ export class World implements IWorld {
entities.push(entity);

for (const rawComponent of Object.entries(rawEntity)) {
entity.addComponent(saveFormat.deserialize(rawComponent[0], rawComponent[1], getDefaultDeserializer()));
entity.addComponent(saveFormat.deserialize(rawComponent[0], rawComponent[1], getDefaultDeserializer(customDeserializer)));
}

this.addEntity(entity);
Expand Down

0 comments on commit e99bc4a

Please sign in to comment.