protected KourageousAnomaly chooseAnomaly(CelestialBody body)
        {
            KourageousTouristsAddOn.printDebug("entered");
            readAnomalyConfig();
            KourageousTouristsAddOn.printDebug(String.Format("anomalies: {0}, distance: {1}",
                                                             anomalies.Count, anomalyDiscoveryDistance));

            List <KourageousAnomaly> chosen = new List <KourageousAnomaly> ();

            foreach (KeyValuePair <string, KourageousAnomaly> entry in anomalies)
            {
                if (entry.Value.body.name.Equals(body.name))
                {
                    chosen.Add(entry.Value);
                }
            }

            KourageousTouristsAddOn.printDebug(String.Format("chosen: {0}, cnt: {1}",
                                                             chosen, chosen.Count));
            if (chosen.Count == 0)
            {
                return(null);
            }

            Random rnd = new Random();

            return(chosen [rnd.Next(chosen.Count)]);
        }
        private void checkCompletion(Vessel v)
        {
            foreach (ProtoCrewMember c in v.GetVesselCrew())
            {
                KourageousTouristsAddOn.printDebug(
                    String.Format("param vessel crew: {0}", c.name));
            }

            // Check that this tourist has already jumped out
            KourageousTouristsAddOn.printDebug(
                $"Checking jump parameter: {Root.GetParameter(0).State}");
            if (Root.GetParameter(0).State != ParameterState.Complete)
            {
                return;
            }

            if (v.isEVA &&
                v.mainBody == targetBody &&
                v.GetVesselCrew().Count == 1 &&
                v.GetVesselCrew() [0].name.Equals(tourist) &&
                v.situation == Vessel.Situations.LANDED)
            {
                base.SetComplete();
            }
        }
 protected override void OnAccepted()
 {
     KourageousTouristsAddOn.printDebug("entered: body=" + targetBody.bodyName);
     foreach (ProtoCrewMember tourist in tourists)
     {
         HighLogic.CurrentGame.CrewRoster.AddCrewMember(tourist);
         KourageousTouristsAddOn.printDebug("adding to roster: " + tourist.name);
     }
 }
Exemplo n.º 4
0
        private void OnEva(GameEvents.FromToAction <Part, Part> action)
        {
            Vessel v = action.to.vessel;

            KourageousTouristsAddOn.printDebug(
                String.Format("triggered; vessel: {0}, {1}; param tourist: {2}; body: {3}; vessel situation: {4}; vessel body: {5}",
                              action.to.vessel, action.from.vessel, this.tourist, this.targetBody.bodyName, v.situation, v.mainBody.bodyName));

            checkCompletion(v);
        }
Exemplo n.º 5
0
 protected override void OnLoad(ConfigNode node)
 {
     base.OnLoad(node);
     this.anomalyName = String.Copy(node.GetValue("anomalyName"));
     KourageousAnomalyContract.readAnomalyConfig();
     this.anomalyDisplayName =
         KourageousAnomalyContract.anomalies [targetBody.name + ":" + anomalyName].anomalyDescription;
     KourageousTouristsAddOn.printDebug("display name: " + anomalyDisplayName);
     setDistance();
 }
Exemplo n.º 6
0
 private void checkCompletion(Vessel v)
 {
     KourageousTouristsAddOn.printDebug(
         $"checking param: vessel crew: {v.GetVesselCrew()[0].name}; alt: {v.radarAltitude}");
     if (v.isEVA &&
         v.mainBody == targetBody &&
         v.GetVesselCrew().Count == 1 &&
         v.GetVesselCrew()[0].name.Equals(tourist) &&
         v.situation == Vessel.Situations.FLYING &&
         v.radarAltitude > 1300)
     {
         KourageousTouristsAddOn.printDebug("Setting 'complete'");
         base.SetComplete();
     }
 }
        public override bool MeetRequirements()
        {
            if (KourageousTouristsAddOn.noSkyDiving)
            {
                return(false);
            }
            ProgressNode buzz = ProgressTracking.Instance.FindNode("TowerBuzz");

            if (buzz == null || !buzz.IsComplete)
            {
                KourageousTouristsAddOn.printDebug("buzz node node complete");
                return(false);
            }
            return(true);
        }
        protected override bool Generate()
        //System.Type contractType, Contract.ContractPrestige difficulty, int seed, State state)
        {
            KourageousTouristsAddOn.printDebug("skydive generate");

            targetBody = selectNextCelestialBody();
            if (targetBody == null)
            {
                KourageousTouristsAddOn.printDebug("target body is null");
                return(false);
            }

            numTourists = UnityEngine.Random.Range(1, 6);
            KourageousTouristsAddOn.printDebug("num tourists: " + numTourists);
            for (int i = 0; i < this.numTourists; i++)
            {
                ProtoCrewMember tourist = CrewGenerator.RandomCrewMemberPrototype(ProtoCrewMember.KerbalType.Tourist);

                tourists.Add(tourist);
                KourageousTouristsAddOn.printDebug("generated: " + tourist.name);

                KourageousSkydiveJumpParameter jumpParameter = new KourageousSkydiveJumpParameter(targetBody, tourist.name);
                jumpParameter.FundsCompletion      = 0.0;
                jumpParameter.FundsFailure         = 0.0;
                jumpParameter.ReputationCompletion = 0.0f;
                jumpParameter.ReputationFailure    = 0.0f;
                jumpParameter.ScienceCompletion    = 0.0f;
                AddParameter(jumpParameter);

                KourageousSkydiveLandParameter landParameter = new KourageousSkydiveLandParameter(targetBody, tourist.name);
                landParameter.FundsCompletion      = 1000.0;
                landParameter.FundsFailure         = 0.0;
                landParameter.ReputationCompletion = 0.0f;
                landParameter.ReputationFailure    = 0.0f;
                landParameter.ScienceCompletion    = 0.0f;
                AddParameter(landParameter);
            }

            GenerateHashString();

            SetExpiry();
            SetScience(0.0f, targetBody);
            SetDeadlineYears(1, targetBody);
            SetReputation(2, 5, targetBody);
            SetFunds(500, 2000, 15000, targetBody);

            return(true);
        }
Exemplo n.º 9
0
 private void checkCompletion(Vessel v)
 {
     foreach (ProtoCrewMember c in v.GetVesselCrew())
     {
         KourageousTouristsAddOn.printDebug(
             String.Format("param vessel crew: {0}", c.name));
     }
     if (v.isEVA &&
         v.mainBody == targetBody &&
         v.GetVesselCrew().Count == 1 &&
         v.GetVesselCrew() [0].name.Equals(tourist) &&
         v.situation == Vessel.Situations.LANDED)
     {
         base.SetComplete();
     }
 }
        protected new CelestialBody selectNextCelestialBody()
        {
            List <CelestialBody> allBodies = getCelestialBodyList().Where(
                b => b.atmosphere).ToList();

            allBodies.Add(Planetarium.fetch.Home);

            KourageousTouristsAddOn.printDebug("skydive bodies: " +
                                               String.Join(", ", allBodies));

            if (allBodies.Count < 1)
            {
                return(null);
            }
            return(allBodies [UnityEngine.Random.Range(0, allBodies.Count - 1)]);
        }
Exemplo n.º 11
0
        private bool isNearbyAnomaly(Vessel v, string anomalyName)
        {
            // FIXME: Can we have objects with same names, but on different bodies?
            // FIXME: So far I think we can.
            GameObject[] obj = UnityEngine.Object.FindObjectsOfType <GameObject>();
            foreach (GameObject anomalyObj in obj)
            {
                Component[] c = anomalyObj.GetComponents <PQSCity> ();
                if (c == null || c.Length == 0)
                {
                    continue;
                }
                KourageousTouristsAddOn.printDebug("has pqscity: " + anomalyObj.name);
                PQSCity pqscity = (PQSCity)c [0];
                if (pqscity == null)
                {
                    continue;
                }

                if (!pqscity.sphere.isAlive)
                {
                    continue;
                }

                Transform tr = anomalyObj.GetComponent <Transform> ();

                if (!anomalyObj.name.Equals(anomalyName))
                {
                    continue;
                }
                if (tr == null)
                {
                    return(false);
                }
                float dist1 = Vector3.Distance(v.transform.position, tr.position);
                KourageousTouristsAddOn.printDebug("distance: " + dist1.ToString() +
                                                   "; min dist: " + minAnomalyDistance.ToString());
                if (dist1 < this.minAnomalyDistance)
                {
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 12
0
 private void onSelfieTaken()
 {
     KourageousTouristsAddOn.printDebug("here");
     foreach (Vessel v in FlightGlobals.VesselsLoaded)
     {
         if (
             v.mainBody == targetBody &&
             v.GetVesselCrew().Count == 1 &&
             v.GetVesselCrew() [0].name.Equals(tourist) &&
             v.situation == Vessel.Situations.LANDED && v.isEVA)
         {
             KourageousTouristsAddOn.printDebug("checking for " + tourist + " at " + anomalyName);
             if (this.isNearbyAnomaly(v, anomalyName))
             {
                 base.SetComplete();
             }
             break;
         }
     }
 }
Exemplo n.º 13
0
        protected void setDistance()
        {
            ConfigNode config = GameDatabase.Instance.GetConfigNodes(
                KourageousTouristsAddOn.cfgRoot).FirstOrDefault();

            this.minAnomalyDistance = defaultMinAnomalyDistance;
            if (config != null)
            {
                String dscvr = config.GetValue(discoveryDistance);
                if (dscvr != null)
                {
                    try {
                        this.minAnomalyDistance = (float)Convert.ToDouble(dscvr);
                    } catch (Exception) {
                    }
                }
            }
            else
            {
                KourageousTouristsAddOn.printDebug("no config found in game database");
            }
        }
Exemplo n.º 14
0
 protected override void OnRegister()
 {
     KourageousTouristsAddOn.printDebug("setting event OnEva");
     GameEvents.onCrewOnEva.Add(OnEva);
     GameEvents.onVesselSituationChange.Add(OnSituationChange);
 }
 protected override string GetTitle()
 {
     KourageousTouristsAddOn.printDebug("entered: anomaly=" + chosenAnomaly);
     return(String.Format("Visit {0} with {1}",
                          chosenAnomaly.anomalyDescription, getProperTouristWordLc()));
 }
        internal static void readAnomalyConfig()
        {
            if (anomalies != null)
            {
                return;
            }

            anomalies = new Dictionary <String, KourageousAnomaly> ();
            ConfigNode config = GameDatabase.Instance.GetConfigNodes(
                KourageousTouristsAddOn.cfgRoot).FirstOrDefault();

            if (config == null)
            {
                return;
            }


            String distanceNode = config.GetValue(anomalyDistance);

            if (distanceNode != null)
            {
                try {
                    anomalyDiscoveryDistance = (float)Convert.ToDouble(distanceNode);
                }
                catch (Exception) {
                }
            }

            ConfigNode[] nodes = config.GetNodes(anomalyCfgNode);
            foreach (ConfigNode node in nodes)
            {
                KourageousAnomaly anomaly = new KourageousAnomaly();

                KourageousTouristsAddOn.printDebug(String.Format("cfg node: {0}", node));
                String name = node.GetValue("name");
                if (name == null)
                {
                    continue;
                }
                anomaly.name = name;

                KourageousTouristsAddOn.printDebug(String.Format("anomaly name: {0}", name));
                String anomalyDescription = node.GetValue("anomalyDescription");
                if (anomalyDescription == null)
                {
                    continue;
                }
                anomaly.anomalyDescription = anomalyDescription;

                String contractDescription = node.GetValue("contractDescription");
                if (contractDescription == null)
                {
                    continue;
                }
                anomaly.contractDescription = contractDescription;

                String contractSynopsis = node.GetValue("contractSynopsis");
                if (contractSynopsis == null)
                {
                    continue;
                }
                anomaly.contractSynopsis = contractSynopsis;

                String bodyStr = node.GetValue("body");
                KourageousTouristsAddOn.printDebug(String.Format("anomaly body: {0}", bodyStr));

                foreach (CelestialBody b in FlightGlobals.Bodies)
                {
                    KourageousTouristsAddOn.printDebug(String.Format("list body name: {0}", b.name));
                    if (b.name.Equals(bodyStr))
                    {
                        anomaly.body = b;
                        break;
                    }
                }
                KourageousTouristsAddOn.printDebug(String.Format("anomaly body obj: {0}", anomaly.body == null));
                if (anomaly.body == null)
                {
                    continue;
                }

                String payoutModifierStr = node.GetValue("payoutModifier");
                KourageousTouristsAddOn.printDebug(String.Format("payout modifier str: {0}", payoutModifierStr));
                if (payoutModifierStr == null)
                {
                    continue;
                }
                float payoutModifier = 1.0f;
                try {
                    payoutModifier = (float)Convert.ToDouble(payoutModifierStr);
                    KourageousTouristsAddOn.printDebug(String.Format("payout modifier: {0}", payoutModifier));
                }
                catch (Exception) {
                }
                anomaly.payoutModifier = payoutModifier;

                anomalies.Add(bodyStr + ":" + name, anomaly);
                KourageousTouristsAddOn.printDebug(String.Format("added: {0}", bodyStr + ":" + name));
            }
        }
Exemplo n.º 17
0
        protected override bool Generate()
        //System.Type contractType, Contract.ContractPrestige difficulty, int seed, State state)
        {
            KourageousTouristsAddOn.printDebug("Selfie entered");

            targetBody = selectNextCelestialBody();
            if (targetBody == null)
            {
                return(false);
            }

            this.numTourists = UnityEngine.Random.Range(2, 5);
            KourageousTouristsAddOn.printDebug("num tourists: " + numTourists);
            for (int i = 0; i < this.numTourists; i++)
            {
                ProtoCrewMember tourist = CrewGenerator.RandomCrewMemberPrototype(ProtoCrewMember.KerbalType.Tourist);

                this.tourists.Add(tourist);
                KourageousTouristsAddOn.printDebug("generated: " + tourist.name);

                // TODO: Add support for gender for 1.3 build
                KerbalTourParameter itinerary = new KerbalTourParameter(tourist.name, tourist.gender);
                // TODO: Add difficulty multiplier
                itinerary.FundsCompletion      = 25000.0;
                itinerary.ReputationCompletion = 0.0f;
                itinerary.ReputationFailure    = 0.0f;
                itinerary.ScienceCompletion    = 0.0f;
                this.AddParameter(itinerary);

                KerbalDestinationParameter dstParameter = new KerbalDestinationParameter(
                    targetBody, FlightLog.EntryType.Land, tourist.name
                    );
                dstParameter.FundsCompletion      = 1000.0f;
                dstParameter.FundsFailure         = 0.0f;
                dstParameter.ReputationCompletion = 0.0f;
                dstParameter.ReputationFailure    = 0.0f;
                dstParameter.ScienceCompletion    = 0.0f;

                /*dstParameter.NestToParent (itinerary);
                 * dstParameter.CreateID ();
                 * dstParameter.AddParameter (new Contracts.Parameters.LandOnBody (targetBody));*/
                itinerary.AddParameter(dstParameter);

                KourageousWalkParameter walkParameter = new KourageousWalkParameter(targetBody, tourist.name);
                walkParameter.FundsCompletion      = 1000.0;
                walkParameter.FundsFailure         = 0.0;
                walkParameter.ReputationCompletion = 0.0f;
                walkParameter.ReputationFailure    = 0.0f;
                walkParameter.ScienceCompletion    = 0.0f;
                itinerary.AddParameter(walkParameter);

                KourageousSelfieParameter selfieParameter = new KourageousSelfieParameter(targetBody, tourist.name);
                walkParameter.FundsCompletion      = 3000.0;
                walkParameter.FundsFailure         = 0.0;
                walkParameter.ReputationCompletion = 0.0f;
                walkParameter.ReputationFailure    = 0.0f;
                walkParameter.ScienceCompletion    = 0.0f;
                itinerary.AddParameter(selfieParameter);
            }

            GenerateHashString();

            base.SetExpiry();
            base.SetScience(0.0f, targetBody);
            base.SetDeadlineYears(1, targetBody);
            base.SetReputation(2, 5, targetBody);
            base.SetFunds(2500, 8000, 19000, targetBody);


            return(true);
        }