//
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
//
namespace MUnique.OpenMU.GameLogic.PlugIns.ChatCommands;
using System.Runtime.InteropServices;
using MUnique.OpenMU.GameLogic.PlugIns.ChatCommands.Arguments;
using MUnique.OpenMU.PlugIns;
///
/// A chat command plugin which handles track commands.
///
[Guid("7F12326A-9B84-4A56-A013-8C485D7B2EF6")]
[PlugIn]
[Display(Name = nameof(PlugInResources.TrackChatCommandPlugIn_Name), Description = nameof(PlugInResources.TrackChatCommandPlugIn_Description), ResourceType = typeof(PlugInResources))]
[ChatCommandHelp(Command, typeof(TraceChatCommandArgs), CharacterStatus.GameMaster)]
public class TrackChatCommandPlugIn : ChatCommandPlugInBase
{
private const string Command = "/track";
///
public override string Key => Command;
///
public override CharacterStatus MinCharacterStatusRequirement => CharacterStatus.GameMaster;
///
protected override async ValueTask DoHandleCommandAsync(Player gameMaster, TraceChatCommandArgs arguments)
{
var player = await this.GetPlayerByCharacterNameAsync(gameMaster, arguments.CharacterName ?? string.Empty).ConfigureAwait(false);
if (gameMaster.SelectedCharacter is null || player is null)
{
return;
}
var gameMasterLocation = new ExitGate
{
Map = gameMaster.SelectedCharacter.CurrentMap,
X1 = gameMaster.SelectedCharacter.PositionX,
X2 = (byte)(gameMaster.SelectedCharacter.PositionX + 2),
Y1 = gameMaster.SelectedCharacter.PositionY,
Y2 = (byte)(gameMaster.SelectedCharacter.PositionY + 2),
};
await player.WarpToAsync(gameMasterLocation).ConfigureAwait(false);
}
}