forked from doshyw/CelesteArchipelago
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDebugCommands.cs
175 lines (169 loc) · 7.5 KB
/
DebugCommands.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
using Monocle;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace Celeste.Mod.CelesteArchipelago
{
internal class DebugCommands
{
[Command("loadscreen", "loads a given level in an area + mode")]
private static void CmdLoadLevel(string sid, string room, string mode = "0")
{
if(!int.TryParse(mode, out var intMode))
{
return;
}
if (sid == null)
{
Engine.Commands.Log("Please specify a map ID or SID.");
return;
}
AreaData areaData = AreaData.Get(sid);
MapData mapData = null;
if (areaData?.Mode.Length > intMode)
{
mapData = ((areaData == null) ? null : areaData.Mode[intMode]?.MapData);
}
if (areaData == null)
{
Engine.Commands.Log("Map " + sid + " does not exist!");
return;
}
if (mapData == null)
{
Engine.Commands.Log($"Map {sid} has no {mode} mode!");
return;
}
if (room != null)
{
List<LevelData> levels = mapData.Levels;
if (levels != null && levels.All((LevelData level) => level.Name != room))
{
Engine.Commands.Log($"Map {sid} / mode {mode} has no room named {room}!");
return;
}
}
AreaKey areaKey = new AreaKey(areaData.ID, (AreaMode)intMode);
SaveData.Instance.LastArea_Safe = areaKey;
Session session = new Session(areaKey);
if (room != null && session.MapData.Get(room) != null)
{
if (AreaData.GetCheckpoint(areaKey, room) != null)
{
session = new Session(areaKey, room)
{
StartCheckpoint = null
};
}
else
{
session.Level = room;
}
session.StartedFromBeginning = (session.FirstLevel = room == session.MapData.StartLevel().Name);
}
Engine.Scene = new LevelLoader(session);
}
[Command("dumplocations", "dumps a file containing collectable screens")]
private static void CmdDumpLocations(string filename = "locations.txt")
{
try
{
ArchipelagoNetworkItem item;
string levelString, entityString, path;
List<string> lines = new List<string>();
lines.Add($"[8061000] Level 1 A-Side Crystal Heart : loadscreen Celeste/1-ForsakenCity s1 0");
using (var writer = new StreamWriter(filename))
{
MapData mapData;
for (int area = 0; area < AreaData.Areas.Count; area++)
{
for (int mode = 0; mode < AreaData.Areas[area].Mode.Count(); mode++)
{
levelString = $"Level {area} {"ABC"[mode]}-Side";
mapData = AreaData.Areas[area].Mode[mode].MapData;
path = AreaData.Areas[area].SID;
item = new ArchipelagoNetworkItem(CollectableType.COMPLETION, area, mode);
entityString = "Completion";
foreach (var level in mapData.Levels)
{
foreach (var entity in level.Entities)
{
switch(entity.Name)
{
case "blackGem":
item = new ArchipelagoNetworkItem(CollectableType.HEARTGEM, area, mode);
entityString = "Crystal Heart";
break;
case "cassette":
item = new ArchipelagoNetworkItem(CollectableType.CASSETTE, area, mode);
entityString = "Cassette";
break;
case "heartGemDoor":
item = new ArchipelagoNetworkItem(CollectableType.HEARTGEM, area, mode);
item.offset = 1;
entityString = "Crystal Heart Door";
break;
case "strawberry":
item = new ArchipelagoNetworkItem(CollectableType.STRAWBERRY, area, mode, new EntityID(entity.Level.Name, entity.ID));
entityString = $"Strawberry {item.offset + 1}";
break;
default: continue;
}
lines.Add($"[{item.ID}] {levelString} {entityString} : loadscreen {path} {level.Name} {mode}");
}
item = new ArchipelagoNetworkItem(CollectableType.COMPLETION, area, mode);
entityString = $"Completion : loadscreen {path} {level.Name} {mode}";
}
lines.Add($"[{item.ID}] {levelString} {entityString}");
}
}
lines.Sort(StringComparer.OrdinalIgnoreCase);
foreach (string line in lines)
{
writer.WriteLine(line.Substring(10));
}
}
}
catch(Exception e)
{
Engine.Commands.Log(e.ToString());
}
}
[Command("dumpallscreens", "dumps a file containing collectable screens")]
private static void CmdDumpAllScreens(string filename = "allscreens.txt")
{
Logger.Log("CelesteArchipelago", "Running dumpallscreens");
try
{
string levelString, path;
List<string> lines = new List<string>();
using (var writer = new StreamWriter(filename))
{
MapData mapData;
for (int area = 0; area < AreaData.Areas.Count; area++)
{
for (int mode = 0; mode < AreaData.Areas[area].Mode.Count(); mode++)
{
levelString = $"0;{area};{mode};";
mapData = AreaData.Areas[area].Mode[mode].MapData;
path = AreaData.Areas[area].SID;
foreach (var level in mapData.Levels)
{
lines.Add($"{levelString}{level.Name} : loadscreen {path} {level.Name} {mode}");
}
}
}
foreach (string line in lines)
{
writer.WriteLine(line);
}
}
}
catch (Exception e)
{
Engine.Commands.Log(e.ToString());
}
}
}
}