Ejemplo n.º 1
0
        private bool ResetSelected(bool objectBeingDeleted, bool deleteChildren)
        {
            bool flag = false;

            if (CurrentlySelectedObject != null)
            {
                ManipulatableObject component         = CurrentlySelectedObject.GetComponent <ManipulatableObject>();
                ObjectManipulator   componentInParent = CurrentlySelectedObject.GetComponentInParent <ObjectManipulator>();
                if (componentInParent != null)
                {
                    if (componentInParent.IsAllowed)
                    {
                        Transform parent = CurrentlySelectedObject.transform.parent;
                        CurrentlySelectedObject.transform.SetParent(oldParentOfSelectedObject, worldPositionStays: true);
                        component.SetParent(parent);
                        componentInParent.WasReparented = true;
                    }
                    else if (!restoreOldObject())
                    {
                        flag = true;
                    }
                    if (!objectBeingDeleted && this.ObjectDeselected != null)
                    {
                        this.ObjectDeselected.InvokeSafe(componentInParent);
                    }
                    if (flag)
                    {
                        component.RemoveObject(deleteChildren);
                    }
                }
            }
            CurrentlySelectedObject = null;
            return(flag);
        }
Ejemplo n.º 2
0
 private bool restoreOldObject()
 {
     if (oldObject != null)
     {
         copyTransform(oldObject.transform, CurrentlySelectedObject.transform);
         ManipulatableObject component = CurrentlySelectedObject.GetComponent <ManipulatableObject>();
         component.SetParent(oldParent);
         return(true);
     }
     return(false);
 }
 private void onAfterManipulatableObjectReParented(Transform newParent, GameObject obj)
 {
     ObjectManipulator.SetUniqueGameObjectName(obj, newParent);
     UpdateLayoutForManipulatableObject(newParent, obj.GetComponent <ManipulatableObject>());
     foreach (Transform item in obj.transform)
     {
         ManipulatableObject component = item.GetComponent <ManipulatableObject>();
         if (component != null)
         {
             component.SetParent(component.transform.parent);
         }
     }
 }
        private void onSplittableObjectChildrenSplit(SplittableObject splittableObject)
        {
            ManipulatableObject component  = splittableObject.GetComponent <ManipulatableObject>();
            CollidableObject    component2 = splittableObject.GetComponent <CollidableObject>();
            int nextAvailable = numberTracker.GetNextAvailable();

            GameObject[] splitList = splittableObject.SplitList;
            foreach (GameObject gameObject in splitList)
            {
                CollidableObject collidableObject = gameObject.AddComponent <CollidableObject>();
                collidableObject.CollisionRuleSet = component2.CollisionRuleSet;
                ManipulatableObject manipulatableObject = gameObject.AddComponent <ManipulatableObject>();
                gameObject.AddComponent <ManipulatableObjectEffects>();
                if (component != null)
                {
                    manipulatableObject.DefinitionId = component.DefinitionId;
                }
                if (this.ObjectAdded != null)
                {
                    this.ObjectAdded.InvokeSafe(manipulatableObject);
                }
                PartneredObject component3 = gameObject.GetComponent <PartneredObject>();
                if (component3 != null)
                {
                    component3.SetOthers(splittableObject.SplitList);
                    component3.SetNumber(nextAvailable);
                }
                UpdateLayoutForManipulatableObject(sceneLayoutContainer, manipulatableObject);
                manipulatableObject.SetParent(sceneLayoutContainer);
                manipulatableObject.OnRemoved           += onObjectRemoved;
                manipulatableObject.BeforeParentChanged += onBeforeManipulatableObjectReParented;
                manipulatableObject.AfterParentChanged  += onAfterManipulatableObjectReParented;
            }
            component.RemoveObject(deleteChildren: false);
            splittableObject.ChildrenSplit -= onSplittableObjectChildrenSplit;
        }