Changed publicized assembly discovery to fallback to the alternate option if the /Pubicized folder cannot be found. IE. Workshop Lua folder if Game folder is missing and vice versa.

This commit is contained in:
MapleWheels
2023-09-29 03:51:05 -04:00
committed by Evil Factory
parent 3708e837e7
commit 40c8f3e666
@@ -298,15 +298,49 @@ public sealed class CsPackageManager : IDisposable
} }
ImmutableList<Assembly> publicizedAssemblies = ImmutableList<Assembly>.Empty; ImmutableList<Assembly> publicizedAssemblies = ImmutableList<Assembly>.Empty;
if (Directory.Exists(publicizedDir)) ImmutableList<string> list;
try
{ {
// search for assemblies // search for assemblies
var list = Directory.GetFiles(publicizedDir, "*.dll") list = Directory.GetFiles(publicizedDir, "*.dll")
#if CLIENT #if CLIENT
.Where(s => !s.ToLowerInvariant().EndsWith("dedicatedserver.dll")); .Where(s => !s.ToLowerInvariant().EndsWith("dedicatedserver.dll"))
#elif SERVER #elif SERVER
.Where(s => !s.ToLowerInvariant().EndsWith("barotrauma.dll")); .Where(s => !s.ToLowerInvariant().EndsWith("barotrauma.dll"))
#endif #endif
.ToImmutableList();
if (list.Count < 1)
throw new DirectoryNotFoundException("No publicized assemblies found.");
}
// no directory found, use the other one
catch (DirectoryNotFoundException dne)
{
if (_luaCsSetup.Config.PreferToUseWorkshopLuaSetup)
{
ModUtils.Logging.PrintError($"Unable to find <LuaCsPackage>/Binary/Publicized/ . Using Game folder instead.");
publicizedDir = Path.Combine(Environment.CurrentDirectory, "Publicized");
}
else
{
ModUtils.Logging.PrintError($"Unable to find <GameFolder>/Publicized/ . Using LuaCsPackage folder instead.");
var pck = LuaCsSetup.GetPackage(LuaCsSetup.LuaForBarotraumaId);
if (pck is not null)
{
publicizedDir = Path.Combine(pck.Dir, "Binary", "Publicized");
}
}
// search for assemblies
list = Directory.GetFiles(publicizedDir, "*.dll")
#if CLIENT
.Where(s => !s.ToLowerInvariant().EndsWith("dedicatedserver.dll"))
#elif SERVER
.Where(s => !s.ToLowerInvariant().EndsWith("barotrauma.dll"))
#endif
.ToImmutableList();
}
// try load them into an acl // try load them into an acl
var loadState = _assemblyManager.LoadAssembliesFromLocations(list, ref _publicizedAssemblyLoader); var loadState = _assemblyManager.LoadAssembliesFromLocations(list, ref _publicizedAssemblyLoader);
@@ -320,7 +354,6 @@ public sealed class CsPackageManager : IDisposable
_assemblyManager.SetACLToTemplateMode(_publicizedAssemblyLoader); _assemblyManager.SetACLToTemplateMode(_publicizedAssemblyLoader);
} }
} }
}
// get packages // get packages