protected override void OnUpdate() { base.OnUpdate(); if (targetBody == null) { return; } // Do a check if either: // REAL_UPDATE_FREQUENCY of real time has elapsed // GAME_UPDATE_FREQUENCY of game time has elapsed if (UnityEngine.Time.fixedTime - lastRealUpdate > REAL_UPDATE_FREQUENCY || Planetarium.GetUniversalTime() - lastGameTimeUpdate > GAME_UPDATE_FREQUENCY) { lastRealUpdate = UnityEngine.Time.fixedTime; lastGameTimeUpdate = Planetarium.GetUniversalTime(); double coverageInPercentage = SCANUtil.GetCoverage((int)scanType, targetBody); // Count the number of sucesses if (coverageInPercentage > coverage) { consecutive_successes++; } else { consecutive_successes = 0; } // We've had enough successes to be sure that the scan is complete if (consecutive_successes >= CONSECUTIVE_SUCCESSES_REQUIRED) { SetComplete(); } } }
internal double GetCoverage(string scantype, CelestialBody body) { double completed = 0d; if (scansatinstalled) { completed = SCANUtil.GetCoverage(GetSCANtype(scantype), body); } return(completed); }
public override bool RequirementMet(ConfiguredContract contract) { double coverageInPercentage = SCANUtil.GetCoverage((int)scanType, targetBody); return(coverageInPercentage >= minCoverage && coverageInPercentage <= maxCoverage); }