Пример #1
0
		public static void HandleGossipHello(IRealmClient client, RealmPacketIn packet)
		{
			var targetEntityId = packet.ReadEntityId();

			var chr = client.ActiveCharacter;
			var target = chr.Region.GetObject(targetEntityId) as Unit;

			if (target == null)
				return;

			if (chr.GossipConversation != null)
			{
				chr.GossipConversation = null;
			}

			var menu = target.GossipMenu;
			if (menu == null)
				return;

			if (target is NPC)
			{
				if (!((NPC)target).CanInteractWith(chr))
				{
					return;
				}
			}
			else if (!chr.Role.IsStaff)
			{
				return;
			}
			chr.OnInteract(target);
			var conversation = new GossipConversation(menu, chr, target, menu.KeepOpen);
			client.ActiveCharacter.GossipConversation = conversation;
			conversation.DisplayCurrentMenu();
		}
Пример #2
0
		/// <summary>
		/// Generate the menu's text dynamically
		/// </summary>
		public override string GetText(GossipConversation convo)
		{
			var text = RealmLocalizer.Instance.Translate(convo.Character.Locale, RealmLangKey.EditorMapMenuText) + GossipTextHelper.Newline;

			if (!GOMgr.Loaded || !NPCMgr.Loaded)
			{
				if (!convo.Speaker.HasUpdateAction(action => action is PeriodicLoadMapTimer))
				{
					// already loading
					text += RealmLocalizer.Instance.Translate(convo.Character.Locale, RealmLangKey.EditorMapMenuStatusNoData);
				}
				else
				{
					// not loading yet
					text += RealmLocalizer.Instance.Translate(convo.Character.Locale, RealmLangKey.EditorMapMenuStatusDataLoading);
				}
			}
			else if (!Editor.Map.IsSpawned)
			{
				if (Editor.Map.IsSpawning)
				{
					// already spawning
					text += RealmLocalizer.Instance.Translate(convo.Character.Locale, RealmLangKey.EditorMapMenuStatusSpawning);
				}
				else
				{
					// not spawning yet
					text += RealmLocalizer.Instance.Translate(convo.Character.Locale, RealmLangKey.EditorMapMenuStatusNotSpawned);
				}
			}
			return text;
		}
Пример #3
0
 public override string GetConfirmText(GossipConversation convo)
 {
     if (this.ConfirmText != null)
     {
         return(this.ConfirmText.Translate(convo.User.Locale));
     }
     return("");
 }
Пример #4
0
 public override string GetTextFemale(GossipConversation convo)
 {
     if (convo == null)
     {
         return("<invalid context>");
     }
     return(this.StringGetter(convo));
 }
Пример #5
0
		public override string GetText(GossipConversation convo)
		{
			return Text.Translate(convo.User.Locale);
		}
Пример #6
0
 public abstract string GetTextFemale(GossipConversation convo);
Пример #7
0
		public virtual void OnSelect(GossipConversation convo)
        {
        }
Пример #8
0
		public override string GetTextFemale(GossipConversation convo)
		{
			return TextFemale;
		}
Пример #9
0
		/// <summary>
		/// Called before menu is sent to Character
		/// </summary>
		protected internal virtual void OnDisplay(GossipConversation convo)
		{
		}
Пример #10
0
 public override string GetText(GossipConversation convo)
 {
     return(this.Text.Translate(convo.User.Locale));
 }
Пример #11
0
		/// <summary>
		/// Handle what happens when clicking on the Teleport option
		/// </summary>
		void HandleTeleport(GossipConversation convo)
		{
			convo.Character.TeleportTo(m_point);
		}
Пример #12
0
 public abstract string GetConfirmText(GossipConversation convo);
Пример #13
0
			/// <summary>
			/// Move the Waypoint over to the Character
			/// </summary>
			void HandleMoveOver(GossipConversation convo)
			{
				m_Point.MoveWP(m_wp, convo.Character.Position);
			}
Пример #14
0
			/// <summary>
			/// Insert a new WP
			/// </summary>
			void HandleInsert(GossipConversation convo)
			{
				m_Point.InsertAfter(m_wp, convo.Character.Position, convo.Character.Orientation);
			}
Пример #15
0
			/// <summary>
			/// Remove the WP
			/// </summary>
			void HandleRemove(GossipConversation convo)
			{
				m_Point.RemoveWP(m_wp);

				// the WP is now gone, so let's send the Menu again (without this Item in it)
				convo.Invalidate();
			}
Пример #16
0
			/// <summary>
			/// Go to the WP
			/// </summary>
			void HandleGoto(GossipConversation convo)
			{
				convo.Character.TeleportTo(m_Point.Region, m_wp.Position);
			}
Пример #17
0
		public void OnSelect(GossipConversation convo)
		{
			m_Handler(convo);
		}
Пример #18
0
			public PeriodicLoadMapTimer(GossipConversation convo)
			{
				m_Convo = convo;
				Delay = 1000;
				Callback = OnTick;
			}
Пример #19
0
		/// <summary>
		/// Handle what happens when clicking on the Remove option
		/// </summary>
		private void HandleRemove(GossipConversation convo)
		{
			m_point.RemoveSpawnLater();
		}
Пример #20
0
		static void OnLoadClicked(GossipConversation convo)
		{
			GOMgr.LoadAllLater();
			NPCMgr.LoadAllLater();

			var chr = convo.Character;
			chr.SendSystemMessage(RealmLangKey.PleaseWait);

			convo.Character.AddUpdateAction(new PeriodicLoadMapTimer(convo));
		}
Пример #21
0
		/// <summary>
		/// Handle what happens when clicking on the Add WP button
		/// </summary>
		private void HandleAddWP(GossipConversation convo)
		{
			var chr = convo.Character;
			m_point.InsertAfter(null, chr.Position, chr.Orientation);
		}
Пример #22
0
		private static string OnTextQuery(GossipConversation convo)
		{
			return ((DynamicTextGossipMenu)convo.CurrentMenu).GetText(convo);
		}
Пример #23
0
 /// <summary>
 /// Called before menu is sent to Character
 /// </summary>
 protected internal virtual void OnDisplay(GossipConversation convo)
 {
 }
Пример #24
0
		internal void NotifyClose(GossipConversation convo)
		{
		}
Пример #25
0
 public override string GetTextFemale(GossipConversation convo)
 {
     return(TextFemale);
 }
Пример #26
0
        /// <summary>
        /// Sends a page to the character
        /// </summary>
        /// <param name="chr">recieving character</param>
        /// <param name="owner">EntityID of sender</param>
        public static void SendPageToCharacter(GossipConversation convo,
                                               IList<QuestMenuItem> questItems)
        {
            var speaker = convo.Speaker;
            var chr = convo.Character;

            var menu = convo.CurrentMenu;
            var gossipItems = menu.GossipItems;
            var gossipEntry = menu.GossipEntry;

            if (gossipEntry.IsDynamic)
            {
                // not cached
                QueryHandler.SendNPCTextUpdate(chr, gossipEntry);
            }

            using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_GOSSIP_MESSAGE))
            {
                packet.Write(speaker.EntityId);
                packet.Write(0);				// new Flag field since 2.4.0 - menu id
                packet.Write(gossipEntry.GossipId);

                var countPos = packet.Position;
                packet.Position += 4;
                var count = 0;
                if (gossipItems != null)
                {
                    for (var i = 0; i < gossipItems.Count; i++)
                    {
                        var item = gossipItems[i];
                        if (item.Action != null && !item.Action.CanUse(convo))
                        {
                            continue;
                        }

                        packet.Write(i);
                        packet.Write((byte)item.Icon);
                        packet.Write(item.Input);
                        packet.Write((uint)item.RequiredMoney);
                        packet.WriteCString(item.GetText(convo));
                        packet.WriteCString(item.GetConfirmText(convo));
                        count++;
                    }
                }

                if (questItems != null)
                {
                    packet.WriteUInt(questItems.Count);
                    for (int i = 0; i < questItems.Count; i++)
                    {
                        var item = questItems[i];
                        packet.Write(item.ID);
                        packet.Write(item.Status);
                        packet.Write(item.Level);
                        packet.Write(0); // quest flags
                        packet.Write((byte)0); // 3.3.3 flag (blue question or yelloe exclamation mark)
                        packet.WriteCString(item.Text);
                    }
                }
                else
                    packet.Write(0);

                packet.Position = countPos;
                packet.Write(count);

                chr.Client.Send(packet);
            }
        }
Пример #27
0
		public override string GetConfirmText(GossipConversation convo)
		{
			if (ConfirmText != null)
				return ConfirmText.Translate(convo.User.Locale);
			return "";
		}
Пример #28
0
 internal void NotifyClose(GossipConversation convo)
 {
 }
Пример #29
0
 public override string GetTextMale(GossipConversation convo)
 {
     return(this.TextMale);
 }
Пример #30
0
		public abstract string GetTextFemale(GossipConversation convo);
Пример #31
0
		/// <summary>
		/// Lets the Character gossip with the given speaker
		/// </summary>
		public void StartGossip(GossipMenu menu, WorldObject speaker)
		{
			GossipConversation = new GossipConversation(menu, this, speaker, menu.KeepOpen);
			GossipConversation.DisplayCurrentMenu();
		}
Пример #32
0
		public override string GetTextFemale(GossipConversation convo)
		{
			if (convo == null) return "<invalid context>";
			return StringGetter(convo);
		}
Пример #33
0
 public override string GetConfirmText(GossipConversation convo)
 {
     return(ConfirmText);
 }
Пример #34
0
		/// <summary>
		/// Lets the Character gossip with herself
		/// </summary>
		public void StartGossip(GossipMenu menu)
		{
			GossipConversation = new GossipConversation(menu, this, this, menu.KeepOpen);
			GossipConversation.DisplayCurrentMenu();
		}
Пример #35
0
		/// <summary>
		/// Sends a page to the character
		/// </summary>
		/// <param name="chr">recieving character</param>
		/// <param name="owner">EntityID of sender</param>
		public static void SendPageToCharacter(GossipConversation convo, uint bodyTextID,
											   IList<GossipMenuItemBase> gossipItems,
											   IList<QuestMenuItem> questItems)
		{
			var owner = convo.Speaker;
			var chr = convo.Character;

			if (bodyTextID == 0)
			{
				// Client won't display the gossip if text id is 0
				bodyTextID = 1;
			}
			using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_GOSSIP_MESSAGE))
			{
				packet.Write(owner.EntityId);
				packet.Write(0);				// new Flag field since 2.4.0 - menu id
				packet.Write(bodyTextID);

				var countPos = packet.Position;
				packet.Position += 4;
				var count = 0;
				if (gossipItems != null)
				{
					for (var i = 0; i < gossipItems.Count; i++)
					{
						var item = gossipItems[i];
						if (item.Action != null && !item.Action.CanUse(chr))
						{
							continue;
						}

						packet.Write(i);
						packet.Write((byte)item.Icon);
						packet.Write(item.Input);
						packet.Write((uint)item.RequiredMoney);
						packet.WriteCString(item.GetText(convo));
						packet.WriteCString(item.GetConfirmText(convo));
						count++;
					}
				}

				if (questItems != null)
				{
					packet.WriteUInt(questItems.Count);
					for (int i = 0; i < questItems.Count; i++)
					{
						var item = questItems[i];
						packet.Write(item.ID);
						packet.Write(item.Status);
						packet.Write(item.Level);
					    packet.Write(0); // quest flags
					    packet.Write((byte)0); // 3.3.3 flag (blue question or yelloe exclamation mark)
						packet.WriteCString(item.Text);
					}
				}
				else
					packet.Write(0);

				packet.Position = countPos;
				packet.Write(count);

				chr.Client.Send(packet);
			}
		}
Пример #36
0
 private static string OnTextQuery(GossipConversation convo)
 {
     return(((DynamicTextGossipMenu)convo.CurrentMenu).GetText(convo));
 }
Пример #37
0
		public override string GetConfirmText(GossipConversation convo)
		{
			return ConfirmTexts.Localize(convo.User.Locale);
		}
Пример #38
0
 public override string GetText(GossipConversation convo)
 {
     return SpawnPoint.ToString();
 }
Пример #39
0
		public override string GetConfirmText(GossipConversation convo)
		{
			return ConfirmText;
		}
Пример #40
0
		public abstract string GetConfirmText(GossipConversation convo);
Пример #41
0
		public override string GetText(GossipConversation convo)
		{
			return "";
		}
Пример #42
0
 public override string GetConfirmText(GossipConversation convo)
 {
     return(ConfirmTexts.Localize(convo.User.Locale));
 }
Пример #43
0
 public override string GetConfirmText(GossipConversation convo)
 {
     return(GetConfirmTextCallback(convo, (M)convo.CurrentMenu));
 }