Example #1
0
    public override int generateEvent()
    {
        if (duration <= 0)
        {
            duration = durationLower + random.NextDouble() * (durationUpper - durationLower);



            currentEvent = base.generateEvent();

            switch (currentEvent)
            {
            case 0:
                KGSSPluginLogger.Log("Neutrino Sensor Module - No Flare of duration " + duration);
                break;

            case 1:
                KGSSPluginLogger.Log("Neutrino Sensor Module - Small Flare of duration " + duration);
                break;

            case 2:
                KGSSPluginLogger.Log("Neutrino Sensor Module - Large Flare of duration " + duration);
                break;
            }
        }
        else
        {
            duration--;
        }

        return(currentEvent);
    }
 private void initialiseFailures(ref List <FailureDescriptor> possibleFailures)
 {
     KGSSPluginLogger.Log(possibleFailures.ToString());
     initialiseIntermittentExplosions(ref possibleFailures);
     //initialiseIntermittentDetatch(ref possibleFailures);
     initialiseIntermittentFuelLeak(ref possibleFailures);
 }
    private void adjustFailureProbabilityBasedOnCraftSize()
    {
        //Adjust failure rate based on the number of parts in the vessel.
        failureProbability = baseFailureProbability + (partsPenaltyFactor * FlightGlobals.ActiveVessel.parts.Count);

        if (failureProbability > 1)
        {
            failureProbability = 1;
        }

        KGSSPluginLogger.Log("Failure Generator - Failure probability set to: " + failureProbability);
    }
Example #4
0
    private void calculateCdf(List <int> weights)
    {
        KGSSPluginLogger.Log("ProbabilityEventGenerator - weights:" + KGSSPluginLogger.ListToString(weights));
        if (weights.Count > 0)
        {
            cdf.Add(weights[0]);

            for (int i = 1; i < weights.Count; i++)
            {
                cdf.Add(cdf[cdf.Count - 1] + weights[i]);
            }
        }

        KGSSPluginLogger.Log("ProbabilityEventGenerator - cdf:" + KGSSPluginLogger.ListToString(cdf));
    }
    public void missionEnd(MinmusCompositionMissionEndInformation info)
    {
        if (oneTrue(info.lineOfSight))
        {
            KGSSPluginLogger.Log("Minmus Composition - Crash Altitude: " + info.alt);
            KGSSPluginLogger.Log("Minmus Composition - Crash Velocity: " + info.velocity);
            KGSSPluginLogger.Log("Minmus Composition - Crash SOI: " + info.soiName);

            foreach (double d in info.distance)
            {
                KGSSPluginLogger.Log("Minmus Composition - Crash Distance: " + d);
            }

            if (info.soiName.Equals(destinationSOI) && info.alt < TERRAIN_THRESHOLD)
            {
                resultText.Add("Mission Success - The KGSS is now busy analysing this latest data.");
                resultText.Add("");
                resultText.Add("Impact Velocity: ");
                resultText.Add((Math.Round(info.velocity, 1) + " m/s"));

                int i = 0;
                foreach (double d in info.distance)
                {
                    if (info.lineOfSight[i])
                    {
                        resultText.Add("Distance from X-ray Satellite: ");
                        resultText.Add((Math.Round(d, 1) + " m"));
                    }

                    i++;
                }

                resultText.Add("Mission Score: ");
                resultText.Add(((info.velocity * sumVectorIf(info.distance, info.lineOfSight) * (double)SCORE_MULT)).ToString());
                Tutorial.StartTutorial(success);
            }
            else
            {
                resultText.Add("Mission Failed - The impact probe was destroyed before reaching the target.");
                Tutorial.StartTutorial(failure);
            }
        }
        else
        {
            resultText.Add("Mission Failed - The KGSS X-ray Satellite had no line of sight to the probes impact site.");
            Tutorial.StartTutorial(failure);
        }
    }
Example #6
0
    private List <Vessel> getXraySatellites()
    {
        List <Vessel> ret = new List <Vessel>();

        KGSSPluginLogger.Log("ImpactProbe - getXraySatellites");
        foreach (Vessel v in FlightGlobals.Vessels)
        {
            KGSSPluginLogger.Log("ImpactProbe - Vessels: " + v.name);
            if (v.name.StartsWith(SATELLITE_NAME))
            {
                ret.Add(v);
            }
        }

        return(ret);
    }
    private void potentiallyCauseFailure()
    {
        if (!FlightGlobals.ActiveVessel.Landed)
        {
            KGSSPluginLogger.Log("Failure Generator - Checking for failure");

            if (random.NextDouble() < failureProbability)
            {
                int eventIndex = probabilityEventGenerator.generateEvent();

                if (eventIndex >= 0)
                {
                    possibleFailures[eventIndex].failure(
                        possibleFailures[eventIndex]);
                }
            }
        }
    }
Example #8
0
    public virtual int generateEvent()
    {
        double selection = random.NextDouble() * cdf[cdf.Count - 1];

        KGSSPluginLogger.Log("ProbabilityEventGenerator - Raw event generated: " + selection);

        int i = 0;

        while (selection > cdf[i])
        {
            i++;
        }

        if (cdf[cdf.Count - 1] == 0)
        {
            KGSSPluginLogger.Log("Probability Event Generator - CDF 0");
            i = -1;
        }

        KGSSPluginLogger.Log("ProbabilityEventGenerator - Event selected: " + i);

        return(i);
    }
 protected void fixedUpdateFailureGenerator()
 {
     KGSSPluginLogger.Log("RandomFailure.fixedUpdateFailureGenerator");
     failureGenerator.fixedUpdate();
 }