//
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
//
namespace MUnique.OpenMU.Persistence.Initialization.Updates;
using MUnique.OpenMU.DataModel.Configuration;
using MUnique.OpenMU.Network;
///
/// This updates adds the new with default settings.
///
public abstract class SystemConfigurationAddedPlugInBase : UpdatePlugInBase
{
///
/// The plug in name.
///
internal const string PlugInName = "Add System Configuration";
///
/// The plug in description.
///
internal const string PlugInDescription = "This update adds the new system configuration.";
///
public override string Name => PlugInName;
///
public override string Description => PlugInDescription;
///
public override bool IsMandatory => true;
///
public override DateTime CreatedAt => new(2023, 03, 24, 20, 0, 0, DateTimeKind.Utc);
///
protected override async ValueTask ApplyAsync(IContext context, GameConfiguration gameConfiguration)
{
if ((await context.GetAsync().ConfigureAwait(false)).FirstOrDefault() is { })
{
// Already exists -> we can skip that.
return;
}
var systemConfiguration = context.CreateNew();
systemConfiguration.SetGuid(0);
systemConfiguration.AutoStart = true;
systemConfiguration.AutoUpdateSchema = true;
systemConfiguration.ReadConsoleInput = false;
var (type, param) = IpAddressResolverFactory.DetermineBestFittingResolver(Environment.GetCommandLineArgs());
systemConfiguration.IpResolver = type;
systemConfiguration.IpResolverParameter = param;
}
}