Beispiel #1
0
        public void RemoveCachedBookMark(CachedBookMark bookMark)
        {
            var methodName = "Remove";

            LogTrace(methodName, "BookMark: {0} ({1})", bookMark.Label, bookMark.Id);

            if (!_bookMarksById.ContainsKey(bookMark.Id))
            {
                _logging.LogMessage("CachedBookMark", "ToBookMark", LogSeverityTypes.Standard, "Error; Bookmark cache did not contain bookmark for ID {0}.",
                                    bookMark.Id);
                return;
            }

            _logging.LogMessage("CachedBookMark", methodName, LogSeverityTypes.Debug, "Removing CachedBookMark \"{0}\" ({1}).",
                                bookMark.Label, bookMark.Id);

            //Delete it in EVE
            var realBookMark = _bookMarksById[bookMark.Id];

            realBookMark.Remove();

            //Remove it from caches
            _bookMarks.Remove(realBookMark);
            _bookMarksById.Remove(bookMark.Id);

            _cachedBookMarks.Remove(bookMark);
        }
Beispiel #2
0
        public bool IsAtBookmark(CachedBookMark bookMark)
        {
            if (IsStationBookMark(bookMark))
            {
                return(_station.IsDockedAtStation(bookMark.ItemId));
            }

            return(_meCache.InSpace && _meCache.SolarSystemId == bookMark.SolarSystemId &&
                   DistanceTo(bookMark.X, bookMark.Y, bookMark.Z) < (int)Ranges.Warp);
        }
        public CachedBookMarkedBelt(CachedBookMark bookmark, bool isIceBelt)
        {
            Id = bookmark.Id;

            BookmarkLabel = bookmark.Label;
            X             = bookmark.X;
            Y             = bookmark.Y;
            Z             = bookmark.Z;

            IsIceBelt = isIceBelt;
        }
Beispiel #4
0
        public bool IsAtBookMark(CachedBookMark bookMark)
        {
            if (SolarSystemId != bookMark.SolarSystemId)
            {
                return(false);
            }

            if (bookMark.ItemId >= 0)
            {
                return(InStation && StealthBot.MeCache.StationId == bookMark.ItemId);
            }

            return(InSpace && DistanceTo(bookMark.X, bookMark.Y, bookMark.Z) < (int)Ranges.Warp);
        }
Beispiel #5
0
 public bool IsStationBookMark(CachedBookMark bookMark)
 {
     return(bookMark.ItemId >= 0 && (_station.StationTypeIDs.Contains(bookMark.TypeId) || bookMark.Type.Contains(StationTag)));
 }
Beispiel #6
0
        public override void Pulse()
        {
            var methodName = "Pulse";

            LogTrace(methodName);

            if (!ShouldPulse())
            {
                return;
            }

            //Get a list of bookmarks to work with this frame
            //StartMethodProfiling("GetBookmarks");
            var eveBookMarks = _isxeveProvider.Eve.GetBookmarks();

            if (eveBookMarks == null)
            {
                LogMessage(methodName, LogSeverityTypes.Debug, "Error: GetBookmarks returned a null list.");
                return;
            }

            _bookMarks.AddRange(eveBookMarks);

            //EndMethodProfiling();
            //StartMethodProfiling("RepopulateTable");
            var bookMarkIDs = new List <Int64>();

            foreach (var bookMark in _bookMarks)
            {
                var bookMarkId = bookMark.ID;

                if (bookMarkId < 0)
                {
                    LogMessage(methodName, LogSeverityTypes.Debug, "Got bookmark with negative ID {0}. Label: {1}, Index (0-based): {2}, Count: {3}",
                               bookMarkId, bookMark.Label, _bookMarks.IndexOf(bookMark), _bookMarks.Count);
                    continue;
                }

                if (!bookMark.IsValid)
                {
                    LogMessage(methodName, LogSeverityTypes.Debug, "Got invalid bookmark. ID: {0}, Index (0-based): {1}, Count: {2}",
                               bookMarkId, _bookMarks.IndexOf(bookMark), _bookMarks.Count);
                    continue;
                }

                bookMarkIDs.Add(bookMarkId);
                _bookMarksById.Add(bookMarkId, bookMark);
                //CachedBookMarks.Add(new CachedBookMark(bookMark));
            }
            //EndMethodProfiling();

            //StartMethodProfiling("PruneDeadBookmarks");
            //First remove any invalid bookmarks
            for (var index = 0; index < _cachedBookMarks.Count; index++)
            {
                var bookmark = _cachedBookMarks[index];

                var remove = bookMarkIDs.All(id => id != _cachedBookMarks[index].Id) ||
                             (_meCache.InSpace && bookmark.X == 0 && bookmark.Y == 0 && bookmark.Z == 0);

                if (!remove)
                {
                    continue;
                }

                //_logging.LogMessage(ObjectName, new LogEventArgs(LogSeverityTypes.Debug,
                //methodName, string.Format("Pruning dead bookmark {0}", CachedBookMarks[idx].ID)));
                _cachedBookMarks.RemoveAt(index);
                index--;
            }
            //EndMethodProfiling();

            StartMethodProfiling("BuildNewBookmarks");
            //Next add any missing
            for (var index = 0; index < bookMarkIDs.Count; index++)
            {
                var found = _cachedBookMarks.Any(cachedBookMark => cachedBookMark.Id == bookMarkIDs[index]);

                if (found)
                {
                    continue;
                }

                var newBookMark = new CachedBookMark(_entityProvider, _meCache.InStation, _bookMarks[index]);

                LogMessage(methodName, LogSeverityTypes.Debug, "Adding or updating bookmark \"{0}\" ({1}) [{2},{3},{4}]",
                           newBookMark.Label, newBookMark.Id, newBookMark.X, newBookMark.Y, newBookMark.Z);
                _cachedBookMarks.Add(newBookMark);
            }
            EndMethodProfiling();
        }
Beispiel #7
0
 public IBookMark GetBookMarkFor(CachedBookMark cachedBookMark)
 {
     return(_bookMarksById[cachedBookMark.Id]);
 }