public void WinningOverrides_Deleted() { var master = new SkyrimMod(new ModKey("Base", ModType.Master), SkyrimRelease.SkyrimSE); var baseNpc = master.Npcs.AddNew(); var otherMasterNpc = master.Npcs.AddNew(); var plugin = new SkyrimMod(new ModKey("Plugin", ModType.Plugin), SkyrimRelease.SkyrimSE); var pluginNpc = plugin.Npcs.AddNew(); var overrideNpc = (Npc)baseNpc.DeepCopy(); plugin.Npcs.RecordCache.Set(overrideNpc); overrideNpc.Name = "Override"; overrideNpc.IsDeleted = true; var winningOverrides = plugin.AsEnumerable().And(master) .WinningOverrides <Npc>(includeDeletedRecords: true) .ToDictionary(n => n.FormKey); Assert.Equal(3, winningOverrides.Count); Assert.Same(otherMasterNpc, winningOverrides[otherMasterNpc.FormKey]); Assert.Same(pluginNpc, winningOverrides[pluginNpc.FormKey]); Assert.Equal(overrideNpc.FormKey, baseNpc.FormKey); Assert.Same(overrideNpc, winningOverrides[baseNpc.FormKey]); winningOverrides = plugin.AsEnumerable().And(master) .WinningOverrides <Npc>(includeDeletedRecords: false) .ToDictionary(n => n.FormKey); Assert.Equal(2, winningOverrides.Count); Assert.Same(otherMasterNpc, winningOverrides[otherMasterNpc.FormKey]); Assert.Same(pluginNpc, winningOverrides[pluginNpc.FormKey]); }
public void ComplexOverrides() { WarmupSkyrim.Init(); // Construct base mod const string Mod1Name = "Mod1"; var mod = new SkyrimMod(TestConstants.PluginModKey, SkyrimRelease.SkyrimSE); var worldspace = mod.Worldspaces.AddNew(); worldspace.EditorID = Mod1Name; var block = new WorldspaceBlock() { BlockNumberX = 2, BlockNumberY = 3, GroupType = GroupTypeEnum.ExteriorCellBlock, }; var subBlock = new WorldspaceSubBlock() { BlockNumberX = 4, BlockNumberY = 5, GroupType = GroupTypeEnum.ExteriorCellSubBlock, }; block.Items.Add(subBlock); worldspace.SubCells.Add(block); var cell = new Cell(mod.GetNextFormKey(), SkyrimRelease.SkyrimSE); cell.EditorID = Mod1Name; subBlock.Items.Add(cell); var placedObj = new PlacedObject(mod.GetNextFormKey(), SkyrimRelease.SkyrimSE); placedObj.EditorID = Mod1Name; cell.Persistent.Add(placedObj); // Override cell in 2nd mod const string Mod2Name = "Mod2"; var mod2 = new SkyrimMod(TestConstants.PluginModKey2, SkyrimRelease.SkyrimSE); var worldspace2 = new Worldspace(worldspace.FormKey, SkyrimRelease.SkyrimSE); worldspace2.EditorID = Mod2Name; mod2.Worldspaces.Add(worldspace2); var block2 = new WorldspaceBlock() { BlockNumberX = 2, BlockNumberY = 3, GroupType = GroupTypeEnum.ExteriorCellBlock, }; var subBlock2 = new WorldspaceSubBlock() { BlockNumberX = 4, BlockNumberY = 5, GroupType = GroupTypeEnum.ExteriorCellSubBlock, }; block2.Items.Add(subBlock2); worldspace2.SubCells.Add(block2); var cell2 = new Cell(cell.FormKey, SkyrimRelease.SkyrimSE); cell2.EditorID = Mod2Name; subBlock2.Items.Add(cell2); // Override worldspace in 3rd mod const string Mod3Name = "Mod3"; var mod3 = new SkyrimMod(TestConstants.PluginModKey3, SkyrimRelease.SkyrimSE); var worldspace3 = new Worldspace(worldspace.FormKey, SkyrimRelease.SkyrimSE); worldspace3.EditorID = Mod3Name; mod3.Worldspaces.Add(worldspace3); // Override in 4th, and check sources var loadOrder = new LoadOrder <ISkyrimModGetter>(mod.AsEnumerable().And(mod2).And(mod3)); var cache = loadOrder.ToImmutableLinkCache(); var contexts = mod.EnumerateMajorRecordContexts <IPlaced, IPlacedGetter>(linkCache: cache).ToArray(); contexts.Should().HaveCount(1); var mod4 = new SkyrimMod(TestConstants.PluginModKey4, SkyrimRelease.SkyrimSE); var placedObjOverride = contexts[0].GetOrAddAsOverride(mod4); placedObjOverride.EditorID.Should().Be(Mod1Name); var cellOverride = mod4.Worldspaces.First().SubCells.First().Items.First().Items.First(); cellOverride.EditorID.Should().Be(Mod2Name); var worldspaceOverride = mod4.Worldspaces.First(); worldspaceOverride.EditorID.Should().Be(Mod3Name); }