Files
ZuneModdingHelper/ZuneModCore/ModManager.cs
T

48 lines
1.3 KiB
C#
Raw Normal View History

2024-05-21 22:14:02 -05:00
using System;
using System.Collections.Generic;
2024-05-21 20:54:02 -05:00
using ZuneModCore.Mods;
namespace ZuneModCore;
public class ModManager
{
2024-05-21 22:14:02 -05:00
private static List<Mod>? _mods;
2024-05-21 20:54:02 -05:00
/// <summary>
/// Factories for all available mods.
/// </summary>
2025-09-02 00:50:51 -07:00
public static readonly IReadOnlyList<IModFactory<Mod>> ModFactories =
[
2024-05-21 20:54:02 -05:00
new FeaturesOverrideModFactory(),
new VideoSyncModFactory(),
new WebservicesModFactory(),
new BackgroundImageModFactory(),
new MbidLocatorModFactory(),
2025-09-02 00:50:51 -07:00
];
2024-05-21 20:54:02 -05:00
2024-05-21 22:14:02 -05:00
/// <summary>
/// Creates instances of each mod using the available factories
/// using the default MVVM IoC instance.
/// </summary>
public static IReadOnlyList<Mod> GetAvailableMods() => GetAvailableMods(CommunityToolkit.Mvvm.DependencyInjection.Ioc.Default);
/// <summary>
/// Creates instances of each mod using the available factories.
/// </summary>
public static IReadOnlyList<Mod> GetAvailableMods(IServiceProvider services)
2024-05-21 20:54:02 -05:00
{
if (_mods is null)
{
_mods = new(ModFactories.Count);
foreach (var modType in ModFactories)
{
var mod = modType.Create(services);
_mods.Add(mod);
}
}
return _mods;
}
}