/// <summary> /// Loads additional information for a persistent NPC from their CharacterTemplate, if they have one. /// </summary> void LoadPersistentNPCTemplateInfo() { if (!CharacterTemplateID.HasValue) { return; } var template = CharacterTemplateManager[CharacterTemplateID.Value]; if (template == null) { return; } var v = template.TemplateTable; _giveCash = v.GiveCash; _giveExp = v.GiveExp; _quests = GetProvidedQuests(template) ?? _emptyQuests; if (v.ChatDialog.HasValue) { _chatDialog = _npcChatManager[v.ChatDialog.Value]; } else { _chatDialog = null; } }
/// <summary> /// When overridden in the derived class, handles additional loading stuff. /// </summary> /// <param name="v">The ICharacterTable containing the database values for this Character.</param> protected override void HandleAdditionalLoading(ICharacterTable v) { base.HandleAdditionalLoading(v); // Set the chat dialog _chatDialog = v.ChatDialog.HasValue ? _npcChatManager[v.ChatDialog.Value] : null; // Set up the shop SetShopFromID(v.ShopID); }
public void StartDialog(NPCChatDialogBase dialog) { if (dialog == null) { Debug.Fail("Dialog is null."); return; } _dialog = dialog; SetFocus(); }
/// <summary> /// Initializes a new instance of the <see cref="NPC"/> class. /// </summary> /// <param name="parent">World that the NPC belongs to.</param> /// <param name="template">NPCTemplate used to create the NPC.</param> /// <param name="map">The map.</param> /// <param name="position">The position.</param> /// <exception cref="ArgumentNullException"><paramref name="parent" /> is <c>null</c>.</exception> /// <exception cref="ArgumentNullException"><paramref name="template" /> is <c>null</c>.</exception> public NPC(World parent, CharacterTemplate template, Map map, Vector2 position) : base(parent, false) { if (parent == null) { throw new ArgumentNullException("parent"); } if (template == null) { throw new ArgumentNullException("template"); } var v = template.TemplateTable; // Set the rest of the template stuff Load(template); _respawnSecs = v.Respawn; _giveExp = v.GiveExp; _giveCash = v.GiveCash; _quests = GetProvidedQuests(template) ?? _emptyQuests; _chatDialog = v.ChatDialog.HasValue ? _npcChatManager[v.ChatDialog.Value] : null; SetShopFromID(v.ShopID); // Set the respawn positions only if the map we set them on is not instanced if (!map.IsInstanced) { RespawnMapID = map.ID; RespawnPosition = position; } else { RespawnMapID = null; RespawnPosition = Vector2.Zero; } LoadSpawnState(); // Done loading SetAsLoaded(); if (log.IsDebugEnabled) { log.DebugFormat("Created NPC instance from template `{0}`.", template); } // Spawn Teleport(map, position); ((IRespawnable)this).Respawn(); }
public void EndDialog() { IsVisible = false; _dialog = null; }