protected override void OnLoad(ConfigNode node) { if (!node.HasValue("targetBody")) { return; } int bodyID = int.Parse(node.GetValue("targetBody")); foreach (var body in FlightGlobals.Bodies) { if (body.flightGlobalsIndex == bodyID) { targetBody = body; } } experimentID = node.GetValue("experimentID"); experimentNode = GetExperimentNode(experimentID); situations = GetSituations(experimentNode); experimentCompleted = node.TryGetValue("experimentCompleted", ref experimentCompleted) && experimentCompleted; // only true if config has value and it is true if (node.HasValue("versionNumber")) { if (int.TryParse("blah", out versionNumber) == false) { versionNumber = CurrentContractVersion; } } }
protected static float getRewardMultiplier(WBIExperimentSituations situations, CelestialBody targetBody) { float multiplier = 1.0f; //Base value * science multiplier //Landed > low > high > sub-orbital > flying if (situations.landed || situations.prelaunch || situations.splashed) { multiplier = targetBody.scienceValues.LandedDataValue; } else if (situations.orbiting) { multiplier = targetBody.scienceValues.InSpaceLowDataValue; } else if (situations.subOrbital || situations.escaping) { multiplier = targetBody.scienceValues.InSpaceHighDataValue; } else if (situations.flying) { multiplier = targetBody.scienceValues.FlyingLowDataValue; } multiplier *= rewardAdjustmentFactor; return(multiplier); }
protected static float getScienceReward(ConfigNode experimentNode, WBIExperimentSituations situations, CelestialBody targetBody) { float reward = float.Parse(experimentNode.GetValue("baseValue")); //Base value * science multiplier reward *= getRewardMultiplier(situations, targetBody); return(reward); }
protected static float getCompletionReward(ConfigNode experimentNode, WBIExperimentSituations situations, CelestialBody targetBody) { float reward = fundsCompleteBase; //Base value * science multiplier //Landed > low > high > sub-orbital > flying reward *= getRewardMultiplier(situations, targetBody); return(reward); }
public static WBIExperimentSituations GetSituations(ConfigNode experimentNode) { WBIExperimentSituations situations = new WBIExperimentSituations(); //DOCKED, ESCAPING, FLYING, LANDED, PRELAUNCH, ORBITING, SPLASHED, SUB_ORBITAL if (experimentNode.HasValue("situations")) { string[] situationRequirements = experimentNode.GetValue("situations").Split(new char[] { ';' }); for (int index = 0; index < situationRequirements.Length; index++) { switch (situationRequirements[index]) { case "DOCKED": situations.docked = true; break; case "ESCAPING": situations.escaping = true; break; case "FLYING": situations.flying = true; break; case "LANDED": situations.landed = true; break; case "PRELAUNCH": situations.prelaunch = true; break; case "SUB_ORBITAL": situations.subOrbital = true; break; case "ORBITING": default: situations.orbiting = true; break; } } } else { situations.any = true; } return(situations); }
protected void generateExperimentIfNeeded() { if (experimentNode == null) { targetBody = getNextTarget(); if (targetBody == null) { targetBody = Planetarium.fetch.Home; } experimentNode = getRandomExperiment(); } experimentID = experimentNode.GetValue("id"); situations = GetSituations(experimentNode); }
protected void generateExperimentIfNeeded() { if (experimentNode == null) { targetBody = getNextTarget(); if (targetBody == null) { targetBody = Planetarium.fetch.Home; Debug.LogWarning("targetBody could not be computed, using homeworld"); } experimentNode = getRandomExperiment(); } experimentID = experimentNode.GetValue("id"); situations = GetSituations(experimentNode); }
public static string GetVicinity(WBIExperimentSituations situations) { string vicinity = string.Empty; //Determine vicinity if (situations.any) { vicinity = "on or while orbiting"; } else if (situations.landed && situations.prelaunch && situations.splashed && situations.orbiting) { vicinity = "on or while orbiting"; } else if (situations.landed && situations.splashed && situations.orbiting) { vicinity = "on or while orbiting"; } else if (situations.landed || situations.prelaunch || situations.splashed) { vicinity = "on"; } else if (situations.orbiting) { vicinity = "while orbiting"; } else if (situations.flying) { vicinity = "flying around"; } else if (situations.escaping) { vicinity = "while escaping"; } else if (situations.subOrbital) { vicinity = "on sub-orbital trajectory around"; } else { vicinity = "Unknown"; } return(vicinity); }
protected override void OnLoad(ConfigNode node) { int bodyID = int.Parse(node.GetValue("targetBody")); foreach (var body in FlightGlobals.Bodies) { if (body.flightGlobalsIndex == bodyID) { targetBody = body; } } experimentID = node.GetValue("experimentID"); experimentNode = GetExperimentNode(experimentID); situations = GetSituations(experimentNode); if (node.HasValue("experimentCompleted")) { experimentCompleted = bool.Parse(node.GetValue("experimentCompleted")); } if (node.HasValue("versionNumber")) { versionNumber = int.Parse("versionNumber"); } }