-
Notifications
You must be signed in to change notification settings - Fork 328
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented logic to create lost map items.
- Loading branch information
Showing
8 changed files
with
211 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// <copyright file="IItemStackedPlugIn.cs" company="MUnique"> | ||
// Licensed under the MIT License. See LICENSE file in the project root for full license information. | ||
// </copyright> | ||
|
||
namespace MUnique.OpenMU.GameLogic.PlugIns; | ||
|
||
using System.Runtime.InteropServices; | ||
using MUnique.OpenMU.PlugIns; | ||
|
||
/// <summary> | ||
/// A plugin interface which is called when an item got moved by the player. | ||
/// </summary> | ||
[Guid("FCDE60E9-6183-4833-BF59-CE907F9EECCD")] | ||
[PlugInPoint("Item stacked", "Plugins which are called when an item has been stacked by the player.")] | ||
public interface IItemStackedPlugIn | ||
{ | ||
/// <summary> | ||
/// Is called when an item has been moved by the player. | ||
/// </summary> | ||
/// <param name="player">The player.</param> | ||
/// <param name="sourceItem">The source item.</param> | ||
/// <param name="targetItem">The target item.</param> | ||
ValueTask ItemStackedAsync(Player player, Item sourceItem, Item targetItem); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// <copyright file="SymbolOfKundunStackedPlugIn.cs" company="MUnique"> | ||
// Licensed under the MIT License. See LICENSE file in the project root for full license information. | ||
// </copyright> | ||
|
||
namespace MUnique.OpenMU.GameLogic.PlugIns; | ||
|
||
using System.Runtime.InteropServices; | ||
using MUnique.OpenMU.PlugIns; | ||
|
||
/// <summary> | ||
/// This plugin transforms a stack of symbol of kundun into a lost map. | ||
/// </summary> | ||
[PlugIn(nameof(SymbolOfKundunStackedPlugIn), "This plugin transforms a stack of symbol of kundun into a lost map.")] | ||
[Guid("F07A9CED-F43E-4824-9587-F5C3C3187A13")] | ||
public sealed class SymbolOfKundunStackedPlugIn : IItemStackedPlugIn | ||
{ | ||
private const byte SymbolOfKundunGroup = 14; | ||
private const byte SymbolOfKundunNumber = 29; | ||
private const byte LostMapGroup = 14; | ||
private const byte LostMapNumber = 28; | ||
|
||
/// <inheritdoc /> | ||
public async ValueTask ItemStackedAsync(Player player, Item sourceItem, Item targetItem) | ||
{ | ||
if (targetItem.Definition is not { Group: SymbolOfKundunGroup, Number: SymbolOfKundunNumber }) | ||
{ | ||
return; | ||
} | ||
|
||
if (targetItem.Durability() < targetItem.Definition.Durability) | ||
{ | ||
return; | ||
} | ||
|
||
var lostMap = player.GameContext.Configuration.Items.FirstOrDefault(item => item is { Group: LostMapGroup, Number: LostMapNumber }); | ||
if (lostMap is null) | ||
{ | ||
player.Logger.LogWarning("Lost map definition not found."); | ||
return; | ||
} | ||
|
||
await player.InvokeViewPlugInAsync<Views.Inventory.IItemRemovedPlugIn>(p => p.RemoveItemAsync(targetItem.ItemSlot)).ConfigureAwait(false); | ||
targetItem.Definition = lostMap; | ||
targetItem.Durability = 1; | ||
await player.InvokeViewPlugInAsync<Views.Inventory.IItemAppearPlugIn>(p => p.ItemAppearAsync(targetItem)).ConfigureAwait(false); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// <copyright file="AddKalimaPlugIn.cs" company="MUnique"> | ||
// Licensed under the MIT License. See LICENSE file in the project root for full license information. | ||
// </copyright> | ||
|
||
using MUnique.OpenMU.DataModel.Configuration.Items; | ||
|
||
namespace MUnique.OpenMU.Persistence.Initialization.Updates; | ||
|
||
using System.Runtime.InteropServices; | ||
using MUnique.OpenMU.DataModel.Configuration; | ||
using MUnique.OpenMU.PlugIns; | ||
|
||
/// <summary> | ||
/// This adds the items required to enter the kalima map. | ||
/// </summary> | ||
[PlugIn(PlugInName, PlugInDescription)] | ||
[Guid("0C99155F-1289-4E73-97F0-47CB67C3716F")] | ||
public class AddKalimaPlugIn : UpdatePlugInBase | ||
{ | ||
/// <summary> | ||
/// The plug in name. | ||
/// </summary> | ||
internal const string PlugInName = "Add Kalima"; | ||
|
||
/// <summary> | ||
/// The plug in description. | ||
/// </summary> | ||
internal const string PlugInDescription = "This adds the items required to enter the kalima map."; | ||
|
||
/// <inheritdoc /> | ||
public override UpdateVersion Version => UpdateVersion.AddKalima; | ||
|
||
/// <inheritdoc /> | ||
public override string DataInitializationKey => VersionSeasonSix.DataInitialization.Id; | ||
|
||
/// <inheritdoc /> | ||
public override string Name => PlugInName; | ||
|
||
/// <inheritdoc /> | ||
public override string Description => PlugInDescription; | ||
|
||
/// <inheritdoc /> | ||
public override bool IsMandatory => true; | ||
|
||
/// <inheritdoc /> | ||
public override DateTime CreatedAt => new(2024, 06, 09, 18, 0, 0, DateTimeKind.Utc); | ||
|
||
/// <inheritdoc /> | ||
#pragma warning disable CS1998 | ||
protected override async ValueTask ApplyAsync(IContext context, GameConfiguration gameConfiguration) | ||
#pragma warning restore CS1998 | ||
{ | ||
this.CreateLostMap(context, gameConfiguration); | ||
this.CreateSymbolOfKundun(context, gameConfiguration); | ||
} | ||
|
||
private void CreateLostMap(IContext context, GameConfiguration gameConfiguration) | ||
{ | ||
var itemDefinition = context.CreateNew<ItemDefinition>(); | ||
itemDefinition.Name = "Lost Map"; | ||
itemDefinition.Number = 28; | ||
itemDefinition.Group = 14; | ||
itemDefinition.DropsFromMonsters = false; | ||
itemDefinition.Durability = 1; | ||
itemDefinition.Width = 1; | ||
itemDefinition.Height = 1; | ||
itemDefinition.MaximumItemLevel = 7; | ||
itemDefinition.SetGuid(itemDefinition.Group, itemDefinition.Number); | ||
gameConfiguration.Items.Add(itemDefinition); | ||
} | ||
|
||
private void CreateSymbolOfKundun(IContext context, GameConfiguration gameConfiguration) | ||
{ | ||
var itemDefinition = context.CreateNew<ItemDefinition>(); | ||
itemDefinition.Name = "Symbol of Kundun"; | ||
itemDefinition.Number = 29; | ||
itemDefinition.Group = 14; | ||
itemDefinition.DropLevel = 0; | ||
itemDefinition.DropsFromMonsters = true; | ||
itemDefinition.Durability = 5; | ||
itemDefinition.Width = 1; | ||
itemDefinition.Height = 1; | ||
itemDefinition.MaximumItemLevel = 7; | ||
itemDefinition.SetGuid(itemDefinition.Group, itemDefinition.Number); | ||
gameConfiguration.Items.Add(itemDefinition); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters