add Cs package check back and fix typos

This commit is contained in:
Evil Factory
2022-04-19 16:59:02 -03:00
parent edb6571aa2
commit 7a440e009b
@@ -18,7 +18,7 @@ namespace Barotrauma
{ {
class LuaCsSetupConfig class LuaCsSetupConfig
{ {
public bool FirstTimeCsWaring = true; public bool FirstTimeCsWarning = true;
public LuaCsSetupConfig() { } public LuaCsSetupConfig() { }
} }
@@ -413,13 +413,14 @@ namespace Barotrauma
lua.Globals["SERVER"] = IsServer; lua.Globals["SERVER"] = IsServer;
lua.Globals["CLIENT"] = IsClient; lua.Globals["CLIENT"] = IsClient;
CsScriptLoader = new CsScriptLoader(this);
CsScriptLoader.SearchFolders(); if (GetPackage("CsForBarotrauma", false) != null)
if (CsScriptLoader.HasSources)
{ {
if (Config.FirstTimeCsWaring) PrintMessage("Cs! Version " + AssemblyInfo.GitRevision);
if (Config.FirstTimeCsWarning)
{ {
Config.FirstTimeCsWaring = false; Config.FirstTimeCsWarning = false;
UpdateConfig(); UpdateConfig();
LuaCsTimer.Wait((args) => PrintCsError(@" LuaCsTimer.Wait((args) => PrintCsError(@"
@@ -427,7 +428,7 @@ namespace Barotrauma
WARNING! WARNING!
-- -- -- -- -- -- -- -- -- -- -- --
!Use of Cs Mods detected! !Cs Package Enabled!
Cs Mods are questionably Cs Mods are questionably
sandboxed, as they have sandboxed, as they have
@@ -440,10 +441,15 @@ modding needs.
"), 200); "), 200);
} }
CsScriptLoader = new CsScriptLoader(this);
CsScriptLoader.SearchFolders();
if (CsScriptLoader.HasSources)
{
try try
{ {
var modTypes = CsScriptLoader.Compile(); var modTypes = CsScriptLoader.Compile();
modTypes.ForEach(t => { modTypes.ForEach(t =>
{
UserData.RegisterType(t); UserData.RegisterType(t);
t.GetConstructor(new Type[] { })?.Invoke(null); t.GetConstructor(new Type[] { })?.Invoke(null);
}); });
@@ -452,8 +458,8 @@ modding needs.
{ {
HandleException(ex, exceptionType: ExceptionType.CSharp); HandleException(ex, exceptionType: ExceptionType.CSharp);
} }
}
PrintMessage("Cs! Version " + AssemblyInfo.GitRevision);
} }