-
Notifications
You must be signed in to change notification settings - Fork 16
/
NPCInteractionController.cs
75 lines (68 loc) · 2.99 KB
/
NPCInteractionController.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
using AutomaticTypeMapper;
using EndlessClient.Dialogs;
using EndlessClient.Dialogs.Actions;
using EndlessClient.HUD;
using EndlessClient.Input;
using EOLib.Domain.Interact;
using EOLib.Domain.NPC;
using EOLib.IO.Repositories;
using EOLib.Localization;
using System.Linq;
namespace EndlessClient.Controllers
{
[AutoMappedType]
public class NPCInteractionController : INPCInteractionController
{
private readonly IMapNPCActions _mapNpcActions;
private readonly IInGameDialogActions _inGameDialogActions;
private readonly IStatusLabelSetter _statusLabelSetter;
private readonly IENFFileProvider _enfFileProvider;
private readonly IActiveDialogProvider _activeDialogProvider;
private readonly IUserInputRepository _userInputRepository;
public NPCInteractionController(IMapNPCActions mapNpcActions,
IInGameDialogActions inGameDialogActions,
IStatusLabelSetter statusLabelSetter,
IENFFileProvider enfFileProvider,
IActiveDialogProvider activeDialogProvider,
IUserInputRepository userInputRepository)
{
_mapNpcActions = mapNpcActions;
_inGameDialogActions = inGameDialogActions;
_statusLabelSetter = statusLabelSetter;
_enfFileProvider = enfFileProvider;
_activeDialogProvider = activeDialogProvider;
_userInputRepository = userInputRepository;
}
public void ShowNPCDialog(INPC npc)
{
if (_activeDialogProvider.ActiveDialogs.Any(x => x.HasValue))
return;
var data = _enfFileProvider.ENFFile[npc.ID];
// there is no "NPC" text in the localized files
_statusLabelSetter.SetStatusLabel($"[ NPC ] {data.Name}");
switch(data.Type)
{
case EOLib.IO.NPCType.Shop:
_mapNpcActions.RequestShop(npc);
_userInputRepository.ClickHandled = true;
break;
case EOLib.IO.NPCType.Quest:
_mapNpcActions.RequestQuest(npc);
_userInputRepository.ClickHandled = true;
break;
case EOLib.IO.NPCType.Bank:
_mapNpcActions.RequestBank(npc);
// note: the npc action types rely on a server response to show the dialog because they are driven
// by config data on the server. Bank account dialog does not have this restriction;
// interaction with the NPC should *always* show the dialog
_inGameDialogActions.ShowBankAccountDialog();
_userInputRepository.ClickHandled = true;
break;
}
}
}
public interface INPCInteractionController
{
void ShowNPCDialog(INPC npc);
}
}