44
55using System . IO ;
66
7- namespace GodotModules . ModLoader
7+ namespace GodotModules
88{
99 public class ModLoader
1010 {
11- public static List < Mod > LoadedMods = new List < Mod > ( ) ;
12- public static Dictionary < string , Mod > ModInfo = new Dictionary < string , Mod > ( ) ;
13- private static MoonSharpVsCodeDebugServer DebugServer { get ; set ; }
14- public static string PathModsEnabled { get ; set ; }
15- public static string PathMods { get ; set ; }
16- public static Script Script { get ; set ; }
17- public static string LuaScriptsPath = "" ;
18-
19- public static void Init ( )
11+ public List < Mod > LoadedMods = new List < Mod > ( ) ;
12+ public Dictionary < string , Mod > ModInfo = new Dictionary < string , Mod > ( ) ;
13+ private MoonSharpVsCodeDebugServer DebugServer { get ; set ; }
14+ public string PathModsEnabled { get ; set ; }
15+ public string PathMods { get ; set ; }
16+ public Script Script { get ; set ; }
17+ public string LuaScriptsPath = "" ;
18+
19+ public void Init ( )
2020 {
2121 PathMods = Path . Combine ( GameManager . GetGameDataPath ( ) , "Mods" ) ;
2222 PathModsEnabled = Path . Combine ( PathMods , "enabled.json" ) ;
@@ -33,7 +33,7 @@ public static void Init()
3333 SortMods ( ) ;
3434 }
3535
36- public static void SortMods ( )
36+ public void SortMods ( )
3737 {
3838 LoadedMods . Clear ( ) ;
3939 ModInfo = FindAllMods ( ) ;
@@ -57,7 +57,7 @@ public static void SortMods()
5757 } ) ;
5858 }
5959
60- public static void LoadMods ( )
60+ public void LoadMods ( )
6161 {
6262 UIModLoader . Instance . ClearLog ( ) ;
6363
@@ -83,7 +83,7 @@ public static void LoadMods()
8383 UIModLoader . Instance . Log ( $ "{ modLoadedCount } mods have loaded successfully") ;
8484 }
8585
86- private static void DisableModsWithLackingDependencies ( )
86+ private void DisableModsWithLackingDependencies ( )
8787 {
8888 var modsToDisable = new List < ModInfo > ( ) ;
8989
@@ -99,7 +99,7 @@ private static void DisableModsWithLackingDependencies()
9999 mod . Enabled = false ;
100100 }
101101
102- private static void CheckAllDependenciesEnabled ( ModInfo firstMod , ModInfo modInfo , List < string > checkedMods , ref List < ModInfo > modsToDisable )
102+ private void CheckAllDependenciesEnabled ( ModInfo firstMod , ModInfo modInfo , List < string > checkedMods , ref List < ModInfo > modsToDisable )
103103 {
104104 foreach ( var dependency in modInfo . Dependencies )
105105 {
@@ -117,7 +117,7 @@ private static void CheckAllDependenciesEnabled(ModInfo firstMod, ModInfo modInf
117117 }
118118 }
119119
120- public static void Call ( string v , params object [ ] args )
120+ public void Call ( string v , params object [ ] args )
121121 {
122122 try
123123 {
@@ -130,7 +130,7 @@ public static void Call(string v, params object[] args)
130130 }
131131 }
132132
133- public static void SetModsEnabled ( )
133+ public void SetModsEnabled ( )
134134 {
135135 var modsEnabled = new Dictionary < string , bool > ( ) ;
136136 foreach ( var mod in ModInfo )
@@ -139,7 +139,7 @@ public static void SetModsEnabled()
139139 File . WriteAllText ( PathModsEnabled , JsonConvert . SerializeObject ( modsEnabled , Formatting . Indented ) ) ;
140140 }
141141
142- public static void GetModsEnabled ( )
142+ public void GetModsEnabled ( )
143143 {
144144 if ( ! File . Exists ( PathModsEnabled ) )
145145 return ;
@@ -152,13 +152,13 @@ public static void GetModsEnabled()
152152 }
153153 }
154154
155- private static void Log ( object obj )
155+ private void Log ( object obj )
156156 {
157157 Logger . Log ( $ "[ModLoader]: { obj } ") ;
158158 UIModLoader . Instance . Log ( $ "{ obj } ") ;
159159 }
160160
161- private static void LoadLuaScripts ( string directory )
161+ private void LoadLuaScripts ( string directory )
162162 {
163163 GodotFileManager . LoadDir ( directory , ( dir , fileName ) =>
164164 {
@@ -182,15 +182,15 @@ private static void LoadLuaScripts(string directory)
182182 } ) ;
183183 }
184184
185- private static void SetupModsEnabled ( )
185+ private void SetupModsEnabled ( )
186186 {
187187 if ( File . Exists ( PathModsEnabled ) )
188188 return ;
189189
190190 File . WriteAllText ( PathModsEnabled , "{}" ) ;
191191 }
192192
193- private static Dictionary < string , Mod > FindAllMods ( )
193+ private Dictionary < string , Mod > FindAllMods ( )
194194 {
195195 var mods = new Dictionary < string , Mod > ( ) ;
196196 var modFolders = Directory . GetDirectories ( PathMods ) ;
@@ -233,13 +233,13 @@ private static Dictionary<string, Mod> FindAllMods()
233233 return mods ;
234234 }
235235
236- private static void AddDependencyToLoadedMods ( int modIndex , string dependency )
236+ private void AddDependencyToLoadedMods ( int modIndex , string dependency )
237237 {
238238 if ( ! LoadedMods . Contains ( ModInfo [ dependency ] ) )
239239 LoadedMods . Insert ( modIndex , ModInfo [ dependency ] ) ;
240240 }
241241
242- private static void LoadMod ( Mod mod , ref int modLoadedCount )
242+ private void LoadMod ( Mod mod , ref int modLoadedCount )
243243 {
244244 try
245245 {
@@ -255,15 +255,15 @@ private static void LoadMod(Mod mod, ref int modLoadedCount)
255255 }
256256 }
257257
258- private static bool ModHasName ( ModInfo modInfo ) => modInfo . Name != null ;
258+ private bool ModHasName ( ModInfo modInfo ) => modInfo . Name != null ;
259259
260- private static bool RequiredModFilesExist ( string folder , string pathInfo , string pathScriptLua ) => File . Exists ( pathInfo ) && File . Exists ( pathScriptLua ) ;
260+ private bool RequiredModFilesExist ( string folder , string pathInfo , string pathScriptLua ) => File . Exists ( pathInfo ) && File . Exists ( pathScriptLua ) ;
261261
262- private static bool IsModMissingDependency ( string dependency ) => ! ModInfo . ContainsKey ( dependency ) ;
262+ private bool IsModMissingDependency ( string dependency ) => ! ModInfo . ContainsKey ( dependency ) ;
263263
264- private static bool ModHasDependency ( string dependency ) => ModInfo . ContainsKey ( dependency ) ;
264+ private bool ModHasDependency ( string dependency ) => ModInfo . ContainsKey ( dependency ) ;
265265
266- private static bool ModHasAllDependenciesEnabled ( Mod mod )
266+ private bool ModHasAllDependenciesEnabled ( Mod mod )
267267 {
268268 var allDependenciesEnabled = true ;
269269
0 commit comments