Elin Decompiled Documentation EA 23.300 Nightly
Loading...
Searching...
No Matches
ModManager Class Reference
Inheritance diagram for ModManager:

Public Member Functions

override void Init (string path, string defaultPackage="_Elona")
 
void SaveLoadOrder ()
 
void LoadLoadOrder ()
 
void ImportSourceLocalizations (string lang)
 
void ImportAllModSourceSheets ()
 
void ImportAllModDialogs ()
 
void ImportAllModGodTalks ()
 
IEnumerator RefreshMods (Action onComplete, bool syncMods)
 
ModPackage AddPackage (DirectoryInfo dir, bool isInPackages=false)
 
ModPackage AddWorkshopPackage (WorkshopItem item, bool isInPackages=false)
 
int CountUserMod ()
 
void LoadLocalPackages ()
 
void LoadCustomPackage ()
 
IEnumerator LoadWorkshopPackages ()
 
void InitPackagesMeta ()
 
void ActivatePackages ()
 
override void ParseExtra (DirectoryInfo dir, BaseModPackage package)
 

Public Attributes

List< FileInfo > replaceFiles = new List<FileInfo>()
 

Static Public Attributes

static List< object > ListPluginObject = new List<object>()
 
static bool disableMod
 

Properties

static List< string > ListChainLoad [get]
 
static DirectoryInfo DirWorkshop [get]
 
static new ModManager Instance [get]
 
static bool IsInitialized [get]
 

Private Member Functions

IEnumerator UpdateWorkshopPackages ()
 

Private Attributes

LoadingScreen _loading
 
Action ImportModGodTalks
 

Detailed Description

Definition at line 14 of file ModManager.cs.

Member Function Documentation

◆ ActivatePackages()

void ModManager.ActivatePackages ( )
inline

Definition at line 498 of file ModManager.cs.

499 {
501 ListPluginObject.Clear();
502 foreach (ModPackage package in packages)
503 {
504 if ((disableMod && !package.builtin) || !package.IsValidVersion())
505 {
506 continue;
507 }
508 try
509 {
510 package.Activate();
511 if (package.activated)
512 {
513 BaseModManager.listChainLoad.Add(package.dirInfo.FullName);
514 }
515 }
516 catch (Exception ex)
517 {
518 _loading.Log("Failed to activate mod: " + package.title + ", reason: " + ex.Message);
519 }
520 }
523 }
static List< string > listChainLoad
Text Log(string s)
LoadingScreen _loading
Definition: ModManager.cs:20
static bool disableMod
Definition: ModManager.cs:18
static List< object > ListPluginObject
Definition: ModManager.cs:16
static void OnModsActivated()
Definition: ModUtil.cs:23
static void LoadTypeFallback()
Definition: ModUtil.cs:37

References _loading, disableMod, BaseModManager.listChainLoad, ListPluginObject, ModUtil.LoadTypeFallback(), LoadingScreen.Log(), and ModUtil.OnModsActivated().

Referenced by RefreshMods().

◆ AddPackage()

ModPackage ModManager.AddPackage ( DirectoryInfo  dir,
bool  isInPackages = false 
)
inline

Definition at line 338 of file ModManager.cs.

339 {
340 ModPackage modPackage = new ModPackage
341 {
342 dirInfo = dir,
343 installed = true,
344 isInPackages = isInPackages,
345 loadPriority = priorityIndex,
346 Mapping = new FileMapping(dir)
347 };
348 packages.Add(modPackage);
349 priorityIndex++;
350 return modPackage;
351 }

References installed.

Referenced by AddWorkshopPackage(), LoadLocalPackages(), and RefreshMods().

◆ AddWorkshopPackage()

ModPackage ModManager.AddWorkshopPackage ( WorkshopItem  item,
bool  isInPackages = false 
)
inline

Definition at line 353 of file ModManager.cs.

354 {
355 ulong sizeOnDisk;
356 string folderPath;
357 DateTime timeStamp;
358 bool itemInstallInfo = UserGeneratedContent.Client.GetItemInstallInfo(item.FileId, out sizeOnDisk, out folderPath, out timeStamp);
359 DirectoryInfo directoryInfo = new DirectoryInfo(folderPath);
360 if (!directoryInfo.Exists)
361 {
362 return null;
363 }
364 ModPackage modPackage = AddPackage(directoryInfo, isInPackages);
365 modPackage.installed = itemInstallInfo;
366 modPackage.banned = item.IsBanned;
367 return modPackage;
368 }
ModPackage AddPackage(DirectoryInfo dir, bool isInPackages=false)
Definition: ModManager.cs:338

References AddPackage(), and item.

Referenced by LoadWorkshopPackages().

◆ CountUserMod()

int ModManager.CountUserMod ( )
inline

Definition at line 370 of file ModManager.cs.

371 {
372 return packages.Count((BaseModPackage p) => !p.builtin);
373 }

References BaseModPackage.builtin.

Referenced by LayerTitle.OnClickContinue(), and LayerTitle.OnClickStart().

◆ ImportAllModDialogs()

void ModManager.ImportAllModDialogs ( )
inline

Definition at line 232 of file ModManager.cs.

233 {
234 Lang.extraExcelDialogs = new HashSet<string>(PathComparer.Default);
235 Lang.excelDialog = null;
236 FileInfo[] files = PackageIterator.GetFiles("Dialog/dialog.xlsx");
237 foreach (FileInfo fileInfo in files)
238 {
239 Lang.extraExcelDialogs.Add(fileInfo.FullName);
240 Debug.Log("#dialog loaded " + fileInfo.ShortPath());
241 }
242 }
Definition: Lang.cs:6
static HashSet< string > extraExcelDialogs
Definition: Lang.cs:62

References Debug, and Lang.extraExcelDialogs.

Referenced by Init().

◆ ImportAllModGodTalks()

void ModManager.ImportAllModGodTalks ( )
inline

Definition at line 244 of file ModManager.cs.

245 {
246 if (Lang.setting?.dir == null)
247 {
248 return;
249 }
250 Dictionary<string, Dictionary<string, string>> map = EClass.sources.dataGodTalk.sheets["_default"].map;
251 foreach (ExcelData item in from f in PackageIterator.GetFiles("Data/god_talk.xlsx")
252 select new ExcelData(f.FullName, 3))
253 {
254 foreach (KeyValuePair<string, Dictionary<string, string>> item2 in map)
255 {
256 item2.Deconstruct(out var key, out var _);
257 string text = key;
258 if (text.IsEmpty())
259 {
260 continue;
261 }
262 Dictionary<string, string> valueOrDefault = item.sheets["_default"].map.GetValueOrDefault(text);
263 if (valueOrDefault == null)
264 {
265 continue;
266 }
267 foreach (KeyValuePair<string, string> item3 in valueOrDefault)
268 {
269 item3.Deconstruct(out key, out var value2);
270 string text2 = key;
271 string value3 = value2;
272 if (text2 != "id")
273 {
274 map[text][text2] = value3;
275 }
276 }
277 }
278 Debug.Log("#dialog loaded " + item.path.ShortPath());
279 }
280 }
Definition: EClass.cs:6
static SourceManager sources
Definition: EClass.cs:43
Dictionary< string, Sheet > sheets
Definition: ExcelData.cs:25
string dir
Definition: LangSetting.cs:28
static LangSetting setting
Definition: Lang.cs:54
ExcelData dataGodTalk

References SourceManager.dataGodTalk, Debug, LangSetting.dir, item, Lang.setting, ExcelData.sheets, and EClass.sources.

◆ ImportAllModSourceSheets()

void ModManager.ImportAllModSourceSheets ( )
inline

Definition at line 194 of file ModManager.cs.

195 {
196 try
197 {
198 SourceCache.InvalidateCacheVersion();
200 {
202 EClass.sources.materials
203 });
204 List<string> list = new List<string>();
205 foreach (ModPackage item in packages.OfType<ModPackage>())
206 {
207 if (item.builtin || !item.activated)
208 {
209 continue;
210 }
211 foreach (FileInfo sourceSheet in item.Mapping.SourceSheets)
212 {
213 if (!sourceSheet.Name.StartsWith(".") && !sourceSheet.Name.Contains("~"))
214 {
215 ModUtil.sourceImporter.fileProviders[sourceSheet.FullName] = item;
216 list.Add(sourceSheet.FullName);
217 }
218 }
219 }
221 SourceCache.FinalizeCache();
222 SourceCache.InvalidateCacheBlobs();
223 SourceCache.ClearDetail();
224 }
225 catch (Exception message)
226 {
227 Debug.LogError(message);
228 }
229 Debug.Log("#source finished importing workbooks");
230 }
static SourceImporter sourceImporter
Definition: ModUtil.cs:15
IEnumerable< SourceData > ImportFilesCached(IEnumerable< string > imports, bool resetData=true)
static void HotInit(IEnumerable< SourceData > sourceData)
Dictionary< string, EMod > fileProviders
SourceElement elements

References Debug, SourceManager.elements, SourceImporter.fileProviders, SourceImporter.HotInit(), SourceImporter.ImportFilesCached(), item, ModUtil.sourceImporter, and EClass.sources.

Referenced by SourceManager.Init().

◆ ImportSourceLocalizations()

void ModManager.ImportSourceLocalizations ( string  lang)
inline

Definition at line 116 of file ModManager.cs.

117 {
118 PackageIterator.RebuildAllMappings(lang);
119 SortedDictionary<string, string> sortedDictionary = new SortedDictionary<string, string>();
120 Dictionary<string, SortedDictionary<string, string>> dictionary = new Dictionary<string, SortedDictionary<string, string>>();
121 string value;
122 string key;
123 foreach (string item in FileMapping.FallbackLut[lang].Append(lang).Distinct())
124 {
125 (FileInfo, EMod)[] filesEx = PackageIterator.GetFilesEx(item + "/SourceLocalization.json", useCache: false);
126 for (int i = 0; i < filesEx.Length; i++)
127 {
128 var (fileInfo, eMod) = filesEx[i];
129 try
130 {
131 SortedDictionary<string, string> sortedDictionary2 = IO.LoadFile<SortedDictionary<string, string>>(fileInfo.FullName);
132 foreach (KeyValuePair<string, string> item2 in sortedDictionary2)
133 {
134 item2.Deconstruct(out value, out key);
135 string key2 = value;
136 string value2 = key;
137 sortedDictionary[key2] = value2;
138 }
139 dictionary[eMod.id] = sortedDictionary2;
140 }
141 catch (Exception arg)
142 {
143 Debug.LogError($"#source localization failed to load {fileInfo.ShortPath()}\n{arg}");
144 }
145 }
146 }
147 JsonSerializerSettings setting = new JsonSerializerSettings
148 {
149 PreserveReferencesHandling = PreserveReferencesHandling.None,
150 NullValueHandling = NullValueHandling.Ignore
151 };
152 foreach (BaseModPackage package in packages)
153 {
154 if (!(package is ModPackage modPackage) || package.builtin || !package.activated)
155 {
156 continue;
157 }
158 HashSet<SourceData.BaseRow> sourceRows = modPackage.sourceRows;
159 if (sourceRows == null || sourceRows.Count <= 0)
160 {
161 continue;
162 }
163 modPackage.ImportSourceLocalizations(sortedDictionary);
164 if (!ModManagerCore.generateLocalizations || (!modPackage.isInPackages && !Application.isEditor))
165 {
166 continue;
167 }
168 try
169 {
170 SortedDictionary<string, string> sortedDictionary3 = dictionary.GetValueOrDefault(modPackage.id) ?? new SortedDictionary<string, string>();
171 SortedDictionary<string, string> sortedDictionary4 = modPackage.ExportSourceLocalizations();
172 SortedDictionary<string, string> final = new SortedDictionary<string, string>();
173 foreach (KeyValuePair<string, string> item3 in sortedDictionary4)
174 {
175 item3.Deconstruct(out key, out value);
176 string key3 = key;
177 string defaultValue = value;
178 final[key3] = sortedDictionary3.GetValueOrDefault(key3, defaultValue);
179 }
180 if (sortedDictionary3.Count != final.Count || sortedDictionary3.Any((KeyValuePair<string, string> kv) => !final.ContainsKey(kv.Key)))
181 {
182 string path = Path.Combine(modPackage.dirInfo.FullName, "LangMod/" + lang + "/SourceLocalization.json");
183 IO.SaveFile(path, final, compress: false, setting);
184 Debug.Log($"#source localization updated {path.ShortPath()} / {modPackage}");
185 }
186 }
187 catch (Exception arg2)
188 {
189 Debug.LogError($"#source localization failed to generate {modPackage}\n{arg2}");
190 }
191 }
192 }
$
Definition: ModManager.cs:87
Definition: IO.cs:11
static void SaveFile(string path, object obj, bool compress=false, JsonSerializerSettings setting=null)
Definition: IO.cs:89

References $, BaseModPackage.activated, Debug, and item.

◆ Init()

override void ModManager.Init ( string  path,
string  defaultPackage = "_Elona" 
)
inline

Definition at line 34 of file ModManager.cs.

35 {
36 base.Init(path, defaultPackage);
37 Debug.Log("IsOffline:" + BaseCore.IsOffline);
38 IniData elinIni = Core.GetElinIni();
39 if (elinIni != null)
40 {
42 {
43 string key = elinIni.GetKey("path_workshop");
44 if (!key.IsEmpty())
45 {
46 dirWorkshop = new DirectoryInfo(key);
47 }
48 }
49 else
50 {
51 string path2 = Path.Combine(App.Client.GetAppInstallDirectory(SteamSettings.behaviour.settings.applicationId), "../../workshop/content/2135150");
52 dirWorkshop = new DirectoryInfo(path2);
53 elinIni.Global["path_workshop"] = dirWorkshop.FullName;
54 Core.SaveElinIni(elinIni);
55 }
56 }
57 if (!dirWorkshop.Exists)
58 {
59 dirWorkshop = null;
60 }
61 Debug.Log("Workshop:" + dirWorkshop);
62 Debug.Log("Packages:" + BaseModManager.rootMod);
63 Debug.Log("Core Mod:" + BaseModManager.rootDefaultPacakge);
64 BaseModManager.SubscribeEvent("elin.source.lang_set", delegate(object lang)
65 {
66 if (ModManagerCore.useLocalizations)
67 {
68 ImportSourceLocalizations(lang as string);
69 ModManagerCore.generateLocalizations = false;
70 }
72 BookList.dict = null;
73 });
74 }
static bool IsOffline
Definition: BaseCore.cs:9
static string rootDefaultPacakge
static string rootMod
static void SubscribeEvent(string eventId, Action< object > handler)
Definition: Core.cs:14
static void SaveElinIni(IniData ini)
Definition: Core.cs:813
static IniData GetElinIni()
Definition: Core.cs:779
void ImportAllModDialogs()
Definition: ModManager.cs:232

References Debug, Core.GetElinIni(), ImportAllModDialogs(), BaseCore.IsOffline, BaseModManager.rootDefaultPacakge, BaseModManager.rootMod, Core.SaveElinIni(), and BaseModManager.SubscribeEvent().

Referenced by CoreDebug.RegenerateNames(), and Core.StartCase().

◆ InitPackagesMeta()

void ModManager.InitPackagesMeta ( )
inline

Definition at line 478 of file ModManager.cs.

479 {
480 foreach (BaseModPackage package in packages)
481 {
482 try
483 {
484 if (package.Init())
485 {
486 mappedPackages[package.id] = package as ModPackage;
487 }
488 _loading?.Log(package.ToString());
489 }
490 catch (Exception ex)
491 {
492 package.willActivate = false;
493 _loading?.Log("Mod " + package.title + "/" + package.id + " has failed to initialize, reason: " + ex.Message);
494 }
495 }
496 }

References _loading, BaseModPackage.id, BaseModPackage.Init(), LoadingScreen.Log(), and BaseModPackage.title.

Referenced by RefreshMods().

◆ LoadCustomPackage()

void ModManager.LoadCustomPackage ( )
inline

Definition at line 390 of file ModManager.cs.

391 {
392 _loading.Log("Loading user Custom...");
393 DirectoryInfo[] directories = new DirectoryInfo(CorePath.custom).GetDirectories();
394 ModPackage package = new ModPackage();
395 DirectoryInfo[] array = directories;
396 foreach (DirectoryInfo dir in array)
397 {
398 ParseExtra(dir, package);
399 }
400 }
static string custom
Definition: CorePath.cs:159

References _loading, CorePath.custom, and LoadingScreen.Log().

Referenced by RefreshMods().

◆ LoadLoadOrder()

void ModManager.LoadLoadOrder ( )
inline

Definition at line 87 of file ModManager.cs.

88 {
89 string path = CorePath.rootExe + "loadorder.txt";
90 if (!File.Exists(path))
91 {
92 return;
93 }
94 Dictionary<string, BaseModPackage> dictionary = new Dictionary<string, BaseModPackage>();
95 foreach (BaseModPackage package in packages)
96 {
97 if (!package.builtin)
98 {
99 dictionary[package.dirInfo.FullName] = package;
100 }
101 }
102 int num = 0;
103 string[] array = File.ReadAllLines(path);
104 for (int i = 0; i < array.Length; i++)
105 {
106 string[] array2 = array[i].Split(',');
107 if (dictionary.TryGetValue(array2[0], out var value))
108 {
109 value.loadPriority = num;
110 value.willActivate = array2[1] == "1";
111 }
112 num++;
113 }
114 }
DirectoryInfo dirInfo

References BaseModPackage.builtin, and BaseModPackage.dirInfo.

Referenced by RefreshMods().

◆ LoadLocalPackages()

void ModManager.LoadLocalPackages ( )
inline

Definition at line 375 of file ModManager.cs.

376 {
377 _loading.Log("Loading local Package...");
378 DirectoryInfo[] directories = new DirectoryInfo(BaseModManager.rootMod).GetDirectories();
379 Array.Reverse(directories);
380 DirectoryInfo[] array = directories;
381 foreach (DirectoryInfo directoryInfo in array)
382 {
383 if (!disableMod || !(directoryInfo.Name != "_Elona") || !(directoryInfo.Name != "_Lang_Chinese"))
384 {
385 AddPackage(directoryInfo, isInPackages: true);
386 }
387 }
388 }

References _loading, AddPackage(), disableMod, LoadingScreen.Log(), and BaseModManager.rootMod.

Referenced by RefreshMods().

◆ LoadWorkshopPackages()

IEnumerator ModManager.LoadWorkshopPackages ( )
inline

Definition at line 402 of file ModManager.cs.

403 {
404 WaitForEndOfFrame awaiter = new WaitForEndOfFrame();
405 UgcQuery activeQuery = UgcQuery.GetSubscribed(withLongDescription: false, withMetadata: false, withKeyValueTags: false, withAdditionalPreviews: false, 0u);
406 activeQuery.Execute(HandleWorkshopQuery);
407 _loading.Log("Fetching subscriptions...(Hit ESC to cancel)");
408 while (activeQuery.handle != UGCQueryHandle_t.Invalid && !UnityEngine.Input.GetKey(KeyCode.Escape))
409 {
410 yield return awaiter;
411 }
412 yield return UpdateWorkshopPackages();
413 void HandleWorkshopQuery(UgcQuery query)
414 {
415 foreach (WorkshopItem results in query.ResultsList)
416 {
417 AddWorkshopPackage(results);
418 }
419 }
420 }
ModPackage AddWorkshopPackage(WorkshopItem item, bool isInPackages=false)
Definition: ModManager.cs:353
IEnumerator UpdateWorkshopPackages()
Definition: ModManager.cs:422

References _loading, AddWorkshopPackage(), LoadingScreen.Log(), and UpdateWorkshopPackages().

Referenced by RefreshMods().

◆ ParseExtra()

override void ModManager.ParseExtra ( DirectoryInfo  dir,
BaseModPackage  package 
)
inline

Definition at line 525 of file ModManager.cs.

526 {
527 ModPackage modPackage = (ModPackage)package;
528 switch (dir.Name)
529 {
530 case "TalkText":
531 modPackage.ParseTalkText(dir);
532 break;
533 case "Map":
534 if (!package.builtin)
535 {
536 modPackage.ParseMap(dir);
537 }
538 break;
539 case "Map Piece":
540 if (!package.builtin)
541 {
542 modPackage.ParseMapPiece(dir);
543 }
544 break;
545 case "Texture Replace":
546 replaceFiles.AddRange(modPackage.ParseTextureReplace(dir));
547 break;
548 case "Texture":
549 modPackage.ParseTexture(dir);
550 break;
551 case "Portrait":
552 modPackage.ParsePortrait(dir);
553 break;
554 case "LangMod":
555 modPackage.ParseLangMod(dir);
556 break;
557 case "Sound":
558 modPackage.ParseSound(dir);
559 break;
560 case "Lang":
561 modPackage.AddOrUpdateLang(dir);
562 break;
563 }
564 }
List< FileInfo > replaceFiles
Definition: ModManager.cs:22
IReadOnlyList< FileInfo > ParseTalkText(DirectoryInfo dir)
Definition: ModPackage.cs:18
void ParseLangMod(DirectoryInfo dir)
Definition: ModPackage.cs:153
IReadOnlyList< FileInfo > ParseTexture(DirectoryInfo dir)
Definition: ModPackage.cs:95
void AddOrUpdateLang(DirectoryInfo dir)
Definition: ModPackage.cs:237
IReadOnlyList< FileInfo > ParseMapPiece(DirectoryInfo dir, bool addToList=true)
Definition: ModPackage.cs:57
IReadOnlyList< FileInfo > ParseTextureReplace(DirectoryInfo dir)
Definition: ModPackage.cs:78
IReadOnlyList< FileInfo > ParsePortrait(DirectoryInfo dir)
Definition: ModPackage.cs:115
IReadOnlyList< FileInfo > ParseMap(DirectoryInfo dir, bool addToList=true)
Definition: ModPackage.cs:36
IReadOnlyList< FileInfo > ParseSound(DirectoryInfo dir)
Definition: ModPackage.cs:168

References ModPackage.AddOrUpdateLang(), BaseModPackage.builtin, ModPackage.ParseLangMod(), ModPackage.ParseMap(), ModPackage.ParseMapPiece(), ModPackage.ParsePortrait(), ModPackage.ParseSound(), ModPackage.ParseTalkText(), ModPackage.ParseTexture(), ModPackage.ParseTextureReplace(), and replaceFiles.

◆ RefreshMods()

IEnumerator ModManager.RefreshMods ( Action  onComplete,
bool  syncMods 
)
inline

Definition at line 282 of file ModManager.cs.

283 {
284 bool flag = !BaseCore.IsOffline && syncMods && UserGeneratedContent.Client.GetNumSubscribedItems() != 0;
285 _loading = Util.Instantiate<LoadingScreen>("LoadingScreen");
286 WaitForEndOfFrame awaiter = new WaitForEndOfFrame();
287 packages.Clear();
288 disableMod |= Application.isEditor && EClass.debug.skipMod;
291 if (!disableMod)
292 {
293 _loading.Log("Loading workshop contents...");
294 if (flag)
295 {
296 yield return LoadWorkshopPackages();
297 }
298 else if (dirWorkshop != null)
299 {
300 DirectoryInfo[] directories = dirWorkshop.GetDirectories();
301 foreach (DirectoryInfo dir in directories)
302 {
303 AddPackage(dir);
304 }
305 }
306 }
309 packages.Sort((BaseModPackage a, BaseModPackage b) => a.loadPriority - b.loadPriority);
310 foreach (BaseModPackage item in packages.Where((BaseModPackage p) => !p.isInPackages && p.willActivate && !p.id.IsEmpty()))
311 {
312 if (mappedPackages.TryGetValue(item.id, out var value) && value.isInPackages)
313 {
314 value.hasPublishedPackage = true;
315 }
316 }
317 _loading.Log($"Total number of mods:{packages.Count}");
318 _loading.Log("Activating Mods...");
319 yield return awaiter;
321 foreach (BaseModPackage package in packages)
322 {
323 if (package.activated)
324 {
325 mappedPackages[package.id] = package as ModPackage;
326 }
327 }
328 BaseModManager.isInitialized = true;
329 yield return awaiter;
330 onComplete?.Invoke();
331 if ((bool)_loading)
332 {
333 UnityEngine.Object.Destroy(_loading.gameObject);
334 }
335 yield return null;
336 }
bool skipMod
Definition: CoreDebug.cs:134
static CoreDebug debug
Definition: EClass.cs:49
void ActivatePackages()
Definition: ModManager.cs:498
void LoadLoadOrder()
Definition: ModManager.cs:87
void LoadCustomPackage()
Definition: ModManager.cs:390
IEnumerator LoadWorkshopPackages()
Definition: ModManager.cs:402
void LoadLocalPackages()
Definition: ModManager.cs:375
void InitPackagesMeta()
Definition: ModManager.cs:478
Definition: Util.cs:10
static Transform Instantiate(string path, Component parent=null)
Definition: Util.cs:67

References $, _loading, BaseModPackage.activated, ActivatePackages(), AddPackage(), EClass.debug, disableMod, BaseModPackage.id, InitPackagesMeta(), BaseModPackage.isInPackages, item, LoadCustomPackage(), LoadLoadOrder(), LoadLocalPackages(), BaseModPackage.loadPriority, LoadWorkshopPackages(), LoadingScreen.Log(), CoreDebug.skipMod, Util, and BaseModPackage.willActivate.

Referenced by Core.StartCase().

◆ SaveLoadOrder()

void ModManager.SaveLoadOrder ( )
inline

Definition at line 76 of file ModManager.cs.

77 {
78 if (!disableMod)
79 {
80 List<string> contents = (from p in packages
81 where !p.builtin && p.dirInfo.Exists
82 select $"{p.dirInfo.FullName},{(p.willActivate ? 1 : 0)}").ToList();
83 File.WriteAllLines(CorePath.rootExe + "loadorder.txt", contents);
84 }
85 }
static string rootExe
Definition: CorePath.cs:168

References $, disableMod, and CorePath.rootExe.

Referenced by LayerMod.Move(), LayerMod.OnInit(), and LayerMod.OnKill().

◆ UpdateWorkshopPackages()

IEnumerator ModManager.UpdateWorkshopPackages ( )
inlineprivate

Definition at line 422 of file ModManager.cs.

423 {
424 _loading?.Log("Updating subscriptions...");
425 WaitForEndOfFrame awaiter = new WaitForEndOfFrame();
426 while (true)
427 {
428 bool flag = false;
429 foreach (BaseModPackage item in packages.Where((BaseModPackage p) => !p.installed))
430 {
431 if (!(item.item is WorkshopItem { IsBanned: false } workshopItem))
432 {
433 continue;
434 }
435 flag = true;
436 string text = "Downloading " + workshopItem.Title + ": ";
437 BaseModPackage baseModPackage = item;
438 if ((object)baseModPackage.progressText == null)
439 {
440 baseModPackage.progressText = _loading?.Log(text);
441 }
442 if (item.downloadStarted && workshopItem.DownloadCompletion >= 1f)
443 {
444 item.installed = true;
445 if ((bool)item.progressText)
446 {
447 item.progressText.text = text + "Done!";
448 }
449 }
450 else if (workshopItem.IsDownloading || workshopItem.IsDownloadPending)
451 {
452 int num = Mathf.FloorToInt(workshopItem.DownloadCompletion * 100f);
453 if ((bool)item.progressText)
454 {
455 item.progressText.text = text + num + "%";
456 }
457 }
458 else if (!item.downloadStarted)
459 {
460 item.downloadStarted = true;
461 workshopItem.DownloadItem(highPriority: true);
462 Debug.Log("Start downloading: " + workshopItem.Title + " | " + $"Installed={workshopItem.IsInstalled}, " + $"Downloading={workshopItem.IsDownloading}, " + $"Pending={workshopItem.IsDownloadPending}");
463 }
464 }
465 if (!flag)
466 {
467 yield break;
468 }
469 if (UnityEngine.Input.GetKey(KeyCode.Escape))
470 {
471 break;
472 }
473 yield return awaiter;
474 }
475 Debug.Log("Workshop updating cancelled");
476 }

References $, _loading, Debug, BaseModPackage.installed, item, LoadingScreen.Log(), and BaseModPackage.progressText.

Referenced by LoadWorkshopPackages().

Member Data Documentation

◆ _loading

◆ disableMod

bool ModManager.disableMod
static

◆ ImportModGodTalks

Action ModManager.ImportModGodTalks
private

Definition at line 24 of file ModManager.cs.

◆ ListPluginObject

List<object> ModManager.ListPluginObject = new List<object>()
static

Definition at line 16 of file ModManager.cs.

Referenced by ActivatePackages(), and Core.StartCase().

◆ replaceFiles

List<FileInfo> ModManager.replaceFiles = new List<FileInfo>()

Definition at line 22 of file ModManager.cs.

Referenced by TextureManager.Init(), and ParseExtra().

Property Documentation

◆ DirWorkshop

DirectoryInfo ModManager.DirWorkshop
staticget

Definition at line 28 of file ModManager.cs.

◆ Instance

new ModManager ModManager.Instance
staticget

Definition at line 30 of file ModManager.cs.

Referenced by SourceManager.Init().

◆ IsInitialized

bool ModManager.IsInitialized
staticget

Definition at line 32 of file ModManager.cs.

Referenced by Core.StartCase().

◆ ListChainLoad

List<string> ModManager.ListChainLoad
staticget

Definition at line 26 of file ModManager.cs.


The documentation for this class was generated from the following file: