Exemplo n.º 1
0
        // Token: 0x06000E2F RID: 3631 RVA: 0x003E7F18 File Offset: 0x003E6118
        public static void Update()
        {
            LockOnHelper._canLockOn = false;
            if (!PlayerInput.UsingGamepad)
            {
                LockOnHelper.SetActive(false);
                return;
            }
            if (--LockOnHelper._lifeTimeArrowDisplay < 0)
            {
                LockOnHelper._lifeTimeArrowDisplay = 0;
            }
            LockOnHelper.Handle3DSTarget();
            if (PlayerInput.Triggers.JustPressed.LockOn && !PlayerInput.WritingText)
            {
                LockOnHelper._lifeTimeCounter      = 40;
                LockOnHelper._lifeTimeArrowDisplay = 30;
                LockOnHelper.HandlePressing();
            }
            if (!LockOnHelper._enabled)
            {
                return;
            }
            if (LockOnHelper.UseMode == LockOnHelper.LockOnMode.FocusTarget && PlayerInput.Triggers.Current.LockOn)
            {
                if (LockOnHelper._lifeTimeCounter <= 0)
                {
                    LockOnHelper.SetActive(false);
                    return;
                }
                LockOnHelper._lifeTimeCounter--;
            }
            NPC aimedTarget = LockOnHelper.AimedTarget;

            if (!LockOnHelper.ValidTarget(aimedTarget))
            {
                LockOnHelper.SetActive(false);
            }
            if (LockOnHelper.UseMode == LockOnHelper.LockOnMode.TargetClosest)
            {
                LockOnHelper.SetActive(false);
                LockOnHelper.SetActive(LockOnHelper.CanEnable());
            }
            if (!LockOnHelper._enabled)
            {
                return;
            }
            Player  player            = Main.player[Main.myPlayer];
            Vector2 predictedPosition = LockOnHelper.PredictedPosition;
            bool    flag = false;

            if (LockOnHelper.ShouldLockOn(player) && (ItemID.Sets.LockOnIgnoresCollision[player.inventory[player.selectedItem].type] || Collision.CanHit(player.Center, 0, 0, predictedPosition, 0, 0) || Collision.CanHitLine(player.Center, 0, 0, predictedPosition, 0, 0) || Collision.CanHit(player.Center, 0, 0, aimedTarget.Center, 0, 0) || Collision.CanHitLine(player.Center, 0, 0, aimedTarget.Center, 0, 0)))
            {
                flag = true;
            }
            if (flag)
            {
                LockOnHelper._canLockOn = true;
            }
        }
Exemplo n.º 2
0
        private static void GetClosestTarget(Vector2 position)
        {
            LockOnHelper._pickedTarget = -1;
            float num1 = -1f;

            if (LockOnHelper.UseMode == LockOnHelper.LockOnMode.ThreeDS)
            {
                Vector2 center  = Main.player[Main.myPlayer].Center;
                Vector2 vector2 = Main.player[Main.myPlayer].DirectionTo(Main.MouseWorld);
                for (int index = 0; index < LockOnHelper._targets.Count; ++index)
                {
                    int   target = LockOnHelper._targets[index];
                    NPC   n      = Main.npc[target];
                    float num2   = Vector2.Dot(n.DirectionFrom(center), vector2);
                    if (LockOnHelper.ValidTarget(n) && (LockOnHelper._pickedTarget == -1 || (double)num2 > (double)num1))
                    {
                        LockOnHelper._pickedTarget = index;
                        num1 = num2;
                    }
                }
            }
            else
            {
                for (int index = 0; index < LockOnHelper._targets.Count; ++index)
                {
                    int target = LockOnHelper._targets[index];
                    NPC n      = Main.npc[target];
                    if (LockOnHelper.ValidTarget(n) && (LockOnHelper._pickedTarget == -1 || (double)n.Distance(position) < (double)num1))
                    {
                        LockOnHelper._pickedTarget = index;
                        num1 = n.Distance(position);
                    }
                }
            }
        }
Exemplo n.º 3
0
        private static void HandlePressing()
        {
            switch (LockOnHelper.UseMode)
            {
            case LockOnHelper.LockOnMode.TargetClosest:
                LockOnHelper.SetActive(!LockOnHelper._enabled);
                break;

            case LockOnHelper.LockOnMode.ThreeDS:
                if (!LockOnHelper._enabled)
                {
                    LockOnHelper.SetActive(true);
                    break;
                }
                LockOnHelper.CycleTargetThreeDS();
                break;

            default:
                if (!LockOnHelper._enabled)
                {
                    LockOnHelper.SetActive(true);
                    break;
                }
                LockOnHelper.CycleTargetFocus();
                break;
            }
        }
Exemplo n.º 4
0
        // Token: 0x06000E3C RID: 3644 RVA: 0x003E845C File Offset: 0x003E665C
        private static void GetClosestTarget(Vector2 position)
        {
            LockOnHelper._pickedTarget = -1;
            float num = -1f;

            if (LockOnHelper.UseMode == LockOnHelper.LockOnMode.ThreeDS)
            {
                Vector2 center = Main.player[Main.myPlayer].Center;
                Vector2 value  = Main.player[Main.myPlayer].DirectionTo(Main.MouseWorld);
                for (int i = 0; i < LockOnHelper._targets.Count; i++)
                {
                    int   num2    = LockOnHelper._targets[i];
                    NPC   expr_54 = Main.npc[num2];
                    float num3    = Vector2.Dot(expr_54.DirectionFrom(center), value);
                    if (LockOnHelper.ValidTarget(expr_54) && (LockOnHelper._pickedTarget == -1 || num3 > num))
                    {
                        LockOnHelper._pickedTarget = i;
                        num = num3;
                    }
                }
                return;
            }
            for (int j = 0; j < LockOnHelper._targets.Count; j++)
            {
                int num4 = LockOnHelper._targets[j];
                NPC nPC  = Main.npc[num4];
                if (LockOnHelper.ValidTarget(nPC) && (LockOnHelper._pickedTarget == -1 || nPC.Distance(position) < num))
                {
                    LockOnHelper._pickedTarget = j;
                    num = nPC.Distance(position);
                }
            }
        }
Exemplo n.º 5
0
 private static void SetActive(bool on)
 {
     if (on)
     {
         if (!LockOnHelper.CanEnable())
         {
             return;
         }
         LockOnHelper.RefreshTargets(Main.MouseWorld, 2000f);
         LockOnHelper.GetClosestTarget(Main.MouseWorld);
         if (LockOnHelper._pickedTarget < 0)
         {
             return;
         }
         LockOnHelper._enabled = true;
     }
     else
     {
         LockOnHelper._enabled = false;
         LockOnHelper._targets.Clear();
         LockOnHelper._lifeTimeCounter     = 0;
         LockOnHelper._threeDSTarget       = -1;
         LockOnHelper._targetClosestTarget = -1;
     }
 }
Exemplo n.º 6
0
 // Token: 0x06000E36 RID: 3638 RVA: 0x003E81A4 File Offset: 0x003E63A4
 private static void HandlePressing()
 {
     if (LockOnHelper.UseMode == LockOnHelper.LockOnMode.TargetClosest)
     {
         LockOnHelper.SetActive(!LockOnHelper._enabled);
         return;
     }
     if (LockOnHelper.UseMode == LockOnHelper.LockOnMode.ThreeDS)
     {
         if (!LockOnHelper._enabled)
         {
             LockOnHelper.SetActive(true);
             return;
         }
         LockOnHelper.CycleTargetThreeDS();
         return;
     }
     else
     {
         if (!LockOnHelper._enabled)
         {
             LockOnHelper.SetActive(true);
             return;
         }
         LockOnHelper.CycleTargetFocus();
         return;
     }
 }
Exemplo n.º 7
0
        // Token: 0x06000E35 RID: 3637 RVA: 0x003E8118 File Offset: 0x003E6318
        private static void Handle3DSTarget()
        {
            LockOnHelper._threeDSTarget = -1;
            if (LockOnHelper.UseMode != LockOnHelper.LockOnMode.ThreeDS)
            {
                return;
            }
            if (!PlayerInput.UsingGamepad)
            {
                return;
            }
            List <int> list = new List <int>();
            int        num  = -1;

            Utils.Swap <List <int> >(ref list, ref LockOnHelper._targets);
            Utils.Swap <int>(ref num, ref LockOnHelper._pickedTarget);
            LockOnHelper.RefreshTargets(Main.MouseWorld, 2000f);
            LockOnHelper.GetClosestTarget(Main.MouseWorld);
            Utils.Swap <List <int> >(ref list, ref LockOnHelper._targets);
            Utils.Swap <int>(ref num, ref LockOnHelper._pickedTarget);
            if (num >= 0)
            {
                LockOnHelper._threeDSTarget = list[num];
            }
            list.Clear();
        }
Exemplo n.º 8
0
 public static void SetDOWN()
 {
     if (!LockOnHelper._canLockOn)
     {
         return;
     }
     LockOnHelper.ResetLockPosition();
 }
Exemplo n.º 9
0
        public static void SetUP()
        {
            if (!LockOnHelper._canLockOn)
            {
                return;
            }
            NPC aimedTarget = LockOnHelper.AimedTarget;

            LockOnHelper.SetLockPosition(Main.ReverseGravitySupport(LockOnHelper.PredictedPosition - Main.screenPosition, 0.0f));
        }
Exemplo n.º 10
0
 // Token: 0x06000E33 RID: 3635 RVA: 0x003E80F0 File Offset: 0x003E62F0
 public static void Toggle(bool forceOff = false)
 {
     LockOnHelper._lifeTimeCounter      = 40;
     LockOnHelper._lifeTimeArrowDisplay = 30;
     LockOnHelper.HandlePressing();
     if (forceOff)
     {
         LockOnHelper._enabled = false;
     }
 }
Exemplo n.º 11
0
        private static void CycleTargetThreeDS()
        {
            int target = LockOnHelper._targets[LockOnHelper._pickedTarget];

            LockOnHelper.RefreshTargets(Main.MouseWorld, 2000f);
            LockOnHelper.GetClosestTarget(Main.MouseWorld);
            if (LockOnHelper._targets.Count >= 1 && (LockOnHelper._targets.Count != 1 || target != LockOnHelper._targets[0]) && target != LockOnHelper._targets[LockOnHelper._pickedTarget])
            {
                return;
            }
            LockOnHelper.SetActive(false);
        }
Exemplo n.º 12
0
        // Token: 0x06000E38 RID: 3640 RVA: 0x003E8284 File Offset: 0x003E6484
        private static void CycleTargetThreeDS()
        {
            int num = LockOnHelper._targets[LockOnHelper._pickedTarget];

            LockOnHelper.RefreshTargets(Main.MouseWorld, 2000f);
            LockOnHelper.GetClosestTarget(Main.MouseWorld);
            if (LockOnHelper._targets.Count < 1 || (LockOnHelper._targets.Count == 1 && num == LockOnHelper._targets[0]) || num == LockOnHelper._targets[LockOnHelper._pickedTarget])
            {
                LockOnHelper.SetActive(false);
                return;
            }
        }
Exemplo n.º 13
0
        private static void RefreshTargets(Vector2 position, float radius)
        {
            LockOnHelper._targets.Clear();
            Rectangle rectangle = Utils.CenteredRectangle(Main.player[Main.myPlayer].Center, new Vector2(1920f, 1080f));
            Vector2   center    = Main.player[Main.myPlayer].Center;
            Vector2   vector2   = Main.player[Main.myPlayer].DirectionTo(Main.MouseWorld);

            for (int index = 0; index < Main.npc.Length; ++index)
            {
                NPC n = Main.npc[index];
                if (LockOnHelper.ValidTarget(n) && (double)n.Distance(position) <= (double)radius && rectangle.Intersects(n.Hitbox) && ((double)Lighting.GetSubLight(n.Center).Length() / 3.0 >= 0.00999999977648258 && (LockOnHelper.UseMode != LockOnHelper.LockOnMode.ThreeDS || (double)Vector2.Dot(n.DirectionFrom(center), vector2) >= 0.649999976158142)))
                {
                    LockOnHelper._targets.Add(index);
                }
            }
        }
Exemplo n.º 14
0
        private static void RefreshTargets(Vector2 position, float radius)
        {
            LockOnHelper._targets.Clear();
            Rectangle rectangle = Utils.CenteredRectangle(Main.player[Main.myPlayer].Center, new Vector2(1920f, 1200f));
            Vector2   center    = Main.player[Main.myPlayer].Center;

            Main.player[Main.myPlayer].DirectionTo(Main.MouseWorld);
            for (int index = 0; index < Main.npc.Length; ++index)
            {
                NPC n = Main.npc[index];
                if (LockOnHelper.ValidTarget(n) && (double)n.Distance(position) <= (double)radius && rectangle.Intersects(n.Hitbox) && (double)Lighting.GetSubLight(n.Center).Length() / 3.0 >= 0.0299999993294477)
                {
                    LockOnHelper._targets.Add(index);
                }
            }
        }
Exemplo n.º 15
0
        // Token: 0x06000E3B RID: 3643 RVA: 0x003E836C File Offset: 0x003E656C
        private static void RefreshTargets(Vector2 position, float radius)
        {
            LockOnHelper._targets.Clear();
            Rectangle rectangle = Utils.CenteredRectangle(Main.player[Main.myPlayer].Center, new Vector2(1920f, 1200f));
            Vector2   center    = Main.player[Main.myPlayer].Center;
            Vector2   value     = Main.player[Main.myPlayer].DirectionTo(Main.MouseWorld);

            for (int i = 0; i < Main.npc.Length; i++)
            {
                NPC nPC = Main.npc[i];
                if (LockOnHelper.ValidTarget(nPC) && nPC.Distance(position) <= radius && rectangle.Intersects(nPC.Hitbox) && Lighting.GetSubLight(nPC.Center).Length() / 3f >= 0.01f && (LockOnHelper.UseMode != LockOnHelper.LockOnMode.ThreeDS || Vector2.Dot(nPC.DirectionFrom(center), value) >= 0.65f))
                {
                    LockOnHelper._targets.Add(i);
                }
            }
        }
Exemplo n.º 16
0
        // Token: 0x06000E37 RID: 3639 RVA: 0x003E81F8 File Offset: 0x003E63F8
        private static void CycleTargetFocus()
        {
            int num = LockOnHelper._targets[LockOnHelper._pickedTarget];

            LockOnHelper.RefreshTargets(Main.MouseWorld, 2000f);
            if (LockOnHelper._targets.Count < 1 || (LockOnHelper._targets.Count == 1 && num == LockOnHelper._targets[0]))
            {
                LockOnHelper.SetActive(false);
                return;
            }
            LockOnHelper._pickedTarget = 0;
            for (int i = 0; i < LockOnHelper._targets.Count; i++)
            {
                if (LockOnHelper._targets[i] > num)
                {
                    LockOnHelper._pickedTarget = i;
                    return;
                }
            }
        }
Exemplo n.º 17
0
        private static void CycleTargetFocus()
        {
            int target = LockOnHelper._targets[LockOnHelper._pickedTarget];

            LockOnHelper.RefreshTargets(Main.MouseWorld, 2000f);
            if (LockOnHelper._targets.Count < 1 || LockOnHelper._targets.Count == 1 && target == LockOnHelper._targets[0])
            {
                LockOnHelper.SetActive(false);
            }
            else
            {
                LockOnHelper._pickedTarget = 0;
                for (int index = 0; index < LockOnHelper._targets.Count; ++index)
                {
                    if (LockOnHelper._targets[index] > target)
                    {
                        LockOnHelper._pickedTarget = index;
                        break;
                    }
                }
            }
        }
Exemplo n.º 18
0
        private static void FindMostViableTarget(LockOnHelper.LockOnMode context, ref int targetVar)
        {
            targetVar = -1;
            if (LockOnHelper.UseMode != context || !LockOnHelper.CanUseLockonSystem())
            {
                return;
            }
            List <int> t1_1 = new List <int>();
            int        t1_2 = -1;

            Utils.Swap <List <int> >(ref t1_1, ref LockOnHelper._targets);
            Utils.Swap <int>(ref t1_2, ref LockOnHelper._pickedTarget);
            LockOnHelper.RefreshTargets(Main.MouseWorld, 2000f);
            LockOnHelper.GetClosestTarget(Main.MouseWorld);
            Utils.Swap <List <int> >(ref t1_1, ref LockOnHelper._targets);
            Utils.Swap <int>(ref t1_2, ref LockOnHelper._pickedTarget);
            if (t1_2 >= 0)
            {
                targetVar = t1_1[t1_2];
            }
            t1_1.Clear();
        }
Exemplo n.º 19
0
        private static void Handle3DSTarget()
        {
            LockOnHelper._threeDSTarget = -1;
            if (LockOnHelper.UseMode != LockOnHelper.LockOnMode.ThreeDS || !PlayerInput.UsingGamepad)
            {
                return;
            }
            var t1_1 = new List <int>();
            var t1_2 = -1;

            Utils.Swap <List <int> >(ref t1_1, ref LockOnHelper._targets);
            Utils.Swap <int>(ref t1_2, ref LockOnHelper._pickedTarget);
            LockOnHelper.RefreshTargets(Main.MouseWorld, 2000f);
            LockOnHelper.GetClosestTarget(Main.MouseWorld);
            Utils.Swap <List <int> >(ref t1_1, ref LockOnHelper._targets);
            Utils.Swap <int>(ref t1_2, ref LockOnHelper._pickedTarget);
            if (t1_2 >= 0)
            {
                LockOnHelper._threeDSTarget = t1_1[t1_2];
            }
            t1_1.Clear();
        }