-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathExtensions.cs
58 lines (51 loc) · 1.83 KB
/
Extensions.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
54
55
56
57
58
using System;
using System.Collections.Generic;
using System.Linq;
using ExileCore.PoEMemory.Components;
using ExileCore.PoEMemory.FilesInMemory;
using ExileCore.PoEMemory.MemoryObjects;
using ExileCore.Shared.Enums;
using SharpDX;
namespace EssenceDrainContagion
{
public static class Extensions
{
private const int PixelBorder = 3;
public static bool HasBuff(this Entity entity, string buff, bool contains = false)
{
return entity.HasComponent<Life>() &&
entity.GetComponent<Life>().Buffs.Any(b => contains ? b.Name.Contains(buff) : b.Name == buff);
}
public static bool IsInside(this Vector2 position, RectangleF container)
{
return position.Y + PixelBorder < container.Bottom
&& position.Y - PixelBorder > container.Top
&& position.X + PixelBorder < container.Right
&& position.X - PixelBorder > container.Left;
}
public static int DistanceFrom(this Entity fromEntity, Entity toEntity)
{
var Object = toEntity.GetComponent<Render>();
try
{
return Convert.ToInt32(Vector3.Distance(fromEntity.Pos, Object.Pos));
}
catch
{
return Int32.MaxValue;
}
}
public static int GetStatValue(this Entity entity, string playerStat, IDictionary<string, StatsDat.StatRecord> recordsByIdentifier)
{
if (!recordsByIdentifier.TryGetValue(playerStat, out var startRecord))
{
return 0;
}
if (!entity.GetComponent<Stats>().StatDictionary.TryGetValue((GameStat) startRecord.ID, out var statValue))
{
return 0;
}
return statValue;
}
}
}