/// <summary> /// Used externally to return the name of the requested part /// </summary> /// <param name="cP">Instance of the requested Contract Parameter</param> /// <returns>Available Part name string</returns> public static string PartName(ContractParameter cP) { DMCollectScience Instance = (DMCollectScience)cP; return(Instance.partName); }
protected override bool Generate() { int total = ContractSystem.Instance.GetCurrentContracts <DMAnomalyContract>().Count(); if (total >= DMUtils.maxAnomaly) { return(false); } //Make sure that the anomaly scanner is available AvailablePart aPart = PartLoader.getPartInfoByName("dmAnomScanner"); if (aPart == null) { return(false); } if (!ResearchAndDevelopment.PartModelPurchased(aPart)) { return(false); } //Kerbin or Mun Anomalies for trivial contracts if (this.Prestige == ContractPrestige.Trivial) { if (rand.Next(0, 3) == 0) { body = FlightGlobals.Bodies[1]; } else { body = FlightGlobals.Bodies[2]; } } //Minmus and Duna are next else if (this.Prestige == ContractPrestige.Significant) { if (!ProgressTracking.Instance.NodeComplete(new string[] { "Kerbin", "Escape" })) { return(false); } if (rand.Next(0, 2) == 0) { body = FlightGlobals.Bodies[3]; } else { body = FlightGlobals.Bodies[6]; } } //Vall, Tylo, and Bop are last; only if we've been to Jool first else if (this.Prestige == ContractPrestige.Exceptional) { if (!ProgressTracking.Instance.NodeComplete(new string[] { "Jool", "Flyby" })) { return(false); } int i = rand.Next(0, 3); if (i == 0) { body = FlightGlobals.Bodies[10]; } else if (i == 1) { body = FlightGlobals.Bodies[11]; } else if (i == 2) { body = FlightGlobals.Bodies[12]; } else { return(false); } } else { return(false); } PQSCity[] Cities = UnityEngine.Object.FindObjectsOfType(typeof(PQSCity)) as PQSCity[]; foreach (PQSCity city in Cities) { if (city.transform.parent.name == body.name) { cities.Add(city); } } //Select random anomaly targetAnomaly = new DMAnomalyObject(cities[rand.Next(0, cities.Count)]); hash = targetAnomaly.name; lon = targetAnomaly.lon; lat = targetAnomaly.lat; fudgedLat = fudgeLat(lat); fudgedLon = fudgeLon(lon); cardNS = NSDirection(lat); cardEW = EWDirection(lon); DMUtils.DebugLog("Anomaly [{0}] Selected On {1} at Latitude: {2:N1} and Longitude: {3:N1}", targetAnomaly.name, body.theName, lat, lon); //Assign primary anomaly contract parameter if ((newParam = DMAnomalyGenerator.fetchAnomalyParameter(body, targetAnomaly)) == null) { return(false); } sciList.AddRange(DMUtils.availableScience[DMScienceType.Anomaly.ToString()].Values); for (i = 0; i < 3; i++) { if (sciList.Count > 0) { DMScience = sciList[rand.Next(0, sciList.Count)]; anomParams[i] = (DMAnomalyGenerator.fetchAnomalyParameter(body, targetAnomaly, DMScience)); sciList.Remove(DMScience); } else { anomParams[i] = null; } } this.AddParameter(newParam); DMUtils.DebugLog("Added Primary Anomaly Parameter"); float primaryLocationMod = GameVariables.Instance.ScoreSituation(DMUtils.convertSit(newParam.Situation), newParam.Body) * ((float)rand.Next(85, 116) / 100f); newParam.SetFunds(20000f * DMUtils.reward * primaryLocationMod, 10000f * DMUtils.penalty * primaryLocationMod, body); newParam.SetReputation(80f * DMUtils.reward * primaryLocationMod, 10f * DMUtils.penalty * primaryLocationMod, body); newParam.SetScience(35f * DMUtils.science * DMUtils.fixSubjectVal(newParam.Situation, 1f, body), null); foreach (DMAnomalyParameter aP in anomParams) { if (aP != null) { this.AddParameter(aP, "collectDMAnomaly"); DMUtils.DebugLog("Added Secondary Anomaly Parameter"); float locationMod = GameVariables.Instance.ScoreSituation(DMUtils.convertSit(aP.Situation), aP.Body) * ((float)rand.Next(85, 116) / 100f); aP.SetFunds(9000f * DMUtils.reward * locationMod, 6000f * DMUtils.penalty * locationMod, body); aP.SetReputation(20f * DMUtils.reward * locationMod, 5f * DMUtils.penalty * locationMod, body); aP.SetScience(aP.Container.exp.baseValue * 2f * DMUtils.science * DMUtils.fixSubjectVal(aP.Situation, 1f, body), null); } } if (this.ParameterCount == 0) { return(false); } this.agent = AgentList.Instance.GetAgent("DMagic"); base.SetExpiry(10 * DMUtils.deadline, 20 * DMUtils.deadline); base.SetDeadlineYears(1.8f * ((float)rand.Next(80, 121)) / 100f * DMUtils.deadline, body); base.SetReputation(20f * DMUtils.reward * primaryLocationMod, 10f * DMUtils.penalty * primaryLocationMod, body); base.SetFunds(25000f * DMUtils.forward * primaryLocationMod, 22000f * DMUtils.reward * primaryLocationMod, 16000f * DMUtils.penalty * primaryLocationMod, body); return(true); }