Ejemplo n.º 1
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="v"></param>
        /// <param name="module"></param>
        internal BVController(Vessel v, ConfigNode module)
        {
            vessel   = v;
            BVModule = module;
            displayedSystemCheckResults = new List <DisplayedSystemCheckResult>();

            // Load values from config if it isn't the first run of the mod (we are reseting vessel on the first run)
            if (!Configuration.FirstRun)
            {
                active            = bool.Parse(BVModule.GetValue("active") != null ? BVModule.GetValue("active") : "false");
                shutdown          = bool.Parse(BVModule.GetValue("shutdown") != null ? BVModule.GetValue("shutdown") : "false");
                arrived           = bool.Parse(BVModule.GetValue("arrived") != null ? BVModule.GetValue("arrived") : "false");
                targetLatitude    = double.Parse(BVModule.GetValue("targetLatitude") != null ? BVModule.GetValue("targetLatitude") : "0");
                targetLongitude   = double.Parse(BVModule.GetValue("targetLongitude") != null ? BVModule.GetValue("targetLongitude") : "0");
                distanceToTarget  = double.Parse(BVModule.GetValue("distanceToTarget") != null ? BVModule.GetValue("distanceToTarget") : "0");
                distanceTravelled = double.Parse(BVModule.GetValue("distanceTravelled") != null ? BVModule.GetValue("distanceTravelled") : "0");
                if (BVModule.GetValue("pathEncoded") != null)
                {
                    path = PathUtils.DecodePath(BVModule.GetValue("pathEncoded"));
                }

                if (BVModule.GetValue("rotationVector") != null)
                {
                    switch (BVModule.GetValue("rotationVector"))
                    {
                    case "0":
                        rotationVector = Vector3d.up;
                        break;

                    case "1":
                        rotationVector = Vector3d.down;
                        break;

                    case "2":
                        rotationVector = Vector3d.forward;
                        break;

                    case "3":
                        rotationVector = Vector3d.back;
                        break;

                    case "4":
                        rotationVector = Vector3d.right;
                        break;

                    case "5":
                        rotationVector = Vector3d.left;
                        break;

                    default:
                        rotationVector = Vector3d.back;
                        break;
                    }
                }
                else
                {
                    rotationVector = Vector3d.back;
                }
            }

            State = VesselState.Idle;
            if (shutdown)
            {
                State = VesselState.ControllerDisabled;
            }

            lastTimeUpdated = 0;
            mainStarIndex   = 0; // In the most cases The Sun
        }
Ejemplo n.º 2
0
 public void UpdateWayPoints()
 {
     wayPoints = PathUtils.DecodePath(currentModule.pathEncoded, currentModule.vessel.mainBody);
 }