private IEnumerator UpdateSubFamilies(FamilyController behaviour, string relatedFamilyId) { GameObject famObj = FamilyInstanceLibrary.GetFamily(relatedFamilyId); famObj.SetActive(false); CoroutineWithData <Message> cd = new CoroutineWithData <Message>( behaviour, this.ServerRequestCoroutine(new Message { Type = "GET", Data = JsonConvert.SerializeObject(new { Id = relatedFamilyId }) }) ); yield return(cd.coroutine); Message getResponse = cd.result; FamilyInstance fam = JObject.Parse(getResponse.Data).ToObject <FamilyInstance>(); famObj.GetComponent <FamilyController>().UpdateInstanceData(fam); famObj.SetActive(true); }
public IEnumerator RecreateFamilyInstance(FamilyController behaviour, FamilyInstance oldData) { FamilyInstance fam = behaviour.GetInstanceData(); Debug.LogError($"UPDATING HOST ID TO {fam.HostId}"); behaviour.UpdateInstanceData(oldData); yield break; }
public IEnumerator SaveFamilyInstance(FamilyController behaviour, FamilyInstance oldData) { if (behaviour.GetInstanceData().HostId == oldData.HostId) { yield return(UpdateFamilyInstance(behaviour, oldData)); } else { yield return(RecreateFamilyInstance(behaviour, oldData)); } }
public IEnumerator UpdateFamilyInstance(FamilyController behaviour, FamilyInstance oldData) { FamilyInstance fam = behaviour.GetInstanceData(); Debug.Log($"Saving {fam.Id} {fam.Name}"); Debug.Log($"Saving {fam.Id} {fam.Name}"); CoroutineWithData <Message> cd = new CoroutineWithData <Message>( behaviour, this.ServerRequestCoroutine(new Message { Type = "SET", Data = JsonConvert.SerializeObject(fam) }) ); yield return(cd.coroutine); Message response = cd.result; if (response == null) { Debug.LogError("FAILED TO UPDATE FAMILY INSTANCE"); behaviour.UpdateInstanceData(oldData); yield break; } FamilyInstance newFamily = JObject.Parse(response.Data).ToObject <FamilyInstance>(); Debug.Log(JsonConvert.SerializeObject(response)); behaviour.UpdateInstanceData(newFamily); if (fam.HostId != null) { yield return(UpdateHostGeometry(behaviour, fam.HostId)); } foreach (string subComponent in fam.SubComponents) { behaviour.StartCoroutine(UpdateSubFamilies(behaviour, subComponent)); } }
private IEnumerator UpdateHostGeometry(FamilyController behaviour, string hostId) { CoroutineWithData <Message> cd = new CoroutineWithData <Message>( behaviour, this.ServerRequestCoroutine(new Message { Type = "GET", Data = JsonConvert.SerializeObject(new { Id = hostId }) }) ); yield return(cd.coroutine); Message getResponse = cd.result; GeometryElement geo = JObject.Parse(getResponse.Data).ToObject <GeometryElement>(); GameObject obj = GeometryLibrary.GetObject(geo.Id); Helpers.MeshGenerator.ResetFaceMeshes(geo, obj); }