-
Notifications
You must be signed in to change notification settings - Fork 0
/
Utils.cs
53 lines (46 loc) · 1.5 KB
/
Utils.cs
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
using System.Collections.Generic;
using System.Linq;
using EloBuddy;
using EloBuddy.SDK;
using SharpDX;
namespace Shaco
{
internal static class Utils
{
public static Vector3 To3DPlayer(this Vector2 vector)
{
return new Vector3(vector.X, vector.Y, ObjectManager.Player.Position.Z);
}
public static bool IsWall(this Vector2 vector)
{
return NavMesh.GetCollisionFlags(vector.X, vector.Y).HasFlag(CollisionFlags.Wall);
}
public static bool IsWall(this Vector3 vector)
{
return NavMesh.GetCollisionFlags(vector.X, vector.Y).HasFlag(CollisionFlags.Wall);
}
public static float GetPath(Obj_AI_Base hero, Vector3 b)
{
var path = hero.GetPath(b);
var lastPoint = path[0];
var distance = 0f;
foreach (var point in path.Where(point => !point.Equals(lastPoint)))
{
distance += lastPoint.Distance(point);
lastPoint = point;
}
return distance;
}
public static Vector3 Extend(this Vector3 vector, Vector3 direction, float distance)
{
if (vector.To2D().Distance(direction.To2D()) == 0)
{
return vector;
}
var edge = direction.To2D() - vector.To2D();
edge.Normalize();
var v = vector.To2D() + edge * distance;
return new Vector3(v.X, v.Y, vector.Z);
}
}
}