baseline: OpenMU upstream b5a0961 (fresh source)
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
// <copyright file="ChangeMuHelperStateAction.cs" company="MUnique">
|
||||
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
|
||||
// </copyright>
|
||||
|
||||
namespace MUnique.OpenMU.GameLogic.PlayerActions.MuHelper;
|
||||
|
||||
using MUnique.OpenMU.GameLogic.MuHelper;
|
||||
|
||||
/// <summary>
|
||||
/// Action to change the MU Helper state.
|
||||
/// </summary>
|
||||
public class ChangeMuHelperStateAction
|
||||
{
|
||||
/// <summary>
|
||||
/// Tries to change the state of the MU Helper to the specified status.
|
||||
/// </summary>
|
||||
/// <param name="player">The player.</param>
|
||||
/// <param name="status">status to be set.</param>
|
||||
public async ValueTask ChangeHelperStateAsync(Player player, MuHelperStatus status)
|
||||
{
|
||||
var configuration = player.GameContext.FeaturePlugIns.GetPlugIn<MuHelperFeaturePlugIn>()?.Configuration;
|
||||
|
||||
if (configuration is null)
|
||||
{
|
||||
await player.ShowLocalizedBlueMessageAsync(nameof(PlayerMessage.MuHelperIsDisabled)).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (status)
|
||||
{
|
||||
case MuHelperStatus.Enabled:
|
||||
await player.MuHelper.TryStartAsync().ConfigureAwait(false);
|
||||
break;
|
||||
case MuHelperStatus.Disabled:
|
||||
await player.MuHelper.StopAsync().ConfigureAwait(false);
|
||||
break;
|
||||
default: // unknown
|
||||
await player.ShowLocalizedBlueMessageAsync(nameof(PlayerMessage.MuHelperCantHandleStatus), status).ConfigureAwait(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
// <copyright file="UpdateMuHelperConfigurationAction.cs" company="MUnique">
|
||||
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
|
||||
// </copyright>
|
||||
|
||||
namespace MUnique.OpenMU.GameLogic.PlayerActions.MuHelper;
|
||||
|
||||
using MUnique.OpenMU.GameLogic.Views.MuHelper;
|
||||
|
||||
/// <summary>
|
||||
/// Action to update the mu helper configuration.
|
||||
/// </summary>
|
||||
public class UpdateMuHelperConfigurationAction
|
||||
{
|
||||
/// <summary>
|
||||
/// Toggle mu bot status.
|
||||
/// </summary>
|
||||
/// <param name="player">the player.</param>
|
||||
/// <param name="data">mu bot data to be saved.</param>
|
||||
public async ValueTask SaveDataAsync(Player player, Memory<byte> data)
|
||||
{
|
||||
if (player.SelectedCharacter is not { } character)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
character.MuHelperConfiguration = data.ToArray();
|
||||
await player.InvokeViewPlugInAsync<IMuHelperConfigurationUpdatePlugIn>(p => p.UpdateMuHelperConfigurationAsync(character.MuHelperConfiguration)).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
player.Logger.LogWarning($"Cannot save MU Helper Configuration => {e}");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user