public override bool RequirementMet(ConfiguredContract contract) { // Perform another validation of the target body to catch late validation issues due to expressions if (!ValidateTargetBody()) { return(false); } double coverageInPercentage = SCANsatUtil.GetCoverage(SCANsatUtil.GetSCANtype(scanType), targetBody); return(coverageInPercentage >= minCoverage && coverageInPercentage <= maxCoverage); }
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(); currentCoverage = SCANsatUtil.GetCoverage(scanType, targetBody); // Count the number of sucesses if (currentCoverage > 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) { SetState(ParameterState.Complete); } // Force a call to GetTitle to update the contracts app GetTitle(); } }