protected override void OnLoad(ConfigNode node) { base.OnLoad(node); readAnomalyConfig(); chosenAnomaly = KourageousAnomaly.Load(node, anomalies); }
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)); } }
protected override bool Generate() //System.Type contractType, Contract.ContractPrestige difficulty, int seed, State state) { KourageousTouristsAddOn.printDebug("entered"); targetBody = selectNextCelestialBody(); if (targetBody == null) { return(false); } chosenAnomaly = chooseAnomaly(targetBody); if (chosenAnomaly == 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); KourageousAnomalyParameter anomalyParameter = new KourageousAnomalyParameter( targetBody, tourist.name, chosenAnomaly.name, chosenAnomaly.anomalyDescription ); anomalyParameter.FundsCompletion = 1300.0; anomalyParameter.FundsFailure = 0.0; anomalyParameter.ReputationCompletion = 1.0f; anomalyParameter.ReputationFailure = 1.0f; anomalyParameter.ScienceCompletion = 0.0f; itinerary.AddParameter(anomalyParameter); } GenerateHashString(); base.SetExpiry(); base.SetScience(0.0f, targetBody); base.SetDeadlineYears(1, targetBody); base.SetReputation(2, 5, targetBody); base.SetFunds( 3000 * chosenAnomaly.payoutModifier, 9000 * chosenAnomaly.payoutModifier, 21000 * chosenAnomaly.payoutModifier, targetBody); return(true); }