A game event to check for mission goals, that are not checkable with the vessel alone. Used for CrashGoal
Exemplo n.º 1
0
        protected override List<Value> values(Vessel vessel, GameEvent events)
        {
            List<Value> values = new List<Value> ();

            int count = 0;
            if (vessel != null) {
                foreach (Part p in vessel.Parts) {
                    if (p.partInfo.name.Equals (partName)) {
                        ++count;
                    }
                }
            }
            if(maxPartCount == -1) {
                if (vessel == null) {
                    values.Add (new Value ("Part", partCount + "x " + partName));
                } else {
                    values.Add (new Value ("Part", partCount + "x " + partName, "" + count, count >= partCount));
                }
            } else {
                if (vessel == null) {
                    values.Add (new Value ("max part", maxPartCount + "x " + partName));
                } else {
                    values.Add (new Value ("max part", maxPartCount + "x " + partName, "" + count, count <= maxPartCount));
                }
            }

            return values;
        }
Exemplo n.º 2
0
        protected override List<Value> values(Vessel vessel, GameEvent events)
        {
            List<Value> values = new List<Value> ();

            int count = 0;
            if (vessel != null) {
                foreach (Part p in vessel.Parts) {
                    if (p.partInfo.name.Equals (partName)) {
                        ++count;
                    }
                }
            }
            // NK get part title
            string ptitle = partName;
            foreach (AvailablePart p in PartLoader.Instance.parts)
                if (p.name.Equals(partName))
                    ptitle = p.title;

            if(maxPartCount == -1) {
                if (vessel == null) {
                    values.Add(new Value("Part", partCount + "x " + ptitle));
                } else {
                    values.Add(new Value("Part", partCount + "x " + ptitle, "" + count, count >= partCount));
                }
            } else {
                if (vessel == null) {
                    values.Add(new Value("max part", maxPartCount + "x " + ptitle));
                } else {
                    values.Add(new Value("max part", maxPartCount + "x " + ptitle, "" + count, count <= maxPartCount));
                }
            }

            return values;
        }
        protected override List<Value> values(Vessel vessel, GameEvent events)
        {
            List<Value> values = new List<Value> ();

            if (vessel == null) {
                values.Add (new Value ("Landing Body", body));
            } else {
                values.Add (new Value ("Landing Body", body, vessel.orbit.referenceBody.bodyName,
                                                 vessel.orbit.referenceBody.bodyName.Equals (body) && (vessel.situation == Vessel.Situations.LANDED ||
                    (splashedValid ? vessel.situation == Vessel.Situations.SPLASHED : false))));
            }

            if(minLatitude != maxLatitude) {
                if(vessel == null) {
                    values.Add(new Value("Latitude", String.Format(MathTools.MinMaxValue, minLatitude, maxLatitude)));
                } else {
                    values.Add(new Value("Latitude", String.Format(MathTools.MinMaxValue, minLatitude, maxLatitude),
                                     vessel.latitude, MathTools.inMinMax(minLatitude, maxLatitude, vessel.latitude)));
                }
            }

            if(minLongitude != maxLongitude) {
                if(vessel == null) {
                    values.Add(new Value("Longitude", String.Format(MathTools.MinMaxValue, minLongitude, maxLongitude)));
                } else {
                    values.Add(new Value("Longitude", String.Format(MathTools.MinMaxValue, minLongitude, maxLongitude),
                                     MathTools.calculateLongitude(vessel.longitude),
                                     MathTools.inMinMax(minLongitude, maxLongitude, MathTools.calculateLongitude(vessel.longitude))));
                }
            }

            return values;
        }
        protected override List<Value> values(Vessel vessel, GameEvent events)
        {
            List<Value> v = new List<Value> ();

            double a = 0;

            if (vessel != null) {
                foreach (Part p in vessel.parts) {
                    if (p.Resources [name] != null) {
                        a += p.Resources [name].amount;
                    }
                }
            }

            if (maxAmount != 0) {
                if(vessel == null) {
                    v.Add(new Value("max. resource " + name, maxAmount));
                } else {
                    v.Add(new Value("max. resource " + name, maxAmount, a, a <= maxAmount));
                }
            }

            if (minAmount != 0) {
                if(vessel == null) {
                    v.Add(new Value("min. resource " + name, minAmount));
                } else {
                    v.Add(new Value("min. resource " + name, minAmount, a, a >= minAmount));
                }
            }

            return v;
        }
        public override bool isDone(Vessel vessel, GameEvent events)
        {
            if (vessel == null)
            {
                return false;
            }

            if (doneOnce)
            {
                return true;
            }

            List<Value> values = getValues(vessel, events);
            foreach (Value v in values)
            {
                if (!v.done)
                {
                    return false;
                }
            }

            // We remember that we have previously completed this goal.
            doneOnce = true;

            return true;
        }
        protected override List<Value> values(Vessel vessel, GameEvent events)
        {
            List<Value> values = new List<Value>();

            if (vessel == null)
            {
                values.Add(new Value("Landing Body", body));
            }
            else
            {
                values.Add(new Value("Landing Body", body, vessel.orbit.referenceBody.bodyName,
                                                 vessel.orbit.referenceBody.bodyName.Equals(body) && (vessel.situation == Vessel.Situations.LANDED ||
                    (splashedValid ? vessel.situation == Vessel.Situations.SPLASHED : false))));
            }

            if (minLatitude != maxLatitude)
            {
                if (vessel == null)
                {
                    values.Add(new Value("Latitude", String.Format(MathTools.MinMaxValue, minLatitude, maxLatitude)));
                }
                else
                {
                    values.Add(new Value("Latitude", String.Format(MathTools.MinMaxValue, minLatitude, maxLatitude),
                                     String.Format(MathTools.SingleDoubleValue, vessel.latitude), MathTools.inMinMax(minLatitude, maxLatitude, vessel.latitude)));
                }
            }

            if (minLongitude != maxLongitude)
            {
                if (vessel == null)
                {
                    values.Add(new Value("Longitude", String.Format(MathTools.MinMaxValue, minLongitude, maxLongitude)));
                }
                else
                {
                    values.Add(new Value("Longitude", String.Format(MathTools.MinMaxValue, minLongitude, maxLongitude),
                                     String.Format(MathTools.SingleDoubleValue, MathTools.calculateLongitude(vessel.longitude)),
                                     MathTools.inMinMax(minLongitude, maxLongitude, MathTools.calculateLongitude(vessel.longitude))));
                }
            }

            if (biome != "")
            {
                if (vessel == null)
                {
                    values.Add(new Value("Biome", biome));
                }
                else
                {
                    CBAttributeMap.MapAttribute currentBiome = vessel.mainBody.BiomeMap.GetAtt(vessel.latitude * Math.PI / 180d, vessel.longitude * Math.PI / 180d);
                    values.Add(new Value("Biome", biome, currentBiome.name, biome == currentBiome.name));
                }
            }

            return values;
        }
        protected override List<Value> values(Vessel vessel, GameEvent events)
        {
            List<Value> values = new List<Value> ();

            foreach (MissionGoal c in subGoals) {
                values = values.Union(c.getValues(vessel, events)).ToList();
            }

            return values;
        }
 public override bool isDone(Vessel vessel, GameEvent events)
 {
     bool value = base.isDone (vessel, events);
     if (value && nonPermanent) {
         foreach (MissionGoal g in subGoals) {
             g.doneOnce = true;
         }
     }
     return value;
 }
 public override bool isDone(Vessel vessel, GameEvent events)
 {
     //bool value = base.isDone (vessel, events);
     //if (value && nonPermanent) {
         foreach (MissionGoal g in subGoals) {
             if (g.isDone(vessel, events))
                 return true;
         }
         return false;
     //}
     //return value;
 }
Exemplo n.º 10
0
        protected override List<Value> values(Vessel v, GameEvent events)
        {
            List<Value> vs = new List<Value> ();

            if (v == null) {
                vs.Add (new Value("EVA", "true"));
            } else {
                vs.Add (new Value("EVA", "true", "" + v.isEVA, v.isEVA));
            }

            return vs;
        }
Exemplo n.º 11
0
        protected override List<Value> values(Vessel vessel, GameEvent events)
        {
            List<Value> values = new List<Value> ();

            if (vessel == null) {
                values.Add (new Value ("Docked", "True"));
            } else {
                bool docked = (events.docked || this.doneOnce);
                values.Add (new Value ("Docked", "True", "" + docked, docked));
            }

            return values;
        }
Exemplo n.º 12
0
        protected override List<Value> values(Vessel vessel, GameEvent events)
        {
            List<Value> v = new List<Value>();

            if(vessel == null) {
                v.Add(new Value("Crashing on", body));
            } else {
                v.Add (new Value("Crashing on", body, vessel.orbit.referenceBody.bodyName,
                                 (body.Equals(vessel.orbit.referenceBody.bodyName) && events.isCrashed) || this.doneOnce));
            }

            return v;
        }
Exemplo n.º 13
0
        protected override List<Value> values(Vessel vessel, GameEvent ev)
        {
            List<Value> values2 = new List<Value>();

                if (vessel == null)
                {
                    values2.Add(new Value("Repaired", "True"));

                }
                else
                {
                    values2.Add(new Value("Repaired", "True", "" + repairStation.repair, repairStation.repair));
                }

                return values2;
        }
Exemplo n.º 14
0
        protected override List<Value> values(Vessel vessel, GameEvent events)
        {
            List<Value> values = new List<Value>();

            if (vessel == null)
            {
                values.Add(new Value("Launch from", launchZone));
            }
            else
            {
                string currentZone = vessel.orbit.referenceBody.bodyName;

                // Only check the lat/long of the vessel location to update the currentZone when the body is Kerbin
                // and the goal specifies the launch pad or runway on Kerbin.
                if ((launchZone.Equals(LaunchPad) || launchZone.Equals(Runway)) && currentZone.Equals("Kerbin"))
                {
                    double currentLongitude = MathTools.calculateLongitude(vessel.longitude);
                    double currentLatitude = vessel.latitude;

                    if (MathTools.inMinMax(runwayMinLongitude, runwayMaxLongitude, currentLongitude) &&
                        MathTools.inMinMax(runwayMinLatitude, runwayMaxLatitude, currentLatitude))
                    {
                        // Within runway parameters.
                        currentZone = Runway;
                    }
                    else if (MathTools.inMinMax(padMinLongitude, padMaxLongitude, currentLongitude) &&
                             MathTools.inMinMax(padMinLatitude, padMaxLatitude, currentLatitude))
                    {
                        // Within launch pad parameters.
                        currentZone = LaunchPad;
                    }
                }
                values.Add(new Value("Launch from", launchZone, currentZone, String.Equals(currentZone, launchZone)));

                // Check the speed to make sure that we are not moving. In most cases "<0.01" will donate a stationary object.
                // However, in some cases, that causes flickering of the text as it goes in and out of spec.
                double speed = MathTools.abs(vessel.horizontalSrfSpeed) + MathTools.abs(vessel.verticalSpeed);
                if (speed > 0.90)
                {
                    values.Add(new Value("Launch", "", "requires stationary position Test Fix, If your still getting message please report.", false));
                }
            }
            return values;
        }
        protected override List<Value> values(Vessel vessel, GameEvent ev)
        {
            List<Value> values2 = new List<Value>();
            if (manager.GetRoverTime == -1.0 && roverSeconds > 0.0 && manager.GetTimeRoverName == "none" && MCERoverScience.doResearch == true)
            {
                manager.SetRoverTime(Planetarium.GetUniversalTime());
                //manager.SetTimeRoverName("probe");
            }
            //if (FlightGlobals.fetch.activeVessel != null && manager.GetTimeRoverName != id && roverSeconds > 0)
            //{
            //    RoverScience.doResearch = false;
            //    manager.SetRoverTime(-1.0);
            //    manager.SetTimeRoverName("none");
            //}

            if (vessel == null)
            {
                values2.Add(new Value("Rover Research", "True"));
                values2.Add(new Value("Research Time", MathTools.formatTime(roverSeconds)));
                if (contractAvailable == 15)
                {
                    values2.Add(new Value("Landing Body", manager.GetRandomLanding));
                }
                else { values2.Add(new Value("Landing Body", body)); }
            }
            else
            {
                values2.Add(new Value("Rover Research", "True", "" + MCERoverScience.doResearch,MCERoverScience.doResearch));
                if (contractAvailable == 15)
                {
                    values2.Add(new Value("Landing Body", manager.GetRandomLanding, vessel.orbit.referenceBody.bodyName,
                                                     vessel.orbit.referenceBody.bodyName.Equals(manager.GetRandomLanding) && (vessel.situation == Vessel.Situations.LANDED ||
                        (splashedValid ? vessel.situation == Vessel.Situations.SPLASHED : false))));
                }
                else
                {
                    values2.Add(new Value("Landing Body", body, vessel.orbit.referenceBody.bodyName,
                                                   vessel.orbit.referenceBody.bodyName.Equals(body) && (vessel.situation == Vessel.Situations.LANDED ||
                      (splashedValid ? vessel.situation == Vessel.Situations.SPLASHED : false))));
                }

                if (roverSeconds > 0.0)
                {
                    double diff2 = (manager.GetRoverTime == -1.0 ? 0 : Planetarium.GetUniversalTime() - manager.GetRoverTime);
                    values2.Add(new Value("Research Time", MathTools.formatTime(roverSeconds), MathTools.formatTime(diff2), diff2 > roverSeconds));
                    if (diff2 > roverSeconds)
                    {
                        MCERoverScience.doResearch = false;
                        manager.SetRoverTime(-1.0);
                        manager.SetTimeRoverName("none");
                    }
                }

            }

            return values2;
        }
Exemplo n.º 16
0
        /// <summary>
        /// Finishes the given mission with the given vessel.
        /// Rewards the space program with the missions reward.
        /// </summary>
        /// <param name="m">mission</param>
        /// <param name="vessel">vessel</param>
        public void finishMission(Mission m, Vessel vessel, GameEvent events)
        {
            if (!isMissionAlreadyFinished (m, vessel) && m.isDone(vessel, events)) {
                MissionStatus status = new MissionStatus (m.name, vessel.id.ToString ());

                status.repeatable = m.repeatable;
                status.repeatableSameVessel = m.repeatableSameVessel;

                if (m.passiveMission) {
                    status.endOfLife = Planetarium.GetUniversalTime () + m.lifetime;
                    status.passiveReward = m.passiveReward;
                    status.lastPassiveRewardTime = Planetarium.GetUniversalTime ();
                }

                if(m.clientControlled) {
                    status.endOfLife = Planetarium.GetUniversalTime () + m.lifetime;
                }

                status.clientControlled = m.clientControlled;

                currentProgram.add(status);
                reward (m.reward);

                // finish unfinished goals
                foreach(MissionGoal goal in m.goals) {
                    finishMissionGoal(goal, vessel, events);
                }

                // If this mission is randomized, we will discard the mission
                if (m.randomized) {
                    discardRandomMission (m);
                    m = reloadMission (m, vessel);
                }
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// Checks if the mission is finishable with the vessel
        /// </summary>
        /// <returns><c>true</c>, if done was ised, <c>false</c> otherwise.</returns>
        /// <param name="vessel">current vessel</param>
        public bool isDone(Vessel vessel, GameEvent events)
        {
            if (vessel == null) {
                return false;
            }

            foreach (MissionGoal c in goals) {
                if (!c.isDone (vessel, events) && !c.optional) {
                    return false;
                }
            }
            return true;
        }
Exemplo n.º 18
0
 /// <summary>
 /// Finishes the given mission goal with the given vessel.
 /// Rewards the space program with the reward from mission goal.
 /// </summary>
 /// <param name="goal">Goal.</param>
 /// <param name="vessel">Vessel.</param>
 public void finishMissionGoal(MissionGoal goal, Vessel vessel, GameEvent events)
 {
     if (!isMissionGoalAlreadyFinished (goal, vessel) && goal.nonPermanent && goal.isDone(vessel, events)) {
         currentProgram.add(new GoalStatus(vessel.id.ToString(), goal.id));
         reward (goal.reward);
     }
 }
Exemplo n.º 19
0
        protected override List<Value> values(Vessel vessel, GameEvent events)
        {
            List<Value> values = new List<Value> ();

            if (eccentricity != 0.0) {
                if(vessel == null) {
                    values.Add (new Value ("Eccentricity", String.Format(MathTools.Range, eccentricity, eccentricityPrecision)));
                } else {
                    values.Add (new Value ("Eccentricity", String.Format(MathTools.Range, eccentricity, eccentricityPrecision),
                                          vessel.orbit.eccentricity, MathTools.inRange (eccentricity, eccentricityPrecision, vessel.orbit.eccentricity)));
                }
            }

            if (body != null) {
                if (vessel == null) {
                    values.Add (new Value ("Body", "" + body));
                } else {
                    values.Add (new Value ("Body", "" + body, vessel.orbit.referenceBody.bodyName, vessel.orbit.referenceBody.bodyName.Equals (body)));
                }
            }

            if (minPeA != 0.0) {
                if (vessel == null) {
                    values.Add (new Value ("min. Periapsis", String.Format(MathTools.SingleDoubleValue, minPeA)));
                } else {
                    values.Add (new Value ("min. Periapsis", String.Format(MathTools.SingleDoubleValue, minPeA),
                                          vessel.orbit.PeA, vessel.orbit.PeA >= minPeA));
                }
            }

            if (minApA != 0.0) {
                if (vessel == null) {
                    values.Add (new Value ("min. Apoapsis", String.Format(MathTools.SingleDoubleValue, minApA)));
                } else {
                    values.Add (new Value ("min. Apoapsis", String.Format(MathTools.SingleDoubleValue, minApA),
                                          vessel.orbit.ApA, vessel.orbit.ApA >= minApA));
                }
            }

            if (maxPeA != 0.0) {
                if (vessel == null) {
                    values.Add (new Value ("max. Periapsis", String.Format(MathTools.SingleDoubleValue, maxPeA)));
                } else {
                    values.Add (new Value ("max. Periapsis", String.Format(MathTools.SingleDoubleValue, maxPeA),
                                           vessel.orbit.PeA, vessel.orbit.PeA <= maxPeA));
                }
            }

            if (maxApA != 0.0 ) {
                if (vessel == null) {
                    values.Add (new Value ("max. Apoapsis", String.Format(MathTools.SingleDoubleValue, maxApA)));
                } else {
                    values.Add (new Value ("max. Apoapsis", String.Format(MathTools.SingleDoubleValue, maxApA),
                                           vessel.orbit.ApA, vessel.orbit.ApA <= maxApA &&
                                            (vessel.orbit.ApA * maxApA > 0))); //either both values are positive, or both are negative
                }
            }

            if (minInclination != maxInclination) {
                if (vessel == null) {
                    values.Add (new Value ("Inclination", String.Format(MathTools.MinMaxValue, minInclination, maxInclination)));
                } else {
                    values.Add (new Value ("Inclination", String.Format(MathTools.MinMaxValue, minInclination, maxInclination),
                                           String.Format(MathTools.SingleDoubleValue, vessel.orbit.inclination),
                                                      MathTools.inMinMax (minInclination, maxInclination, vessel.orbit.inclination)));
                }
            }

            if (minLan != maxLan) {
                if (vessel == null) {
                    values.Add (new Value ("LAN", String.Format(MathTools.MinMaxValue, minLan, maxLan)));
                } else {
                    values.Add (new Value ("LAN", String.Format(MathTools.MinMaxValue, minLan, maxLan),
                                           vessel.orbit.LAN, MathTools.inMinMax (minLan, maxLan, vessel.orbit.LAN)));
                }
            }

            if (minAltitude != 0.0) {
                if (vessel == null) {
                    values.Add (new Value ("min Altitude", String.Format(MathTools.SingleDoubleValue, minAltitude)));
                } else {
                    values.Add (new Value ("min Altitude", String.Format(MathTools.SingleDoubleValue, minAltitude),
                                           vessel.orbit.altitude, vessel.orbit.altitude >= minAltitude));
                }
            }

            if (maxAltitude != 0.0) {
                if (vessel == null) {
                    values.Add (new Value ("max Altitude", String.Format(MathTools.SingleDoubleValue, maxAltitude)));
                } else {
                    values.Add (new Value ("max Altitude", String.Format(MathTools.SingleDoubleValue, maxAltitude),
                                           vessel.orbit.altitude, vessel.orbit.altitude <= maxAltitude));
                }
            }

            if (minSpeedOverGround != 0.0) {
                if (vessel == null) {
                    values.Add (new Value ("min speed over ground", String.Format(MathTools.SingleDoubleValue, minSpeedOverGround)));
                } else {
                    values.Add (new Value ("min speed over ground", String.Format(MathTools.SingleDoubleValue, minSpeedOverGround),
                                           vessel.horizontalSrfSpeed, vessel.horizontalSrfSpeed >= minSpeedOverGround));
                }
            }

            if (maxSpeedOverGround != 0.0) {
                if (vessel == null) {
                    values.Add (new Value ("max speed over ground", String.Format(MathTools.SingleDoubleValue, maxSpeedOverGround)));
                } else {
                    values.Add (new Value ("max speed over ground", String.Format(MathTools.SingleDoubleValue, maxSpeedOverGround),
                                           vessel.horizontalSrfSpeed, vessel.horizontalSrfSpeed <= maxSpeedOverGround));
                }
            }

            if(maxEccentricity != minEccentricity) {
                // If both min < max, then max has not been set at all and ignore the max value
                if(minEccentricity < maxEccentricity) {
                    if (vessel == null) {
                        values.Add (new Value ("Eccentricity", String.Format(MathTools.HighPrecisionMinMaxValue, minEccentricity, maxEccentricity)));
                    } else {
                        values.Add (new Value ("Eccentricity", String.Format(MathTools.HighPrecisionMinMaxValue, minEccentricity, maxEccentricity),
                                              vessel.orbit.eccentricity, MathTools.inMinMax(minEccentricity, maxEccentricity, vessel.orbit.eccentricity), true));
                    }
                } else {
                    if (vessel == null) {
                        values.Add (new Value ("min. Eccentricity", String.Format(MathTools.HighPrecisionDoubleValue, minEccentricity)));
                    } else {
                        values.Add (new Value ("min. Eccentricity", String.Format(MathTools.HighPrecisionDoubleValue, minEccentricity),
                                              vessel.orbit.eccentricity, minEccentricity < vessel.orbit.eccentricity, true));
                    }
                }
            }

            if (minOrbitalPeriod < maxOrbitalPeriod) {
                if (vessel == null || Planetarium.fetch == null) {
                    values.Add (new Value("Orbital Period", String.Format(MathTools.MinMaxString,
                                                                         MathTools.formatTime(minOrbitalPeriod), MathTools.formatTime(maxOrbitalPeriod))));
                } else {
                    values.Add (new Value("Orbital Period", String.Format(MathTools.MinMaxString,
                                                                          MathTools.formatTime(minOrbitalPeriod), MathTools.formatTime(maxOrbitalPeriod)),
                                          MathTools.formatTime(vessel.orbit.period), MathTools.inMinMax(minOrbitalPeriod, maxOrbitalPeriod, vessel.orbit.period)));
                }
            }

            if (minVerticalSpeed != 0.0) { //both min and max Vertical Speed variables are tested in game.  Good Test.
                if (vessel == null) {
                    values.Add (new Value ("Min Vertical Speed", String.Format(MathTools.SingleDoubleValue, minVerticalSpeed)));
                } else {
                    values.Add (new Value ("Min Vertical Speed", String.Format(MathTools.SingleDoubleValue, minVerticalSpeed),
                                           vessel.verticalSpeed, vessel.verticalSpeed >= minVerticalSpeed));
                }
            }

            if (maxVerticalSpeed != 0.0) {
                if (vessel == null) {
                    values.Add (new Value ("Max Vertical Speed", String.Format(MathTools.SingleDoubleValue, maxVerticalSpeed)));
                } else {
                    values.Add (new Value ("Max Vertical Speed", String.Format(MathTools.SingleDoubleValue, maxVerticalSpeed),
                                           vessel.verticalSpeed, vessel.verticalSpeed <= maxVerticalSpeed));
                }
            }

            if (minGForce != 0.0) {
                if (vessel == null) {
                    values.Add (new Value ("Min G Force", String.Format(MathTools.SingleDoubleValue, minGForce)));
                } else {
                    values.Add (new Value ("Min G Force", String.Format(MathTools.SingleDoubleValue, minGForce),
                                           vessel.geeForce, vessel.geeForce >= minGForce));
                }
            }

            if (maxGForce != 0.0) {
                if (vessel == null) {
                    values.Add (new Value ("Max G Force", String.Format(MathTools.SingleDoubleValue, maxGForce)));
                } else {
                    values.Add (new Value ("Max G Force", String.Format(MathTools.SingleDoubleValue, maxGForce),
                                           vessel.geeForce, vessel.geeForce <= maxGForce));
                }
            }

            if(minLatitude != maxLatitude) {
                if(vessel == null) {
                    values.Add(new Value("Latitude", String.Format(MathTools.MinMaxValue, minLatitude, maxLatitude)));
                } else {
                    values.Add(new Value("Latitude", String.Format(MathTools.MinMaxValue, minLatitude, maxLatitude),
                                         vessel.latitude, MathTools.inMinMax(minLatitude, maxLatitude, vessel.latitude)));
                }
            }

            if(minLongitude != maxLongitude) {
                if(vessel == null) {
                    values.Add(new Value("Longitude", String.Format(MathTools.MinMaxValue, minLongitude, maxLongitude)));
                } else {
                    values.Add(new Value("Longitude", String.Format(MathTools.MinMaxValue, minLongitude, maxLongitude),
                                         MathTools.calculateLongitude(vessel.longitude),
                                         MathTools.inMinMax(minLongitude, maxLongitude, MathTools.calculateLongitude(vessel.longitude))));
                }
            }

            return values;
        }
Exemplo n.º 20
0
        /// <summary>
        /// Checks, if this mission goal has been accomplished.
        /// </summary>
        /// <returns><c>true</c>, if mission goal is done, <c>false</c> otherwise.</returns>
        /// <param name="vessel">current vessel</param>
        public virtual bool isDone(Vessel vessel, GameEvent events)
        {
            if (vessel == null) {
                return false;
            }

            if (nonPermanent && doneOnce) {
                return true;
            }

            if(vessel.orbit == null) {
                return false;
            }

            List<Value> values = getValues (vessel, events);
            foreach (Value v in values) {
                if(!v.done) {
                    return false;
                }
            }

            // If this is a one time mission condition and everything has been done
            // we remember this for now
            if (nonPermanent) {
                doneOnce = true;
            }
            return true;
        }
Exemplo n.º 21
0
 /// <summary>
 /// Returns an array of necessary values, like orbital parameters.
 /// </summary>
 /// <param name="v">current vessel, might be null when in editor mode or in space center mode!</param>
 protected virtual List<Value> values(Vessel v, GameEvent events)
 {
     return new List<Value> ();
 }
Exemplo n.º 22
0
        /// <summary>
        /// Returns all values related to this mission goal
        /// </summary>
        /// <returns>The values.</returns>
        /// <param name="vessel">current vessel</param>
        public List<Value> getValues(Vessel vessel, GameEvent events)
        {
            List<Value> vs = values (vessel, events);

            if (crewCount != 0) {
                if(vessel == null) {
                    vs.Add (new Value ("Crew count", "" + crewCount));
                } else {
                    vs.Add (new Value ("Crew count", "" + crewCount, "" + vessel.GetCrewCount (),
                                   crewCount <= vessel.GetCrewCount ()));
                }
            }

            if (minTotalMass != 0.0) {
                if (vessel == null) {
                    vs.Add(new Value("min. total mass", String.Format(MathTools.SingleDoubleValue, minTotalMass)));
                } else {
                    vs.Add(new Value("min. total mass", String.Format(MathTools.SingleDoubleValue, minTotalMass),
                                     String.Format(MathTools.SingleDoubleValue, vessel.GetTotalMass()),
                                     vessel.GetTotalMass() >= minTotalMass));
                }
            }

            if (maxTotalMass != 0.0) {
                if (vessel == null) {
                    vs.Add(new Value("max. total mass", String.Format(MathTools.SingleDoubleValue, maxTotalMass)));
                } else {
                    vs.Add(new Value("max. total mass", String.Format(MathTools.SingleDoubleValue, maxTotalMass),
                                     String.Format(MathTools.SingleDoubleValue, vessel.GetTotalMass()),
                                     vessel.GetTotalMass() <= maxTotalMass));
                }
            }

            bool done = true;
            foreach (Value v in vs) {
                done = done && v.done;
            }

            // If the mission goal is finished so far and we need to throttle down in order
            // to finish the mission goal, add another value if not throttled down
            if (vessel != null) {
                if (done && throttleDown && FlightInputHandler.state.mainThrottle != 0.0) {
                    vs.Add (new Value ("Throttle down!", "true", "false", false));
                    done = false;
                }
            }

            if (done && timeStarted == -1.0 && minSeconds > 0.0) {
                timeStarted = Planetarium.GetUniversalTime ();
            }

            if (minSeconds > 0.0 && !done) {
                timeStarted = -1.0;
            }

            if (minSeconds > 0.0) {
                if (vessel != null) {
                    double diff = (timeStarted == -1.0 ? 0 : Planetarium.GetUniversalTime () - timeStarted);
                    vs.Add (new Value("Minimal time", MathTools.formatTime(minSeconds), MathTools.formatTime(diff), diff > minSeconds));
                } else {
                    vs.Add (new Value("Minimal time", MathTools.formatTime(minSeconds)));
                }
            }

            return vs;
        }