baseline: OpenMU upstream b5a0961 (fresh source)

This commit is contained in:
Acentech Dev
2026-07-14 19:00:35 +03:00
parent 450402e47d
commit 36fc125d5c
11968 changed files with 748705 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
// <copyright file="PartyKickAction.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.Party;
using MUnique.OpenMU.GameLogic;
/// <summary>
/// Action to kick players from the party.
/// </summary>
public class PartyKickAction
{
/// <summary>
/// Kicks the player.
/// Only the party master is allowed to kick other players. However, players can kick themselves out of the party.
/// </summary>
/// <param name="player">The player.</param>
/// <param name="index">The index.</param>
public async ValueTask KickPlayerAsync(Player player, byte index)
{
if (player.Party is not { } party)
{
return;
}
if (!Equals(player, party.PartyList[0]) &&
!Equals(player, party.PartyList[index]))
{
player.Logger.LogWarning("Suspicious party kick request of {0}, could be hack attempt.", player);
return;
}
await party.KickPlayerAsync(index).ConfigureAwait(false);
}
}

View File

@@ -0,0 +1,28 @@
// <copyright file="PartyListRequestAction.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.Party;
using MUnique.OpenMU.GameLogic;
using MUnique.OpenMU.GameLogic.Views.Party;
/// <summary>
/// Action to request the party list.
/// </summary>
public class PartyListRequestAction
{
/// <summary>
/// Requests the party list.
/// </summary>
/// <param name="player">The player who is requesting the list.</param>
public async ValueTask RequestPartyListAsync(Player player)
{
if (player.Party is null)
{
return;
}
await player.InvokeViewPlugInAsync<IUpdatePartyListPlugIn>(p => p.UpdatePartyListAsync()).ConfigureAwait(false);
}
}

View File

@@ -0,0 +1,86 @@
// <copyright file="PartyRequestAction.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.Party;
using MUnique.OpenMU.GameLogic.MuHelper;
using MUnique.OpenMU.GameLogic.Views.Party;
/// <summary>
/// The party request action.
/// </summary>
public class PartyRequestAction
{
/// <summary>
/// Handles the party request from the <paramref name="player"/> to <paramref name="toRequest"/>.
/// </summary>
/// <param name="player">The player.</param>
/// <param name="toRequest">The player which receives the request.</param>
public async ValueTask HandlePartyRequestAsync(Player player, Player toRequest)
{
var isPartyMember = player.Party != null && !Equals(player.Party.PartyMaster, player);
if (player.CurrentMiniGame?.Definition.AllowParty is false)
{
await player.ShowLocalizedBlueMessageAsync(nameof(PlayerMessage.PartyNotPossibleDuringEvent)).ConfigureAwait(false);
return;
}
if (toRequest.Party != null || toRequest.LastPartyRequester != null)
{
if (toRequest.Party != null && Equals(toRequest.Party.PartyMaster, toRequest))
{
if (await PartyRequestHandler.TryAutoAcceptPartyRequestAsync(toRequest, player).ConfigureAwait(false))
{
return;
}
}
await player.ShowLocalizedBlueMessageAsync(nameof(PlayerMessage.PlayerIsAlreadyInParty), toRequest.Name).ConfigureAwait(false);
return;
}
if (isPartyMember)
{
await player.ShowLocalizedBlueMessageAsync(nameof(PlayerMessage.YouAreNotPartyMaster)).ConfigureAwait(false);
return;
}
if (toRequest is Offline.OfflinePlayer)
{
if (await PartyRequestHandler.TryAutoAcceptPartyRequestAsync(toRequest, player).ConfigureAwait(false))
{
return;
}
await player.ShowLocalizedBlueMessageAsync(nameof(PlayerMessage.PlayerIsAlreadyInParty), toRequest.Name).ConfigureAwait(false);
return;
}
if (await toRequest.PlayerState.TryAdvanceToAsync(PlayerState.PartyRequest).ConfigureAwait(false))
{
await this.SendPartyRequestAsync(toRequest, player).ConfigureAwait(false);
await player.ShowLocalizedBlueMessageAsync(nameof(PlayerMessage.RequestedPlayerForParty), toRequest.Name).ConfigureAwait(false);
}
}
private async ValueTask SendPartyRequestAsync(IPartyMember toRequest, IPartyMember requester)
{
if (Equals(requester, toRequest))
{
return;
}
toRequest.LastPartyRequester = requester;
if (toRequest is Player receiver && requester is Player requesterPlayer)
{
if (await PartyRequestHandler.TryAutoAcceptPartyRequestAsync(receiver, requesterPlayer).ConfigureAwait(false))
{
return;
}
}
await toRequest.InvokeViewPlugInAsync<IShowPartyRequestPlugIn>(p => p.ShowPartyRequestAsync(requester)).ConfigureAwait(false);
}
}

View File

@@ -0,0 +1,68 @@
// <copyright file="PartyResponseAction.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.Party;
using MUnique.OpenMU.GameLogic;
/// <summary>
/// The party response action.
/// </summary>
public class PartyResponseAction
{
/// <summary>
/// Handles the response of the party request of <see cref="IPartyMember.LastPartyRequester"/>.
/// </summary>
/// <param name="player">The player.</param>
/// <param name="accepted">if set to <c>true</c> the player accepted the party request of <see cref="IPartyMember.LastPartyRequester"/>.</param>
public async ValueTask HandleResponseAsync(Player player, bool accepted)
{
if (player.PlayerState.CurrentState != PlayerState.PartyRequest)
{
player.LastPartyRequester = null;
return;
}
if (player.LastPartyRequester is null)
{
return;
}
await player.PlayerState.TryAdvanceToAsync(PlayerState.EnteredWorld).ConfigureAwait(false);
if (!accepted)
{
player.LastPartyRequester = null;
return;
}
if (player.Party != null)
{
player.LastPartyRequester = null;
return;
}
if (player.CurrentMiniGame?.Definition.AllowParty is false)
{
await player.ShowLocalizedBlueMessageAsync(nameof(PlayerMessage.PartyNotPossibleDuringEvent)).ConfigureAwait(false);
player.LastPartyRequester = null;
return;
}
if (player.LastPartyRequester.Party != null)
{
// The Requester got a party already, so add him to his party
await player.LastPartyRequester.Party.AddAsync(player).ConfigureAwait(false);
}
else
{
var master = player.LastPartyRequester;
var party = player.GameContext.PartyManager.CreateParty();
await party.AddAsync(master).ConfigureAwait(false);
await party.AddAsync(player).ConfigureAwait(false);
}
player.LastPartyRequester = null;
}
}