private EntityData.Entity serializeEntityFull(EntityRef entityRef) { EntityData.Entity.Builder entity = EntityData.Entity.newBuilder(); entity.setId(entityRef.getId()); for (Component component : entityRef.iterateComponents()) { if (component.getClass().equals(EntityInfoComponent.class)) continue; EntityData.Component componentData = serializeComponent(component); if (componentData != null) { entity.addComponent(componentData); } } return entity.build(); }
private EntityData.Entity serializeEntityDelta(EntityRef entityRef, Prefab prefab) { EntityData.Entity.Builder entity = EntityData.Entity.newBuilder(); entity.setId(entityRef.getId()); entity.setParentPrefab(prefab.getName()); for (Component component : entityRef.iterateComponents()) { if (component.getClass().equals(EntityInfoComponent.class)) continue; Component prefabComponent = prefab.getComponent(component.getClass()); EntityData.Component componentData; if (prefabComponent == null) { componentData = serializeComponent(component); } else { componentData = serializeComponent(prefabComponent, component); } if (componentData != null) { entity.addComponent(componentData); } } for (Component prefabComponent : prefab.listComponents()) { if (!entityRef.hasComponent(prefabComponent.getClass())) { entity.addRemovedComponent(ComponentUtil.getComponentClassName(prefabComponent.getClass())); } } return entity.build(); }