-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathYRPP.cs
70 lines (60 loc) · 1.88 KB
/
YRPP.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
59
60
61
62
63
64
65
66
67
68
69
70
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using DynamicPatcher;
namespace PatcherYRpp
{
public static class YRPP
{
public class GLOBAL_DVC_ARRAY<T> : IEnumerable<Pointer<T>>
{
public Pointer<DynamicVectorClass<Pointer<T>>> Pointer;
public ref DynamicVectorClass<Pointer<T>> Array { get => ref Pointer.Ref; }
public GLOBAL_DVC_ARRAY(IntPtr pVector)
{
Pointer = pVector;
}
public Pointer<T> Find(string ID)
{
int idx = FindIndex(ID);
if (idx >= 0)
{
return Array.Get(idx);
}
return Pointer<T>.Zero;
}
public int FindIndex(string ID)
{
int i = 0;
foreach (var ptr in Array)
{
Pointer<AbstractTypeClass> pItem = ptr.Convert<AbstractTypeClass>();
if (pItem.Ref.ID == ID)
{
return i;
}
i++;
}
return -1;
}
public IEnumerator<Pointer<T>> GetEnumerator() => Array.GetEnumerator();
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}
public static Pointer<T>[] Finds<T>(this GLOBAL_DVC_ARRAY<T> dvc, IEnumerable<string> ts)
{
return ts.Select(id => dvc.Find(id)).ToArray();
}
public static int[] FindIndexes<T>(this GLOBAL_DVC_ARRAY<T> dvc, IEnumerable<string> ts)
{
return ts.Select(id => dvc.FindIndex(id)).ToArray();
}
static YRPP()
{
}
}
}