public override void OnUpdate() { // Check if we are near a surface feature Boolean isNearObject = false; Physics.OverlapSphereNonAlloc(FlightGlobals.ship_position, distance, _colliders); for (Int32 i = 0; i < _colliders.Length; i++) { if (_colliders[i] == null) { continue; } if (!_colliders[i].gameObject.activeSelf) { continue; } KopernicusSurfaceObject surfaceObject = _colliders[i].GetComponent <KopernicusSurfaceObject>(); if (!surfaceObject || !objects.Contains(surfaceObject.objectName)) { continue; } isNearObject = true; break; } // Has the value changed? if (isNearObject != _isNearObject) { _targetModule.SendMessage(isNearObject ? "OnObjectInRange" : "OnObjectOutOfRange"); } _isNearObject = isNearObject; if (toggles == null) { return; } for (Int32 i = 0; i < toggles.Count; i++) { if (_targetModule.Events[toggles[i]] != null) { _targetModule.Events[toggles[i]].guiActive = _isNearObject; } if (_targetModule.Actions[toggles[i]] != null) { _targetModule.Actions[toggles[i]].active = _isNearObject; } if (_targetModule.Fields[toggles[i]] != null) { _targetModule.Fields[toggles[i]].guiActive = _isNearObject; } } }
public override void OnUpdate() { // Check if we are near one Boolean isNearObject = false; Physics.OverlapSphereNonAlloc(FlightGlobals.ship_position, distance, _colliders); for (Int32 i = 0; i < _colliders.Length; i++) { if (_colliders[i] == null) { continue; } if (!_colliders[i].gameObject.activeSelf) { continue; } KopernicusSurfaceObject surfaceObject = _colliders[i].GetComponent <KopernicusSurfaceObject>(); if (!surfaceObject || surfaceObject.objectName != objectName) { continue; } isNearObject = true; break; } // Has the value changed? if (isNearObject != _isNearObject) { _targetModule.SendMessage(isNearObject ? "OnObjectInRange" : "OnObjectOutOfRange", objectName); } _isNearObject = isNearObject; if (_toggle == null) { return; } for (Int32 i = 0; i < _toggle.Count; i++) //iterate through all the toggless { if (_targetModule.Events[_toggle[i]] != null) //if it is an event, enable the gui if we are near the scatter { _targetModule.Events[_toggle[i]].guiActive = _isNearObject; } if (_targetModule.Actions[_toggle[i]] != null) //if it is an action, activate it if we are near the scatter { _targetModule.Actions[_toggle[i]].active = _isNearObject; } if (_targetModule.Fields[_toggle[i]] != null) //if it is a field, show it if we are near the scatter { _targetModule.Fields[_toggle[i]].guiActive = _isNearObject; } } }
public static void MyReviewData() { for (int i = 0; i < FlightGlobals.ActiveVessel.Parts.Count; i++) { Part part = FlightGlobals.ActiveVessel.Parts[i]; for (int m = 0; m < part.Modules.Count; m++) { PartModule module = part.Modules[m]; if (module.moduleName == "ModuleScienceExperiment") { module.SendMessage("ReviewData"); } } } }
//============================================================================================================================================ public void EngageChute() { //FAR Compatibility =) if (assemblyFARUsed == true) { foreach (Part EnabledPart in EnabledPartList) { if (EnabledPart.Modules.Contains ("RealChuteFAR")) { //FerramAerospaceResearch.RealChuteLite.RealChuteFAR RCF = new FerramAerospaceResearch.RealChuteLite.RealChuteFAR (); //RCF = EnabledPart.FindModuleImplementing<FerramAerospaceResearch.RealChuteLite.RealChuteFAR> (); ChuteFARModuleReference = EnabledPart.Modules ["RealChuteFAR"]; PropertyInfo ChuteFARModuleDeploymentState = ChuteFARModuleReference.GetType().GetProperty("deploymentState"); RoboBrakes_ParaEnabledCount++; ChuteFARDeploymentString = ChuteFARModuleReference.Fields.GetValue ("depState").ToString (); //Repack if Chute was already Cut if ((ChuteFARDeploymentString == "CUT") && (IsLanded == false) && (RoboBrakes_CHUTEAUTO == true)) { //Bypassing RealChutes Repacking Method so we don't have to EVA - Also we can't set 'canRepack' bool as it is read only :-/ ChuteFARModuleDeploymentState.SetValue(ChuteFARModuleReference, 1, null); ChuteFARModuleReference.part.Effect ("rcrepack"); ChuteFARModuleReference.part.stackIcon.SetIconColor (XKCDColors.White); ChuteFARModuleReference.part.DragCubes.SetCubeWeight ("PACKED", 1); ChuteFARModuleReference.part.DragCubes.SetCubeWeight ("RCDEPLOYED", 0); print ("ROBOBRAKES - RealChute " + EnabledPart.name + " was already Cut! Repacked Automatically!"); } //Deploy Chute if ((RoboBrakes_CHUTEREADY == true && RoboBrakes_CHUTEAUTO == true)) { RoboBrakes_CHUTEREADY = false; //Deploy Real Chute ChuteFARModuleReference.SendMessage("ActivateRC"); } //Repack Chute Automatically if (ChuteFARDeploymentString == "DEPLOYED" | ChuteFARDeploymentString == "PREDEPLOYED") { if (RoboBrakes_CUTCHUTE == true) { RoboBrakes_CUTCHUTE = false; //Cut Real Chute ChuteFARModuleReference.SendMessage("Cut"); //Bypassing RealChutes Repacking Method so we don't have to EVA - Also we can't set 'canRepack' bool as it is read only :-/ ChuteFARModuleDeploymentState.SetValue(ChuteFARModuleReference, 1, null); ChuteFARModuleReference.part.Effect ("rcrepack"); ChuteFARModuleReference.part.stackIcon.SetIconColor (XKCDColors.White); ChuteFARModuleReference.part.DragCubes.SetCubeWeight ("PACKED", 1); ChuteFARModuleReference.part.DragCubes.SetCubeWeight ("RCDEPLOYED", 0); print ("ROBOBRAKES - RealChute " + EnabledPart.name + " was Cut & Repacked Automatically!"); } } } } } foreach (Part EnabledPart in EnabledPartList) { //Module Parachutes //--------------------------------------------------------------------------------------------------------------------- if (EnabledPart.Modules.Contains ("ModuleParachute")) { ModuleParachute MPA = new ModuleParachute (); MPA = EnabledPart.FindModuleImplementing<ModuleParachute> (); RoboBrakes_ParaEnabledCount++; //Repack the Chute automatically if it has been manually cut if ((MPA.deploymentState.Equals (ModuleParachute.deploymentStates.CUT)) && (IsLanded == false) && (RoboBrakes_CHUTEAUTO == true)) { MPA.Repack (); print ("ROBOBRAKES - Chute " + EnabledPart.name + " was already Cut! Repacked Automatically!"); } //Deploy Chute if ((RoboBrakes_AUTOMATICBRAKE_ACTIVE == true && RoboBrakes_CHUTEAUTO == true)) { if (RoboBrakes_CHUTEREADY == true) { RoboBrakes_CHUTEREADY = false; MPA.Deploy (); } } //Repack Chute if (MPA.deploymentState.Equals (ModuleParachute.deploymentStates.DEPLOYED)) { if (RoboBrakes_CUTCHUTE == true) { RoboBrakes_CUTCHUTE = false; MPA.CutParachute (); MPA.Repack (); print ("ROBOBRAKES - Chute " + EnabledPart.name + " was Cut & Repacked Automatically!"); } } } } }
public override void OnUpdate() { // Find all active surface objects KopernicusSurfaceObject surfaceObject = FlightGlobals.currentMainBody.pqsController.GetComponentsInChildren <KopernicusSurfaceObject>(false) .First(m => m.objectName == objectName); // Check if we are near one Boolean isNearObject = false; Physics.OverlapSphereNonAlloc(FlightGlobals.ship_position, distance, _colliders); for (Int32 i = 0; i < _colliders.Length; i++) { if (_colliders[i] == null) { continue; } if (!_colliders[i].gameObject.activeSelf) { continue; } if (_colliders[i].transform.parent != surfaceObject.transform) { continue; } isNearObject = true; break; } // Has the value changed? if (isNearObject != _isNearObject) { if (isNearObject) { _targetModule.SendMessage("OnObjectInRange", surfaceObject); } else { _targetModule.SendMessage("OnObjectOutOfRange", objectName); } } _isNearObject = isNearObject; if (_toggle == null) { return; } for (Int32 i = 0; i < _toggle.Count; i++) { if (_targetModule.Events[_toggle[i]] != null) { _targetModule.Events[_toggle[i]].guiActive = _isNearObject; } if (_targetModule.Actions[_toggle[i]] != null) { _targetModule.Actions[_toggle[i]].active = _isNearObject; } if (_targetModule.Fields[_toggle[i]] != null) { _targetModule.Fields[_toggle[i]].guiActive = _isNearObject; } } }