Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
mrudat committed Jul 17, 2021
2 parents e5ff4f1 + f818a82 commit 649fe17
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 18 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
*/obj/*

.editorconfig

UniquePlayer/Properties/launchSettings.json
7 changes: 5 additions & 2 deletions Tests/TextureSets_Tests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using Moq;
using Mutagen.Bethesda;
using Mutagen.Bethesda.Plugins;
using Mutagen.Bethesda.Plugins.Cache;
using Mutagen.Bethesda.Plugins.Exceptions;
using Mutagen.Bethesda.Skyrim;
using System.Collections.Generic;
using System.IO;
Expand Down Expand Up @@ -42,7 +45,7 @@ public void TestUpdateTextureSet()
EditorID = "oldTextureSet",
};

linkCache.Setup(x => x.TryResolve<ITextureSetGetter>(textureSetFormKey, out oldTextureSet)).Returns(true);
linkCache.Setup(x => x.TryResolve<ITextureSetGetter>(textureSetFormKey, out oldTextureSet, ResolveTarget.Winner)).Returns(true);

TextureSets program = new(patchMod.Object, linkCache.Object);

Expand Down Expand Up @@ -73,7 +76,7 @@ public void TestUpdateTextureSet2()
Diffuse = "replaced_d.dds",
};

linkCache.Setup(x => x.TryResolve<ITextureSetGetter>(textureSetFormKey, out oldTextureSet)).Returns(true);
linkCache.Setup(x => x.TryResolve<ITextureSetGetter>(textureSetFormKey, out oldTextureSet, ResolveTarget.Winner)).Returns(true);

var patchMod = new SkyrimMod(PatchModKey, SkyrimRelease.SkyrimSE);

Expand Down
3 changes: 3 additions & 0 deletions Tests/UpdateHeadParts_Tests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using Moq;
using Mutagen.Bethesda;
using Mutagen.Bethesda.Plugins;
using Mutagen.Bethesda.Plugins.Cache;
using Mutagen.Bethesda.Plugins.Exceptions;
using Mutagen.Bethesda.Skyrim;
using System.Collections.Generic;
using System.IO;
Expand Down
3 changes: 2 additions & 1 deletion UniquePlayer/FormKeys/FormList.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Autogenerated by https://github.com/Mutagen-Modding/Mutagen.Bethesda.FormKeys

using Mutagen.Bethesda.Plugins;
using Mutagen.Bethesda.Skyrim;

namespace Mutagen.Bethesda.FormKeys.SkyrimSE
Expand All @@ -8,7 +9,7 @@ public static partial class RaceCompatibility
{
public static class FormList
{
private static FormLink<IFormListGetter> Construct(uint id) => new FormLink<IFormListGetter>(ModKey.MakeFormKey(id));
private static FormLink<IFormListGetter> Construct(uint id) => new(ModKey.MakeFormKey(id));
public static FormLink<IFormListGetter> PlayableRaceList => Construct(0xd62);
public static FormLink<IFormListGetter> PlayableVampireList => Construct(0xd63);
}
Expand Down
3 changes: 2 additions & 1 deletion UniquePlayer/FormKeys/Keyword.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Autogenerated by https://github.com/Mutagen-Modding/Mutagen.Bethesda.FormKeys

using Mutagen.Bethesda.Plugins;
using Mutagen.Bethesda.Skyrim;

namespace Mutagen.Bethesda.FormKeys.SkyrimSE
Expand All @@ -8,7 +9,7 @@ public static partial class RaceCompatibility
{
public static class Keyword
{
private static FormLink<IKeywordGetter> Construct(uint id) => new FormLink<IKeywordGetter>(ModKey.MakeFormKey(id));
private static FormLink<IKeywordGetter> Construct(uint id) => new(ModKey.MakeFormKey(id));
public static FormLink<IKeywordGetter> ActorProxyBreton => Construct(0x1d8a);
public static FormLink<IKeywordGetter> ActorProxyArgonian => Construct(0x1d8b);
public static FormLink<IKeywordGetter> ActorProxyKhajiit => Construct(0x1d8c);
Expand Down
1 change: 1 addition & 0 deletions UniquePlayer/FormKeys/ModKey.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Mutagen.Bethesda.Plugins;
using System.CodeDom.Compiler;

namespace Mutagen.Bethesda.FormKeys.SkyrimSE
Expand Down
3 changes: 2 additions & 1 deletion UniquePlayer/FormKeys/Quest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Autogenerated by https://github.com/Mutagen-Modding/Mutagen.Bethesda.FormKeys

using Mutagen.Bethesda.Plugins;
using Mutagen.Bethesda.Skyrim;

namespace Mutagen.Bethesda.FormKeys.SkyrimSE
Expand All @@ -8,7 +9,7 @@ public static partial class RaceCompatibility
{
public static class Quest
{
private static FormLink<IQuestGetter> Construct(uint id) => new FormLink<IQuestGetter>(ModKey.MakeFormKey(id));
private static FormLink<IQuestGetter> Construct(uint id) => new(ModKey.MakeFormKey(id));
public static FormLink<IQuestGetter> RaceDispatcher => Construct(0x9f27);
}
}
Expand Down
11 changes: 9 additions & 2 deletions UniquePlayer/HeadParts.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
using Mutagen.Bethesda;
using Mutagen.Bethesda.Plugins;
using Mutagen.Bethesda.Plugins.Cache;
using Mutagen.Bethesda.Plugins.Exceptions;
using Mutagen.Bethesda.Plugins.Records;
using Mutagen.Bethesda.Skyrim;
using Noggog;
using System;
Expand Down Expand Up @@ -71,10 +75,13 @@ public void UpdateHeadPart(IFormLinkGetter<IHeadPartGetter> headPartItem, string
};

var newHeadPart = PatchMod.HeadParts.AddNew($"{headPart.EditorID}_UniquePlayer");
newHeadPart.DeepCopyIn(headPart, new HeadPart.TranslationMask(defaultOn: true)

newHeadPart.DeepCopyIn(headPart, out var foo, new HeadPart.TranslationMask(defaultOn: true)
{
EditorID = false
});
if (foo.IsInError() && foo.Overall is Exception e) throw e;

// TODO duplicate headPart FormList and restrict to player only?

newHeadPart.Parts.ForEach(x =>
Expand All @@ -90,7 +97,7 @@ public void UpdateHeadPart(IFormLinkGetter<IHeadPartGetter> headPartItem, string
}
catch (Exception e)
{
throw RecordException.Factory(e, headPart);
throw RecordException.Enrich(e, headPart);
}
}
}
Expand Down
18 changes: 12 additions & 6 deletions UniquePlayer/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
using Mutagen.Bethesda;
using Mutagen.Bethesda.FormKeys.SkyrimSE;
using Mutagen.Bethesda.Plugins;
using Mutagen.Bethesda.Plugins.Cache;
using Mutagen.Bethesda.Plugins.Exceptions;
using Mutagen.Bethesda.Plugins.Order;
using Mutagen.Bethesda.Skyrim;
using Mutagen.Bethesda.Synthesis;
using Noggog;
Expand All @@ -21,7 +25,7 @@ public class Program

private readonly ILinkCache<ISkyrimMod, ISkyrimModGetter> LinkCache;

private readonly LoadOrder<IModListing<ISkyrimModGetter>> LoadOrder;
private readonly ILoadOrder<IModListing<ISkyrimModGetter>> LoadOrder;

private readonly IFileSystem _fileSystem;
private readonly System.IO.Abstractions.IPath Path;
Expand Down Expand Up @@ -112,12 +116,12 @@ public void RunPatch()

var victimRaceFormKeys = playableRaceFormLinks.Select(x => x.FormKey.AsLinkGetter<IRaceGetter>()).Concat(playableVampireRaceFormLinks.Select(x => x.FormKey.AsLinkGetter<IRaceGetter>())).ToHashSet();

var otherFormLists =
var otherFormLists = (
from x in LoadOrder.PriorityOrder.WinningOverrides<IFormListGetter>()
where !x.Equals(RaceCompatibility.FormList.PlayableRaceList)
&& !x.Equals(RaceCompatibility.FormList.PlayableVampireList)
&& x.ContainedFormLinks.Any(y => victimRaceFormKeys.Contains(y.FormKey.AsLink<IRaceGetter>()))
select PatchMod.FormLists.GetOrAddAsOverride(x);
select PatchMod.FormLists.GetOrAddAsOverride(x)).ToList();

var modifiedPlayableRaceFormList = PatchMod.FormLists.GetOrAddAsOverride(playableRaceFormList);
var modifiedPlayableVampireRaceFormList = PatchMod.FormLists.GetOrAddAsOverride(playableVampireRaceFormList);
Expand All @@ -132,7 +136,7 @@ from x in LoadOrder.PriorityOrder.WinningOverrides<IFormListGetter>()
var vampireRace = vampireRaceLink.Resolve(LinkCache);

if (!race.Flags.HasFlag(Race.Flag.Playable))
throw RecordException.Factory(new Exception("Race in PlayableRaceList was not playable"), race);
throw RecordException.Create("Race in PlayableRaceList was not playable", race);

var newRace = CopyRace(race, texturesPath, meshesPath);

Expand Down Expand Up @@ -203,12 +207,13 @@ void applyModelEdit(Model? model)
if (needsEdit)
{
var newArmorAddon = PatchMod.ArmorAddons.AddNew($"{armorAddon.EditorID}_UniquePlayer");
newArmorAddon.DeepCopyIn(armorAddon, new ArmorAddon.TranslationMask(defaultOn: true)
newArmorAddon.DeepCopyIn(armorAddon, out var ex, new ArmorAddon.TranslationMask(defaultOn: true)
{
EditorID = false,
Race = false,
AdditionalRaces = false
});
if (ex.Overall is Exception e) throw e;
newArmorAddon.Race.SetTo(replacementRaces.First());
replacementRaces.Skip(1).ForEach(x => newArmorAddon.AdditionalRaces.Add(x));

Expand Down Expand Up @@ -258,11 +263,12 @@ from armor in LoadOrder.PriorityOrder.WinningOverrides<IArmorGetter>()
public Race CopyRace(IRaceGetter oldRace, string texturesPath, string meshesPath)
{
var newRace = PatchMod.Races.AddNew($"{oldRace.EditorID}_UniquePlayer");
newRace.DeepCopyIn(oldRace, new Race.TranslationMask(defaultOn: true)
newRace.DeepCopyIn(oldRace, out var ex, new Race.TranslationMask(defaultOn: true)
{
EditorID = false,
ArmorRace = false
});
if (ex.Overall is Exception e) throw e;
newRace.MorphRace.SetTo(oldRace);
replacementPlayableRacesDict.Add(oldRace.FormKey, newRace.FormKey);

Expand Down
8 changes: 6 additions & 2 deletions UniquePlayer/TextureSets.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using Mutagen.Bethesda;
using Mutagen.Bethesda.Plugins;
using Mutagen.Bethesda.Plugins.Cache;
using Mutagen.Bethesda.Plugins.Exceptions;
using Mutagen.Bethesda.Skyrim;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -51,10 +54,11 @@ public bool UpdateTextureSet(IFormLinkGetter<ITextureSetGetter> textureSetFormLi
}

var newTxst = PatchMod.TextureSets.AddNew($"{txst.EditorID}_UniquePlayer");
newTxst.DeepCopyIn(txst, new TextureSet.TranslationMask(defaultOn: true)
newTxst.DeepCopyIn(txst, out var ex, new TextureSet.TranslationMask(defaultOn: true)
{
EditorID = false
});
if (ex.Overall is Exception e) throw e;
replacementTextureSets.Add(textureSetFormKey, newTxst.FormKey);

newTxst.Diffuse = TexturePaths.ChangeTexturePath(txst.Diffuse, ref changed, texturesPath);
Expand All @@ -69,7 +73,7 @@ public bool UpdateTextureSet(IFormLinkGetter<ITextureSetGetter> textureSetFormLi
}
catch (Exception e)
{
throw RecordException.Factory("UpdatTextureSet", txst, e);
throw RecordException.Enrich(e, txst);
}
}

Expand Down
6 changes: 3 additions & 3 deletions UniquePlayer/UniquePlayer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Mutagen.Bethesda" Version="0.29.3" />
<PackageReference Include="Mutagen.Bethesda.Synthesis" Version="0.18.3" />
<PackageReference Include="Mutagen.Bethesda.FormKeys.SkyrimSE" Version="2.0.0" />
<PackageReference Include="Mutagen.Bethesda" Version="0.30.6" />
<PackageReference Include="Mutagen.Bethesda.Synthesis" Version="0.19.2" />
<PackageReference Include="Mutagen.Bethesda.FormKeys.SkyrimSE" Version="2.1.0" />
</ItemGroup>
</Project>

0 comments on commit 649fe17

Please sign in to comment.