예제 #1
0
파일: Program.cs 프로젝트: wty0512/Gnomodia
        static void Main()
        {
#if DEBUG
            // This helps us re-attach the debugger to the application on a restart
            if (!Debugger.IsAttached)
            {
                Thread.Sleep(500);
                Debugger.Launch();
            }
#endif

            // Make sure we know where Gnomoria is
            if (!VerifyOrConfigureGnomoriaInstallationPath())
            {
                return;
            }

            // Custom assembly resolving
            AppDomain.CurrentDomain.AssemblyResolve += (s, e) =>
            {
                var trgName = new AssemblyName(e.Name);
                if (trgName.Name == "Gnomoria")
                {
                    return(Assembly.Load(File.ReadAllBytes(Reference.GameDirectory.GetFile(Reference.OriginalExecutable).FullName)));
                }
                if (trgName.Name == "gnomorialib")
                {
                    return(Assembly.Load(File.ReadAllBytes(Reference.GameDirectory.GetFile(Reference.OriginalLibrary).FullName)));
                }
                return(null);
            };

            // Set up composition
            InitializeCompositionContainer();

            // Mod game
            GameModder gameModder = new GameModder();
            try
            {
                Container.ComposeParts(gameModder);
            }
            catch (ReflectionTypeLoadException e)
            {
                var exes = e.LoaderExceptions;
                foreach (var ex in exes)
                {
                    Trace.WriteLine(ex);
                }
            }
            gameModder.ModifyGnomoria();

            // Launch game
            GameLauncher.Run();
        }
예제 #2
0
        static void Main()
        {
            #if DEBUG
            // This helps us re-attach the debugger to the application on a restart
            if (!Debugger.IsAttached)
            {
                Thread.Sleep(500);
                Debugger.Launch();
            }
            #endif

            // Make sure we know where Gnomoria is
            if (!VerifyOrConfigureGnomoriaInstallationPath())
                return;

            // Custom assembly resolving
            AppDomain.CurrentDomain.AssemblyResolve += (s, e) =>
            {
                var trgName = new AssemblyName(e.Name);
                if (trgName.Name == "Gnomoria")
                    return Assembly.Load(File.ReadAllBytes(Reference.GameDirectory.GetFile(Reference.OriginalExecutable).FullName));
                if (trgName.Name == "gnomorialib")
                    return Assembly.Load(File.ReadAllBytes(Reference.GameDirectory.GetFile(Reference.OriginalLibrary).FullName));
                return null;
            };

            // Set up composition
            InitializeCompositionContainer();

            // Mod game
            GameModder gameModder = new GameModder();
            try
            {
                Container.ComposeParts(gameModder);
            }
            catch (ReflectionTypeLoadException e)
            {
                var exes = e.LoaderExceptions;
                foreach (var ex in exes)
                {
                    Trace.WriteLine(ex);
                }
            }
            gameModder.ModifyGnomoria();

            // Launch game
            GameLauncher.Run();
        }