예제 #1
0
 /// <summary>
 /// Checks if the player can access the targeted block.
 /// </summary>
 private bool CanAccessTargetBlock()
 {
     return(Target.TBlock != null &&
            BlockInRange() &&
            Target.CanLocalPlayerAccess &&
            (!BvConfig.Current.targeting.closeIfNotInView || LocalPlayer.IsLookingInBlockDir(Target.TBlock)) &&
            (LocalPlayer.IsControllingCharacter || LocalPlayer.IsSpectating));
 }
예제 #2
0
            /// <summary>
            /// Updates position of menu on screen.
            /// </summary>
            private void UpdatePos()
            {
                Vector3D targetPos, worldPos;
                Vector2D screenPos, screenBounds;

                if (!Cfg.forceToCenter)
                {
                    if (LocalPlayer.IsLookingInBlockDir(target.TBlock))
                    {
                        targetPos    = target.GetPosition();
                        worldPos     = LocalPlayer.GetWorldToScreenPos(targetPos);
                        screenPos    = new Vector2D(worldPos.X, worldPos.Y);
                        screenBounds = new Vector2D(1d, 1d) - menu.Size / 2;

                        if (Cfg.clampHudPos)
                        {
                            screenPos.X = Utilities.Clamp(screenPos.X, -screenBounds.X, screenBounds.X);
                            screenPos.Y = Utilities.Clamp(screenPos.Y, -screenBounds.Y, screenBounds.Y);
                        }
                    }
                    else if (Cfg.hideIfNotVis)
                    {
                        menu.Visible = false;
                        screenPos    = Vector2D.Zero;
                    }
                    else
                    {
                        screenPos = Vector2D.Zero;
                    }
                }
                else
                {
                    screenPos = Vector2D.Zero;
                }

                menu.ScaledPos      = screenPos;
                menu.SelectionIndex = index - visStart;
            }
예제 #3
0
 /// <summary>
 /// Checks if the player can access the targeted block.
 /// </summary>
 private bool CanAccessTargetBlock() =>
 BlockInRange() && target.CanLocalPlayerAccess && (!Cfg.closeIfNotInView || LocalPlayer.IsLookingInBlockDir(target.TBlock));
예제 #4
0
        protected override void Layout()
        {
            var   specCon = MyAPIGateway.Session.CameraController as MySpectator;
            float scale   = BvConfig.Current.genUI.hudScale;

            if (BvConfig.Current.genUI.resolutionScaling)
            {
                scale *= HudMain.ResScale;
            }

            if (Target.TBlock != null && Open)
            {
                Vector3D targetWorldPos, targetScreenPos;
                Vector2  screenBounds = new Vector2(HudMain.ScreenWidth, HudMain.ScreenHeight) * HudMain.ResScale * .5f,
                         menuPos;

                if (!BvConfig.Current.genUI.useCustomPos)
                {
                    if (LocalPlayer.IsLookingInBlockDir(Target.TBlock))
                    {
                        targetWorldPos  = Target.Position + Target.ModelOffset * .75d;
                        targetScreenPos = LocalPlayer.GetWorldToScreenPos(targetWorldPos) / 2d;

                        menuPos = new Vector2((float)targetScreenPos.X, (float)targetScreenPos.Y);
                        menuPos = HudMain.GetPixelVector(menuPos) / scale;
                    }
                    else
                    {
                        menuPos = lastPos;
                    }
                }
                else
                {
                    menuPos = BvConfig.Current.genUI.hudPos;
                    menuPos = HudMain.GetPixelVector(menuPos) / scale;

                    if (menuPos.X < 0)
                    {
                        menuPos.X += .5f * quickActionMenu.Width;
                    }
                    else
                    {
                        menuPos.X -= .5f * quickActionMenu.Width;
                    }

                    if (menuPos.Y < 0)
                    {
                        menuPos.Y += .5f * quickActionMenu.Height;
                    }
                    else
                    {
                        menuPos.Y -= .5f * quickActionMenu.Height;
                    }
                }

                if (BvConfig.Current.genUI.clampHudPos || BvConfig.Current.genUI.useCustomPos)
                {
                    screenBounds -= .5f * quickActionMenu.Size;
                    menuPos.X     = MathHelper.Clamp(menuPos.X, -screenBounds.X, screenBounds.X);
                    menuPos.Y     = MathHelper.Clamp(menuPos.Y, -screenBounds.Y, screenBounds.Y);
                }

                if ((lastPos - menuPos).LengthSquared() > 1f && !(HudMain.EnableCursor && SharedBinds.LeftButton.IsPressed))
                {
                    posLerpFactor = 0f;
                    lastPos       = menuPos;
                }

                if (BvConfig.Current.genUI.useCustomPos)
                {
                    posLerpFactor = 1f;
                }

                lerpScale     = frameTimer.ElapsedMilliseconds / 16.6667f;
                posLerpFactor = Math.Min(posLerpFactor + .4f * lerpScale, 1f);

                quickActionMenu.Offset  = Vector2.Lerp(quickActionMenu.Offset, lastPos, posLerpFactor);
                quickActionMenu.Visible = bpTick > 30;

                if (specCon != null && lastSpecSpeeds != null)
                {
                    specCon.SpeedModeAngular = lastSpecSpeeds.Value.X;
                    specCon.SpeedModeLinear  = lastSpecSpeeds.Value.Y;
                }
            }
            else if (specCon != null)
            {
                lastSpecSpeeds = new Vector2(specCon.SpeedModeAngular, specCon.SpeedModeLinear);
            }

            // Rescale draw matrix based on config
            PlaneToWorldRef[0] = MatrixD.CreateScale(scale, scale, 1d) * HudMain.PixelToWorld;
            base.Layout();

            frameTimer.Restart();
        }