public static PacketWriter AcceptOrTurnInQuest(MapEntityIndex questProvider, QuestID questID) { var pw = GetWriter(ClientPacketID.AcceptOrTurnInQuest); pw.Write(questProvider); pw.Write(questID); return pw; }
public static PacketWriter NotifyLevel(MapEntityIndex mapEntityIndex) { var pw = GetWriter(ServerPacketID.NotifyLevel); pw.Write(mapEntityIndex); return(pw); }
public static PacketWriter CharDamage(MapEntityIndex mapEntityIndex, int damage) { var pw = GetWriter(ServerPacketID.CharDamage); pw.Write(mapEntityIndex); pw.Write(damage); return pw; }
public static PacketWriter RemoveDynamicEntity(MapEntityIndex mei) { var pw = GetWriter(ServerPacketID.RemoveDynamicEntity); pw.Write(mei); return(pw); }
public static PacketWriter UseWorld(MapEntityIndex useItemIndex) { var pw = GetWriter(ClientPacketID.UseWorld); pw.Write(useItemIndex); return(pw); }
public static PacketWriter StartShopping(MapEntityIndex entityIndex) { var pw = GetWriter(ClientPacketID.StartShopping); pw.Write(entityIndex); return(pw); }
public static PacketWriter RequestDynamicEntity(MapEntityIndex index) { var pw = GetWriter(ClientPacketID.RequestDynamicEntity); pw.Write(index); return(pw); }
public static PacketWriter PickupItem(MapEntityIndex mapEntityIndex) { var pw = GetWriter(ClientPacketID.PickupItem); pw.Write(mapEntityIndex); return(pw); }
public ItemEntity(MapEntityIndex mapEntityIndex, Vector2 pos, Vector2 size, GrhIndex graphicIndex, TickCount currentTime) : base(pos, size) { Amount = 0; ((IDynamicEntitySetMapEntityIndex)this).SetMapEntityIndex(mapEntityIndex); _grh = new Grh(GrhInfo.GetData(graphicIndex), AnimType.Loop, currentTime); }
public static PacketWriter StartNPCChatDialog(MapEntityIndex npcIndex, bool forceSkipQuestDialog) { var pw = GetWriter(ClientPacketID.StartNPCChatDialog); pw.Write(npcIndex); pw.Write(forceSkipQuestDialog); return(pw); }
public static PacketWriter AcceptOrTurnInQuest(MapEntityIndex questProvider, QuestID questID) { var pw = GetWriter(ClientPacketID.AcceptOrTurnInQuest); pw.Write(questProvider); pw.Write(questID); return(pw); }
public static PacketWriter UseEntity(MapEntityIndex usedEntity, MapEntityIndex usedBy) { var pw = GetWriter(ServerPacketID.UseEntity); pw.Write(usedEntity); pw.Write(usedBy); return(pw); }
public static PacketWriter Emote(MapEntityIndex mapEntityIndex, Emoticon emoticon) { var pw = GetWriter(ServerPacketID.Emote); pw.Write(mapEntityIndex); pw.WriteEnum(emoticon); return(pw); }
public static PacketWriter ChatSay(string name, MapEntityIndex mapEntityIndex, string text) { var pw = GetWriter(ServerPacketID.ChatSay); pw.Write(name, GameData.MaxServerSayNameLength); pw.Write(mapEntityIndex); pw.Write(text, GameData.MaxServerSayLength); return pw; }
public static PacketWriter SkillStartCasting_ToMap(MapEntityIndex entityIndex, SkillType skillType) { var pw = GetWriter(ServerPacketID.SkillStartCasting_ToMap); pw.Write(entityIndex); pw.WriteEnum(skillType); return(pw); }
public static PacketWriter PlaySoundAtEntity(SoundID sound, MapEntityIndex mapEntityIndex) { var pw = GetWriter(ServerPacketID.PlaySoundAtEntity); pw.Write(sound); pw.Write(mapEntityIndex); return(pw); }
public static PacketWriter CharDamage(MapEntityIndex mapEntityIndex, int damage) { var pw = GetWriter(ServerPacketID.CharDamage); pw.Write(mapEntityIndex); pw.Write(damage); return(pw); }
public static PacketWriter Attack(MapEntityIndex? target) { var pw = GetWriter(ClientPacketID.Attack); pw.Write(target.HasValue); if (target.HasValue) pw.Write(target.Value); return pw; }
public static PacketWriter StartChatDialog(MapEntityIndex npcIndex, NPCChatDialogID dialogID) { var pw = GetWriter(ServerPacketID.StartChatDialog); pw.Write(npcIndex); pw.Write(dialogID); return(pw); }
public static PacketWriter StartShopping(MapEntityIndex shopOwnerIndex, IShop<ShopItem> shop) { var pw = GetWriter(ServerPacketID.StartShopping); pw.Write(shopOwnerIndex); pw.Write(shop.CanBuy); pw.Write(shop.Name); shop.WriteShopItems(pw); return pw; }
public static void SetProvidedQuests(PacketWriter pw, MapEntityIndex mapEntityIndex, IEnumerable <QuestID> quests) { pw.WriteEnum(ServerPacketID.SetProvidedQuests); pw.Write(mapEntityIndex); pw.Write((byte)quests.Count()); foreach (var q in quests) { pw.Write(q); } }
public static PacketWriter SetCharacterPaperDoll(MapEntityIndex mapEntityIndex, IEnumerable<string> layers) { var pw = GetWriter(ServerPacketID.SetCharacterPaperDoll); pw.Write(mapEntityIndex); pw.Write((byte)layers.Count()); foreach (var layer in layers) { pw.Write(layer); } return pw; }
public static PacketWriter CharAttack(MapEntityIndex attacker, MapEntityIndex? attacked = null, ActionDisplayID? actionDisplay = null) { var pw = GetWriter(ServerPacketID.CharAttack); pw.Write(attacker); pw.Write(attacked.HasValue); if (attacked.HasValue) pw.Write(attacked.Value); pw.Write(actionDisplay.HasValue); if (actionDisplay.HasValue) pw.Write(actionDisplay.Value); return pw; }
public static PacketWriter SkillUse(MapEntityIndex user, MapEntityIndex? target, SkillType skillType) { var pw = GetWriter(ServerPacketID.SkillUse); pw.Write(user); if (target.HasValue) { pw.Write(true); pw.Write(target.Value); } else pw.Write(false); pw.WriteEnum(skillType); return pw; }
static Character GetTargetCharacter(Character user, MapEntityIndex? index) { if (!index.HasValue) return null; // Check for a valid user if (user == null || user.Map == null) return null; // Check for a valid target index var target = user.Map.GetDynamicEntity<Character>(index.Value); if (target == null || target.Map != user.Map) return null; // Check for a valid distance if (user.GetDistance(target) > GameData.MaxTargetDistance) return null; return target; }
public static PacketWriter StartQuestChatDialog(MapEntityIndex npcIndex, IEnumerable <QuestID> availableQuests, IEnumerable <QuestID> turnInQuests) { var pw = GetWriter(ServerPacketID.StartQuestChatDialog); pw.Write(npcIndex); // Write the list of available quests if (availableQuests != null) { var values = availableQuests.ToImmutable(); Debug.Assert(values.Count() <= byte.MaxValue); pw.Write((byte)values.Count()); foreach (var q in values) { pw.Write(q); } } else { pw.Write((byte)0); } // Write the list of quests that can be turned in if (turnInQuests != null) { var values = turnInQuests.ToImmutable(); Debug.Assert(values.Count() <= byte.MaxValue); pw.Write((byte)values.Count()); foreach (var q in values) { pw.Write(q); } } else { pw.Write((byte)0); } return(pw); }
public static PacketWriter PlaySoundAtEntity(SoundID sound, MapEntityIndex mapEntityIndex) { var pw = GetWriter(ServerPacketID.PlaySoundAtEntity); pw.Write(sound); pw.Write(mapEntityIndex); return pw; }
public static PacketWriter RemoveDynamicEntity(MapEntityIndex mei) { var pw = GetWriter(ServerPacketID.RemoveDynamicEntity); pw.Write(mei); return pw; }
public static PacketWriter UseEntity(MapEntityIndex usedEntity, MapEntityIndex usedBy) { var pw = GetWriter(ServerPacketID.UseEntity); pw.Write(usedEntity); pw.Write(usedBy); return pw; }
public static PacketWriter UseSkill(SkillType skillType, MapEntityIndex? target) { var pw = GetWriter(ClientPacketID.UseSkill); pw.WriteEnum(skillType); pw.Write(target.HasValue); if (target.HasValue) pw.Write(target.Value); return pw; }
public static PacketWriter UseWorld(MapEntityIndex useItemIndex) { var pw = GetWriter(ClientPacketID.UseWorld); pw.Write(useItemIndex); return pw; }
public static PacketWriter Emote(MapEntityIndex mapEntityIndex, Emoticon emoticon) { var pw = GetWriter(ServerPacketID.Emote); pw.Write(mapEntityIndex); pw.WriteEnum(emoticon); return pw; }
/// <summary> /// Gets a dynamic entity. /// </summary> /// <typeparam name="T">The type of <see cref="DynamicEntity"/> to get.</typeparam> /// <param name="index">The <see cref="MapEntityIndex"/>.</param> /// <returns>The <see cref="DynamicEntity"/> for the given <paramref name="index"/>, or null if no <see cref="DynamicEntity"/> /// exists at that index or it was an invalid type.</returns> public T GetDynamicEntity <T>(MapEntityIndex index) where T : class { var de = _parent.Map.GetDynamicEntity(index); var casted = de as T; if (casted != null) { // Successfully got the DynamicEntity Debug.Assert(de.MapEntityIndex == index); _getDynamicEntityFailTimers.Remove(index); return(casted); } // Failed to get the DynamicEntity in the right type (or at all) // Log if (de == null) { // No DynamicEntity found const string errmsg = "No DynamicEntity found at index `{0}`."; if (log.IsInfoEnabled) { log.InfoFormat(errmsg, index); } } else { // DynamicEntity found, but of the wrong type const string errmsg = "DynamicEntity `{0}` found at index `{1}`, but it was of type `{2}` and not `{3}`."; if (log.IsErrorEnabled) { log.ErrorFormat(errmsg, de, index, de.GetType(), typeof(T)); } } var now = TickCount.Now; // Check if we have failed with this index before, and if it is time to send a request to the server. Or, if we haven't // had a failure yet, add it. TickCount firstFailTime; if (!_getDynamicEntityFailTimers.TryGetValue(index, out firstFailTime)) { _getDynamicEntityFailTimers.Add(index, now); } else { var deltaTime = now - firstFailTime; if (deltaTime > _maxGetDynamicEntityFailTimeout) { const string msg = "Sending request for DynamicEntity with index `{0}`."; if (log.IsInfoEnabled) { log.InfoFormat(msg, index); } // Enough time has elapsed to send the request using (var pw = ClientPacket.RequestDynamicEntity(index)) { _parent.NetworkSender.Send(pw, ClientMessageType.System); } _getDynamicEntityFailTimers.Remove(index); } } return(null); }
public static PacketWriter StartShopping(MapEntityIndex entityIndex) { var pw = GetWriter(ClientPacketID.StartShopping); pw.Write(entityIndex); return pw; }
public static PacketWriter SkillStartCasting_ToMap(MapEntityIndex entityIndex, SkillType skillType) { var pw = GetWriter(ServerPacketID.SkillStartCasting_ToMap); pw.Write(entityIndex); pw.WriteEnum(skillType); return pw; }
/// <summary> /// Sets which map character is the one controlled by the user /// </summary> /// <param name="mapEntityIndex">Map character index controlled by the user</param> public static PacketWriter SetUserChar(MapEntityIndex mapEntityIndex) { var pw = GetWriter(); SetUserChar(pw, mapEntityIndex); return pw; }
public static void SetUserChar(PacketWriter pw, MapEntityIndex mapEntityIndex) { pw.Write(ServerPacketID.SetUserChar); pw.Write(mapEntityIndex); }
public static PacketWriter RequestDynamicEntity(MapEntityIndex index) { var pw = GetWriter(ClientPacketID.RequestDynamicEntity); pw.Write(index); return pw; }
public static PacketWriter NotifyLevel(MapEntityIndex mapEntityIndex) { var pw = GetWriter(ServerPacketID.NotifyLevel); pw.Write(mapEntityIndex); return pw; }
public static void SetCharacterMPPercent(PacketWriter pw, MapEntityIndex mapEntityIndex, byte mpPercent) { pw.Write(ServerPacketID.SetCharacterMPPercent); pw.Write(mapEntityIndex); pw.Write(mpPercent); }
public static PacketWriter StartChatDialog(MapEntityIndex npcIndex, NPCChatDialogID dialogID) { var pw = GetWriter(ServerPacketID.StartChatDialog); pw.Write(npcIndex); pw.Write(dialogID); return pw; }
public static PacketWriter StartQuestChatDialog(MapEntityIndex npcIndex, IEnumerable<QuestID> availableQuests, IEnumerable<QuestID> turnInQuests) { var pw = GetWriter(ServerPacketID.StartQuestChatDialog); pw.Write(npcIndex); // Write the list of available quests if (availableQuests != null) { var values = availableQuests.ToImmutable(); Debug.Assert(values.Count() <= byte.MaxValue); pw.Write((byte)values.Count()); foreach (var q in values) { pw.Write(q); } } else pw.Write((byte)0); // Write the list of quests that can be turned in if (turnInQuests != null) { var values = turnInQuests.ToImmutable(); Debug.Assert(values.Count() <= byte.MaxValue); pw.Write((byte)values.Count()); foreach (var q in values) { pw.Write(q); } } else pw.Write((byte)0); return pw; }
public static PacketWriter CreateActionDisplayAtEntity(ActionDisplayID actionDisplayId, MapEntityIndex sourceEntityIndex, MapEntityIndex?targetEntityIndex = null) { var pw = GetWriter(ServerPacketID.CreateActionDisplayAtEntity); pw.Write(actionDisplayId); pw.Write(sourceEntityIndex); pw.Write(targetEntityIndex.HasValue); if (targetEntityIndex.HasValue) { pw.Write(targetEntityIndex.Value); } return(pw); }
public static PacketWriter CreateActionDisplayAtEntity(ActionDisplayID actionDisplayId, MapEntityIndex sourceEntityIndex, MapEntityIndex? targetEntityIndex = null) { var pw = GetWriter(ServerPacketID.CreateActionDisplayAtEntity); pw.Write(actionDisplayId); pw.Write(sourceEntityIndex); pw.Write(targetEntityIndex.HasValue); if (targetEntityIndex.HasValue) pw.Write(targetEntityIndex.Value); return pw; }
public static PacketWriter SetCharacterMPPercent(MapEntityIndex mapEntityIndex, byte mpPercent) { var pw = GetWriter(); SetCharacterMPPercent(pw, mapEntityIndex, mpPercent); return pw; }
public static PacketWriter SkillStopCasting_ToMap(MapEntityIndex entityIndex) { var pw = GetWriter(ServerPacketID.SkillStopCasting_ToMap); pw.Write(entityIndex); return pw; }
public static PacketWriter StartNPCChatDialog(MapEntityIndex npcIndex, bool forceSkipQuestDialog) { var pw = GetWriter(ClientPacketID.StartNPCChatDialog); pw.Write(npcIndex); pw.Write(forceSkipQuestDialog); return pw; }
public static void SetProvidedQuests(PacketWriter pw, MapEntityIndex mapEntityIndex, IEnumerable<QuestID> quests) { pw.WriteEnum(ServerPacketID.SetProvidedQuests); pw.Write(mapEntityIndex); pw.Write((byte)quests.Count()); foreach (var q in quests) { pw.Write(q); } }
public static void Write(this BitStream bitStream, MapEntityIndex mapEntityIndex) { bitStream.Write(null, mapEntityIndex); }