Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathExtensions.cs
More file actions
Latest commit
55 lines (48 loc) · 1.55 KB
/
Copy pathExtensions.cs
File metadata and controls
55 lines (48 loc) · 1.55 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
usingSystem.Collections.Generic;
usingSystem.Numerics;
usingSystem.Text.RegularExpressions;
usingExileCore.PoEMemory.Components;
usingGameOffsets.Native;
namespaceRadar;
publicstaticclassExtensions
{
publicstaticVector3GridPos(thisRenderrender)
{
returnrender.PosNum/Radar.GridToWorldMultiplier;
}
publicstaticVector2iTruncate(thisVector2v)
{
returnnewVector2i((int)v.X,(int)v.Y);
}
publicstaticIEnumerable<T>GetEveryNth<T>(thisIEnumerable<T>source,intn)
{
vari=0;
foreach(variteminsource)
{
if(i==0)
{
yieldreturnitem;
}
i++;
i%=n;
}
}
/// <summary>
/// Compares the string against a given pattern.
/// </summary>
/// <param name="str">The string.</param>
/// <param name="pattern">The pattern to match, where "*" means any sequence of characters, and "?" means any single character.</param>
/// <returns><c>true</c> if the string matches the given pattern; otherwise <c>false</c>.</returns>
publicstaticboolLike(thisstringstr,stringpattern)
{
returnToLikeRegex(pattern).IsMatch(str);
}
publicstaticRegexToLikeRegex(thisstringpattern)
{
returnnewRegex("^"+
Regex.Escape(pattern)
.Replace(@"\*",".*")
.Replace(@"\?",".")
+"$",RegexOptions.IgnoreCase|RegexOptions.Singleline);
}
}