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)); } }