-
Notifications
You must be signed in to change notification settings - Fork 0
/
gen_pluginmerger.cs
72 lines (69 loc) · 2.77 KB
/
gen_pluginmerger.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
using Mutagen.Bethesda.Environments;
using Mutagen.Bethesda.Plugins;
using Mutagen.Bethesda.Starfield;
using Mutagen.Bethesda;
using Noggog;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FrankyCLI
{
class gen_pluginmerger
{
public static int Generate(string[] args)
{
Random random = new Random();
StarfieldMod myMod;
string modname = args[0];
string mode = args[1];
string importmodname = args[2];
string item = args[3];
string form = args[4];
string datapath = "";
using (var env = GameEnvironment.Typical.Builder<IStarfieldMod, IStarfieldModGetter>(GameRelease.Starfield).Build())
{
var immutableLoadOrderLinkCache = env.LoadOrder.ToImmutableLinkCache();
datapath = env.DataFolderPath;
//Find the modkey
ModKey newMod = new ModKey(modname, ModType.Master);
myMod = new StarfieldMod(newMod, StarfieldRelease.Starfield);
if (!env.LoadOrder.ModExists(newMod))
{
myMod = new StarfieldMod(newMod, StarfieldRelease.Starfield);
}
else
{
for (int i = 0; i < env.LoadOrder.Count; i++)
{
if (env.LoadOrder[i].FileName == modname + ".esm")
{
ModPath modPath = Path.Combine(env.DataFolderPath, env.LoadOrder[i].FileName);
myMod = StarfieldMod.CreateFromBinary(modPath, StarfieldRelease.Starfield);
}
}
}
//Merge
for (int i = 0; i < env.LoadOrder.Count; i++)
{
if (env.LoadOrder[i].FileName == importmodname + ".esm")
{
ModPath importmodPath = Path.Combine(env.DataFolderPath, env.LoadOrder[i].FileName);
var importmod = StarfieldMod.CreateFromBinary(importmodPath, StarfieldRelease.Starfield);
myMod.DeepCopyIn(importmod);
//myMod.ModHeader.MasterReferences.Clear();
/*
foreach (var weapon in importmod.EnumerateMajorRecords<Weapon>())
{
myMod.Weapons.DuplicateInAsNewRecord(weapon);
}*/
}
}
}
myMod.WriteToBinary(datapath + "\\" + modname + ".esm");
Console.WriteLine("Finished");
return 0;
}
}
}