feat(ADAMU-CUSTOM): port remote-NPC (open NPC window from anywhere via 0x8000 marker)
This commit is contained in:
@@ -57,6 +57,39 @@ public class TalkNpcAction
|
||||
}
|
||||
}
|
||||
|
||||
// ADAMU-CUSTOM: remote NPC — NPC'ye definition number ile her yerden konuş (mobile "NPC list").
|
||||
/// <summary>
|
||||
/// Talks to an NPC identified by its definition <paramref name="npcNumber"/>, regardless of the
|
||||
/// player's current position or map (no proximity required). Used by the mobile "NPC list" to
|
||||
/// open a merchant store / chaos machine / vault from anywhere. Loads the NPC's home map if it
|
||||
/// isn't loaded yet, then reuses the normal <see cref="TalkToNpcAsync"/> flow.
|
||||
/// </summary>
|
||||
/// <param name="player">The player.</param>
|
||||
/// <param name="npcNumber">The NPC definition number.</param>
|
||||
public async ValueTask TalkToNpcByNumberAsync(Player player, short npcNumber)
|
||||
{
|
||||
var gameContext = player.GameContext;
|
||||
|
||||
// NPC'nin spawn olduğu haritayı bul, (gerekiyorsa) yükle ve instance'ı al.
|
||||
foreach (var mapDef in gameContext.Configuration.Maps)
|
||||
{
|
||||
if (mapDef.MonsterSpawns is null
|
||||
|| !mapDef.MonsterSpawns.Any(s => s.MonsterDefinition?.Number == npcNumber))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var map = await gameContext.GetMapAsync((ushort)mapDef.Number).ConfigureAwait(false);
|
||||
if (map?.GetNpcByNumber(npcNumber) is { } npc)
|
||||
{
|
||||
await this.TalkToNpcAsync(player, npc).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ADAMU-CUSTOM end
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether this action advances the player state to <see cref="PlayerState.NpcDialogOpened" />.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user