Beispiel #1
0
 public override void Load()
 {
     if (!Main.dedServ)
     {
         OwnerMusicInstance       = new Dictionary <int, MusicBase>();
         Languages.LanguageAction = new Action <List <(string, string[])> >(delegate { });
         Code.GetTypes().ForEach(delegate(Type type, int index)
         {
             if (type.IsClass)
             {
                 if (type.IsSubclassOf(typeof(MusicBase)))
                 {
                     (type.GetField("instanceIndex", BindingFlags.NonPublic | BindingFlags.Static) ??
                      throw new Exception($"{type.FullName} hasnot a static int insanceIndex field.")).SetValue(null, index);
                     OwnerMusicInstance.Add(index, (MusicBase)Activator.CreateInstance(type));
                 }
                 if (type.GetInterface(typeof(ILanguageLoad).Name) != null)
                 {
                     MethodInfo info           = type.GetMethod("LanguageAdd", BindingFlags.Public | BindingFlags.Instance);
                     Languages.LanguageAction += CreateTo <Action <List <(string, string[])> > >(info);
                 }
             }
             T CreateTo <T>(MethodInfo info) where T: Delegate => (T)info.CreateDelegate(typeof(T));
         }, true);
         DailyDay.Load();
         Main.OnPostDraw += MenuDraw.DrawCurrent;
     }
 }
Beispiel #2
0
 public override void Unload()
 {
     if (!Main.dedServ)
     {
         Languages.LanguageAction = null;
         DailyDay.Unload();
         Main.OnPostDraw -= MenuDraw.DrawCurrent;
     }
 }