private void onObjectRemoved(GameObject obj, bool deleteChildren) { DecorationLayoutData decorationLayoutData = default(DecorationLayoutData); decorationLayoutData.Id = DecorationLayoutData.ID.FromFullPath(GetRelativeGameObjectPath(obj)); DecorationLayoutData decoration = decorationLayoutData; SceneLayoutData.RemoveDecoration(decoration, deleteChildren); if (selectedObjectStartingId == decoration.Id.GetFullPath()) { selectedObjectStartingId = null; ObjectManipulator component = obj.GetComponent <ObjectManipulator>(); if (component != null) { for (int i = 0; i < sceneModifiers.Length; i++) { sceneModifiers[i].AfterObjectDeselected(component); } } } decorationInventoryService.MarkStructuresDirty(); decorationInventoryService.MarkDecorationsDirty(); if (this.ObjectRemoved != null) { ManipulatableObject component2 = obj.GetComponent <ManipulatableObject>(); this.ObjectRemoved.InvokeSafe(component2); } UnityEngine.Object.Destroy(obj); removePartneredObject(obj); }
private IEnumerator processDecoration(DecorationLayoutData decoration, PrefabContentKey contentKey) { PrefabCacheTracker.PrefabRequest prefabRequest = prefabCacheTracker.Acquire(contentKey); while (!prefabRequest.IsComplete) { yield return(null); } yield return(new WaitForEndOfFrame()); while (loadOrder.Peek() != decoration.Id.GetFullPath()) { yield return(null); } string idFromQueue = loadOrder.Dequeue(); Assert.IsTrue(idFromQueue == decoration.Id.GetFullPath()); if (prefabRequest != null && prefabRequest.Prefab != null) { bool flag = true; Transform transform = Container.Find(decoration.Id.ParentPath); if (transform == null) { if (string.IsNullOrEmpty(decoration.Id.ParentPath)) { transform = Container; } else { Log.LogErrorFormatted(this, "Invalid path of decoration. Removing from layout: {0}", decoration.Id.GetFullPath()); layout.RemoveDecoration(decoration, deleteChildren: true); flag = false; } } if (flag) { GameObject gameObject = UnityEngine.Object.Instantiate(prefabRequest.Prefab, transform, worldPositionStays: false); SplittableObject component = gameObject.GetComponent <SplittableObject>(); Vector3 localScale = gameObject.transform.localScale; if (component != null) { gameObject = component.ExtractSingleItem(); gameObject.transform.SetParent(transform, worldPositionStays: false); } configurePartneredObject(decoration, gameObject); gameObject.transform.localPosition = decoration.Position; gameObject.transform.localRotation = decoration.Rotation; gameObject.name = decoration.Id.Name; gameObject.transform.localScale = decoration.UniformScale * localScale; prefabCacheTracker.SetCache(gameObject, prefabRequest.ContentKey); } } else { Log.LogErrorFormatted(this, "Something went wrong loading {0}.", contentKey.Key); prefabCacheTracker.Release(contentKey); } checkForLoadComplete(); }
private void onBeforeManipulatableObjectReParented(Transform newParent, GameObject obj) { ManipulatableObject component = obj.GetComponent <ManipulatableObject>(); DecorationLayoutData decorationLayoutData = default(DecorationLayoutData); decorationLayoutData.Id = DecorationLayoutData.ID.FromFullPath(component.PathId); DecorationLayoutData decoration = decorationLayoutData; if (SceneLayoutData.ContainsKey(decoration.Id.GetFullPath())) { SceneLayoutData.RemoveDecoration(decoration, deleteChildren: true); } }