Skip to content

Commit 5f3f1ef

Browse files
committed
chore: slight cleanup/formatting
1 parent 513f2b4 commit 5f3f1ef

File tree

2 files changed

+187
-146
lines changed

2 files changed

+187
-146
lines changed

Assembly-CSharp/ModLoader.cs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ Assembly Resolve(object sender, ResolveEventArgs args)
225225
var toPreload = new Dictionary<string, List<(ModInstance, List<string> objectNames)>>();
226226
// dict<scene name, list<(mod, list<objectNames>)>
227227
var preloadPrefabs = new Dictionary<string, List<(ModInstance, List<string> objectNames)>>();
228-
// dict<mod, dict<real scene name, scene naem in getpreloadobjects>>
228+
// dict<mod, dict<real scene name, scene name in getpreloadobjects>>
229229
var sceneNamesMap = new Dictionary<ModInstance, Dictionary<string, string>>();
230230
// dict<mod, dict<scene, dict<objName, object>>>
231231
var preloadedObjects = new Dictionary<ModInstance, Dictionary<string, Dictionary<string, GameObject>>>();
@@ -321,11 +321,8 @@ Dictionary<ModInstance, Dictionary<string, string>> sceneNamesMap
321321
// dict<scene, list<objects>>
322322
Dictionary<string, List<string>> prefabPreloads = new();
323323

324-
if (!sceneNamesMap.TryGetValue(mod, out var sceneNames))
325-
{
326-
sceneNames = new();
327-
sceneNamesMap[mod] = sceneNames;
328-
}
324+
if (!sceneNamesMap.TryGetValue(mod, out var sceneNames))
325+
sceneNamesMap[mod] = sceneNames = new Dictionary<string, string>();
329326

330327
foreach ((string scene, string obj) in preloadNames)
331328
{
@@ -341,28 +338,33 @@ Dictionary<ModInstance, Dictionary<string, string>> sceneNamesMap
341338
if (!sceneName.Equals("resources"))
342339
{
343340
if (!int.TryParse(sceneName.Substring(12), out var sceneId))
344-
{
345341
continue;
346-
}
342+
347343
if (sceneId >= UnityEngine.SceneManagement.SceneManager.sceneCountInBuildSettings)
348344
{
349345
Logger.APILogger.LogWarn(
350346
$"Mod `{mod.Mod.GetName()}` attempted preload from non-existent assets file `{scene}.assets`"
351347
);
352348
continue;
353349
}
354-
var origSceneName = sceneName;
350+
351+
string origSceneName = sceneName;
352+
355353
sceneName = Path.GetFileNameWithoutExtension(
356354
SceneUtility.GetScenePathByBuildIndex(sceneId)
357-
);
355+
);
356+
358357
sceneNames[sceneName] = origSceneName;
359358
}
359+
360360
if (!prefabPreloads.TryGetValue(sceneName, out List<string> prefabs))
361361
{
362362
prefabs = new List<string>();
363363
prefabPreloads[sceneName] = prefabs;
364364
}
365+
365366
prefabs.Add(obj);
367+
366368
Logger.APILogger.LogFine($"Found prefab `{scene}.{obj}`");
367369
continue;
368370
}
@@ -399,6 +401,7 @@ Dictionary<ModInstance, Dictionary<string, string>> sceneNamesMap
399401
scenePreloads.Add((mod, objects));
400402
toPreload[scene] = scenePreloads;
401403
}
404+
402405
foreach ((string scene, List<string> objects) in prefabPreloads)
403406
{
404407
if (!preloadedPrefabs.TryGetValue(scene, out var scenePreloads))
@@ -418,7 +421,9 @@ Dictionary<ModInstance, Dictionary<string, string>> sceneNamesMap
418421
private static void UpdateModText()
419422
{
420423
StringBuilder builder = new StringBuilder();
424+
421425
builder.AppendLine("Modding API: " + ModHooks.ModVersion);
426+
422427
foreach (ModInstance mod in ModInstances)
423428
{
424429
if (mod.Error is not ModErrorState err)

0 commit comments

Comments
 (0)