public void DuplicateReference()
        {
            var modToExtract = new SkyrimMod(Utility.PluginModKey, SkyrimRelease.SkyrimSE);
            var npc          = modToExtract.Npcs.AddNew();
            var race         = modToExtract.Races.AddNew();

            race.CloseLootSound.SetTo(modToExtract.SoundDescriptors.AddNew());
            var unneededRace = modToExtract.Races.AddNew();

            var targetMod = new SkyrimMod(Utility.PluginModKey2, SkyrimRelease.SkyrimSE);

            targetMod.Npcs.Add(npc);
            var safeNpc = targetMod.Npcs.AddNew();

            safeNpc.Race = new FormLink <IRaceGetter>(race.FormKey);
            var safeNpc2 = targetMod.Npcs.AddNew();

            safeNpc2.Race = new FormLink <IRaceGetter>(race.FormKey);

            var linkCache = new MutableLoadOrderLinkCache <ISkyrimMod, ISkyrimModGetter>(modToExtract, targetMod);

            targetMod.DuplicateFromOnlyReferenced(linkCache, modToExtract.ModKey, out var mapping);
            targetMod.Npcs.Should().HaveCount(3);
            targetMod.Races.Should().HaveCount(1);
            targetMod.SoundDescriptors.Should().HaveCount(1);
            targetMod.EnumerateMajorRecords().Should().HaveCount(5);
            targetMod.Npcs.Should().Contain(safeNpc);
            targetMod.Npcs.Should().Contain(safeNpc2);
            var newRaceFormKey = mapping[race.FormKey];
            var newRace        = targetMod.Races.First();

            newRace.FormKey.Should().Be(newRaceFormKey);
            safeNpc.Race.FormKey.Should().Be(newRaceFormKey);
        }
Exemple #2
0
 public void AddOutfits(MutableLoadOrderLinkCache <ISkyrimMod, ISkyrimModGetter> cache, IEnumerable <KeyValuePair <FormKey, string> > outfits)
 {
     outfits.ForEach(o => {
         var ot = cache.Resolve <IOutfitGetter>(o.Key);
         AddOutfit(ot);
     });
 }
        public void MistypedExtraction()
        {
            var modToExtract = new SkyrimMod(Utility.PluginModKey, SkyrimRelease.SkyrimSE);
            var npc          = modToExtract.Npcs.AddNew();
            var race         = modToExtract.Races.AddNew();

            race.CloseLootSound.SetTo(modToExtract.SoundDescriptors.AddNew());
            var unneededRace = modToExtract.Races.AddNew();

            var targetMod = new SkyrimMod(Utility.PluginModKey2, SkyrimRelease.SkyrimSE);

            targetMod.Npcs.Add(npc);
            var safeNpc = targetMod.Npcs.AddNew();

            safeNpc.Race = new FormLink <IRaceGetter>(race.FormKey);

            var linkCache = new MutableLoadOrderLinkCache <ISkyrimMod, ISkyrimModGetter>(modToExtract, targetMod);

            targetMod.DuplicateFromOnlyReferenced(linkCache, modToExtract.ModKey, out var mapping, typeof(IAmmunitionGetter));
            targetMod.EnumerateMajorRecords().Should().HaveCount(2);
            targetMod.Npcs.Should().HaveCount(2);
            targetMod.Npcs.Should().Contain(safeNpc);
            targetMod.Npcs.Should().Contain(npc);
        }