Skip to content

Commit

Permalink
Add initialization plugin to add the new attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
sven-n committed Jun 9, 2024
1 parent 3f82544 commit 5e6029d
Showing 1 changed file with 57 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// <copyright file="AddPointsPerResetAttributePlugIn.cs" company="MUnique">
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
// </copyright>

namespace MUnique.OpenMU.Persistence.Initialization.Updates;

using System;
using System.Runtime.InteropServices;
using MUnique.OpenMU.AttributeSystem;

using MUnique.OpenMU.DataModel.Configuration;
using MUnique.OpenMU.GameLogic.Attributes;
using MUnique.OpenMU.PlugIns;

/// <summary>
/// This update adds the <see cref="Stats.PointsPerReset"/>.
/// </summary>
[PlugIn(PlugInName, PlugInDescription)]
[Guid("6011A1B8-7FA5-48EB-935D-EEAF83017799")]
public class AddPointsPerResetAttributePlugIn : UpdatePlugInBase
{
/// <summary>
/// The plug in name.
/// </summary>
internal const string PlugInName = "Adds attribute PointsPerReset";

/// <summary>
/// The plug in description.
/// </summary>
internal const string PlugInDescription = "This update adds the attribute PointsPerReset.";

/// <inheritdoc />
public override string Name => PlugInName;

/// <inheritdoc />
public override string Description => PlugInDescription;

/// <inheritdoc />
public override UpdateVersion Version => UpdateVersion.AddPointsPerResetByClassAttribute;

/// <inheritdoc />
public override string DataInitializationKey => VersionSeasonSix.DataInitialization.Id;

/// <inheritdoc />
public override bool IsMandatory => true;

/// <inheritdoc />
public override DateTime CreatedAt => new(2024, 06, 09, 13, 30, 0, DateTimeKind.Utc);

/// <inheritdoc />
protected override async ValueTask ApplyAsync(IContext context, GameConfiguration gameConfiguration)
{
var attribute = Stats.PointsPerReset;
var persistentAttribute = context.CreateNew<AttributeDefinition>(attribute.Id, attribute.Designation, attribute.Description);
gameConfiguration.Attributes.Add(persistentAttribute);
}
}

0 comments on commit 5e6029d

Please sign in to comment.