public void UpdateVessel()
        {
            var vesselUpdate = this.socketWorker.VesselUpdate;

            if (vesselUpdate == null)
            {
                return;
            }

            CheckVessels();
            TrackingStation.UpdateVessel(this, vesselUpdate);
        }
Ejemplo n.º 2
0
        public void UnityWorker()
        {
            try
            {
                var message = this.socketWorker.logMessages.TryPop(null);
                if (message != null)
                {
                    this.Log(message);
                }

                UpdateTime(this.socketWorker.TimeUpdate);

                var vesselUpdate = this.socketWorker.VesselUpdate;
                var vessel       = FlightGlobals.ActiveVessel;
                if (vessel == null || vessel.state == Vessel.State.DEAD || vesselUpdate == null)
                {
                    // Main process has probably gone back to space center,
                    // so let's go back to the tracking station.
                    HighLogic.LoadScene(GameScenes.TRACKSTATION);
                    return;
                }

                if (vesselUpdate.Id != vessel.id)
                {
                    // This might look odd, but it aint my fault.
                    // If you try and switch loaded scenes too quickly,
                    // data structures in squad's code don't get populated
                    // and it's exception city.
                    if (vessel.patchedConicRenderer == null ||
                        vessel.patchedConicRenderer.solver == null ||
                        vessel.patchedConicRenderer.solver.maneuverNodes == null)
                    {
                        return;
                    }

                    // Vessel switched, tracking station code handles that
                    TrackingStation.UpdateVessel(this, vesselUpdate);
                    return;
                }

                this.UpdateManeuverNodes();
                this.UpdateTarget();

                IList <ManeuverNode> maneuvers;
                if (vessel.patchedConicSolver == null)
                {
                    maneuvers = null;
                }
                else
                {
                    maneuvers = vessel.patchedConicSolver.maneuverNodes;
                }

                this.socketWorker.Send(maneuvers, vessel.targetObject);
                this.UpdateVessel(vessel, vesselUpdate);
            }
            catch (Exception e)
            {
                LogException(e);
                throw;
            }
        }