Files
AdamuSw/src/GameLogic/PlugIns/ChatCommands/WalkMonsterChatCommand.cs
2026-07-14 19:00:35 +03:00

41 lines
1.7 KiB
C#

// <copyright file="WalkMonsterChatCommand.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.ChatCommands;
using System.Runtime.InteropServices;
using MUnique.OpenMU.GameLogic.NPC;
using MUnique.OpenMU.GameLogic.PlugIns.ChatCommands.Arguments;
using MUnique.OpenMU.PlugIns;
/// <summary>
/// Chat command to let a monster walk to specific coordinates.
/// </summary>
[Guid("1852FED5-8184-431E-8C5F-5131356D348F")]
[PlugIn]
[Display(Name = nameof(PlugInResources.WalkMonsterChatCommand_Name), Description = nameof(PlugInResources.WalkMonsterChatCommand_Description), ResourceType = typeof(PlugInResources))]
[ChatCommandHelp(Command, typeof(MoveMonsterCommandArgs), CharacterStatus.GameMaster)]
internal class WalkMonsterChatCommand : ChatCommandPlugInBase<MoveMonsterCommandArgs>
{
private const string Command = "/walkmonster";
/// <inheritdoc />
public override string Key => Command;
/// <inheritdoc/>
public override CharacterStatus MinCharacterStatusRequirement => CharacterStatus.GameMaster;
/// <inheritdoc />
protected override async ValueTask DoHandleCommandAsync(Player gameMaster, MoveMonsterCommandArgs arguments)
{
var monster = gameMaster.ObservingBuckets.SelectMany(b => b).OfType<Monster>().FirstOrDefault(m => m.Id == arguments.Id);
if (monster is null)
{
await gameMaster.ShowLocalizedBlueMessageAsync(nameof(PlayerMessage.MonsterNotFoundById), arguments.Id).ConfigureAwait(false);
return;
}
await monster.WalkToAsync(arguments.Coordinates).ConfigureAwait(false);
}
}