/// <summary>
        /// Given an NPC and player, begins a dialog between the two.
        /// </summary>
        /// <param name="player"></param>
        /// <param name="npc"></param>
        public void BeginDialog(Player player, Npc npc)
        {
            var npcDialog = npc.DialogTemplate;

            DialogProvider dialogProvider;

            if (_dialogProviders[player].FindProviderFor(npc) == null)
            {

                //TODO: Frequent IO hit; bad
                dialogProvider = new DialogProvider(npcDialog);

                // Insert the provider
                _dialogProviders[player].InsertProviderFor(npc, dialogProvider);

                dialogProvider.DialogNodeChanged -= DialogProviderOnDialogNodeChanged;
                dialogProvider.DialogNodeChanged += DialogProviderOnDialogNodeChanged;

            }
            else
            {
                dialogProvider = _dialogProviders[player].FindProviderFor(npc);
            }

            // Begin the dialog
            dialogProvider.BeginDialogWith(player);
        }
        public static Npc CreateNpc(long id)
        {
            using (var context = new GameDatabaseContext())
            {
                var template = context.Npcs.FirstOrDefault(x => x.Id == id);

                if (template == null)
                    throw new Exception("Creating an NPC with the given Id is invalid.");

                // Load up the quests this NPC will have
                context.Entry(template).Collection(x => x.Quests).Load();
                context.Entry(template).Reference(x => x.ConversationAvailableTemplate).Load();

                foreach (var quest in template.Quests)
                {

                    context.Entry(quest).Collection(x => x.QuestSteps).Load();
                    context.Entry(quest).Collection(x => x.Rewards).Load();

                    // Load up our set of requirements from the table
                    foreach (var x in quest.QuestSteps)
                        context.Entry(x).Collection(a => a.Requirements).Load();

                }

                var npc = new Npc(template);

                return npc;

            }
        }
 public NpcEventReceiverContext(Player localPlayer, Npc localNpc)
 {
     LocalPlayer = localPlayer;
     LocalNpc = localNpc;
 }
 public void AdvanceDialog(Player player, Npc npc, int linkId)
 {
     // Advance the dialog, which will fire an update to the client anyway
     var dialogProvider = _dialogProviders[player].FindProviderFor(npc);
     dialogProvider.FollowLinkWithAndUpdate(player, linkId);
 }