Exemplo n.º 1
0
 private void handleEnteredNormalSpaceEvent(Event @event)
 {
     // We can derive a "Glide" event from the context in our status
     if (currentStatus.near_surface && currentStatus.fsd_status == "masslock")
     {
         gliding = true;
         EnteredNormalSpaceEvent theEvent = (EnteredNormalSpaceEvent)@event;
         EDDI.Instance.eventHandler(new GlideEvent(DateTime.UtcNow, gliding, theEvent.system, theEvent.systemAddress, theEvent.body, theEvent.bodyType));
     }
 }
Exemplo n.º 2
0
 private bool eventEnteredNormalSpace(EnteredNormalSpaceEvent theEvent)
 {
     if (Environment == null || Environment != Constants.ENVIRONMENT_NORMAL_SPACE)
     {
         Environment = Constants.ENVIRONMENT_NORMAL_SPACE;
         updateCurrentSystem(theEvent.system);
         return(true);
     }
     return(false);
 }
Exemplo n.º 3
0
        public void TestJournalEnteredNormalSpaceEvent()
        {
            string       line   = @"{ ""timestamp"":""2018 - 02 - 07T07: 13:39Z"", ""event"":""SupercruiseExit"", ""StarSystem"":""Wyrd"", ""SystemAddress"":5031654888146, ""Body"":""Vonarburg Co-operative"", ""BodyID"":35, ""BodyType"":""Station"" }";
            List <Event> events = JournalMonitor.ParseJournalEntry(line);

            Assert.IsTrue(events.Count == 1);
            EnteredNormalSpaceEvent normalSpaceEvent = (EnteredNormalSpaceEvent)events[0];

            Assert.AreEqual("Vonarburg Co-operative", normalSpaceEvent.body);
            Assert.AreEqual("Station", normalSpaceEvent.bodytype);
            Assert.AreEqual("Wyrd", normalSpaceEvent.system);
            Assert.AreEqual(5031654888146, normalSpaceEvent.systemAddress);
        }
Exemplo n.º 4
0
        public void TestRingCurrentBody()
        {
            string       line   = @"{ ""timestamp"":""2018-12-02T07:59:04Z"", ""event"":""SupercruiseExit"", ""StarSystem"":""HIP 17704"", ""SystemAddress"":246119654564, ""Body"":""HIP 17704 4 A Ring"", ""BodyID"":18, ""BodyType"":""PlanetaryRing"" }";
            List <Event> events = JournalMonitor.ParseJournalEntry(line);

            Assert.AreEqual(1, events.Count);
            EnteredNormalSpaceEvent @event = (EnteredNormalSpaceEvent)events[0];

            Assert.IsNotNull(@event);
            Assert.IsInstanceOfType(@event, typeof(EnteredNormalSpaceEvent));

            PrivateObject privateObject = new PrivateObject(Eddi.EDDI.Instance);

            privateObject.Invoke("updateCurrentStellarBody", new object[] { @event.bodyname, @event.systemname, @event.systemAddress });
            Assert.AreEqual("HIP 17704 4", EDDI.Instance.CurrentStellarBody?.bodyname);
        }
Exemplo n.º 5
0
        public void TestRingCurrentBody()
        {
            string                  line   = @"{ ""timestamp"":""2018-12-02T07:59:04Z"", ""event"":""SupercruiseExit"", ""StarSystem"":""HR 6421"", ""SystemAddress"":27076330676, ""Body"":""HR 6421 4 A Ring"", ""BodyID"":18, ""BodyType"":""PlanetaryRing"" }";
            List <Event>            events = JournalMonitor.ParseJournalEntry(line);
            EnteredNormalSpaceEvent @event = (EnteredNormalSpaceEvent)events[0];

            Assert.IsInstanceOfType(@event, typeof(EnteredNormalSpaceEvent));

            var           system        = DeserializeJsonResource <StarSystem>(Resources.sqlStarSystem5);
            PrivateObject privateObject = new PrivateObject(EDDI.Instance);

            privateObject.SetFieldOrProperty("CurrentStarSystem", system);

            privateObject.Invoke("updateCurrentStellarBody", new object[] { @event.bodyname, @event.systemname, @event.systemAddress });
            Assert.AreEqual("HR 6421 4", EDDI.Instance.CurrentStellarBody?.bodyname);
        }
Exemplo n.º 6
0
 private void handleEnteredNormalSpaceEvent(Event @event)
 {
     // We can derive a "Glide" event from the context in our status
     lastEnteredNormalSpaceEvent = (EnteredNormalSpaceEvent)@event;
 }
Exemplo n.º 7
0
        public void handleStatus(Status thisStatus)
        {
            if (thisStatus == null)
            {
                return;
            }

            if (currentStatus != thisStatus)
            {
                // Save our last status for reference and update our current status
                lastStatus    = currentStatus;
                currentStatus = thisStatus;

                // Update environment and vehicle information
                if (EDDI.Instance.Environment != Constants.ENVIRONMENT_WITCH_SPACE)
                {
                    if (thisStatus.hyperspace)
                    {
                        EDDI.Instance.Environment = Constants.ENVIRONMENT_WITCH_SPACE;
                        gliding = false;
                    }
                    else if (thisStatus.supercruise)
                    {
                        EDDI.Instance.Environment = Constants.ENVIRONMENT_SUPERCRUISE;
                        gliding = false;
                    }
                    else if (thisStatus.docked)
                    {
                        EDDI.Instance.Environment = Constants.ENVIRONMENT_DOCKED;
                        gliding = false;
                    }
                    else if (thisStatus.landed)
                    {
                        EDDI.Instance.Environment = Constants.ENVIRONMENT_LANDED;
                        gliding = false;
                    }
                    else
                    {
                        EDDI.Instance.Environment = Constants.ENVIRONMENT_NORMAL_SPACE;
                    }
                }
                EDDI.Instance.Vehicle = thisStatus.vehicle;

                // Trigger events for changed status, as applicable
                if (thisStatus.shields_up != lastStatus.shields_up && thisStatus.vehicle == lastStatus.vehicle)
                {
                    // React to changes in shield state.
                    // We check the vehicle to make sure that events aren't generated when we switch vehicles, start the game, or stop the game.
                    if (thisStatus.shields_up)
                    {
                        EDDI.Instance.enqueueEvent(new ShieldsUpEvent(thisStatus.timestamp));
                    }
                    else
                    {
                        EDDI.Instance.enqueueEvent(new ShieldsDownEvent(thisStatus.timestamp));
                    }
                }
                if (thisStatus.srv_turret_deployed != lastStatus.srv_turret_deployed)
                {
                    EDDI.Instance.enqueueEvent(new SRVTurretEvent(thisStatus.timestamp, thisStatus.srv_turret_deployed));
                }
                if (thisStatus.silent_running != lastStatus.silent_running)
                {
                    EDDI.Instance.enqueueEvent(new SilentRunningEvent(thisStatus.timestamp, thisStatus.silent_running));
                }
                if (thisStatus.srv_under_ship != lastStatus.srv_under_ship)
                {
                    // If the turret is deployable then we are not under our ship. And vice versa.
                    bool deployable = !thisStatus.srv_under_ship;
                    EDDI.Instance.enqueueEvent(new SRVTurretDeployableEvent(thisStatus.timestamp, deployable));
                }
                if (thisStatus.fsd_status != lastStatus.fsd_status &&
                    thisStatus.vehicle == Constants.VEHICLE_SHIP &&
                    !thisStatus.docked)
                {
                    if (thisStatus.fsd_status == "ready")
                    {
                        switch (lastStatus.fsd_status)
                        {
                        case "charging":
                            if (!jumping && thisStatus.supercruise == lastStatus.supercruise)
                            {
                                EDDI.Instance.enqueueEvent(new ShipFsdEvent(thisStatus.timestamp, "charging cancelled"));
                            }
                            jumping = false;
                            break;

                        case "cooldown":
                            EDDI.Instance.enqueueEvent(new ShipFsdEvent(thisStatus.timestamp, "cooldown complete"));
                            break;

                        case "masslock":
                            EDDI.Instance.enqueueEvent(new ShipFsdEvent(thisStatus.timestamp, "masslock cleared"));
                            break;
                        }
                    }
                    else
                    {
                        EDDI.Instance.enqueueEvent(new ShipFsdEvent(thisStatus.timestamp, thisStatus.fsd_status));
                    }
                }
                if (thisStatus.low_fuel != lastStatus.low_fuel)
                {
                    // Don't trigger 'low fuel' event when fuel exceeds 25% or when we're not in our ship
                    if (thisStatus.low_fuel &&
                        thisStatus.vehicle == Constants.VEHICLE_SHIP)
                    {
                        EDDI.Instance.enqueueEvent(new ShipLowFuelEvent(thisStatus.timestamp));
                    }
                }
                if (thisStatus.landing_gear_down != lastStatus.landing_gear_down)
                {
                    EDDI.Instance.enqueueEvent(new ShipLandingGearEvent(thisStatus.timestamp, thisStatus.landing_gear_down));
                }
                if (thisStatus.cargo_scoop_deployed != lastStatus.cargo_scoop_deployed)
                {
                    EDDI.Instance.enqueueEvent(new ShipCargoScoopEvent(thisStatus.timestamp, thisStatus.cargo_scoop_deployed));
                }
                if (thisStatus.lights_on != lastStatus.lights_on)
                {
                    EDDI.Instance.enqueueEvent(new ShipLightsEvent(thisStatus.timestamp, thisStatus.lights_on));
                }
                if (thisStatus.hardpoints_deployed != lastStatus.hardpoints_deployed)
                {
                    EDDI.Instance.enqueueEvent(new ShipHardpointsEvent(thisStatus.timestamp, thisStatus.hardpoints_deployed));
                }
                if (thisStatus.flight_assist_off != lastStatus.flight_assist_off)
                {
                    EDDI.Instance.enqueueEvent(new FlightAssistEvent(thisStatus.timestamp, thisStatus.flight_assist_off));
                }
                if (gliding && thisStatus.fsd_status == "cooldown")
                {
                    gliding = false;
                    EDDI.Instance.enqueueEvent(new GlideEvent(currentStatus.timestamp, gliding, EDDI.Instance.CurrentStellarBody.systemname, EDDI.Instance.CurrentStellarBody.systemAddress, EDDI.Instance.CurrentStellarBody.bodyname, EDDI.Instance.CurrentStellarBody.bodyType));
                }
                else if (!currentStatus.supercruise && lastStatus.supercruise)
                {
                    // We are exiting supercruise
                    if (!gliding && lastEnteredNormalSpaceEvent != null)
                    {
                        // We're not already gliding and we have data from a prior `EnteredNormalSpace` event
                        if (currentStatus.fsd_status == "ready" &&
                            currentStatus.slope >= -60 && currentStatus.slope <= -5 &&
                            currentStatus.altitude < 100000 &&
                            currentStatus.altitude < lastStatus.altitude)
                        {
                            // The FSD status is `ready`, altitude is less than 100000 meters, and we are dropping
                            gliding = true;
                            EnteredNormalSpaceEvent theEvent = lastEnteredNormalSpaceEvent;
                            EDDI.Instance.enqueueEvent(new GlideEvent(DateTime.UtcNow, gliding, theEvent.systemname, theEvent.systemAddress, theEvent.bodyname, theEvent.bodyType)
                            {
                                fromLoad = theEvent.fromLoad
                            });
                        }
                    }
                }
                // Reset our fuel log if we change vehicles or refuel
                if (thisStatus.vehicle != lastStatus.vehicle || thisStatus.fuel > lastStatus.fuel)
                {
                    fuelLog = null;
                }

                // Pass the change in status to all subscribed processes
                OnStatus(StatusUpdatedEvent, currentStatus);
            }
        }