@Override public EntityRef deserializeEntity(EntityData.Entity entityData) { EntityRef entity = entityManager.createEntityRefWithId(entityData.getId()); if (entityData.hasParentPrefab() && !entityData.getParentPrefab().isEmpty() && prefabManager.exists(entityData.getParentPrefab())) { Prefab prefab = prefabManager.getPrefab(entityData.getParentPrefab()); for (Component component : prefab.listComponents()) { String componentName = ComponentUtil.getComponentClassName(component.getClass()); if (!containsIgnoreCase(componentName, entityData.getRemovedComponentList())) { entity.addComponent(componentLibrary.copy(component)); } } entity.addComponent(new EntityInfoComponent(entityData.getParentPrefab())); } for (EntityData.Component componentData : entityData.getComponentList()) { Class<? extends Component> componentClass = getComponentClass(componentData); if (componentClass == null) continue; if (!entity.hasComponent(componentClass)) { entity.addComponent(deserializeComponent(componentData)); } else { deserializeComponentOnto(entity.getComponent(componentClass), componentData); } } return entity; }
/** creates a zonelist component used to save all zones (persist) */ private static void createZoneList() { zonelist = CoreRegistry.get(EntityManager.class).create(); ZoneListComponent zonecomp = new ZoneListComponent(); zonelist.addComponent(zonecomp); zonelist.setPersisted(true); zonelist.saveComponent(zonecomp); }