public override void OnUpdate() { base.OnUpdate(); if (anim == null) { return; } //We're only interested in the act of inflating the module. if (isDeployed == false) { animationStarted = false; return; } //If we've completed the animation then we are done. if (animationStarted == false) { return; } //Animation may not be done yet. if (anim.isPlaying) { return; } //At this point we know that the animation was playing but has now stopped. //We also know that the animation was started. Now reset the flag. animationStarted = false; //Hide seismometer if (impactSeismometer != null) { IScienceDataContainer container = (IScienceDataContainer)impactSeismometer; BaseEvent reviewEvent = impactSeismometer.Events["reviewEvent"]; if (reviewEvent != null) { reviewEvent.guiActive = false; reviewEvent.guiActiveUnfocused = false; } //clear out the impact data if the current template isn't a geology lab if (CurrentTemplateName != "Geology Lab") { ScienceData[] dataItems = container.GetData(); if (dataItems != null) { foreach (ScienceData doomed in dataItems) { container.DumpData(doomed); } } } } checkAndShowToolTip(); }
public override void TransmitData() { ThrowIfNotCPUVessel(); IScienceDataContainer container = module as IScienceDataContainer; ScienceData[] data = container.GetData(); List <IScienceDataTransmitter> tranList = module.vessel.FindPartModulesImplementing <IScienceDataTransmitter>(); if (tranList.Count() > 0 && data.Count() > 0) { tranList.OrderBy(ScienceUtil.GetTransmitterScore).First().TransmitData(new List <ScienceData>(data)); if (!container.IsRerunnable()) { module.SetInoperable(); } DumpData(); } else { ScreenMessages.PostScreenMessage("No transmitters available on this vessel or no data to transmit.", 4f, ScreenMessageStyle.UPPER_LEFT); } }
public static void StoreData(this IScienceDataContainer container, IScienceDataContainer experiment, bool dumpDuplicates) { if (container == experiment as IScienceDataContainer) { ScreenMessages.PostScreenMessage("Container is the same as experiment!", 1f, ScreenMessageStyle.UPPER_LEFT); return; } var containerData = container.GetData(); var experimentData = experiment.GetData(); for (var i = 0; i < experimentData.Length; i++) { if (!container.HasData(experimentData[i])) { container.ReturnData(experimentData[i]); if (container.HasData(experimentData[i])) { experiment.DumpData(experimentData[i]); } else { ScreenMessages.PostScreenMessage("Container didnt store the experiment", 1f, ScreenMessageStyle.UPPER_LEFT); } } else if (dumpDuplicates) { experiment.DumpData(experimentData[i]); } } }
public bool CanTransfer(ModuleScienceExperiment baseExperiment, IScienceDataContainer moduleScienceContainer) { var currentExperiment = baseExperiment as DMModuleScienceAnimate; if ((currentExperiment as IScienceDataContainer).GetScienceCount() == 0) { Log(currentExperiment.experimentID, ": Experiment has no data skiping transfer. Data found: ", (currentExperiment as IScienceDataContainer).GetScienceCount(), "_", currentExperiment.experimentNumber); return(false); } if (!currentExperiment.IsRerunnable()) { if (!_AutomatedScienceSamplerInstance.craftSettings.transferAllData) { Log(currentExperiment.experimentID, ": Experiment isn't rerunnable and transferAllData is turned off."); return(false); } } if (!_AutomatedScienceSamplerInstance.craftSettings.dumpDuplicates) { foreach (var data in (currentExperiment as IScienceDataContainer).GetData()) { if (moduleScienceContainer.HasData(data)) { Log(currentExperiment.experimentID, ": Target already has experiment and dumping is disabled."); return(false); } } } Log(currentExperiment.experimentID, ": We can transfer the science!"); return(true); }
public void Transfer(ModuleScienceExperiment baseExperiment, IScienceDataContainer moduleScienceContainer) { var currentExperiment = baseExperiment as DMModuleScienceAnimate; Log(currentExperiment.experimentID, ": transfering"); moduleScienceContainer.StoreData(currentExperiment, _AutomatedScienceSamplerInstance.craftSettings.dumpDuplicates); }
public static bool experimentCanConduct(IScienceDataContainer isc) { if (_MIexperimentCanConduct == null) { return(false); } return((bool)_MIexperimentCanConduct.Invoke(null, new object[] { isc })); }
public static bool deployDMExperiment(IScienceDataContainer isc) { if (_MIdeployDMExperiment == null) { return(false); } return((bool)_MIdeployDMExperiment.Invoke(null, new object[] { isc, Config.HideExperimentResultsDialog })); }
public bool deployDMExperiment(IScienceDataContainer isc, bool HideResultsWindow) { if (_MIdeployDMExperiment == null) { return(false); } return((bool)_MIdeployDMExperiment.Invoke(null, new object[] { isc, HideResultsWindow })); }
/// <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); }
// remove one experiment at random from the vessel public static void RemoveData(Vessel v) { // stock science system if (!Features.Science) { // if vessel is loaded if (v.loaded) { // get all science containers/experiments with data List<IScienceDataContainer> modules = Lib.FindModules<IScienceDataContainer>(v).FindAll(k => k.GetData().Length > 0); // remove a data sample at random if (modules.Count > 0) { IScienceDataContainer container = modules[Lib.RandomInt(modules.Count)]; ScienceData[] data = container.GetData(); container.DumpData(data[Lib.RandomInt(data.Length)]); } } // if not loaded else { // get all science containers/experiments with data var modules = new List<ProtoPartModuleSnapshot>(); modules.AddRange(Lib.FindModules(v.protoVessel, "ModuleScienceContainer").FindAll(k => k.moduleValues.GetNodes("ScienceData").Length > 0)); modules.AddRange(Lib.FindModules(v.protoVessel, "ModuleScienceExperiment").FindAll(k => k.moduleValues.GetNodes("ScienceData").Length > 0)); // remove a data sample at random if (modules.Count > 0) { ProtoPartModuleSnapshot container = modules[Lib.RandomInt(modules.Count)]; ConfigNode[] data = container.moduleValues.GetNodes("ScienceData"); container.moduleValues.RemoveNode(data[Lib.RandomInt(data.Length)]); } } } // our own science system else { // select a file at random and remove it Drive drive = DB.Vessel(v).drive; if (drive.files.Count > 0) //< it should always be the case { string filename = string.Empty; int i = Lib.RandomInt(drive.files.Count); foreach (var pair in drive.files) { if (i-- == 0) { filename = pair.Key; break; } } drive.files.Remove(filename); } } }
internal Experiment(Part part, ModuleScienceExperiment experiment_) { Part = part; experiment = experiment_; dataContainer = experiment_; if (experiment == null) { throw new ArgumentException("Part is not a science experiment"); } }
public ScienceExperimentFields(PartModule module, SharedObjects shared) : base(module, shared) { this.container = module as IScienceDataContainer; if (container == null) { throw new KOSException("This module is not a science data container"); } InitializeSuffixes(); }
/// <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); }
bool ActiveContainerHasAllData(IScienceDataContainer container) { ScienceData[] datalist = container.GetData(); for (int i = 0; i < datalist.Length; i++) { if (!ActiveContainer().HasData(datalist[i])) { return(false); } } return(true); }
public void Awake() { vessel = this.GetComponent<Vessel>(); Print("VesselSettings for " + vessel.vesselName + " started."); _expanded = new List<IScienceDataContainer>(); _selectedContainer = null; _selectedData = null; UpdateContainerLists(); GameEvents.onVesselWasModified.Add(OnVesselWasModified); }
public static Notes_ScienceTransfer Create(Part p, IScienceDataContainer src, Callback<CrewTransfer.DismissAction> call) { if (!stringsLoaded) loadStrings(); Notes_ScienceTransfer transfer = new GameObject("Notes_ScienceTransfer").AddComponent<Notes_ScienceTransfer>(); transfer.host = p; transfer.onDismiss = call; transfer.dataCount = src.GetScienceCount(); transfer.containers = new List<IScienceDataContainer>(1) { src }; transfer.transferSetup(); return transfer; }
public ScienceExperimentFields(PartModule module, SharedObjects shared) : base(module, shared) { this.container = module as IScienceDataContainer; part = module.part; if (container == null) { throw new KOSException("This module is not a science data container"); } InitializeSuffixes(); }
public static bool HasData(this IScienceDataContainer container, ScienceData data) { var dataStore = container.GetData();; var scienceCount = dataStore.Length; for (var i = 0; i < scienceCount; i++) { if (dataStore[i].subjectID == data.subjectID) { return(true); } } return(false); }
public VesselScienceContents(Vessel vessel) { for (int partIndex = 0; partIndex < vessel.parts.Count; ++partIndex) { Part part = vessel.parts[partIndex]; for (int moduleIndex = 0; moduleIndex < part.Modules.Count; ++moduleIndex) { PartModule module = part.Modules[moduleIndex]; IScienceDataContainer container = module as IScienceDataContainer; if (container != null) { scienceContainers.Add(container); } } // for each module on the part } // for each part on the vessel }
/// <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 a 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(DMModuleScienceAnimateGeneric_NM.DMModuleScienceAnimateGeneric)) { DMModuleScienceAnimateGeneric_NM.DMModuleScienceAnimateGeneric DMMod = (DMModuleScienceAnimateGeneric_NM.DMModuleScienceAnimateGeneric)isc; return(DMMod.canConduct()); } return(false); }
private static void TransferScience(IScienceDataContainer source, ModuleScienceContainer target) { if (source == null || target == null || source == target) { return; } ScienceData[] sd = source.GetData(); if (sd == null || sd.Length == 0) { Debug.Log("No data "); return; } if (source is ModuleScienceContainer) { foreach (ScienceData data in sd) { if (TargetAcceptsData(target, data)) { if (target.AddData(data)) { ((ModuleScienceContainer)source).RemoveData(data); } else { Debug.Log("Transfer fail"); } } } } else if (source is ModuleScienceExperiment) { if (TargetAcceptsData(target, sd[0])) { if (target.AddData(sd[0])) { ((ModuleScienceExperiment)source).DumpData(sd[0]); } else { Debug.Log("Transfer fail"); } } } }
public static void StoreData(this IScienceDataContainer container, IScienceDataContainer experiment, bool dumpDuplicates, ILogHandler logHandler) { if (logHandler == null) { logHandler = new ScreenMessageLogHandler(); } if (container == experiment) { logHandler.Log("Container is the same as experiment!"); return; } var containerWrapper = new ScienceDataContainerWrapper(container); var experimentWrapper = new ScienceDataContainerWrapper(experiment); var containerData = containerWrapper.GetData(); var experimentData = experimentWrapper.GetData(); if (experimentData.Length == 0) { logHandler.Log($"GetData returned no scienceData"); } for (var i = 0; i < experimentData.Length; i++) { var currentData = experimentData[i]; logHandler.Log($"Processing {i + 1}/{experimentData.Length}: {currentData.subjectID} ({currentData.title})"); if (!containerWrapper.HasData(currentData)) { containerWrapper.ReturnData(currentData); if (containerWrapper.HasData(currentData)) { experimentWrapper.DumpData(currentData); logHandler.Log($"{currentData.dataAmount} data stored"); } else { logHandler.Log($"Container didn't store the experiment"); } } else if (dumpDuplicates) { logHandler.Log($"{currentData.subjectID} - {currentData.title}: already contains -> dump"); experimentWrapper.DumpData(currentData); } } }
/// <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 a ModuleScienceExperiment.</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(DMModuleScienceAnimateGeneric_NM.DMModuleScienceAnimateGeneric)) { DMModuleScienceAnimateGeneric_NM.DMModuleScienceAnimateGeneric DMMod = (DMModuleScienceAnimateGeneric_NM.DMModuleScienceAnimateGeneric)isc; DMMod.gatherScienceData(silent); return(true); } return(false); }
protected override void setupPartModules() { base.setupPartModules(); //Setup the science container if (scienceContainer == null) { scienceContainer = this.part.FindModuleImplementing <ModuleScienceContainer>(); scienceContainer.Events["ReviewDataEvent"].guiActiveUnfocused = false; scienceContainer.Events["ReviewDataEvent"].guiActive = false; //Terrain uplink terrainUplinkView.part = this.part; terrainUplinkView.scienceContainer = scienceContainer; } //Kerbnet access kerbNetAccess = this.part.FindModuleImplementing <ModuleKerbNetAccess>(); if (kerbNetAccess != null) { } //Grab the seismometer (if any) foreach (PartModule mod in this.part.Modules) { if (mod.moduleName == "Seismometer") { impactSeismometer = mod; impactSensor = (IScienceDataContainer)impactSeismometer; ScienceData[] impactData = impactSensor.GetData(); foreach (ScienceData data in impactData) { scienceContainer.AddData(data); } foreach (ScienceData doomed in impactData) { impactSensor.DumpData(doomed); } break; } } }
/// <summary> /// Search through all science experiments and containers to determine whether /// they contain the specified subject. Returns true if any do. /// </summary> /// <param name="subject"></param> /// <returns></returns> private bool FindScience(string subjectId) { for (int containerIndex = 0; containerIndex < scienceContainers.Count; ++containerIndex) { IScienceDataContainer container = scienceContainers[containerIndex]; if (container.GetScienceCount() == 0) { continue; } ScienceData[] data = container.GetData(); for (int dataIndex = 0; dataIndex < data.Length; ++dataIndex) { if (data[dataIndex].subjectID == subjectId) { return(true); } } } return(false); }
private IEnumerable <string> GetVesselSubjects(Vessel v) { foreach (Part p in v.parts) { for (int i = 0; i < p.Modules.Count; i++) { IScienceDataContainer scienceContainer = p.Modules[i] as IScienceDataContainer; if (scienceContainer != null) { foreach (ScienceData data in scienceContainer.GetData()) { if (!string.IsNullOrEmpty(data.subjectID)) { yield return(data.subjectID); } } } } } }
//[KSPField(guiActive = true, guiName = "Status", isPersistant = false)] //public string status; public void addDataButton(ScienceData sd, IScienceDataContainer cont) { var subject = ResearchAndDevelopment.GetSubjectByID(sd.subjectID); var parts = sd.subjectID.Split('@'); var experiment = ResearchAndDevelopment.GetExperiment(parts[0]); if (experiment != null && sd.baseTransmitValue < txValue) { KSPEvent kspevent = new KSPEvent(); kspevent.active = true; kspevent.name = sd.subjectID; kspevent.guiActive = true; kspevent.guiName = sd.title; IScienceDataContainer my_cont = cont; ScienceData my_sd = sd; BaseEvent ev = new BaseEvent(Events, sd.subjectID, delegate() { analyze(my_cont, my_sd); }, kspevent); sampleEvents.Add(ev); Events.Add(ev); } }
private List <ScienceData> RecoverScienceContent() { List <ScienceData> result = new List <ScienceData>(); Dictionary <string, PartContent> contents = this.GetContent(); // Iterate through the contents, of which there may be multiple of each part. foreach (PartContent partContent in contents.Values) { // Iterate through all of the instances of this part. (stateless = false) foreach (ConfigNode partConfigNode in partContent.instances) { ProtoPartSnapshot partSnapshot = KAS_Shared.LoadProtoPartSnapshot(partConfigNode); foreach (ProtoPartModuleSnapshot moduleSnapshot in partSnapshot.modules) { // In order to load the state of the module, it must be added to a part. Temporarily add it to this // module's host part and then remove it after it is evaluated. int moduleIndex = this.part.Modules.Count; part.AddModule(moduleSnapshot.moduleName); PartModule module = moduleSnapshot.Load(this.part, ref moduleIndex); // ModuleScienceExperiment and ModuleScienceContainer implement IScienceDataContainer. Also, because KASModuleContainer // now implements IScienceDataContainer, it is conceivable that nested KAS containers with science data will be properly // recovered. if (module is IScienceDataContainer) { IScienceDataContainer scienceDataContainer = (IScienceDataContainer)module; // Duplicate science experiments are OK, the science awards are evaluated correctly by KSP. result.AddRange(scienceDataContainer.GetData()); } this.part.RemoveModule(module); } } } return(result); }
public void analyze(IScienceDataContainer cont, ScienceData sd) { //print(sd.title); if (GetScienceCount() > 0) { ScreenMessages.PostScreenMessage("Analyzer already full. Transmit the data!", 6, ScreenMessageStyle.UPPER_CENTER); return; } cont.DumpData(sd); this.AddData(sd); if (kuarqsRequired > 0) { setResourceMaxAmount("Kuarqs", kuarqsRequired); Events["ReviewDataEvent"].guiActive = false; } else { sd.transmitValue = txValue; this.ReviewData(); } this.updateList(); }
public void analyze(IScienceDataContainer cont, ScienceData sd) { //print(sd.title); if (GetScienceCount() > 0) { ScreenMessages.PostScreenMessage(Localizer.Format("#autoLOC_StatSci_screen_analyseFull"), 6, ScreenMessageStyle.UPPER_CENTER); return; } cont.DumpData(sd); this.AddData(sd); if (kuarqsRequired > 0) { setResourceMaxAmount("Kuarqs", kuarqsRequired); Events["ReviewDataEvent"].guiActive = false; } else { sd.baseTransmitValue = txValue; this.ReviewData(); } this.updateList(); }
internal bool RunExperiment(string sid, ModuleScienceExperiment exp, bool runSingleUse = true) { IScienceDataContainer m = null; // If possible run with DMagic new API IEnumerable <DMModuleScienceAnimateGeneric_NM.DMModuleScienceAnimateGeneric> lm = FindDMAnimateGenericsForExperiment(sid); if (lm != null && lm.Any()) { m = lm.FirstOrDefault(x => (int)x.Fields.GetValue("experimentsLimit") > 1 ? DMSciAnimAPI.experimentCanConduct(x) : DMSciAnimAPI.experimentCanConduct(x) && (x.rerunnable || runSingleUse)); if (m != null) { DMSciAnimAPI.deployDMExperiment(m, false); } return(true); } return(false); }
public bool CanTransfer(ModuleScienceExperiment baseExperiment, IScienceDataContainer moduleScienceContainer) { Log(baseExperiment.experimentID, ": CanTransfer"); if (moduleScienceContainer == baseExperiment as IScienceDataContainer) {//no point in transfering to the same container Log(baseExperiment.experimentID, ": Experiment is same as Container ", baseExperiment.GetScienceCount()); return(false); } if (baseExperiment.GetScienceCount() == 0) { Log(baseExperiment.experimentID, ": Experiment has no data skiping transfer ", baseExperiment.GetScienceCount()); return(false); } if (!baseExperiment.IsRerunnable()) { if (!_AutomatedScienceSamplerInstance.craftSettings.transferAllData) { Log(baseExperiment.experimentID, ": Experiment isn't rerunnable and transferAllData is turned off."); return(false); } } if (!_AutomatedScienceSamplerInstance.craftSettings.dumpDuplicates) { foreach (var data in baseExperiment.GetData()) { if (moduleScienceContainer.HasData(data)) { Log(baseExperiment.experimentID, ": Target already has experiment and dumping is disabled."); return(false); } } } Log(baseExperiment.experimentID, ": We can transfer the science!"); return(true); }
public int GetActiveVesselDataCount() { int dataCnt = 0; if (FlightGlobals.ActiveVessel != null) { Vessel activeVessel = FlightGlobals.ActiveVessel; int pCount = activeVessel.parts.Count; while (pCount-- > 0) { Part part = activeVessel.parts[pCount]; int mCount = part.Modules.Count; while (mCount-- > 0) { IScienceDataContainer scienceDataContainer = part.Modules[mCount] as IScienceDataContainer; if (scienceDataContainer != null) { dataCnt += scienceDataContainer.GetScienceCount(); } } } } return(dataCnt); }
public bool SelectContainer(IScienceDataContainer container) { bool b = false; if(container != null) { if(_containers.Contains(container)) { if(_selectedContainer != container) { _selectedContainer = container; _selectedData = null; b = true; Print(((PartModule)container).part.partInfo.title + " was selected."); } /*else { _selectedContainer = null; Print(((PartModule)container).part.partInfo.title + " was deselected."); }*/ } else { Print("The container doesn't exist in the avaliable containers."); } } else { _selectedContainer = null; Print("No container (null) was selected."); } return b; }
public void ExpandContainer(IScienceDataContainer container) { if(container != null && _containers.Contains(container)) { if(!_expanded.Contains(container)) { Print(((PartModule)container).part.partInfo.title + "'s ScienceData expanded."); _expanded.Add(container); } } }
public void CollapseContainer(IScienceDataContainer container) { if(container != null && _containers.Contains(container)) { if(_expanded.Contains(container)) { Print(((PartModule)container).part.partInfo.title + "'s ScienceData collapsed."); _expanded.Remove(container); } } }
public Notes_DataObject(ScienceData d, Notes_DataPart r, IScienceDataContainer c) { data = d; root = r; container = c; sub = ResearchAndDevelopment.GetSubjectByID(d.subjectID); if (sub != null) { returnValue = ResearchAndDevelopment.GetScienceValue(data.dataAmount, sub, 1f) * HighLogic.CurrentGame.Parameters.Career.ScienceGainMultiplier; transmitValue = ResearchAndDevelopment.GetScienceValue(data.dataAmount, sub, data.transmitValue) * HighLogic.CurrentGame.Parameters.Career.ScienceGainMultiplier; remainingValue = Math.Min(sub.scienceCap, Math.Max(0f, sub.scienceCap * sub.scientificValue)) * HighLogic.CurrentGame.Parameters.Career.ScienceGainMultiplier; text = ResearchAndDevelopment.GetResults(sub.id); } title = d.title; }
public void addPartData(ScienceData Data, IScienceDataContainer Container) { Notes_DataObject n = new Notes_DataObject(Data, this, Container); if (!partData.Contains(n)) partData.Add(n); }
protected void setupPartModules() { //GPS if (gps == null) { gps = this.part.FindModuleImplementing<ModuleGPS>(); gps.Fields["bioName"].guiActive = false; gps.Fields["body"].guiActive = false; gps.Fields["lat"].guiActive = false; gps.Fields["lon"].guiActive = false; } //Biome Scanner if (biomeScanner == null) { biomeScanner = this.part.FindModuleImplementing<ModuleBiomeScanner>(); biomeScanner.Events["RunAnalysis"].guiActive = false; biomeScanner.Events["RunAnalysis"].guiActiveUnfocused = false; } //Setup the science container if (scienceContainer == null) { scienceContainer = this.part.FindModuleImplementing<ModuleScienceContainer>(); scienceContainer = this.part.FindModuleImplementing<ModuleScienceContainer>(); scienceContainer.Events["ReviewDataEvent"].guiActiveUnfocused = false; scienceContainer.Events["ReviewDataEvent"].guiActive = false; //Terrain uplink terrainUplinkView.part = this.part; terrainUplinkView.scienceContainer = scienceContainer; } //Grab the seismometer (if any) foreach (PartModule mod in this.part.Modules) if (mod.moduleName == "Seismometer") { impactSeismometer = mod; impactSensor = (IScienceDataContainer)impactSeismometer; ScienceData[] impactData = impactSensor.GetData(); foreach (ScienceData data in impactData) scienceContainer.AddData(data); foreach (ScienceData doomed in impactData) impactSensor.DumpData(doomed); break; } //Resource list if (resourceList == null) resourceList = ResourceMap.Instance.GetResourceItemList(HarvestTypes.Planetary, this.part.vessel.mainBody); else if (resourceList.Count == 0) resourceList = ResourceMap.Instance.GetResourceItemList(HarvestTypes.Planetary, this.part.vessel.mainBody); }
public void OnPMEvaCollectStore(IScienceDataContainer cont, int origDataCount) { //condition to meet before we signal controller Func<bool> pollForMove = () => //cont get captured into the delegate { //wait for module to collect or store if (cont.GetData().Length == origDataCount) { return false; } //alert models m_activeShip.FireScienceEvent(); m_externShip.FireScienceEvent(); return true; }; m_rightClickEvents.Add(pollForMove); }
public override void OnStart(StartState state) { base.OnStart(state); SetGuiVisible(false); showResults = false; resourceList = ResourceMap.Instance.GetResourceItemList(HarvestTypes.Planetary, this.part.vessel.mainBody); gps = this.part.FindModuleImplementing<ModuleGPS>(); biomeScanner = this.part.FindModuleImplementing<ModuleBiomeScanner>(); hideStockGUI(); //Grab the seismometer (if any) foreach (PartModule mod in this.part.Modules) if (mod.moduleName == "Seismometer") { impactSeismometer = mod; impactSensor = (IScienceDataContainer)impactSeismometer; break; } //Create swizzler swizzler = new WBIResultsDialogSwizzler(); swizzler.onTransmit = transmitData; //Setup the science container scienceContainer = this.part.FindModuleImplementing<ModuleScienceContainer>(); scienceContainer.Events["ReviewDataEvent"].guiActiveUnfocused = false; scienceContainer.Events["ReviewDataEvent"].guiActive = false; if (impactSensor != null) { ScienceData[] impactData = impactSensor.GetData(); foreach (ScienceData data in impactData) scienceContainer.AddData(data); foreach (ScienceData doomed in impactData) impactSensor.DumpData(doomed); } //Terrain uplink terrainUplinkView.part = this.part; terrainUplinkView.scienceContainer = scienceContainer; //Elapsed time for current experiment if (ModuleIsActive()) { //Get the new elapsed time. int elapsedTimeIndex = (int)currentExperiment; elapsedTime = elapsedTimes[elapsedTimeIndex]; //Reset the research start time. cycleStartTime = Planetarium.GetUniversalTime() - elapsedTime; } CBAttributeMapSO.MapAttribute biome = Utils.GetCurrentBiome(this.part.vessel); biomeName = biome.name; if (this.part.vessel.situation == Vessel.Situations.LANDED || this.part.vessel.situation == Vessel.Situations.SPLASHED || this.part.vessel.situation == Vessel.Situations.PRELAUNCH) { planetID = this.part.vessel.mainBody.flightGlobalsIndex; harvestType = (HarvestTypes)harvestID; } }
public XferQueuePacket(ScienceHardDrive drive, IScienceDataContainer container, ScienceData data) { this.drive = drive; this.container = container; this.data = data; }
public void QueueDataForXfer(ScienceHardDrive drive, IScienceDataContainer container, ScienceData data) { Dictionary<ScienceData, IScienceDataContainer> queue; if(!xferQueues.Any(kvp => kvp.Value.ContainsKey(data))) { if(xferQueues.TryGetValue(drive, out queue)) { float queueAmount = 0; foreach(ScienceData d in queue.Keys) { queueAmount += d.dataAmount; } if(data.dataAmount + queueAmount <= drive.freeSpace) { Print("Queue for " + drive.part.partInfo.title + " found and queuing " + data.title); queue.Add(data, container); } else { Print("Not enough room to queue " + data.title + " in the queue for " + drive.part.partInfo.title); } } else { if(data.dataAmount <= drive.freeSpace) { Print(drive.part.partInfo.title + " doesn't have a queue. Making one and queuing " + data.title); xferQueues.Add(drive, new Dictionary<ScienceData, IScienceDataContainer> { { data, container } }); } else { Print("Not enough room to queue " + data.title + " in the queue for " + drive.part.partInfo.title); } } if(!drive.IsXfering()) { Print(drive.part.partInfo.title + " starting data transfer."); StartCoroutine(TransferData(drive)); } else { Print(drive.part.partInfo.title + " is already tranfering data."); } } else { Print(data.title + " is already queued."); } }
public bool SelectData(ScienceData data) { bool b = false; if(data != null) { if(_containers.Any(c => c.GetData().Contains(data))) { if(_selectedData != data) { _selectedContainer = null; _selectedData = data; ExpandContainer(containers.First(c => ((PartModule)c).part.flightID == data.container)); b = true; Print(data.title + " was selected."); } /*else { _selectedData = null; Print(data.title + " was deselected."); }*/ } else { Print("The data doesn't exist in any of the avaliable containers."); } } else { _selectedData = null; Print("No data (null) was selected."); } return b; }
public static void ReviewContainer(IScienceDataContainer container) { if(vesselSettings.SelectData(container.GetData().OrderBy(d => d.title).First())) { UpdateScienceInfo(vesselSettings.selectedData); isVisable = true; } }
public static void UpdateScienceInfo(ScienceData data) { Print("Upating selected ScienceData information."); ScienceSubject subjectId = ResearchAndDevelopment.GetSubjectByID(data.subjectID); float scienceMultiplier = HighLogic.CurrentGame.Parameters.Career.ScienceGainMultiplier; dataContainer = vesselSettings.containers.First(c => ((PartModule)c).part.flightID == data.container); dataRefValue = ResearchAndDevelopment.GetReferenceDataValue(data.dataAmount, subjectId) * HighLogic.CurrentGame.Parameters.Career.ScienceGainMultiplier; dataValue = ResearchAndDevelopment.GetScienceValue(data.dataAmount, subjectId, 1f) * HighLogic.CurrentGame.Parameters.Career.ScienceGainMultiplier; dataXmitValue = ResearchAndDevelopment.GetScienceValue(data.dataAmount, subjectId, data.transmitValue) * HighLogic.CurrentGame.Parameters.Career.ScienceGainMultiplier; dataValueAfterRec = ResearchAndDevelopment.GetNextScienceValue(data.dataAmount, subjectId, 1f) * HighLogic.CurrentGame.Parameters.Career.ScienceGainMultiplier; dataValueAfterXmit = ResearchAndDevelopment.GetNextScienceValue(data.dataAmount, subjectId, data.transmitValue) * HighLogic.CurrentGame.Parameters.Career.ScienceGainMultiplier; dataResultText = ResearchAndDevelopment.GetResults(subjectId.id); dataSizeText = "Data Size: " + data.dataAmount + " Mits"; dataRecoverText = "Recovery: +" + dataValue.ToString("0.0") + " Science"; dataXmitText = "Transmit: +" + dataXmitValue.ToString("0.0") + " Science"; }