Skip to content

Commit

Permalink
Make guild npcs interactable and add Guild_Open handler (#356)
Browse files Browse the repository at this point in the history
Also adds some resource IDs for guild icons and text
  • Loading branch information
sorokya authored Jun 5, 2024
1 parent d5f2181 commit efd8591
Show file tree
Hide file tree
Showing 12 changed files with 388 additions and 0 deletions.
29 changes: 29 additions & 0 deletions EOLib.Localization/EOResourceID.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,37 @@ public enum EOResourceID

DIALOG_TRANSFER_TRANSFER = 176,

GUILD_GUILD_MASTER = 177,
GUILD_INFORMATION = 178,
GUILD_ADMINISTRATION = 179,
GUILD_MANAGEMENT = 180,

ADMIN_INFO_WORD_BANK_ACCOUNT = 181,

GUILD_BANK_ACCOUNT = ADMIN_INFO_WORD_BANK_ACCOUNT,
GUILD_LEARN_MORE = 182,
GUILD_JOIN_LEAVE_REGISTER = 183,
GUILD_MODIFY_RANKING_DISBAND = 184,
GUILD_DEPOSIT_TO_GUILD_ACCOUNT = 185,
GUILD_JOIN_GUILD = 186,
GUILD_LEAVE_GUILD = 187,
GUILD_REGISTER_GUILD = 188,
GUILD_JOIN_AN_EXISTING_GUILD = 189,
GUILD_LEAVE_YOUR_CURRENT_GUILD = 190,
GUILD_CREATE_YOUR_OWN_GUILD = 191,
GUILD_MODIFY_GUILD = 192,
GUILD_RANKING = 193,
GUILD_DISBAND = 194,
GUILD_CHANGE_YOUR_GUILD_DETAILS = 195,
GUILD_CHANGE_MEMBER_RANKINGS = 196,
GUILD_DISBAND_YOUR_GUILD = 197,
GUILD_DEPOSIT = 198,
GUILD_WITHDRAW = 199,
GUILD_ADD_FUNDS_TO_GUILD = 200,
GUILD_WITHDRAW_FUNDS_FROM_GUILD = 201,
GUILD_REMOVE_MEMBER = 202,
GUILD_REMOVE_A_MEMBER_FROM_GUILD = 203,

SETTING_KEYBOARD_ENGLISH = 253,
SETTING_KEYBOARD_DUTCH = 254,
SETTING_KEYBOARD_SWEDISH = 255,
Expand Down
37 changes: 37 additions & 0 deletions EOLib/Domain/Interact/Guild/GuildActions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using AutomaticTypeMapper;
using EOLib.Net.Communication;
using Moffat.EndlessOnline.SDK.Protocol.Net.Client;

namespace EOLib.Domain.Interact.Guild
{
[AutoMappedType]
public class GuildActions : IGuildActions
{
private readonly IGuildSessionProvider _guildSessionProvider;
private readonly IPacketSendService _packetSendService;

public GuildActions(IGuildSessionProvider guildSessionProvider,
IPacketSendService packetSendService)
{
_guildSessionProvider = guildSessionProvider;
_packetSendService = packetSendService;
}

public void Lookup(string identity)
{
_packetSendService.SendPacket(new GuildReportClientPacket { SessionId = _guildSessionProvider.SessionID, GuildIdentity = identity });
}

public void ViewMembers(string identity)
{
_packetSendService.SendPacket(new GuildTellClientPacket { SessionId = _guildSessionProvider.SessionID, GuildIdentity = identity });
}
}

public interface IGuildActions
{
void Lookup(string identity);

void ViewMembers(string identity);
}
}
25 changes: 25 additions & 0 deletions EOLib/Domain/Interact/Guild/GuildSessionRepository.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using AutomaticTypeMapper;

namespace EOLib.Domain.Interact.Guild
{
public interface IGuildSessionProvider
{
int SessionID { get; }
}

public interface IGuildSessionRepository
{
int SessionID { get; set; }
}

[AutoMappedType(IsSingleton = true)]
public class GuildSessionRepository : IGuildSessionRepository, IGuildSessionProvider
{
public int SessionID { get; set; }

public GuildSessionRepository()
{
SessionID = 0;
}
}
}
8 changes: 8 additions & 0 deletions EOLib/Domain/Interact/MapNPCActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ public void RequestBarber(NPC.NPC npc)
var packet = new BarberOpenClientPacket { NpcIndex = npc.Index };
_packetSendService.SendPacket(packet);
}

public void RequestGuild(NPC.NPC npc)
{
var packet = new GuildOpenClientPacket { NpcIndex = npc.Index };
_packetSendService.SendPacket(packet);
}
}

public interface IMapNPCActions
Expand All @@ -87,6 +93,8 @@ public interface IMapNPCActions
void RequestLaw(NPC.NPC npc);
void RequestPriest(NPC.NPC npc);
void RequestBarber(NPC.NPC npc);

void RequestGuild(NPC.NPC npc);
}

}
45 changes: 45 additions & 0 deletions EOLib/PacketHandlers/Guild/GuildOpenHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using AutomaticTypeMapper;
using EOLib.Domain.Interact;
using EOLib.Domain.Interact.Guild;
using EOLib.Domain.Login;
using EOLib.Domain.Map;
using EOLib.Net.Handlers;
using Moffat.EndlessOnline.SDK.Protocol.Net;
using Moffat.EndlessOnline.SDK.Protocol.Net.Server;
using Optional;
using System.Collections.Generic;

namespace EOLib.PacketHandlers.Guild
{
[AutoMappedType]

public class GuildOpenHandler : InGameOnlyPacketHandler<GuildOpenServerPacket>
{
private readonly IGuildSessionRepository _guildSessionRepository;

private readonly IEnumerable<INPCInteractionNotifier> _npcInteractionNotifiers;

public override PacketFamily Family => PacketFamily.Guild;

public override PacketAction Action => PacketAction.Open;

public GuildOpenHandler(IPlayerInfoProvider playerInfoProvider,
IGuildSessionRepository guildSessionRepository,
IEnumerable<INPCInteractionNotifier> npcInteractionNotifiers)
: base(playerInfoProvider)
{
_guildSessionRepository = guildSessionRepository;
_npcInteractionNotifiers = npcInteractionNotifiers;
}

public override bool HandlePacket(GuildOpenServerPacket packet)
{
_guildSessionRepository.SessionID = packet.SessionId;

foreach (var notifier in _npcInteractionNotifiers)
notifier.NotifyInteractionFromNPC(IO.NPCType.Guild);

return true;
}
}
}
3 changes: 3 additions & 0 deletions EndlessClient/Controllers/NPCInteractionController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ public void ShowNPCDialog(NPC npc)
case EOLib.IO.NPCType.Barber:
_mapNpcActions.RequestBarber(npc);
break;
case EOLib.IO.NPCType.Guild:
_mapNpcActions.RequestGuild(npc);
break;
}
}
}
Expand Down
19 changes: 19 additions & 0 deletions EndlessClient/Dialogs/Actions/InGameDialogActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class InGameDialogActions : IInGameDialogActions
private readonly IJukeboxDialogFactory _jukeboxDialogFactory;
private readonly IInnkeeperDialogFactory _innkeeperDialogFactory;
private readonly ILawDialogFactory _lawDialogFactory;
private readonly IGuildDialogFactory _guildDialogFactory;
private readonly IHelpDialogFactory _helpDialogFactory;
private readonly ISfxPlayer _sfxPlayer;
private readonly IStatusLabelSetter _statusLabelSetter;
Expand Down Expand Up @@ -67,6 +68,7 @@ public InGameDialogActions(IFriendIgnoreListDialogFactory friendIgnoreListDialog
IJukeboxDialogFactory jukeboxDialogFactory,
IInnkeeperDialogFactory innkeeperDialogFactory,
ILawDialogFactory lawDialogFactory,
IGuildDialogFactory guildDialogFactory,
IHelpDialogFactory helpDialogFactory,
ISfxPlayer sfxPlayer,
IStatusLabelSetter statusLabelSetter,
Expand All @@ -92,6 +94,7 @@ public InGameDialogActions(IFriendIgnoreListDialogFactory friendIgnoreListDialog
_jukeboxDialogFactory = jukeboxDialogFactory;
_innkeeperDialogFactory = innkeeperDialogFactory;
_lawDialogFactory = lawDialogFactory;
_guildDialogFactory = guildDialogFactory;
_helpDialogFactory = helpDialogFactory;
_sfxPlayer = sfxPlayer;
_statusLabelSetter = statusLabelSetter;
Expand Down Expand Up @@ -438,6 +441,20 @@ public void ShowLawDialog()
});
}

public void ShowGuildDialog()
{
_activeDialogRepository.GuildDialog.MatchNone(() =>
{
var dlg = _guildDialogFactory.Create();
dlg.DialogClosed += (_, _) => _activeDialogRepository.GuildDialog = Option.None<GuildDialog>();
_activeDialogRepository.GuildDialog = Option.Some(dlg);

dlg.Show();

UseDefaultDialogSounds(dlg);
});
}

public void ShowHelpDialog()
{
_activeDialogRepository.HelpDialog.MatchNone(() =>
Expand Down Expand Up @@ -540,6 +557,8 @@ public interface IInGameDialogActions

void ShowLawDialog();

void ShowGuildDialog();

void ShowHelpDialog();

void ShowBarberDialog();
Expand Down
1 change: 1 addition & 0 deletions EndlessClient/Dialogs/Actions/NpcInteractionActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public void NotifyInteractionFromNPC(NPCType npcType)
case NPCType.Law: _inGameDialogActions.ShowLawDialog(); break;
case NPCType.Barber: _inGameDialogActions.ShowBarberDialog(); break;
case NPCType.Priest: ShowPriestDialog(); break;
case NPCType.Guild: _inGameDialogActions.ShowGuildDialog(); break;
}
}

Expand Down
6 changes: 6 additions & 0 deletions EndlessClient/Dialogs/ActiveDialogRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ public interface IActiveDialogRepository : IDisposable

Option<BarberDialog> BarberDialog { get; set; }

Option<GuildDialog> GuildDialog { get; set; }

Option<ScrollingListDialog> HelpDialog { get; set; }

IReadOnlyList<Option<IXNADialog>> ActiveDialogs { get; }
Expand Down Expand Up @@ -144,6 +146,8 @@ public class ActiveDialogRepository : IActiveDialogRepository, IActiveDialogProv

public Option<BarberDialog> BarberDialog { get; set; }

public Option<GuildDialog> GuildDialog { get; set; }

public Option<ScrollingListDialog> HelpDialog { get; set; }

IReadOnlyList<Option<IXNADialog>> ActiveDialogs
Expand Down Expand Up @@ -172,6 +176,7 @@ IReadOnlyList<Option<IXNADialog>> ActiveDialogs
InnkeeperDialog.Map(Map),
LawDialog.Map(Map),
BarberDialog.Map(Map),
GuildDialog.Map(Map),
HelpDialog.Map(Map),
}.ToList();

Expand Down Expand Up @@ -211,6 +216,7 @@ public void Dispose()
InnkeeperDialog = Option.None<InnkeeperDialog>();
LawDialog = Option.None<LawDialog>();
BarberDialog = Option.None<BarberDialog>();
GuildDialog = Option.None<GuildDialog>();
HelpDialog = Option.None<ScrollingListDialog>();
}
}
Expand Down
64 changes: 64 additions & 0 deletions EndlessClient/Dialogs/Factories/GuildDialogFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
using AutomaticTypeMapper;
using EndlessClient.Content;
using EndlessClient.Dialogs.Services;
using EOLib.Domain.Interact.Guild;
using EOLib.Domain.Map;
using EOLib.Graphics;
using EOLib.IO.Repositories;
using EOLib.Localization;

namespace EndlessClient.Dialogs.Factories
{
[AutoMappedType]
public class GuildDialogFactory : IGuildDialogFactory
{
private readonly INativeGraphicsManager _nativeGraphicsManager;
private readonly IEODialogButtonService _dialogButtonService;
private readonly IEODialogIconService _dialogIconService;
private readonly ILocalizedStringFinder _localizedStringFinder;
private readonly ITextInputDialogFactory _textInputDialogFactory;
private readonly IGuildActions _GuildActions;
private readonly IContentProvider _contentProvider;
private readonly ICurrentMapStateProvider _currentMapStateProvider;
private readonly IENFFileProvider _enfFileProvider;

public GuildDialogFactory(INativeGraphicsManager nativeGraphicsManager,
IEODialogButtonService dialogButtonService,
IEODialogIconService dialogIconService,
ILocalizedStringFinder localizedStringFinder,
ITextInputDialogFactory textInputDialogFactory,
IGuildActions GuildActions,
IContentProvider contentProvider,
ICurrentMapStateProvider currentMapStateProvider,
IENFFileProvider enfFileProvider)
{
_nativeGraphicsManager = nativeGraphicsManager;
_dialogButtonService = dialogButtonService;
_dialogIconService = dialogIconService;
_localizedStringFinder = localizedStringFinder;
_textInputDialogFactory = textInputDialogFactory;
_GuildActions = GuildActions;
_contentProvider = contentProvider;
_currentMapStateProvider = currentMapStateProvider;
_enfFileProvider = enfFileProvider;
}

public GuildDialog Create()
{
return new GuildDialog(_nativeGraphicsManager,
_dialogButtonService,
_dialogIconService,
_localizedStringFinder,
_textInputDialogFactory,
_GuildActions,
_contentProvider,
_currentMapStateProvider,
_enfFileProvider);
}
}

public interface IGuildDialogFactory
{
GuildDialog Create();
}
}
Loading

0 comments on commit efd8591

Please sign in to comment.