-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKazeAndTheWildMasksMemory.cs
63 lines (47 loc) · 1.91 KB
/
KazeAndTheWildMasksMemory.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
using System;
using Voxif.AutoSplitter;
using Voxif.Helpers.Unity;
using Voxif.IO;
using Voxif.Memory;
namespace LiveSplit.KazeAndTheWildMasks {
public class KazeAndTheWildMasksMemory : Memory {
protected override string[] ProcessNames => new string[] { "Kaze and the Wild Masks" };
public StringPointer SceneName { get; private set; }
public Pointer<GameState> GameState { get; private set; }
public StringPointer LevelName { get; private set; }
private UnityHelperTask unityTask;
public KazeAndTheWildMasksMemory(Logger logger) : base(logger) {
OnHook += () => {
unityTask = new UnityHelperTask(game, logger);
unityTask.Run(InitPointers);
};
OnExit += () => {
if(unityTask != null) {
unityTask.Dispose();
unityTask = null;
}
};
}
private void InitPointers(IMonoHelper unity) {
MonoNestedPointerFactory ptrFactory = new MonoNestedPointerFactory(game, unity);
var scene = ptrFactory.Make<IntPtr>("SceneCore", "_instance", 0x10, 0x18, 0x30);
SceneName = ptrFactory.MakeString(scene, 0x10, 0x30, 0x60, 0x0);
SceneName.StringType = EStringType.UTF8;
GameState = ptrFactory.Make<GameState>(scene, 0x80);
LevelName = ptrFactory.MakeString(scene, 0x90, 0x10, 0x18, ptrFactory.StringHeaderSize);
LevelName.StringType = EStringType.AutoSized;
logger.Log(ptrFactory.ToString());
unityTask = null;
}
public override bool Update() => base.Update() && unityTask == null;
public bool SceneIs(string value) {
return SceneName.New.StartsWith(value, StringComparison.Ordinal);
}
}
public enum GameState {
Playing,
Paused,
None,
Finished
}
}