Skip to content

Commit

Permalink
Add support for Mutagen ExtraSettingsDataPath
Browse files Browse the repository at this point in the history
  • Loading branch information
tr4wzified committed Oct 15, 2020
1 parent 42f144c commit d0d460f
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions KnowYourEnemyMutagen/KnowYourEnemyMutagen.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
</ItemGroup>

<ItemGroup>
<None Update="creature_rules.json">
<None Update="Data\creature_rules.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="misc.json">
<None Update="Data\misc.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="settings.json">
<None Update="Data\settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
Expand Down
16 changes: 8 additions & 8 deletions KnowYourEnemyMutagen/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ private static void RunPatch(SynthesisState<ISkyrimMod, ISkyrimModGetter> state)
if (!state.LoadOrder.ContainsKey(KnowYourEnemy))
throw new Exception("ERROR: Know Your Enemy not detected in load order. You need to install KYE prior to running this patcher!");

string[] requiredFiles = { "creature_rules.json", "misc.json", "settings.json" };
foreach (string file in requiredFiles)
{
if (!File.Exists(file)) throw new Exception("Required file " + file + " does not exist! Make sure to copy all files over when installing the patcher, and don't run it from within an archive.");
}
Console.WriteLine(state.ExtraSettingsDataPath);
string[] requiredFiles = {@"\creature_rules.json", @"\misc.json", @"\settings.json"};
string[] foundFiles = Directory.GetFiles(state.ExtraSettingsDataPath);
if (!requiredFiles.SequenceEqual(foundFiles))
throw new Exception("Missing required files! Make sure to copy all files over when installing the patcher, and don't run it from within an archive.");

// Retrieve all the perks that are going to be applied to NPCs in part 5
Dictionary<string, FormKey> perks = PerkArray
Expand All @@ -106,8 +106,8 @@ private static void RunPatch(SynthesisState<ISkyrimMod, ISkyrimModGetter> state)
.ToDictionary(x => x.key, x => x.perk, StringComparer.OrdinalIgnoreCase);

// Reading JSON and converting it to a normal list because .Contains() is weird in Newtonsoft.JSON
JObject misc = JObject.Parse(File.ReadAllText("misc.json"));
JObject settings = JObject.Parse(File.ReadAllText("settings.json"));
JObject misc = JObject.Parse(File.ReadAllText(state.ExtraSettingsDataPath + @"\misc.json"));
JObject settings = JObject.Parse(File.ReadAllText(state.ExtraSettingsDataPath + @"\settings.json"));
var effectIntensity = (float)settings["effect_intensity"]!;
var patchSilverPerk = (bool)settings["patch_silver_perk"]!;
Console.WriteLine("*** DETECTED SETTINGS ***");
Expand All @@ -121,7 +121,7 @@ private static void RunPatch(SynthesisState<ISkyrimMod, ISkyrimModGetter> state)
List<string> kyePerkNames = GetFromJson("kye_perk_names", misc).ToList();
List<string> kyeAbilityNames = GetFromJson("kye_ability_names", misc).ToList();

Dictionary<string, string[]> creatureRules = JsonConvert.DeserializeObject<Dictionary<string, string[]>>(File.ReadAllText("creature_rules.json"));
Dictionary<string, string[]> creatureRules = JsonConvert.DeserializeObject<Dictionary<string, string[]>>(File.ReadAllText(state.ExtraSettingsDataPath + @"\creature_rules.json"));

// Part 1a
// Removing other magical resistance/weakness systems
Expand Down

0 comments on commit d0d460f

Please sign in to comment.