Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup: Remove Mods #2190

Merged
merged 3 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using JetBrains.Annotations;
using NexusMods.Abstractions.Loadouts;
using NexusMods.Abstractions.Loadouts.Mods;
using NexusMods.MnemonicDB.Abstractions;

namespace NexusMods.Abstractions.Diagnostics.References;
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using JetBrains.Annotations;
using NexusMods.Abstractions.Loadouts;
using NexusMods.Abstractions.Loadouts.Mods;
using File = NexusMods.Abstractions.Loadouts.Files.File;

namespace NexusMods.Abstractions.Diagnostics.References;

Expand All @@ -22,17 +20,6 @@ public static LoadoutReference ToReference(this Loadout.ReadOnly loadout)
TxId = loadout.Db.BasisTxId,
};
}

/// <summary/>
[Obsolete("To be replaced")]
public static ModReference ToReference(this Mod.ReadOnly mod, Loadout.ReadOnly loadout)
{
return new ModReference
{
DataId = mod.ModId,
TxId = mod.Db.BasisTxId,
};
}

/// <summary>
/// Creates a new <see cref="LoadoutItemGroupReference"/> for the given <see cref="LoadoutItemGroup.ReadOnly"/>.
Expand All @@ -45,15 +32,4 @@ public static LoadoutItemGroupReference ToReference(this LoadoutItemGroup.ReadOn
TxId = group.Db.BasisTxId,
};
}

/// <summary/>
[Obsolete("To be replaced")]
public static ModFileReference ToReference(this File.ReadOnly modFile)
{
return new ModFileReference
{
DataId = modFile.FileId,
TxId = modFile.Db.BasisTxId,
};
}
}
1 change: 0 additions & 1 deletion src/Abstractions/NexusMods.Abstractions.Games/AGame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using NexusMods.Abstractions.Diagnostics.Emitters;
using NexusMods.Abstractions.GameLocators;
using NexusMods.Abstractions.GameLocators.GameCapabilities;
using NexusMods.Abstractions.Games.DTO;
using NexusMods.Abstractions.IO;
using NexusMods.Abstractions.Library.Installers;
using NexusMods.Abstractions.Loadouts.Synchronizers;
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using DynamicData.Kernel;
using JetBrains.Annotations;
using NexusMods.Abstractions.Loadouts.Mods;
using NexusMods.MnemonicDB.Abstractions;
using NexusMods.MnemonicDB.Abstractions.Attributes;

Expand All @@ -16,60 +15,4 @@ public static class LoadoutExtensions
{
return loadout.Items.OfTypeLoadoutItemGroup().Where(group => group.AsLoadoutItem().IsEnabled());
}

private static IEnumerable<Mod.ReadOnly> GetEnabledMods(this Loadout.ReadOnly loadout, bool onlyEnabledMods)
{
var enumerable = onlyEnabledMods
? loadout.Mods.Where(mod => mod.Enabled)
: loadout.Mods;

return enumerable.Where(mod => mod.Category == ModCategory.Mod);
}

/// <summary>
/// Gets all enabled mods in the Loadout.
/// </summary>
public static IEnumerable<Mod.ReadOnly> GetEnabledMods(this Loadout.ReadOnly loadout)
{
return loadout.GetEnabledMods(onlyEnabledMods: true);
}

/// <summary>
/// Counts all mods that have the given metadata.
/// </summary>
public static int CountModsWithMetadata(
this Loadout.ReadOnly loadout,
IAttribute attribute,
bool onlyEnabledMods = true)
{
return loadout
.GetEnabledMods(onlyEnabledMods)
.Count(mod => mod.Contains(attribute));
}

/// <summary>
/// Gets all mods that have metadata of type <typeparamref name="T"/>.
/// </summary>
public static IEnumerable<ValueTuple<Mod.ReadOnly, TOuter>> GetModsWithMetadata<TOuter, TInner>(
this Loadout.ReadOnly loadout,
ScalarAttribute<TOuter, TInner> attribute,
bool onlyEnabledMods = true) where TOuter : notnull
{
return loadout
.GetEnabledMods(onlyEnabledMods)
.Where(mod => mod.Contains(attribute))
.Select(mod => (mod, attribute.Get(mod)));
}

/// <summary>
/// Gets the first mod that has metadata of type <typeparamref name="T"/>.
/// </summary>
public static Optional<ValueTuple<Mod.ReadOnly, TOuter>> GetFirstModWithMetadata<TOuter, TInner>(
this Loadout.ReadOnly loadout,
ScalarAttribute<TOuter, TInner> attribute,
bool onlyEnabledMods = true) where TOuter : notnull
{
return loadout.GetModsWithMetadata(attribute, onlyEnabledMods)
.FirstOrOptional(_ => true);
}
}

This file was deleted.

38 changes: 0 additions & 38 deletions src/Abstractions/NexusMods.Abstractions.Loadouts/Files/File.cs

This file was deleted.

25 changes: 0 additions & 25 deletions src/Abstractions/NexusMods.Abstractions.Loadouts/Files/Metadata.cs

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using NexusMods.Abstractions.Loadouts.Mods;

namespace NexusMods.Abstractions.Loadouts;

/// <summary>
Expand Down
14 changes: 0 additions & 14 deletions src/Abstractions/NexusMods.Abstractions.Loadouts/Loadout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
using NexusMods.Abstractions.GameLocators;
using NexusMods.Abstractions.Library.Models;
using NexusMods.Abstractions.Loadouts.Ids;
using NexusMods.Abstractions.Loadouts.Mods;
using NexusMods.Abstractions.MnemonicDB.Attributes;
using NexusMods.Abstractions.MnemonicDB.Attributes.Extensions;
using NexusMods.MnemonicDB.Abstractions;
using NexusMods.MnemonicDB.Abstractions.Attributes;
using NexusMods.MnemonicDB.Abstractions.BuiltInEntities;
using NexusMods.MnemonicDB.Abstractions.Models;
using NexusMods.MnemonicDB.Abstractions.TxFunctions;
using File = NexusMods.Abstractions.Loadouts.Files.File;
using ULongAttribute = NexusMods.Abstractions.MnemonicDB.Attributes.ULongAttribute;

namespace NexusMods.Abstractions.Loadouts;
Expand Down Expand Up @@ -64,18 +62,6 @@ public partial class Loadout : IModelDefinition
DefaultValue = DateTime.MinValue,
};

/// <summary>
/// Mods that are part of this loadout point to this entity via Mod.Loadout
/// </summary>
[Obsolete(message: $"To be replaced with {nameof(Items)}")]
public static readonly BackReferenceAttribute<Mod> Mods = new(Mod.Loadout);

/// <summary>
/// All the files that are part of this loadout point to this entity via File.Loadout
/// </summary>
[Obsolete(message: $"To be replaced with {nameof(Items)}")]
public static readonly BackReferenceAttribute<File> Files = new(File.Loadout);

/// <summary>
/// All items in the Loadout.
/// </summary>
Expand Down
Loading
Loading