Beispiel #1
0
        private bool eventJumping(JumpingEvent theEvent)
        {
            bool passEvent;

            Logging.Debug("Jumping to " + theEvent.system);
            if (CurrentStarSystem == null || CurrentStarSystem.name != theEvent.system)
            {
                // New system
                passEvent = true;
                updateCurrentSystem(theEvent.system);
                // The information in the event is more up-to-date than the information we obtain from external sources, so update it here
                CurrentStarSystem.x = theEvent.x;
                CurrentStarSystem.y = theEvent.y;
                CurrentStarSystem.z = theEvent.z;
                CurrentStarSystem.visits++;
                CurrentStarSystem.lastvisit = DateTime.Now;
                StarSystemSqLiteRepository.Instance.SaveStarSystem(CurrentStarSystem);
                setCommanderTitle();
            }
            else
            {
                // Restatement of current system
                passEvent = false;
            }

            // Whilst jumping we are in witch space
            Environment = Constants.ENVIRONMENT_WITCH_SPACE;

            return(passEvent);
        }
        public void Handle(Event theEvent)
        {
            if (starMapService != null)
            {
                // We could receive either or both of JumpingEvent and JumpedEvent.  Send EDSM update as soon as possible,
                // but don't send it twice
                if (theEvent is JumpingEvent)
                {
                    JumpingEvent jumpingEvent = (JumpingEvent)theEvent;

                    if (jumpingEvent.system != system)
                    {
                        Logging.Debug("Sending jump data to EDSM (jumping)");
                        starMapService.sendStarMapLog(jumpingEvent.timestamp, jumpingEvent.system, jumpingEvent.x, jumpingEvent.y, jumpingEvent.z);
                        system = jumpingEvent.system;
                    }
                }
                else if (theEvent is JumpedEvent)
                {
                    JumpedEvent jumpedEvent = (JumpedEvent)theEvent;

                    if (jumpedEvent.system != system)
                    {
                        Logging.Debug("Sending jump data to EDSM (jumped)");
                        starMapService.sendStarMapLog(jumpedEvent.timestamp, jumpedEvent.system, jumpedEvent.x, jumpedEvent.y, jumpedEvent.z);
                        system = jumpedEvent.system;
                    }
                }
            }
        }
Beispiel #3
0
        public void Handle(Event theEvent)
        {
            if (EDDI.Instance.inCQC)
            {
                // We don't do anything whilst in CQC
                return;
            }

            if (EDDI.Instance.inBeta)
            {
                // We don't send data whilst in beta
                return;
            }

            if (starMapService != null)
            {
                // We could receive either or both of JumpingEvent and JumpedEvent.  Send EDSM update as soon as possible,
                // but don't send it twice
                if (theEvent is JumpingEvent)
                {
                    JumpingEvent jumpingEvent = (JumpingEvent)theEvent;

                    if (jumpingEvent.system != system)
                    {
                        Logging.Debug("Sending jump data to EDSM (jumping)");
                        starMapService.sendStarMapLog(jumpingEvent.timestamp, jumpingEvent.system, jumpingEvent.x, jumpingEvent.y, jumpingEvent.z);
                        system = jumpingEvent.system;
                    }
                }
                else if (theEvent is JumpedEvent)
                {
                    JumpedEvent jumpedEvent = (JumpedEvent)theEvent;

                    if (jumpedEvent.system != system)
                    {
                        Logging.Debug("Sending jump data to EDSM (jumped)");
                        starMapService.sendStarMapLog(jumpedEvent.timestamp, jumpedEvent.system, jumpedEvent.x, jumpedEvent.y, jumpedEvent.z);
                        system = jumpedEvent.system;
                    }
                }
                else if (theEvent is CommanderContinuedEvent)
                {
                    CommanderContinuedEvent continuedEvent = (CommanderContinuedEvent)theEvent;
                    starMapService.sendCredits(continuedEvent.credits, continuedEvent.loan);
                }
                else if (theEvent is CommanderProgressEvent)
                {
                    CommanderProgressEvent progressEvent = (CommanderProgressEvent)theEvent;
                    if (EDDI.Instance.Cmdr != null && EDDI.Instance.Cmdr.federationrating != null)
                    {
                        starMapService.sendRanks(EDDI.Instance.Cmdr.combatrating.rank, (int)progressEvent.combat,
                                                 EDDI.Instance.Cmdr.traderating.rank, (int)progressEvent.trade,
                                                 EDDI.Instance.Cmdr.explorationrating.rank, (int)progressEvent.exploration,
                                                 EDDI.Instance.Cmdr.cqcrating.rank, (int)progressEvent.cqc,
                                                 EDDI.Instance.Cmdr.federationrating.rank, (int)progressEvent.federation,
                                                 EDDI.Instance.Cmdr.empirerating.rank, (int)progressEvent.empire);
                    }
                }
            }
        }
        private static void HandleNetLogLine(string line, Action <Event> callback)
        {
            string  starSystem  = null;
            string  environment = null;
            decimal x           = 0;
            decimal y           = 0;
            decimal z           = 0;

            Match oldMatch = OldSystemRegex.Match(line);

            if (oldMatch.Success)
            {
                Logging.Debug("Match against old regex");
                if (@"Training" == oldMatch.Groups[3].Value || @"Destination" == oldMatch.Groups[3].Value)
                {
                    // We ignore training missions
                    return;
                }

                if (@"ProvingGround" == oldMatch.Groups[4].Value)
                {
                    // We ignore CQC
                    return;
                }

                starSystem  = oldMatch.Groups[3].Value;
                environment = oldMatch.Groups[3].Value;
            }
            else
            {
                Match match = SystemRegex.Match(line);
                if (match.Success)
                {
                    Logging.Debug("Match against new regex");
                    if (@"Training" == match.Groups[2].Value || @"Destination" == match.Groups[2].Value)
                    {
                        // We ignore training missions
                        return;
                    }

                    if (@"ProvingGround" == match.Groups[6].Value)
                    {
                        // We ignore CQC
                        return;
                    }

                    starSystem  = match.Groups[2].Value;
                    environment = match.Groups[6].Value;
                    x           = Math.Round(decimal.Parse(match.Groups[3].Value) * 32) / (decimal)32.0;
                    y           = Math.Round(decimal.Parse(match.Groups[4].Value) * 32) / (decimal)32.0;
                    z           = Math.Round(decimal.Parse(match.Groups[5].Value) * 32) / (decimal)32.0;
                }
            }

            Event theEvent = null;

            if (starSystem != null)
            {
                if (starSystem != lastStarsystem)
                {
                    // Change of system
                    theEvent        = new JumpingEvent(DateTime.Now.ToUniversalTime(), starSystem, x, y, z);
                    lastStarsystem  = starSystem;
                    lastEnvironment = environment;
                }
                //else if (environment != lastEnvironment)
                //{
                //    // Change of environment
                //    if (environment == "Supercruise")
                //    {
                //        theEvent = new EnteredSupercruiseEvent(DateTime.Now.ToUniversalTime(), starSystem);
                //        lastEnvironment = environment;
                //    }
                //    else if (environment == "NormalFlight")
                //    {
                //        theEvent = new EnteredNormalSpaceEvent(DateTime.Now.ToUniversalTime(), starSystem, null, null);
                //        lastEnvironment = environment;
                //    }
                //}
            }
            if (theEvent != null)
            {
                Logging.Debug("Returning event " + theEvent);
                callback(theEvent);
            }
        }