private ModEntry GetMod(object target) { if (LowerAndIsEmpty(target, out string id)) { return(this); } return(ModScanner.GetModById(id)); }
private IEnumerable <Assembly> GetAssemblies(object target) { if (LowerAndIsEmpty(target, out string id)) { return(ModAssemblies ?? Enumerable.Empty <Assembly>()); } switch (id) { case "modnix": return(new Assembly[] { Assembly.GetExecutingAssembly() }); case "loader": var ppml = ModLoader.PpmlAssembly; var loaderList = new Assembly[ppml == null ? 1 : 2]; loaderList[0] = Assembly.GetExecutingAssembly(); if (ppml != null) { loaderList[1] = ppml; } return(loaderList); case "phoenixpointmodloader": case "phoenix point mod loader": case "ppml": return(new Assembly[] { ModLoader.PpmlAssembly }); case "phoenixpoint": case "phoenix point": case "game": if (GameAssembly == null) // No need to lock. No conflict. { GameAssembly = Array.Find(AppDomain.CurrentDomain.GetAssemblies(), e => e.FullName.StartsWith("Assembly-CSharp,")); } return(new Assembly[] { GameAssembly }); default: var mod = ModScanner.GetModById(id); if (mod == null) { return(null); } return(mod.ModAssemblies ?? Enumerable.Empty <Assembly>()); } }
private string GetPath(object target) { if (LowerAndIsEmpty(target, out string id)) { return(Path); } switch (id) { case "mods_root": return(ModLoader.ModDirectory); case "loader": case "modnix": return(ModLoader.LoaderPath); case "phoenixpoint": case "phoenix point": case "game": return(Process.GetCurrentProcess().MainModule?.FileName); default: return(ModScanner.GetModById(id)?.Path); } }