-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAutoAnglerProfile.cs
More file actions
112 lines (99 loc) · 2.7 KB
/
AutoAnglerProfile.cs
File metadata and controls
112 lines (99 loc) · 2.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using Styx;
using Styx.CommonBot.Profiles;
using Styx.Helpers;
using Styx.WoWInternals.WoWObjects;
namespace HighVoltz.AutoAngler
{
class AutoAnglerProfile
{
private int _currentIndex;
public AutoAnglerProfile(Profile profile, PathingType pathType, List<uint> poolsToFish)
{
HBProfile = profile;
PathType = pathType;
PoolsToFish = poolsToFish.AsReadOnly();
LoadWayPoints();
FishAtHotspot = WayPoints.Count == 1;
}
public bool FishAtHotspot { get; private set; }
public List<WoWPoint> WayPoints { get; private set; }
public Profile HBProfile { get; private set; }
public ReadOnlyCollection<uint> PoolsToFish { get; private set; }
public PathingType PathType { get; private set; }
public WoWPoint CurrentPoint
{
get
{
return WayPoints != null && WayPoints.Count > 0
? WayPoints[_currentIndex]
: WoWPoint.Zero;
}
}
public void LoadWayPoints()
{
if (HBProfile != null && HBProfile.GrindArea != null && HBProfile.GrindArea.Hotspots != null)
{
var myLoc = StyxWoW.Me.Location;
WayPoints = HBProfile.GrindArea.Hotspots.ConvertAll(hs => hs.Position);
WoWPoint closestPoint =
WayPoints.OrderBy(u => u.DistanceSqr(myLoc)).FirstOrDefault();
_currentIndex = WayPoints.FindIndex(w => w == closestPoint);
return;
}
WayPoints = new List<WoWPoint>();
}
public void CycleToNextPoint()
{
if (WayPoints == null || !WayPoints.Any())
return;
if (_currentIndex >= WayPoints.Count - 1)
{
if (PathType == PathingType.Bounce)
{
WayPoints.Reverse();
_currentIndex = 1;
}
else
{
_currentIndex = 0;
}
}
else
{
_currentIndex++;
}
}
private WoWPoint GetNextWayPoint()
{
int i = _currentIndex + 1;
if (i >= WayPoints.Count)
{
if (PathType == PathingType.Bounce)
i = WayPoints.Count - 2;
else
i = 0;
}
if (WayPoints != null && i < WayPoints.Count)
return WayPoints[i];
return WoWPoint.Zero;
}
//if pool is between CurrentPoint and NextPoint then cycle to nextPoint
public void CycleToNextIfBehind(WoWGameObject pool)
{
WoWPoint cp = CurrentPoint;
WoWPoint point = GetNextWayPoint();
point = new WoWPoint(point.X - cp.X, point.Y - cp.Y, 0);
point.Normalize();
float angle = WoWMathHelper.NormalizeRadian((float)Math.Atan2(point.Y, point.X - 1));
if (WoWMathHelper.IsFacing(CurrentPoint, angle, pool.Location)
&& CurrentPoint != WayPoints[WayPoints.Count - 1])
{
CycleToNextPoint();
}
}
}
}