feat(hs): NPC talk plugin opens team panel when registration is open

This commit is contained in:
Acentech Dev
2026-07-20 23:33:55 +03:00
parent 2efe1ef84d
commit 7e954b610f
2 changed files with 71 additions and 0 deletions

View File

@@ -304,6 +304,23 @@ public class GameContext : AsyncDisposable, IGameContext
return miniGameContext; return miniGameContext;
} }
/// <summary>
/// Gets the currently open <see cref="MiniGames.HeykelSavasiContext"/> instance, if any.
/// </summary>
/// <returns>The open Heykel Savasi context, or <see langword="null" /> if none is currently open.</returns>
/// <remarks>
/// ADAMU-CUSTOM: used by <see cref="PlugIns.HeykelSavasiNpcPlugin"/> to look up the event context
/// when a player talks to NPC 560. Mutations of <see cref="_miniGames"/> (<see cref="GetMiniGameAsync"/>,
/// <see cref="RemoveMiniGameAsync"/>) are synchronized via <see cref="_mapInitializerLock"/>, so this
/// read takes the same lock and snapshots the values before searching.
/// </remarks>
public async ValueTask<MiniGames.HeykelSavasiContext?> GetOpenHeykelSavasiAsync()
{
using var l = await this._mapInitializerLock.LockAsync().ConfigureAwait(false);
return this._miniGames.Values.OfType<MiniGames.HeykelSavasiContext>()
.FirstOrDefault(g => g.State == MiniGameState.Open);
}
/// <inheritdoc /> /// <inheritdoc />
public async ValueTask RemoveMiniGameAsync(MiniGameContext miniGameContext) public async ValueTask RemoveMiniGameAsync(MiniGameContext miniGameContext)
{ {

View File

@@ -0,0 +1,54 @@
// <copyright file="HeykelSavasiNpcPlugin.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.GameLogic.MiniGames;
using MUnique.OpenMU.GameLogic.NPC;
using MUnique.OpenMU.GameLogic.Views;
using MUnique.OpenMU.GameLogic.Views.MiniGames;
using MUnique.OpenMU.Interfaces;
using MUnique.OpenMU.PlugIns;
/// <summary>
/// Handles talking to the Heykel Savasi (statue war) NPC (number 560): opens the team-select
/// panel while the event's registration is open.
/// </summary>
[Guid("80E3B326-474F-45AC-9FA4-3464801AE079")]
[PlugIn]
public class HeykelSavasiNpcPlugin : IPlayerTalkToNpcPlugIn
{
/// <summary>
/// Gets the NPC number of the Heykel Savasi event NPC.
/// </summary>
public static short NpcNumber => 560;
/// <inheritdoc />
public async ValueTask PlayerTalksToNpcAsync(Player player, NonPlayerCharacter npc, NpcTalkEventArgs eventArgs)
{
if (npc.Definition.Number != NpcNumber)
{
return;
}
eventArgs.HasBeenHandled = true;
eventArgs.LeavesDialogOpen = false;
var context = player.GameContext is GameContext gameContext
? await gameContext.GetOpenHeykelSavasiAsync().ConfigureAwait(false)
: null;
if (context is null)
{
await player.InvokeViewPlugInAsync<IShowMessagePlugIn>(p =>
p.ShowMessageAsync("Heykel Savasi su an acik degil.", MessageType.BlueNormal)).ConfigureAwait(false);
return;
}
var red = context.TeamCount(HeykelSavasiTeam.Red);
var blue = context.TeamCount(HeykelSavasiTeam.Blue);
await player.InvokeViewPlugInAsync<IShowHeykelSavasiTeamPanelPlugIn>(p =>
p.ShowTeamPanelAsync(red, blue)).ConfigureAwait(false);
}
}