Esempio n. 1
0
        /// <summary>
        /// Populates the handle variables with the relevant static bodies and
        /// sets the collision masking and visual masking.
        /// </summary>
        public void SetDefaults()
        {
            SetProcess(true);
            SetProcessPriority(0);
            EditorViewport = GetNode <Viewport>("/root/main/UI/AppWindow/EnvironmentContainer/4WayViewport/VerticalSplit/HSplit1/Viewport1/Viewport");

            HandleX = GetNode <Godot.StaticBody>("HandleX");
            HandleY = GetNode <Godot.StaticBody>("HandleY");
            HandleZ = GetNode <Godot.StaticBody>("HandleZ");

            // Set collision layers to layer 2 so the handles don't
            // collide with anything.
            HandleX.CollisionMask  = 0b11;
            HandleX.CollisionLayer = 0b11;

            HandleY.CollisionMask  = 0b11;
            HandleY.CollisionLayer = 0b11;

            HandleZ.CollisionMask  = 0b11;
            HandleZ.CollisionLayer = 0b11;

            // Set visual layers to draw handles over whole environment.
            HandleX.GetNode <MeshInstance>("Handle").Layers = 0b10;
            HandleY.GetNode <MeshInstance>("Handle").Layers = 0b10;
            HandleZ.GetNode <MeshInstance>("Handle").Layers = 0b10;

            HandleX.SetProcessUnhandledInput(true);
            HandleY.SetProcessUnhandledInput(true);
            HandleZ.SetProcessUnhandledInput(true);

            // Connect mouse enter/exit signals
            HandleX.Connect("mouse_entered", this, "OnXHandleMouseEnter");
            HandleY.Connect("mouse_entered", this, "OnYHandleMouseEnter");
            HandleZ.Connect("mouse_entered", this, "OnZHandleMouseEnter");

            HandleX.Connect("mouse_exited", this, "OnXHandleMouseExit");
            HandleY.Connect("mouse_exited", this, "OnYHandleMouseExit");
            HandleZ.Connect("mouse_exited", this, "OnZHandleMouseExit");

            HandleX.Connect("input_event", this, "InputEvent");
            HandleY.Connect("input_event", this, "InputEvent");
            HandleZ.Connect("input_event", this, "InputEvent");

            if (!EnabledByDefault)
            {
                Disable();
            }
        }