public override void OnStart(StartState state) { base.OnStart(state); if (HighLogic.LoadedSceneIsFlight == false) { setupExperimentGUI(); return; } //Get drill animation drillAnimation = this.part.FindModuleImplementing <ModuleAnimationGroup>(); //Harvester harvester = this.part.FindModuleImplementing <ModuleResourceHarvester>(); //Core sample state coreSampleState = CoreSampleStates.Ready; //If the biome has been unlocked yet then get the samples left if (situationIsValid() && Utils.IsBiomeUnlocked(this.part.vessel)) { coreSampleStatus = getSamplesLeft().ToString(); } else { coreSampleStatus = kUnknown; } //Setup the gui setupGUI(); }
public void TakeSample() { //If we aren't in the right situation for the resource type then we're done. if (situationIsValid() == false) { return; } //If the biome hasn't been unlocked yet then we're done. if (Utils.IsBiomeUnlocked(this.part.vessel) == false) { ScreenMessages.PostScreenMessage(kUnlockBiome, kMessageDuration, ScreenMessageStyle.UPPER_CENTER); return; } //If we're out of attempts then we're done. if (getSamplesLeft() == 0) { ScreenMessages.PostScreenMessage(kNoMoreAttempts, kWarningMsgDuration, ScreenMessageStyle.UPPER_CENTER); Events["InvalidateResults"].guiActive = true; Events["InvalidateResults"].guiActiveUnfocused = true; return; } //If the drill isn't deployed then deploy it before performing the analysis. if (drillAnimation != null) { if (drillAnimation.isDeployed == false) { drillAnimation.DeployModule(); coreSampleState = CoreSampleStates.Deploying; Events["TakeSample"].guiActive = false; Events["TakeSample"].guiActiveUnfocused = false; return; } } //If we're aren't drilling then take a sample if (harvester != null) { if (harvester.isActiveAndEnabled) { performAnalysis(); } else { Events["TakeSample"].guiActive = false; Events["TakeSample"].guiActiveUnfocused = false; coreSampleState = CoreSampleStates.TakingSample; harvester.StartResourceConverter(); analysisTimeRemaining = analysisTime; } } }
protected void updateCoreSampleState() { string message; if (HighLogic.LoadedSceneIsFlight == false) { return; } switch (coreSampleState) { //If we're done deploying then start taking a core sample. case CoreSampleStates.Deploying: if (drillAnimation != null) { if (drillAnimation.DeployAnimation.isPlaying == false) { //Get a small sample if (harvester != null) { harvester.StartResourceConverter(); } //Set analysis time analysisTimeRemaining = analysisTime; //Update state coreSampleState = CoreSampleStates.TakingSample; } } break; case CoreSampleStates.TakingSample: //Use regular time to prevent timewarp cheating analysisTimeRemaining -= Time.fixedDeltaTime; if (analysisTimeRemaining <= 0.001f) { //Reset state coreSampleState = CoreSampleStates.Retracting; analysisStatusMsg = null; //Stop harvesting if (harvester != null) { harvester.StopResourceConverter(); } //Retract harvester drillAnimation.RetractModule(); //Perform analysis performAnalysis(); } else { message = kAnalysisStatus; if (analysisStatusMsg == null) { analysisStatusMsg = ScreenMessages.PostScreenMessage(message, analysisTime, ScreenMessageStyle.UPPER_LEFT); } } break; case CoreSampleStates.Retracting: if (drillAnimation != null) { if (drillAnimation.Fields["animationStatus"].guiActive == false) { //Reset GUI coreSampleState = CoreSampleStates.Ready; Events["TakeSample"].guiActive = true; Events["TakeSample"].guiActiveUnfocused = true; } } break; } }
public override void OnStart(StartState state) { base.OnStart(state); if (HighLogic.LoadedSceneIsFlight == false) { setupExperimentGUI(); return; } //Get drill animation drillAnimation = this.part.FindModuleImplementing<ModuleAnimationGroup>(); //Harvester harvester = this.part.FindModuleImplementing<ModuleResourceHarvester>(); //Core sample state coreSampleState = CoreSampleStates.Ready; //If the biome has been unlocked yet then get the samples left if (situationIsValid() && Utils.IsBiomeUnlocked(this.part.vessel)) coreSampleStatus = getSamplesLeft().ToString(); else coreSampleStatus = kUnknown; //Setup the gui setupGUI(); }
protected void updateCoreSampleState() { string message; if (HighLogic.LoadedSceneIsFlight == false) return; switch (coreSampleState) { //If we're done deploying then start taking a core sample. case CoreSampleStates.Deploying: if (drillAnimation != null) { if (drillAnimation.DeployAnimation.isPlaying == false) { //Get a small sample if (harvester != null) harvester.StartResourceConverter(); //Set analysis time analysisTimeRemaining = analysisTime; //Update state coreSampleState = CoreSampleStates.TakingSample; } } break; case CoreSampleStates.TakingSample: //Use regular time to prevent timewarp cheating analysisTimeRemaining -= Time.fixedDeltaTime; if (analysisTimeRemaining <= 0.001f) { //Reset state coreSampleState = CoreSampleStates.Retracting; analysisStatusMsg = null; //Stop harvesting if (harvester != null) harvester.StopResourceConverter(); //Retract harvester drillAnimation.RetractModule(); //Perform analysis performAnalysis(); } else { message = kAnalysisStatus; if (analysisStatusMsg == null) analysisStatusMsg = ScreenMessages.PostScreenMessage(message, analysisTime, ScreenMessageStyle.UPPER_LEFT); } break; case CoreSampleStates.Retracting: if (drillAnimation != null) { if (drillAnimation.Fields["animationStatus"].guiActive == false) { //Reset GUI coreSampleState = CoreSampleStates.Ready; Events["TakeSample"].guiActive = true; Events["TakeSample"].guiActiveUnfocused = true; } } break; } }
public void TakeSample() { //If we aren't in the right situation for the resource type then we're done. if (situationIsValid() == false) return; //If the biome hasn't been unlocked yet then we're done. if (Utils.IsBiomeUnlocked(this.part.vessel) == false) { ScreenMessages.PostScreenMessage(kUnlockBiome, kMessageDuration, ScreenMessageStyle.UPPER_CENTER); return; } //If we're out of attempts then we're done. if (getSamplesLeft() == 0) { ScreenMessages.PostScreenMessage(kNoMoreAttempts, kWarningMsgDuration, ScreenMessageStyle.UPPER_CENTER); Events["InvalidateResults"].guiActive = true; Events["InvalidateResults"].guiActiveUnfocused = true; return; } //If the drill isn't deployed then deploy it before performing the analysis. if (drillAnimation != null) { if (drillAnimation.isDeployed == false) { drillAnimation.DeployModule(); coreSampleState = CoreSampleStates.Deploying; Events["TakeSample"].guiActive = false; Events["TakeSample"].guiActiveUnfocused = false; return; } } //If we're aren't drilling then take a sample if (harvester != null) { if (harvester.isActiveAndEnabled) { performAnalysis(); } else { Events["TakeSample"].guiActive = false; Events["TakeSample"].guiActiveUnfocused = false; coreSampleState = CoreSampleStates.TakingSample; harvester.StartResourceConverter(); analysisTimeRemaining = analysisTime; } } }