private void registerDMScience(DMAsteroidScience newAst, ScienceSubject sub)
        {
            if (HighLogic.CurrentGame.Mode == Game.Modes.SANDBOX)
            {
                return;
            }

            DMScienceData DMData    = null;
            DMScienceData DMScience = DMScienceScenario.SciScenario.getDMScience(sub.title);

            if (DMScience != null)
            {
                sub.scientificValue *= DMScience.SciVal;
                DMData = DMScience;
            }

            if (DMData == null)
            {
                float astSciCap = exp.scienceCap * 25f;
                DMScienceScenario.SciScenario.RecordNewScience(sub.title, exp.baseValue, 1f, 0f, astSciCap);
                sub.scientificValue = 1f;
            }
            sub.subjectValue = newAst.SciMult;
            sub.scienceCap   = exp.scienceCap * sub.subjectValue;
            sub.science      = Math.Max(0f, Math.Min(sub.scienceCap, sub.scienceCap - (sub.scienceCap * sub.scientificValue)));
        }
        private ScienceData makeScience(float dist, ModuleAsteroid m)
        {
            if (dist <= 0)
            {
                DMUtils.Logging("Asteroid Not Scanned...  Distance Passed Through Asteroid: " + dist.ToString("N3"));
                if (asteroidInSight)
                {
                    ScreenMessages.PostScreenMessage("No Asteroid Detected Between The Transmitting And Receiving Instruments...", 6f, ScreenMessageStyle.UPPER_CENTER);
                }
                else if (receiverInRange)
                {
                    ScreenMessages.PostScreenMessage("No Asteroid Detected In The Scanning Area...", 6f, ScreenMessageStyle.UPPER_CENTER);
                }
                return(null);
            }
            if (m == null)
            {
                DMUtils.Logging("Asteroid Not Scanned. Something Went Wrong Here; No Asteroid Was Detected; Distance Passed Through Asteroid: " + dist.ToString("N3"));
                return(null);
            }
            ScienceData       data       = null;
            ScienceSubject    sub        = null;
            CelestialBody     body       = null;
            DMAsteroidScience ast        = null;
            string            biome      = "";
            float             multiplier = 1f;

            ast        = new DMAsteroidScience(m);
            body       = ast.Body;
            biome      = ast.AType + ast.ASeed;
            multiplier = Math.Min(1f, dist / astWidth[aClassInt(ast.AClass)]);

            if (exp == null)
            {
                Debug.LogError("[DM] Something Went Wrong Here; Null Asteroid Experiment Returned; Please Report This On The KSP Forum With Output.log Data");
                return(null);
            }

            sub = ResearchAndDevelopment.GetExperimentSubject(exp, ExperimentSituations.InSpaceLow, body, biome);

            if (sub == null)
            {
                Debug.LogError("[DM] Something Went Wrong Here; Null Asteroid Subject Returned; Please Report This On The KSP Forum With Output.log Data");
                return(null);
            }

            DMUtils.OnAsteroidScience.Fire(ast.AClass, exp.id);
            sub.title = string.Format("{0} through a {1} asteroid", exp.experimentTitle, ast.AType);
            string dataTitle = string.Format("{0} through {1:P0} of a {2} asteroid", exp.experimentTitle, multiplier, ast.AType);

            registerDMScience(ast, sub);
            body.bodyName = asteroidBodyNameFixed;

            data = new ScienceData(multiplier * exp.baseValue * sub.dataScale, transmitValue, 0f, sub.id, dataTitle, false, part.flightID);

            return(data);
        }
Beispiel #3
0
        private ScienceData makeScience(float boost)
        {
            ExperimentSituations vesselSituation = getSituation();
            string        biome     = getBiome(vesselSituation);
            CelestialBody mainBody  = vessel.mainBody;
            bool          asteroids = false;

            //Check for asteroids and alter the biome and celestialbody values as necessary
            if (asteroidReports && (DMAsteroidScience.asteroidGrappled() || DMAsteroidScience.asteroidNear()))
            {
                newAsteroid = new DMAsteroidScience();
                asteroids   = true;
                mainBody    = newAsteroid.body;
                biome       = newAsteroid.aType + newAsteroid.aSeed.ToString();
            }

            ScienceData       data = null;
            ScienceExperiment exp  = null;
            ScienceSubject    sub  = null;

            exp = ResearchAndDevelopment.GetExperiment(experimentID);
            if (exp == null)
            {
                Debug.LogError("[DM] Something Went Wrong Here; Null Experiment Returned; Please Report This On The KSP Forum With Output.log Data");
                return(null);
            }

            sub = ResearchAndDevelopment.GetExperimentSubject(exp, vesselSituation, mainBody, biome);
            if (sub == null)
            {
                Debug.LogError("[DM] Something Went Wrong Here; Null Subject Returned; Please Report This On The KSP Forum With Output.log Data");
                return(null);
            }

            if (asteroids)
            {
                DMUtils.OnAsteroidScience.Fire(newAsteroid.aClass, experimentID);
                sub.title = exp.experimentTitle + astCleanup(vesselSituation, newAsteroid.aType);
                registerDMScience(newAsteroid, exp, sub, vesselSituation, biome);
                mainBody.bodyName = bodyNameFixed;
            }
            else
            {
                DMUtils.OnAnomalyScience.Fire(mainBody, experimentID, biome);
                sub.title        = exp.experimentTitle + situationCleanup(vesselSituation, biome);
                sub.subjectValue = fixSubjectValue(vesselSituation, sub.subjectValue, boost, mainBody);
                sub.scienceCap   = exp.scienceCap * sub.subjectValue;
            }

            data = new ScienceData(exp.baseValue * sub.dataScale, xmitDataScalar, 0f, sub.id, sub.title);

            return(data);
        }
Beispiel #4
0
 protected override bool canConduct()
 {
     if (base.canConduct())
     {
         if (drillImpact(asteroidReports && DMAsteroidScience.asteroidGrappled()))
         {
             return(true);
         }
         failMessage = "The drill cannot impact the surface from this distance";
     }
     return(false);
 }
Beispiel #5
0
        protected virtual ExperimentSituations getSituation()
        {
            if (asteroidReports && DMAsteroidScience.asteroidGrappled())
            {
                return(ExperimentSituations.SrfLanded);
            }
            if (asteroidReports && DMAsteroidScience.asteroidNear())
            {
                return(ExperimentSituations.InSpaceLow);
            }
            switch (vessel.situation)
            {
            case Vessel.Situations.LANDED:
            case Vessel.Situations.PRELAUNCH:
                return(ExperimentSituations.SrfLanded);

            case Vessel.Situations.SPLASHED:
                return(ExperimentSituations.SrfSplashed);

            default:
                if (vessel.altitude < (vessel.mainBody.atmosphereScaleHeight * 1000 * Math.Log(1e6)) && vessel.mainBody.atmosphere)
                {
                    if (vessel.altitude < vessel.mainBody.scienceValues.flyingAltitudeThreshold)
                    {
                        return(ExperimentSituations.FlyingLow);
                    }
                    else
                    {
                        return(ExperimentSituations.FlyingHigh);
                    }
                }
                if (vessel.altitude < vessel.mainBody.scienceValues.spaceAltitudeThreshold)
                {
                    return(ExperimentSituations.InSpaceLow);
                }
                else
                {
                    return(ExperimentSituations.InSpaceHigh);
                }
            }
        }
Beispiel #6
0
 private void registerDMScience(DMAsteroidScience newAst, ScienceExperiment exp, ScienceSubject sub, ExperimentSituations expsit, string s)
 {
     DMScienceScenario.DMScienceData DMData = null;
     DMUtils.DebugLog("Checking for DM Data in list length: {0}", DMScienceScenario.SciScenario.recoveredScienceList.Count);
     foreach (DMScienceScenario.DMScienceData DMScience in DMScienceScenario.SciScenario.recoveredScienceList)
     {
         if (DMScience.title == sub.title)
         {
             DMUtils.DebugLog("found matching DM Data");
             sub.scientificValue *= DMScience.scival;
             DMData = DMScience;
             break;
         }
     }
     if (DMData == null)
     {
         float astSciCap = exp.scienceCap * 40f;
         DMScienceScenario.SciScenario.RecordNewScience(sub.title, exp.baseValue, 1f, 0f, astSciCap);
         sub.scientificValue = 1f;
     }
     sub.subjectValue = newAst.sciMult;
     sub.scienceCap   = exp.scienceCap * sub.subjectValue;
     sub.science      = sub.scienceCap - (sub.scienceCap * sub.scientificValue);
 }
        private ScienceData makeScience(float boost, ExperimentSituations vesselSituation)
        {
            string biome = getBiome(vesselSituation);
            CelestialBody mainBody = vessel.mainBody;
            bool asteroids = false;
            DMAsteroidScience newAsteroid = null;

            //Check for asteroids and alter the biome and celestialbody values as necessary
            if (asteroidReports && (DMAsteroidScience.AsteroidGrappled || DMAsteroidScience.AsteroidNear))
            {
                newAsteroid = new DMAsteroidScience();
                asteroids = true;
                mainBody = newAsteroid.Body;
                biome = newAsteroid.AType + newAsteroid.ASeed.ToString();
            }

            ScienceData data = null;
            ScienceSubject sub = null;

            if (scienceExp == null)
            {
                Debug.LogError("[DM] Something Went Wrong Here; Null Experiment Returned; Please Report This On The KSP Forum With Output.log Data");
                return null;
            }

            sub = ResearchAndDevelopment.GetExperimentSubject(scienceExp, vesselSituation, mainBody, biome);
            if (sub == null)
            {
                Debug.LogError("[DM] Something Went Wrong Here; Null Subject Returned; Please Report This On The KSP Forum With Output.log Data");
                return null;
            }

            if (asteroids)
            {
                DMUtils.OnAsteroidScience.Fire(newAsteroid.AClass, experimentID);
                sub.title = scienceExp.experimentTitle + astCleanup(vesselSituation, newAsteroid.AType);
                registerDMScience(newAsteroid, sub);
                mainBody.bodyName = bodyNameFixed;
            }
            else
            {
                DMUtils.OnAnomalyScience.Fire(mainBody, experimentID, biome);
                sub.title = scienceExp.experimentTitle + situationCleanup(vesselSituation, biome);
                sub.subjectValue = fixSubjectValue(vesselSituation, sub.subjectValue, boost, mainBody);
                sub.scienceCap = scienceExp.scienceCap * sub.subjectValue;
            }

            data = new ScienceData(scienceExp.baseValue * sub.dataScale, xmitDataScalar, 1f, sub.id, sub.title, false, part.flightID);

            return data;
        }
        private void registerDMScience(DMAsteroidScience newAst, ScienceSubject sub)
        {
            if (HighLogic.CurrentGame.Mode == Game.Modes.SANDBOX)
                return;

            DMScienceData DMData = null;

            DMScienceData DMScience = DMScienceScenario.SciScenario.getDMScience(sub.title);
            if (DMScience != null)
            {
                sub.scientificValue *= DMScience.SciVal;
                DMData = DMScience;
            }

            if (DMData == null)
            {
                float astSciCap = scienceExp.scienceCap * 40f;
                DMScienceScenario.SciScenario.RecordNewScience(sub.title, scienceExp.baseValue, 1f, 0f, astSciCap);
                sub.scientificValue = 1f;
            }

            sub.subjectValue = newAst.SciMult;
            sub.scienceCap = scienceExp.scienceCap * sub.subjectValue;
            sub.science = Math.Max(0f, Math.Min(sub.scienceCap, sub.scienceCap - (sub.scienceCap * sub.scientificValue)));
        }
        private ScienceData makeScience(float dist, ModuleAsteroid m)
        {
            if (dist <= 0)
            {
                DMUtils.Logging("Asteroid Not Scanned...  Distance Passed Through Asteroid: " + dist.ToString("N3"));
                if (asteroidInSight)
                    ScreenMessages.PostScreenMessage("No Asteroid Detected Between The Transmitting And Receiving Instruments...", 6f, ScreenMessageStyle.UPPER_CENTER);
                else if (receiverInRange)
                    ScreenMessages.PostScreenMessage("No Asteroid Detected In The Scanning Area...", 6f, ScreenMessageStyle.UPPER_CENTER);
                return null;
            }
            if (m == null)
            {
                DMUtils.Logging("Asteroid Not Scanned. Something Went Wrong Here; No Asteroid Was Detected; Distance Passed Through Asteroid: " + dist.ToString("N3"));
                return null;
            }
            ScienceData data = null;
            ScienceSubject sub = null;
            CelestialBody body = null;
            DMAsteroidScience ast = null;
            string biome = "";
            float multiplier = 1f;

            ast = new DMAsteroidScience(m);
            body = ast.Body;
            biome = ast.AType + ast.ASeed;
            multiplier = Math.Min(1f, dist / astWidth[aClassInt(ast.AClass)]);

            if (exp == null)
            {
                Debug.LogError("[DM] Something Went Wrong Here; Null Asteroid Experiment Returned; Please Report This On The KSP Forum With Output.log Data");
                return null;
            }

            sub = ResearchAndDevelopment.GetExperimentSubject(exp, ExperimentSituations.InSpaceLow, body, biome);

            if (sub == null)
            {
                Debug.LogError("[DM] Something Went Wrong Here; Null Asteroid Subject Returned; Please Report This On The KSP Forum With Output.log Data");
                return null;
            }

            DMUtils.OnAsteroidScience.Fire(ast.AClass, exp.id);
            sub.title = string.Format("{0} through a {1} asteroid", exp.experimentTitle, ast.AType);
            string dataTitle = string.Format("{0} through {1:P0} of a {2} asteroid", exp.experimentTitle, multiplier, ast.AType);
            registerDMScience(ast, sub);
            body.bodyName = asteroidBodyNameFixed;

            data = new ScienceData(multiplier * exp.baseValue * sub.dataScale, transmitValue, 0f, sub.id, dataTitle);

            return data;
        }