Пример #1
0
 public void UpdateStatedElement(StatedElementUpdatedMessage update)
 {
     if (!update.StatedElement.OnCurrentMap)
     {
         return;
     }
     StatedElements.Remove(
         StatedElements.Find(x => x.ElementId == update.StatedElement.ElementId));
     StatedElements.Add(update.StatedElement);
 }
Пример #2
0
 public void ParseStatedElement(StatedElement[] elements)
 {
     foreach (var element in elements)
     {
         if (element.OnCurrentMap)
         {
             StatedElements.Add(element);
         }
     }
 }
Пример #3
0
        private void HandleMapComplementaryInformationsDataMessage(IAccount account,
                                                                   MapComplementaryInformationsDataMessage message)
        {
            lock (CheckLock)
            {
                SubAreaId = message.SubAreaId;
                Data      = MapsManager.FromId(message.MapId);
                var subArea = ObjectDataManager.Instance.Get <SubArea>(SubAreaId);
                var mapName =
                    FastD2IReader.Instance.GetText(ObjectDataManager.Instance.Get <Area>(subArea.AreaId).NameId);
                var subAreaName = FastD2IReader.Instance.GetText(subArea.NameId);
                Position = $"[{X}, {Y}]";
                Zone     = $"{mapName} ({subAreaName})";
                Entities.Clear();
                Monsters.Clear();
                Npcs.Clear();
                Players.Clear();
                Resources.Clear();
                AddActors(message.Actors);
                StatedElements.Clear();
                //Populate the StateElements with new ones received.
                //StatesElements are the elements which our current bot in theory can harvest.
                foreach (var statedElement in message.StatedElements)
                {
                    if (!StatedElements.ContainsKey(statedElement.ElementId))
                    {
                        StatedElements.Add(statedElement.ElementId, new StatedElement(statedElement.ElementCellId, (uint)statedElement.ElementId, statedElement.ElementState));
                    }
                }
                InteractiveElements.Clear();
                Doors.Clear();
                //populate the interactiveElements which are essencially items that we can interact with. Their location is hardcoded into the map.layer
                foreach (var interactiveElement in message.InteractiveElements)
                {
                    if (!InteractiveElements.ContainsKey(interactiveElement.ElementId))
                    {
                        InteractiveElements.Add(interactiveElement.ElementId, new InteractiveElement((uint)interactiveElement.ElementId, interactiveElement.ElementTypeId, interactiveElement.EnabledSkills, interactiveElement.DisabledSkills));
                    }
                }
            }

            UpdateMapControl();

            OnMapChanged();
        }
Пример #4
0
 private void HandleStatedElementUpdatedMessage(IAccount account, StatedElementUpdatedMessage message)
 {
     lock (CheckLock)
     {
         if (!message.StatedElement.OnCurrentMap)
         {
             return;
         }
         var statedElement = StatedElements.GetValue(message.StatedElement.ElementId);
         if (statedElement != null)
         {
             StatedElements.Remove((int)statedElement.Id);
         }
         StatedElements.Add(message.StatedElement.ElementId,
                            new StatedElement(message.StatedElement.ElementCellId, (uint)message.StatedElement.ElementId,
                                              message.StatedElement.ElementState));
     }
 }
Пример #5
0
 private void HandleStatedMapUpdateMessage(IAccount account, StatedMapUpdateMessage message)
 {
     lock (CheckLock)
     {
         foreach (var statedElementDofus in message.StatedElements)
         {
             if (!statedElementDofus.OnCurrentMap)
             {
                 continue;
             }
             var selectedStatedElement = StatedElements.GetValue(statedElementDofus.ElementId);
             if (selectedStatedElement != null)
             {
                 StatedElements.Remove((int)selectedStatedElement.Id);
             }
             StatedElements.Add(statedElementDofus.ElementId,
                                new StatedElement(statedElementDofus.ElementCellId, (uint)statedElementDofus.ElementId,
                                                  statedElementDofus.ElementState));
         }
     }
 }
Пример #6
0
        private void HandleMapComplementaryInformationsDataMessage(IAccount account,
                                                                   MapComplementaryInformationsDataMessage message)
        {
            lock (CheckLock)
            {
                SubAreaId = message.SubAreaId;
                Data      = MapsManager.FromId(message.MapId);

                var subArea = ObjectDataManager.Instance.Get <SubArea>(SubAreaId);
                var mapName =
                    FastD2IReader.Instance.GetText(ObjectDataManager.Instance.Get <Area>(subArea.AreaId).NameId);
                var subAreaName = FastD2IReader.Instance.GetText(subArea.NameId);
                Position = $"[{X}, {Y}]";
                Zone     = $"{mapName} ({subAreaName})";
                Entities.Clear();
                Monsters.Clear();
                Npcs.Clear();
                Players.Clear();
                AddActors(message.Actors);
                StatedElements.Clear();
                foreach (var statedElementDofus in message.StatedElements)
                {
                    if (!StatedElements.ContainsKey(statedElementDofus.ElementId) && statedElementDofus.OnCurrentMap)
                    {
                        StatedElements.Add(statedElementDofus.ElementId,
                                           new StatedElement(statedElementDofus.ElementCellId, (uint)statedElementDofus.ElementId,
                                                             statedElementDofus.ElementState));
                    }
                }
                InteractiveElements.Clear();
                Doors.Clear();
                foreach (var element in message.InteractiveElements)
                {
                    if (!element.OnCurrentMap)
                    {
                        continue;
                    }
                    InteractiveElements.Add(element.ElementId,
                                            new InteractiveElement((uint)element.ElementId, element.ElementTypeId,
                                                                   element.EnabledSkills.ToList(), element.DisabledSkills.ToList()));
                    var interactiveElement = element;
                    var listDoorSkillId    = new List <int>(new[] { 184, 183, 187, 198, 114 });
                    var listDoorTypeId     = new List <int>(new[] { -1, 128, 168, 16 });
                    if (!listDoorTypeId.Contains(interactiveElement.ElementTypeId) ||
                        interactiveElement.EnabledSkills.Count <= 0 ||
                        !listDoorSkillId.Contains((int)interactiveElement.EnabledSkills[0].SkillId))
                    {
                        continue;
                    }
                    foreach (var layer in ((API.Gamedata.D2p.Map)Data).Layers)
                    {
                        foreach (var cell in layer.Cells)
                        {
                            foreach (var layerElement in cell.Elements)
                            {
                                if (layerElement is GraphicalElement graphicalElement)
                                {
                                    if (graphicalElement.Identifier == interactiveElement.ElementId &&
                                        !Doors.ContainsKey(cell.CellId))
                                    {
                                        Doors.Add(cell.CellId,
                                                  new InteractiveElement((uint)element.ElementId, element.ElementTypeId,
                                                                         element.EnabledSkills.ToList(), element.DisabledSkills.ToList()));
                                    }
                                }
                            }
                        }
                    }
                }
            }

            UpdateMapControl();

            OnMapChanged();
        }