/// <summary> /// Use to determine whether an experiment can be conducted at this time. This returns the same value as the internal check used when an experiment is deplyed from the right-click menu. /// </summary> /// <param name="isc">The science experiment module must be cast as an IScienceDataContianer.</param> /// <returns>Returns true if the experiment can be performed; will return false if the science module is not of the right type.</returns> public static bool experimentCanConduct(IScienceDataContainer isc) { if (isc == null) { return(false); } Type t = isc.GetType(); if (t == typeof(DMAnomalyScanner)) { DMAnomalyScanner DMMod = (DMAnomalyScanner)isc; return(DMMod.canConduct()); } else if (t == typeof(DMBioDrill)) { DMBioDrill DMMod = (DMBioDrill)isc; return(DMMod.canConduct()); } else if (t == typeof(DMSIGINT)) { DMSIGINT DMMod = (DMSIGINT)isc; return(DMMod.canConduct()); } else if (t == typeof(DMXRayDiffract)) { DMXRayDiffract DMMod = (DMXRayDiffract)isc; return(DMMod.canConduct()); } else if (t.IsSubclassOf(typeof(DMModuleScienceAnimate))) { DMModuleScienceAnimate DMMod = (DMModuleScienceAnimate)isc; return(DMMod.canConduct()); } else if (t == typeof(DMModuleScienceAnimate)) { DMModuleScienceAnimate DMMod = (DMModuleScienceAnimate)isc; return(DMMod.canConduct()); } else if (t == typeof(DMSeismicHammer)) { DMSeismicHammer DMMod = (DMSeismicHammer)isc; return(DMMod.canConduct()); } else if (t == typeof(DMSeismicSensor)) { DMSeismicSensor DMMod = (DMSeismicSensor)isc; return(DMMod.canConduct()); } else if (t == typeof(DMAsteroidScanner)) { DMAsteroidScanner DMMod = (DMAsteroidScanner)isc; return(DMMod.canConduct()); } return(false); }
/// <summary> /// Uses the internal method for conducting an experiment; the experiment cannot be forced and must first pass the "canConduct". All associated animations and other functions will be called. Optinally run the experiment without opening the results window. /// </summary> /// <param name="isc">The science experiment module must be cast as an IScienceDataContianer.</param> /// <param name="silent">Set to true to prevent the science results dialog from opening.</param> /// <returns>Returns true if the science module is of the right type and the gather science method is called.</returns> public static bool deployDMExperiment(IScienceDataContainer isc, bool silent = false) { if (isc == null) { return(false); } Type t = isc.GetType(); if (t == typeof(DMAnomalyScanner)) { DMAnomalyScanner DMMod = (DMAnomalyScanner)isc; DMMod.gatherScienceData(silent); return(true); } else if (t == typeof(DMBioDrill)) { DMBioDrill DMMod = (DMBioDrill)isc; DMMod.gatherScienceData(silent); return(true); } else if (t.IsSubclassOf(typeof(DMModuleScienceAnimate))) { DMModuleScienceAnimate DMMod = (DMModuleScienceAnimate)isc; DMMod.gatherScienceData(silent); return(true); } else if (t == typeof(DMModuleScienceAnimate)) { DMModuleScienceAnimate DMMod = (DMModuleScienceAnimate)isc; DMMod.gatherScienceData(silent); return(true); } else if (t == typeof(DMSeismicHammer)) { DMSeismicHammer DMMod = (DMSeismicHammer)isc; DMMod.gatherScienceData(silent); return(true); } else if (t == typeof(DMSeismicSensor)) { DMSeismicSensor DMMod = (DMSeismicSensor)isc; DMMod.gatherScienceData(silent); return(true); } else if (t == typeof(DMAsteroidScanner)) { DMAsteroidScanner DMMod = (DMAsteroidScanner)isc; DMMod.gatherScienceData(silent); return(true); } return(false); }
public void addLoadedSeismometer(uint id, IDMSeismometer sensor) { if (sensor.GetType() == typeof(DMSeismicSensor)) { if (!seismometers.ContainsKey(id)) { DMSeismicSensor s = (DMSeismicSensor)sensor; DMSeismometerValues v = new DMSeismometerValues(s.vessel, s.part.protoPartSnapshot, s.snapshot, false); seismometers.Add(id, v); } } else if (sensor.GetType() == typeof(DMSeismicHammer)) { if (!hammers.ContainsKey(id)) { DMSeismicHammer h = (DMSeismicHammer)sensor; DMSeismometerValues v = new DMSeismometerValues(h.vessel, h.part.protoPartSnapshot, h.snapshot, true); hammers.Add(id, v); } } }