using System.Collections.Generic; public class ObjectiveInteractWithNPCRebirth : BaseObjective { public override void SetupObjective() { //Log.Out("ObjectiveInteractWithNPCRebirth-SetupObjective"); } public override void SetupDisplay() { //Log.Out("ObjectiveInteractWithNPCRebirth-SetupDisplay"); Description = Localization.Get("ObjectiveTalkToTrader_" + traderID); StatusText = ""; } public override bool PlayObjectiveComplete { get { return false; } } public override void AddHooks() { //Log.Out("ObjectiveInteractWithNPCRebirth-AddHooks"); QuestEventManager.Current.NPCInteract += Current_NPCInteract; if (useClosest) { List entitiesInBounds = GameManager.Instance.World.GetEntitiesInBounds(null, new Bounds(OwnerQuest.Position, new Vector3(50f, 50f, 50f))); if (entitiesInBounds != null && entitiesInBounds.Count > 0) { for (int i = 0; i < entitiesInBounds.Count; i++) { if (entitiesInBounds[i] is EntityNPC) { OwnerQuest.SetPositionData(Quest.PositionDataTypes.QuestGiver, entitiesInBounds[i].position); OwnerQuest.QuestGiverID = entitiesInBounds[i].entityId; OwnerQuest.QuestFaction = ((EntityNPC)entitiesInBounds[i]).NPCInfo.QuestFaction; OwnerQuest.RallyMarkerActivated = true; OwnerQuest.HandleMapObject(Quest.PositionDataTypes.QuestGiver, NavObjectName, -1); return; } } } } } public override void RemoveHooks() { //Log.Out("ObjectiveInteractWithNPCRebirth-RemoveHooks"); QuestEventManager.Current.NPCInteract -= Current_NPCInteract; } private void Current_NPCInteract(EntityNPC npc) { /*Log.Out("ObjectiveInteractWithNPCRebirth-Current_NPCInteract EntityName: " + npc.EntityName); Log.Out("ObjectiveInteractWithNPCRebirth-Current_NPCInteract entityClassName: " + npc.EntityClass.entityClassName); Log.Out("ObjectiveInteractWithNPCRebirth-Current_NPCInteract traderID: " + traderID);*/ string[] words = traderID.Split('~'); for (int i = 0; i < words.Length; i++) { if (npc.EntityClass.entityClassName == words[i]) { if (OwnerQuest.QuestFaction == 0) { OwnerQuest.QuestFaction = npc.NPCInfo.QuestFaction; } traderName = npc.EntityName; CurrentValue = 1; Refresh(); break; } } } public override void Refresh() { //Log.Out("ObjectiveInteractWithNPCRebirth-Refresh"); if (Complete) return; bool complete = CurrentValue == 1; Complete = complete; if (Complete) { OwnerQuest.RefreshQuestCompletion(QuestClass.CompletionTypes.AutoComplete, null, PlayObjectiveComplete); } } public override BaseObjective Clone() { //Log.Out("ObjectiveInteractWithNPCRebirth-Clone"); ObjectiveInteractWithNPCRebirth ObjectiveInteractWithNPCRebirth = new ObjectiveInteractWithNPCRebirth(); CopyValues(ObjectiveInteractWithNPCRebirth); ObjectiveInteractWithNPCRebirth.useClosest = useClosest; ObjectiveInteractWithNPCRebirth.traderID = traderID; return ObjectiveInteractWithNPCRebirth; } public override void ParseProperties(DynamicProperties properties) { //Log.Out("ObjectiveInteractWithNPCRebirth-ParseProperties"); base.ParseProperties(properties); if (properties.Values.ContainsKey(PropUseClosest)) { useClosest = StringParsers.ParseBool(properties.Values[PropUseClosest], 0, -1, true); } if (properties.Values.ContainsKey(PropTraderName)) { traderID = properties.Values[PropTraderName]; } //Log.Out("ObjectiveInteractWithNPCRebirth-ParseProperties, this.traderID: " + this.traderID); } public static string PropUseClosest = "use_closest"; public static string PropTraderName = "trader_id"; private bool useClosest; private string traderID = ""; private string traderName = ""; }