Exemplo n.º 1
0
        protected void moveHandle(Vector3 position, Quaternion rotation, Vector3 scale, bool doRotation, bool doScale)
        {
            DevkitTransactionManager.beginTransaction(new TranslatedText(new TranslationReference("#SDG::Devkit.Transactions.Transform")));
            Matrix4x4 matrix4x  = Matrix4x4.TRS(this.handlePosition, this.handleRotation, Vector3.one);
            Matrix4x4 inverse   = matrix4x.inverse;
            Matrix4x4 matrix4x2 = Matrix4x4.TRS(Vector3.zero, Quaternion.Inverse(this.handleRotation) * rotation, Vector3.one);

            matrix4x *= matrix4x2;
            Vector3 vector = position - this.handlePosition;

            foreach (DevkitSelection devkitSelection in DevkitSelectionManager.selection)
            {
                if (!(devkitSelection.gameObject == null))
                {
                    DevkitTransactionUtility.recordObjectDelta(devkitSelection.transform);
                    if (doRotation)
                    {
                        Matrix4x4 matrix4x3 = inverse * devkitSelection.transform.localToWorldMatrix;
                        Matrix4x4 matrix    = matrix4x * matrix4x3;
                        devkitSelection.transform.position = matrix.GetPosition();
                        devkitSelection.transform.rotation = matrix.GetRotation();
                    }
                    devkitSelection.transform.position += vector;
                    if (doScale)
                    {
                        devkitSelection.transform.localScale = scale;
                    }
                }
            }
            this.transformSelection();
            DevkitTransactionManager.endTransaction();
        }
Exemplo n.º 2
0
 // Token: 0x06001179 RID: 4473 RVA: 0x000717F8 File Offset: 0x0006FBF8
 public override void copyValue(object newValue)
 {
     if (base.type.IsValueType)
     {
         DevkitTransactionUtility.recordObjectDelta(base.instance);
         this.property.SetValue(base.instance, newValue, null);
     }
     if (base.parent != null)
     {
         base.parent.copyValue(base.instance);
     }
 }
Exemplo n.º 3
0
 protected virtual void handleTextSubmitted(Sleek2Field field, string value)
 {
     if (this.leaf != null)
     {
         DevkitTransactionManager.beginTransaction(new TranslatedText(new TranslationReference("#SDG::Devkit.Transactions.Translation")));
         DevkitTransactionUtility.recordObjectDelta(this.leaf);
         DevkitTransactionUtility.recordObjectDelta(this.leaf.translation);
         this.leaf.text = value;
         this.leaf.version++;
         this.leaf.translation.isDirty = true;
         DevkitTransactionManager.endTransaction();
     }
 }
Exemplo n.º 4
0
        public static DevkitHierarchyWorldObject addDevkitObject(Guid GUID, Vector3 position, Quaternion rotation, Vector3 scale, ELevelObjectPlacementOrigin placementOrigin)
        {
            GameObject gameObject = new GameObject();

            gameObject.transform.position   = position;
            gameObject.transform.rotation   = rotation;
            gameObject.transform.localScale = scale;
            DevkitTransactionUtility.recordInstantiation(gameObject);
            DevkitHierarchyWorldObject devkitHierarchyWorldObject = gameObject.AddComponent <DevkitHierarchyWorldObject>();

            LevelHierarchy.initItem(devkitHierarchyWorldObject);
            devkitHierarchyWorldObject.GUID            = GUID;
            devkitHierarchyWorldObject.placementOrigin = placementOrigin;
            return(devkitHierarchyWorldObject);
        }
Exemplo n.º 5
0
        public static void instantiate(ObjectAsset asset, Vector3 position, Quaternion rotation, Vector3 scale)
        {
            if (asset == null)
            {
                return;
            }
            if (!Level.isEditor)
            {
                return;
            }
            TranslationReference newReference   = new TranslationReference("#SDG::Devkit.Transactions.Spawn");
            TranslatedText       translatedText = new TranslatedText(newReference);

            translatedText.format(asset.objectName);
            DevkitTransactionManager.beginTransaction(translatedText);
            DevkitHierarchyWorldObject devkitHierarchyWorldObject = LevelObjects.addDevkitObject(asset.GUID, position, rotation, scale, ELevelObjectPlacementOrigin.MANUAL);

            DevkitTransactionUtility.recordInstantiation(devkitHierarchyWorldObject.gameObject);
            DevkitTransactionManager.endTransaction();
        }
Exemplo n.º 6
0
        public static void instantiate(Type type, Vector3 position, Quaternion rotation, Vector3 scale)
        {
            if (!Level.isEditor)
            {
                return;
            }
            TranslationReference newReference   = new TranslationReference("#SDG::Devkit.Transactions.Spawn");
            TranslatedText       translatedText = new TranslatedText(newReference);

            translatedText.format(type.Name);
            DevkitTransactionManager.beginTransaction(translatedText);
            IDevkitHierarchySpawnable devkitHierarchySpawnable;

            if (typeof(MonoBehaviour).IsAssignableFrom(type))
            {
                GameObject gameObject = new GameObject();
                gameObject.name = type.Name;
                gameObject.transform.position   = position;
                gameObject.transform.rotation   = rotation;
                gameObject.transform.localScale = scale;
                DevkitTransactionUtility.recordInstantiation(gameObject);
                devkitHierarchySpawnable = (gameObject.AddComponent(type) as IDevkitHierarchySpawnable);
            }
            else
            {
                devkitHierarchySpawnable = (Activator.CreateInstance(type) as IDevkitHierarchySpawnable);
            }
            if (devkitHierarchySpawnable != null)
            {
                devkitHierarchySpawnable.devkitHierarchySpawn();
            }
            IDevkitHierarchyItem devkitHierarchyItem = devkitHierarchySpawnable as IDevkitHierarchyItem;

            if (devkitHierarchyItem != null)
            {
                LevelHierarchy.initItem(devkitHierarchyItem);
            }
            DevkitTransactionManager.endTransaction();
        }
Exemplo n.º 7
0
        public virtual void update()
        {
            if (this.copySelectionDelay.Count > 0)
            {
                DevkitSelectionManager.clear();
                foreach (GameObject newGameObject in this.copySelectionDelay)
                {
                    DevkitSelectionManager.add(new DevkitSelection(newGameObject, null));
                }
                this.copySelectionDelay.Clear();
            }
            if (!DevkitNavigation.isNavigating)
            {
                if (DevkitInput.canEditorReceiveInput)
                {
                    if (Input.GetKeyDown(113))
                    {
                        this.mode = DevkitSelectionTool.ESelectionMode.POSITION;
                    }
                    if (Input.GetKeyDown(119))
                    {
                        this.mode = DevkitSelectionTool.ESelectionMode.ROTATION;
                    }
                    if (Input.GetKeyDown(114))
                    {
                        this.mode = DevkitSelectionTool.ESelectionMode.SCALE;
                    }
                }
                Ray        pointerToWorldRay = DevkitInput.pointerToWorldRay;
                RaycastHit raycastHit;
                if (!Physics.Raycast(pointerToWorldRay, ref raycastHit, 8192f, RayMasks.LOGIC))
                {
                    Physics.Raycast(pointerToWorldRay, ref raycastHit, 8192f, (int)DevkitSelectionToolOptions.instance.selectionMask);
                    if (DevkitInput.canEditorReceiveInput && Input.GetKeyDown(101) && raycastHit.transform != null)
                    {
                        if (DevkitSelectionManager.selection.Count > 0)
                        {
                            this.handleTeleportTransformed(raycastHit.point, raycastHit.normal);
                        }
                        else
                        {
                            this.instantiate(raycastHit.point, raycastHit.normal);
                        }
                    }
                }
                if (DevkitInput.canEditorReceiveInput)
                {
                    if (Input.GetKeyDown(323))
                    {
                        this.drag = new DevkitSelection((!(raycastHit.transform != null)) ? null : raycastHit.transform.gameObject, raycastHit.collider);
                        if (this.drag.isValid)
                        {
                            DevkitSelectionManager.data.point = raycastHit.point;
                            this.isDragging = DevkitSelectionManager.beginDrag(this.drag);
                            if (this.isDragging)
                            {
                                DevkitTransactionManager.beginTransaction(new TranslatedText(new TranslationReference("#SDG::Devkit.Transactions.Transform")));
                                foreach (DevkitSelection devkitSelection in DevkitSelectionManager.selection)
                                {
                                    DevkitTransactionUtility.recordObjectDelta(devkitSelection.transform);
                                }
                            }
                        }
                        if (!this.isDragging)
                        {
                            DevkitSelectionManager.data.point = raycastHit.point;
                            this.beginAreaSelect     = DevkitInput.pointerViewportPoint;
                            this.beginAreaSelectTime = Time.time;
                        }
                    }
                    if (Input.GetKey(323) && !this.isDragging && !this.isAreaSelecting && Time.time - this.beginAreaSelectTime > 0.1f)
                    {
                        this.isAreaSelecting = true;
                        this.areaSelection.Clear();
                        if (!Input.GetKey(304) && !Input.GetKey(306))
                        {
                            DevkitSelectionManager.clear();
                        }
                    }
                }
                if (this.isDragging && this.drag.collider != null)
                {
                    DevkitSelectionManager.data.point = raycastHit.point;
                    DevkitSelectionManager.continueDrag(this.drag);
                }
                if (this.isAreaSelecting)
                {
                    Vector3 pointerViewportPoint = DevkitInput.pointerViewportPoint;
                    Vector2 vector;
                    Vector2 vector2;
                    if (pointerViewportPoint.x < this.beginAreaSelect.x)
                    {
                        vector.x  = pointerViewportPoint.x;
                        vector2.x = this.beginAreaSelect.x;
                    }
                    else
                    {
                        vector.x  = this.beginAreaSelect.x;
                        vector2.x = pointerViewportPoint.x;
                    }
                    if (pointerViewportPoint.y < this.beginAreaSelect.y)
                    {
                        vector.y  = pointerViewportPoint.y;
                        vector2.y = this.beginAreaSelect.y;
                    }
                    else
                    {
                        vector.y  = this.beginAreaSelect.y;
                        vector2.y = pointerViewportPoint.y;
                    }
                    int selectionMask = (int)DevkitSelectionToolOptions.instance.selectionMask;
                    foreach (IDevkitHierarchyItem devkitHierarchyItem in LevelHierarchy.instance.items)
                    {
                        int num = 1 << devkitHierarchyItem.areaSelectGameObject.layer;
                        if ((num & selectionMask) == num)
                        {
                            Vector3         vector3          = MainCamera.instance.WorldToViewportPoint(devkitHierarchyItem.areaSelectCenter);
                            DevkitSelection devkitSelection2 = new DevkitSelection(devkitHierarchyItem.areaSelectGameObject, null);
                            if (vector3.z > 0f && vector3.x > vector.x && vector3.x < vector2.x && vector3.y > vector.y && vector3.y < vector2.y)
                            {
                                if (!this.areaSelection.Contains(devkitSelection2))
                                {
                                    this.areaSelection.Add(devkitSelection2);
                                    DevkitSelectionManager.add(devkitSelection2);
                                }
                            }
                            else if (this.areaSelection.Contains(devkitSelection2))
                            {
                                this.areaSelection.Remove(devkitSelection2);
                                DevkitSelectionManager.remove(devkitSelection2);
                            }
                        }
                    }
                }
                if (Input.GetKeyUp(323))
                {
                    if (this.isDragging)
                    {
                        if (this.drag.isValid)
                        {
                            DevkitSelectionManager.data.point = raycastHit.point;
                            DevkitSelectionManager.endDrag(this.drag);
                        }
                        this.drag       = DevkitSelection.invalid;
                        this.isDragging = false;
                        this.transformSelection();
                        DevkitTransactionManager.endTransaction();
                    }
                    else if (this.isAreaSelecting)
                    {
                        this.isAreaSelecting = false;
                    }
                    else if (DevkitInput.canEditorReceiveInput)
                    {
                        DevkitSelectionManager.select(this.drag);
                    }
                }
                if (raycastHit.transform != this.hover.transform || raycastHit.collider != this.hover.collider)
                {
                    if (this.hover.isValid)
                    {
                        DevkitSelectionManager.data.point = raycastHit.point;
                        DevkitSelectionManager.endHover(this.hover);
                    }
                    this.hover.transform = raycastHit.transform;
                    this.hover.collider  = raycastHit.collider;
                    if (this.hover.isValid)
                    {
                        DevkitSelectionManager.data.point = raycastHit.point;
                        DevkitSelectionManager.beginHover(this.hover);
                    }
                }
            }
            if (DevkitSelectionManager.selection.Count > 0)
            {
                this.handlePosition = Vector3.zero;
                this.handleRotation = Quaternion.identity;
                bool flag = !DevkitSelectionToolOptions.instance.localSpace;
                foreach (DevkitSelection devkitSelection3 in DevkitSelectionManager.selection)
                {
                    if (!(devkitSelection3.gameObject == null))
                    {
                        this.handlePosition += devkitSelection3.transform.position;
                        if (!flag)
                        {
                            this.handleRotation = devkitSelection3.transform.rotation;
                            flag = true;
                        }
                    }
                }
                this.handlePosition /= (float)DevkitSelectionManager.selection.Count;
                this.positionGameObject.SetActive(this.mode == DevkitSelectionTool.ESelectionMode.POSITION);
                this.positionHandle.suggestTransform(this.handlePosition, this.handleRotation);
                this.rotationGameObject.SetActive(this.mode == DevkitSelectionTool.ESelectionMode.ROTATION);
                this.rotationHandle.suggestTransform(this.handlePosition, this.handleRotation);
                this.scaleGameObject.SetActive(this.mode == DevkitSelectionTool.ESelectionMode.SCALE);
                this.scaleHandle.suggestTransform(this.handlePosition, this.handleRotation);
                if (DevkitInput.canEditorReceiveInput)
                {
                    if (Input.GetKeyDown(99))
                    {
                        this.copyBuffer.Clear();
                        foreach (DevkitSelection devkitSelection4 in DevkitSelectionManager.selection)
                        {
                            this.copyBuffer.Add(devkitSelection4.gameObject);
                        }
                    }
                    if (Input.GetKeyDown(118))
                    {
                        TranslationReference newReference = new TranslationReference("#SDG::Devkit.Transactions.Paste");
                        TranslatedText       name         = new TranslatedText(newReference);
                        DevkitTransactionManager.beginTransaction(name);
                        foreach (GameObject gameObject in this.copyBuffer)
                        {
                            IDevkitSelectionCopyableHandler component = gameObject.GetComponent <IDevkitSelectionCopyableHandler>();
                            GameObject gameObject2;
                            if (component != null)
                            {
                                gameObject2 = component.copySelection();
                            }
                            else
                            {
                                gameObject2 = Object.Instantiate <GameObject>(gameObject);
                            }
                            IDevkitHierarchyItem component2 = gameObject2.GetComponent <IDevkitHierarchyItem>();
                            if (component2 != null)
                            {
                                component2.instanceID = LevelHierarchy.generateUniqueInstanceID();
                            }
                            DevkitTransactionUtility.recordInstantiation(gameObject2);
                            this.copySelectionDelay.Add(gameObject2);
                        }
                        DevkitTransactionManager.endTransaction();
                    }
                    if (Input.GetKeyDown(127))
                    {
                        TranslationReference newReference2 = new TranslationReference("#SDG::Devkit.Transactions.Delete_Selection");
                        TranslatedText       name2         = new TranslatedText(newReference2);
                        DevkitTransactionManager.beginTransaction(name2);
                        foreach (DevkitSelection devkitSelection5 in DevkitSelectionManager.selection)
                        {
                            DevkitTransactionUtility.recordDestruction(devkitSelection5.gameObject);
                        }
                        DevkitSelectionManager.clear();
                        DevkitTransactionManager.endTransaction();
                    }
                    if (Input.GetKeyDown(98))
                    {
                        this.referencePosition = this.handlePosition;
                        this.referenceRotation = this.handleRotation;
                        this.referenceScale    = Vector3.one;
                        this.hasReferenceScale = false;
                        if (DevkitSelectionManager.selection.Count == 1)
                        {
                            foreach (DevkitSelection devkitSelection6 in DevkitSelectionManager.selection)
                            {
                                if (!(devkitSelection6.gameObject == null))
                                {
                                    this.referenceScale    = devkitSelection6.transform.localScale;
                                    this.hasReferenceScale = true;
                                }
                            }
                        }
                    }
                    if (Input.GetKeyDown(110))
                    {
                        this.moveHandle(this.referencePosition, this.referenceRotation, this.referenceScale, true, this.hasReferenceScale && DevkitSelectionManager.selection.Count == 1);
                    }
                    if (Input.GetKeyDown(102))
                    {
                        List <Collider> list = ListPool <Collider> .claim();

                        List <Renderer> list2 = ListPool <Renderer> .claim();

                        Bounds bounds;
                        bounds..ctor(this.handlePosition, Vector3.zero);
                        foreach (DevkitSelection devkitSelection7 in DevkitSelectionManager.selection)
                        {
                            if (!(devkitSelection7.gameObject == null))
                            {
                                list.Clear();
                                devkitSelection7.gameObject.GetComponentsInChildren <Collider>(list);
                                foreach (Collider collider in list)
                                {
                                    bounds.Encapsulate(collider.bounds);
                                }
                                list2.Clear();
                                devkitSelection7.gameObject.GetComponentsInChildren <Renderer>(list2);
                                foreach (Renderer renderer in list2)
                                {
                                    bounds.Encapsulate(renderer.bounds);
                                }
                            }
                        }
                        ListPool <Collider> .release(list);

                        ListPool <Renderer> .release(list2);

                        DevkitNavigation.focus(bounds);
                    }
                }
            }
            else
            {
                this.positionGameObject.SetActive(false);
                this.rotationGameObject.SetActive(false);
                this.scaleGameObject.SetActive(false);
            }
        }
Exemplo n.º 8
0
 protected virtual void endChangeHotkeyTransaction()
 {
     DevkitTransactionUtility.endGenericTransaction();
 }
Exemplo n.º 9
0
 protected virtual void beginChangeHotkeyTransaction()
 {
     DevkitTransactionUtility.beginGenericTransaction();
     DevkitTransactionUtility.recordObjectDelta(DevkitFoliageToolOptions.instance);
 }