Example #1
0
    internal void Load()
    {
        try
        {
            Assembly = Assembly.LoadFrom(Path.Combine(Directory, DLL));

            bool entry = false;
            foreach (Type t in Assembly.GetTypes())
            {
                if (t.GetInterfaces().Contains(typeof(IMod)))
                {
                    Mod   = (IMod)Activator.CreateInstance(t);
                    entry = true;
                    UnderMod.API.instance.GetLogger().Info("Loading mod: " + Name + " " + Version + " by " + Author + " | " + Tagline);
                    Mod.OnEntry();
                    break;
                }
            }
            if (!entry)
            {
                UnderMod.API.instance.GetLogger().Warn("Mod " + Name + " does not contain an entrypoint (implementation of UnderModAPI.Mod).");
            }
        } catch (Exception e)
        {
            UnderMod.API.instance.GetLogger().Error("Mod " + Name + " threw an error during OnEntry: " + e.Message);
        }
    }