Exemplo n.º 1
0
        protected override void Perform(ModificationInfo info)
        {
            string source = Path.Combine(info.NuterraData, GalaxyAssemblyFile);
            string target = Path.Combine(info.TerraTechManaged, GalaxyAssemblyFile);

            File.Copy(source, target, overwrite: true);
        }
Exemplo n.º 2
0
        protected override void Perform(ModificationInfo info)
        {
            AssemblyResolver resolver = new AssemblyResolver();

            resolver.PreSearchPaths.Add(info.TerraTechManaged);
            info.AssemblyCSharp = ModuleDefMD.Load(info.CleanAssemblyPath);
        }
Exemplo n.º 3
0
        protected override void Perform(ModificationInfo info)
        {
            string output = /*info.AssemblyCSharpOutputPath ?? */ Path.Combine(info.TerraTechManaged, "Assembly-CSharp-Modded.dll");
            ModuleWriterOptions writerOptions = new ModuleWriterOptions();

            writerOptions.MetaDataOptions.Flags = MetaDataFlags.PreserveAll | MetaDataFlags.KeepOldMaxStack;
            info.AssemblyCSharp.Write(output, writerOptions);
        }
Exemplo n.º 4
0
 private void PerformInternal(ModificationInfo info)
 {
     Perform(info);
     if (Next != null)
     {
         Next.PerformInternal(info);
     }
 }
Exemplo n.º 5
0
        protected override void Perform(ModificationInfo info)
        {
            var importer        = new ModuleImporter(info.AssemblyCSharp.Assembly.ManifestModule, makeEverythingPublic: false);
            var assemblyBytes   = File.ReadAllBytes(info.NuterraAssembly);
            var debugFileResult = new DebugFileResult();

            importer.Import(assemblyBytes, debugFileResult, ModuleImporter.Options.None);
            new AddUpdatedNodesHelper().Finish(info.AssemblyCSharp, importer);
        }
Exemplo n.º 6
0
        protected override void Perform(ModificationInfo info)
        {
            string terraTechData = Directory.EnumerateDirectories(info.TerraTechRoot, "TerraTech*_Data").SingleOrDefault();

            if (terraTechData == null)
            {
                Error.InvalidRootDirectory();
            }
            info.TerraTechData = terraTechData;
        }
Exemplo n.º 7
0
        public static ModificationInfo Parse(string[] commandLineArgs)
        {
            ModificationInfo info = new ModificationInfo();

            for (int i = 0; i < commandLineArgs.Length; i++)
            {
                string param    = commandLineArgs[i];
                string next     = (i < commandLineArgs.Length - 1) ? commandLineArgs[i + 1] : null;
                bool   skipNext = false;

                if (param.Equals(CommonSwitches.TerraTechDir, StringComparison.OrdinalIgnoreCase))
                {
                    info.TerraTechRoot = next;
                    skipNext           = true;
                }

                if (param.Equals(CommonSwitches.AssemblyHash, StringComparison.OrdinalIgnoreCase))
                {
                    info.AcceptedHashes.Add(next);
                    skipNext = true;
                }

                if (param.Equals(CommonSwitches.AssemblyOutput, StringComparison.OrdinalIgnoreCase))
                {
                    info.AssemblyCSharpOutputPath = next;
                    skipNext = true;
                }

                if (param.Equals(CommonSwitches.AccessFile, StringComparison.OrdinalIgnoreCase))
                {
                    info.AccessFilePath = next;
                    skipNext            = true;
                }

                if (param.Equals(CommonSwitches.NuterraData, StringComparison.OrdinalIgnoreCase))
                {
                    info.NuterraData = next;
                    skipNext         = true;
                }

                if (param.Equals(CommonSwitches.NuterraAssembly, StringComparison.OrdinalIgnoreCase))
                {
                    info.NuterraAssembly = next;
                    skipNext             = true;
                }

                if (skipNext)
                {
                    i++;
                }
            }
            info.InitDefaults();

            return(info);
        }
Exemplo n.º 8
0
        private static void MainInternal(string[] args)
        {
            var info = ModificationInfo.Parse(args);
            var modificationChain = new VerifyRootDirectory();

            modificationChain
            .SetNext(new FindCleanAssembly())
            .SetNext(new LoadAssemblyCSharp())
            .SetNext(new ModifyAccessors())
            .SetNext(new SaveAssemblyCSharp());

            modificationChain.ExecuteSteps(info);
        }
Exemplo n.º 9
0
 protected override void Perform(ModificationInfo info)
 {
     foreach (string hash in info.AcceptedHashes)
     {
         string cleanAssemblyPath = AssemblyCSharpUtil.FindCleanAssembly(info.TerraTechManaged, hash);
         if (cleanAssemblyPath != null)
         {
             info.CleanAssemblyPath = cleanAssemblyPath;
             return;
         }
     }
     Error.NoCleanBackup();
 }
Exemplo n.º 10
0
 internal static void Main(string[] args)
 {
     try
     {
         var info = ModificationInfo.Parse(args);
         PerformInstall(info);
         Console.WriteLine("Install successfull");
     }
     catch (ModificationException ex)
     {
         Console.WriteLine(ex.Message);
         Console.WriteLine("Install failed");
     }
 }
Exemplo n.º 11
0
        public static void PerformInstall(ModificationInfo info)
        {
            if (info == null)
            {
                throw new ArgumentNullException(nameof(info));
            }
            var modificationChain = new VerifyRootDirectory();

            modificationChain
            .SetNext(new FindCleanAssembly())
            .SetNext(new LoadAssemblyCSharp())
            .SetNext(new ModifyAccessors())
            .SetNext(new AbsorbNuterra())
            .SetNext(new HookNuterra())
            .SetNext(new SaveAssemblyCSharp())
            .SetNext(new FixMissingDependencies());

            modificationChain.ExecuteSteps(info);
        }
Exemplo n.º 12
0
 protected override void Perform(ModificationInfo info)
 {
     Apply(info.AssemblyCSharp, info.AccessFilePath);
 }
Exemplo n.º 13
0
 public void ExecuteSteps(ModificationInfo info)
 {
     PerformInternal(info);
 }
Exemplo n.º 14
0
 protected abstract void Perform(ModificationInfo info);
Exemplo n.º 15
0
 protected override void Perform(ModificationInfo info)
 {
     Hooking.Hooker.Apply(info.AssemblyCSharp);
 }