10 using Microsoft.Xna.Framework.Graphics;
14 namespace Loot.Api.Loaders
19 internal static class LoadingFunneler
21 internal static void Load()
30 ModSupportTunneler.AddServerSupport();
34 internal static void Unload()
37 Loot.IsLoaded =
false;
40 internal static void PostLoad()
42 RegistryLoader.ProcessMods();
45 Loot.ModContentManager.Load();
52 private static void LoadMod()
54 ModSupportTunneler.Init();
56 RegistryLoader.Initialize();
57 RegistryLoader.Load();
58 ContentLoader.Initialize();
63 private static void LoadModForClient()
68 Loot.ModContentManager.Initialize(
Loot.Instance);
70 Loot.Instance.GuiInterface =
new UserInterface();
71 Loot.Instance.GuiState =
new GuiTabWindow();
72 Loot.Instance.GuiState.Activate();
74 AssetLoader.RegisterAssets(
Loot.Instance,
"GraphicsAssets");
75 ModSupportTunneler.AddClientSupport();
78 private static void UnloadMod()
80 ContentLoader.Unload();
81 RegistryLoader.Unload();
82 Loot.ModContentManager?.Unload();
83 Loot.ModContentManager = null;
87 private static void LoadStaticAssets()
89 foreach (var mem
in ReflectUtils.GetStaticAssetTypes())
91 var attr = (StaticAssetAttribute)mem.GetCustomAttribute(typeof(StaticAssetAttribute));
92 Debug.Assert(attr != null);
93 if (mem is PropertyInfo prop && prop.PropertyType == typeof(Texture2D))
94 prop.SetValue(null, attr.LoadTexture2D());
95 if (mem is FieldInfo field && field.FieldType == typeof(Texture2D))
96 field.SetValue(null, attr.LoadTexture2D());
100 private static void UnloadStaticAssets()
102 foreach (var mem
in ReflectUtils.GetStaticAssetTypes())
104 if (!mem.GetType().IsValueType || Nullable.GetUnderlyingType(mem.GetType()) != null)
106 if (mem is PropertyInfo prop)
107 prop.SetValue(null, null);
108 if (mem is FieldInfo field)
109 field.SetValue(null, null);
114 private static void LoadILEdits()
116 foreach (var type
in ReflectUtils.GetILEdits())
119 ((ILEdit)Activator.CreateInstance(type)).Apply(Main.dedServ);
This class is responsible for managing instances of TextureModContent for registered mods...