diff options
-rw-r--r-- | Temple of Starlight.asl | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/Temple of Starlight.asl b/Temple of Starlight.asl new file mode 100644 index 0000000..eb06656 --- /dev/null +++ b/Temple of Starlight.asl | |||
@@ -0,0 +1,93 @@ | |||
1 | // AutoSplit script for Temple of Starlight, by hatkirby | ||
2 | |||
3 | state("Temple of Starlight") {} | ||
4 | |||
5 | startup { | ||
6 | // Relative to Livesplit.exe | ||
7 | vars.logFilePath = Directory.GetCurrentDirectory() + "\\autosplitter_starlight.log"; | ||
8 | vars.log = (Action<string>)((string logLine) => { | ||
9 | print("[Temple of Starlight ASL] " + logLine); | ||
10 | string time = System.DateTime.Now.ToString("dd/MM/yy hh:mm:ss.fff"); | ||
11 | // AppendAllText will create the file if it doesn't exist. | ||
12 | System.IO.File.AppendAllText(vars.logFilePath, time + ": " + logLine + "\r\n"); | ||
13 | }); | ||
14 | |||
15 | var bytes = File.ReadAllBytes(@"Components\LiveSplit.ASLHelper.bin"); | ||
16 | var type = Assembly.Load(bytes).GetType("ASLHelper.Unity"); | ||
17 | vars.Helper = Activator.CreateInstance(type, timer, this); | ||
18 | vars.Helper.LoadSceneManager = true; | ||
19 | |||
20 | vars.prevLevel = 0; | ||
21 | vars.prev = new List<int>(); | ||
22 | vars.firstRoom = false; | ||
23 | |||
24 | vars.noSplitScenes = new List<String>{ | ||
25 | "StartScene", | ||
26 | "LevelSelect" | ||
27 | }; | ||
28 | |||
29 | vars.log("Autosplitter loaded"); | ||
30 | } | ||
31 | |||
32 | init { | ||
33 | vars.Helper.TryOnLoad = (Func<dynamic, bool>)(mono => | ||
34 | { | ||
35 | return true; | ||
36 | }); | ||
37 | |||
38 | vars.Helper.Load(); | ||
39 | } | ||
40 | |||
41 | update { | ||
42 | if (!vars.Helper.Update()) | ||
43 | return false; | ||
44 | |||
45 | current.level = vars.Helper.Scenes.Active.Index; | ||
46 | } | ||
47 | |||
48 | onStart { | ||
49 | vars.prevLevel = current.level; | ||
50 | vars.prev.Clear(); | ||
51 | vars.firstRoom = false; | ||
52 | } | ||
53 | |||
54 | split { | ||
55 | // Split when level index changes. We don't split for the first room change | ||
56 | // in a run, because that is always going to be changing to the first room, | ||
57 | // and it happens a couple of seconds after the timer starts. | ||
58 | if (vars.firstRoom | ||
59 | && current.level != vars.prevLevel | ||
60 | && current.level > 0 | ||
61 | && !vars.noSplitScenes.Contains(vars.Helper.Scenes.Active.Name)) { | ||
62 | vars.log(String.Format("{0}: '{1}'", current.level, vars.Helper.Scenes.Active.Name)); | ||
63 | |||
64 | string action = "NO SPLIT"; | ||
65 | |||
66 | if (vars.prevLevel != 0) { | ||
67 | action = "SPLIT"; | ||
68 | |||
69 | if (vars.prev.Contains(current.level)) { | ||
70 | action = "NO SPLIT"; | ||
71 | } | ||
72 | vars.prev.Add(current.level); | ||
73 | vars.log(String.Format("Level changed from {0} to {1}: {2}", vars.prevLevel, current.level, action)); | ||
74 | } | ||
75 | |||
76 | vars.prevLevel = current.level; | ||
77 | return action.StartsWith("SPLIT"); | ||
78 | } else if (!vars.firstRoom && vars.Helper.Scenes.Active.Name == "Level01") { | ||
79 | vars.firstRoom = true; | ||
80 | vars.prevLevel = current.level; | ||
81 | vars.prev.Add(current.level); | ||
82 | } | ||
83 | } | ||
84 | |||
85 | exit | ||
86 | { | ||
87 | vars.Helper.Dispose(); | ||
88 | } | ||
89 | |||
90 | shutdown | ||
91 | { | ||
92 | vars.Helper.Dispose(); | ||
93 | } | ||