├── .gitattributes ├── .gitignore ├── GameData └── KerboKatz │ └── AutomatedScienceSampler │ ├── LICENSE │ └── automatedsciencesampler.KerboKatzAsset ├── LICENSE └── source ├── AutomatedScienceSampler ├── AutomatedScienceSampler.cs ├── DefaultActivator.cs ├── IScienceActivator.cs ├── Properties │ └── AssemblyInfo.cs └── Settings.cs └── Plugins ├── DMModuleScienceAnimateGeneric ├── Activator.cs └── Properties │ └── AssemblyInfo.cs ├── DMagic Orbital Science ├── Activator.cs └── Properties │ └── AssemblyInfo.cs └── Station Science ├── Activator.cs └── Properties └── AssemblyInfo.cs /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.dll 2 | 3 | *.so 4 | *.csproj 5 | # Object files 6 | *.o 7 | *.ko 8 | *.obj 9 | *.elf 10 | 11 | # Precompiled Headers 12 | *.gch 13 | *.pch 14 | 15 | # Libraries 16 | *.lib 17 | *.a 18 | *.la 19 | *.lo 20 | 21 | # Shared objects (inc. Windows DLLs) 22 | #*.dll 23 | *.so 24 | *.so.* 25 | *.dylib 26 | 27 | # Executables 28 | *.exe 29 | *.out 30 | *.app 31 | *.i*86 32 | *.x86_64 33 | *.hex 34 | ## Ignore Visual Studio temporary files, build results, and 35 | ## files generated by popular Visual Studio add-ons. 36 | 37 | # User-specific files 38 | *.suo 39 | *.user 40 | *.userosscache 41 | *.sln.docstates 42 | *.sln 43 | 44 | # User-specific files (MonoDevelop/Xamarin Studio) 45 | *.userprefs 46 | 47 | # Build results 48 | [Dd]ebug/ 49 | [Dd]ebugPublic/ 50 | [Rr]elease/ 51 | [Rr]eleases/ 52 | x64/ 53 | x86/ 54 | build/ 55 | bld/ 56 | [Bb]in/ 57 | [Oo]bj/ 58 | 59 | # Visual Studo 2015 cache/options directory 60 | .vs/ 61 | 62 | # MSTest test Results 63 | [Tt]est[Rr]esult*/ 64 | [Bb]uild[Ll]og.* 65 | 66 | #NUNIT 67 | *.VisualState.xml 68 | TestResult.xml 69 | 70 | # Build Results of an ATL Project 71 | [Dd]ebugPS/ 72 | [Rr]eleasePS/ 73 | dlldata.c 74 | 75 | *_i.c 76 | *_p.c 77 | *_i.h 78 | *.ilk 79 | *.meta 80 | *.obj 81 | *.pch 82 | *.pdb 83 | *.pgc 84 | *.pgd 85 | *.rsp 86 | *.sbr 87 | *.tlb 88 | *.tli 89 | *.tlh 90 | *.tmp 91 | *.tmp_proj 92 | *.log 93 | *.vspscc 94 | *.vssscc 95 | .builds 96 | *.pidb 97 | *.svclog 98 | *.scc 99 | 100 | # Chutzpah Test files 101 | _Chutzpah* 102 | 103 | # Visual C++ cache files 104 | ipch/ 105 | *.aps 106 | *.ncb 107 | *.opensdf 108 | *.sdf 109 | *.cachefile 110 | 111 | # Visual Studio profiler 112 | *.psess 113 | *.vsp 114 | *.vspx 115 | 116 | # TFS 2012 Local Workspace 117 | $tf/ 118 | 119 | # Guidance Automation Toolkit 120 | *.gpState 121 | 122 | # ReSharper is a .NET coding add-in 123 | _ReSharper*/ 124 | *.[Rr]e[Ss]harper 125 | *.DotSettings.user 126 | 127 | # JustCode is a .NET coding addin-in 128 | .JustCode 129 | 130 | # TeamCity is a build add-in 131 | _TeamCity* 132 | 133 | # DotCover is a Code Coverage Tool 134 | *.dotCover 135 | 136 | # NCrunch 137 | _NCrunch_* 138 | .*crunch*.local.xml 139 | 140 | # MightyMoose 141 | *.mm.* 142 | AutoTest.Net/ 143 | 144 | # Web workbench (sass) 145 | .sass-cache/ 146 | 147 | # Installshield output folder 148 | [Ee]xpress/ 149 | 150 | # DocProject is a documentation generator add-in 151 | DocProject/buildhelp/ 152 | DocProject/Help/*.HxT 153 | DocProject/Help/*.HxC 154 | DocProject/Help/*.hhc 155 | DocProject/Help/*.hhk 156 | DocProject/Help/*.hhp 157 | DocProject/Help/Html2 158 | DocProject/Help/html 159 | 160 | # Click-Once directory 161 | publish/ 162 | 163 | # Publish Web Output 164 | *.[Pp]ublish.xml 165 | *.azurePubxml 166 | # TODO: Comment the next line if you want to checkin your web deploy settings 167 | # but database connection strings (with potential passwords) will be unencrypted 168 | *.pubxml 169 | *.publishproj 170 | 171 | # NuGet Packages 172 | *.nupkg 173 | # The packages folder can be ignored because of Package Restore 174 | **/packages/* 175 | # except build/, which is used as an MSBuild target. 176 | !**/packages/build/ 177 | # Uncomment if necessary however generally it will be regenerated when needed 178 | #!**/packages/repositories.config 179 | 180 | # Windows Azure Build Output 181 | csx/ 182 | *.build.csdef 183 | 184 | # Windows Store app package directory 185 | AppPackages/ 186 | 187 | # Others 188 | *.[Cc]ache 189 | ClientBin/ 190 | [Ss]tyle[Cc]op.* 191 | ~$* 192 | *~ 193 | *.dbmdl 194 | *.dbproj.schemaview 195 | *.pfx 196 | *.publishsettings 197 | node_modules/ 198 | bower_components/ 199 | 200 | # RIA/Silverlight projects 201 | Generated_Code/ 202 | 203 | # Backup & report files from converting an old project file 204 | # to a newer Visual Studio version. Backup files are not needed, 205 | # because we have git ;-) 206 | _UpgradeReport_Files/ 207 | Backup*/ 208 | UpgradeLog*.XML 209 | UpgradeLog*.htm 210 | 211 | # SQL Server files 212 | *.mdf 213 | *.ldf 214 | 215 | # Business Intelligence projects 216 | *.rdl.data 217 | *.bim.layout 218 | *.bim_*.settings 219 | 220 | # Microsoft Fakes 221 | FakesAssemblies/ 222 | 223 | # Node.js Tools for Visual Studio 224 | .ntvs_analysis.dat 225 | 226 | # Visual Studio 6 build log 227 | *.plg 228 | 229 | # Visual Studio 6 workspace options file 230 | *.opt 231 | -------------------------------------------------------------------------------- /GameData/KerboKatz/AutomatedScienceSampler/LICENSE: -------------------------------------------------------------------------------- 1 | All rights reserved. -------------------------------------------------------------------------------- /GameData/KerboKatz/AutomatedScienceSampler/automatedsciencesampler.KerboKatzAsset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KerboKatz/AutomatedScienceSampler/02fa309dcf38810abee7fc41fecec333d84c1f50/GameData/KerboKatz/AutomatedScienceSampler/automatedsciencesampler.KerboKatzAsset -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | All rights reserved. 2 | -------------------------------------------------------------------------------- /source/AutomatedScienceSampler/AutomatedScienceSampler.cs: -------------------------------------------------------------------------------- 1 | using KerboKatz.Assets; 2 | using KerboKatz.Extensions; 3 | using KerboKatz.Toolbar; 4 | using System; 5 | using System.Collections; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using UnityEngine; 9 | using UnityEngine.Events; 10 | using UnityEngine.UI; 11 | 12 | namespace KerboKatz.ASS 13 | { 14 | [KSPAddon(KSPAddon.Startup.Flight, false)] 15 | public class AutomatedScienceSampler : KerboKatzBase, IToolbar 16 | { 17 | private Dictionary shipCotainsExperiments = new Dictionary(); 18 | private Dictionary activators = new Dictionary(); 19 | private double nextUpdate; 20 | private float CurrentFrame; 21 | private float lastFrameCheck; 22 | private static List _activeScences = new List() { GameScenes.FLIGHT }; 23 | private Sprite _icon = AssetLoader.GetAsset("icon56", "Icons/AutomatedScienceSampler", "AutomatedScienceSampler/AutomatedScienceSampler"); 24 | private List experiments; 25 | private List scienceContainers; 26 | private Dropdown transferScienceUIElement; 27 | private bool uiElementsReady; 28 | private string settingsUIName; 29 | private KerbalEVA kerbalEVAPart; 30 | private Vessel parentVessel; 31 | public PerCraftSetting craftSettings; 32 | private Transform uiContent; 33 | 34 | private float frameCheck { get { return 1 / settings.spriteFPS; } } 35 | 36 | #region init/destroy 37 | 38 | public AutomatedScienceSampler() 39 | { 40 | modName = "AutomatedScienceSampler"; 41 | displayName = "Automated Science Sampler"; 42 | settingsUIName = "AutomatedScienceSampler"; 43 | tooltip = "Use left click to turn AutomatedScienceSampler on/off.\n Use shift+left click to open the settings menu."; 44 | requiresUtilities = new Version(1, 5, 2); 45 | ToolbarBase.instance.Add(this); 46 | LoadSettings("AutomatedScienceSampler", "Settings"); 47 | Log("Init done!"); 48 | } 49 | 50 | public override void OnAwake() 51 | { 52 | if (!(HighLogic.CurrentGame.Mode == Game.Modes.CAREER || HighLogic.CurrentGame.Mode == Game.Modes.SCIENCE_SANDBOX)) 53 | { 54 | Log("Game mode not supported!"); 55 | Destroy(this); 56 | return; 57 | } 58 | GetScienceActivators(); 59 | LoadUI(settingsUIName, "AutomatedScienceSampler/AutomatedScienceSampler"); 60 | 61 | GameEvents.onVesselChange.Add(OnVesselChange); 62 | GameEvents.onVesselWasModified.Add(OnVesselChange); 63 | GameEvents.onCrewOnEva.Add(GoingEva); 64 | Log("Awake"); 65 | } 66 | 67 | private void GetScienceActivators() 68 | { 69 | Log("Starting search"); 70 | Utilities.LoopTroughAssemblies(CheckTypeForScienceActivator); 71 | 72 | DefaultActivator.instance = activators[typeof(ModuleScienceExperiment)] as DefaultActivator; 73 | } 74 | 75 | private void CheckTypeForScienceActivator(Type type) 76 | { 77 | if (type.GetInterfaces().Contains(typeof(IScienceActivator)) && type.GetConstructor(Type.EmptyTypes) != null) 78 | { 79 | var activator = Activator.CreateInstance(type) as IScienceActivator; 80 | activator.AutomatedScienceSampler = this; 81 | Log("Found", activator.GetType()); 82 | foreach (var validType in activator.GetValidTypes()) 83 | { 84 | Log("...for type: ", validType); 85 | activators.Add(validType, activator); 86 | } 87 | } 88 | } 89 | 90 | protected override void AfterDestroy() 91 | { 92 | GameEvents.onVesselChange.Remove(OnVesselChange); 93 | GameEvents.onVesselWasModified.Remove(OnVesselChange); 94 | GameEvents.onCrewOnEva.Remove(GoingEva); 95 | ToolbarBase.instance.Remove(this); 96 | Log("AfterDestroy"); 97 | } 98 | 99 | private void GetCraftSettings() 100 | { 101 | string guid; 102 | if (settings.perCraftSetting) 103 | { 104 | if (FlightGlobals.ActiveVessel.isEVA) 105 | { 106 | if (parentVessel != null) 107 | guid = parentVessel.id.ToString(); 108 | else 109 | guid = "EVA"; 110 | } 111 | else 112 | { 113 | guid = FlightGlobals.ActiveVessel.id.ToString(); 114 | } 115 | } 116 | else 117 | { 118 | guid = "Single"; 119 | } 120 | 121 | craftSettings = settings.GetSettingsForCraft(guid); 122 | UpdateUIVisuals(); 123 | } 124 | 125 | #endregion init/destroy 126 | 127 | #region ui 128 | 129 | protected override void OnUIElemntInit(UIData uiWindow) 130 | { 131 | var prefabWindow = uiWindow.gameObject.transform as RectTransform; 132 | uiContent = prefabWindow.Find("Content"); 133 | UpdateUIVisuals(); 134 | InitToggle(uiContent, "DropOutOfWarp", settings.dropOutOfWarp, OnDropOutOfWarpChange); 135 | InitToggle(uiContent, "UsePerCraftSettings", settings.perCraftSetting, OnPerCraftSettingChange); 136 | InitToggle(uiContent, "Debug", settings.debug, OnDebugChange); 137 | InitToggle(uiContent, "UseKKToolbar", settings.useKKToolbar, OnToolbarChange); 138 | InitSlider(uiContent, "SpriteFPS", settings.spriteFPS, OnSpriteFPSChange); 139 | transferScienceUIElement = InitDropdown(uiContent, "TransferScience", OnTransferScienceChange); 140 | } 141 | 142 | private void UpdateUIVisuals() 143 | { 144 | if (craftSettings != null) 145 | { 146 | InitInputField(uiContent, "Threshold", craftSettings.threshold.ToString(), OnThresholdChange, true); 147 | InitToggle(uiContent, "SingleRunExperiments", craftSettings.oneTimeOnly, OnSingleRunExperimentsChange, true); 148 | InitToggle(uiContent, "ResetExperiments", craftSettings.resetExperiments, OnResetExperimentsChange, true); 149 | InitToggle(uiContent, "HideScienceDialog", craftSettings.hideScienceDialog, OnHideScienceDialogChange, true); 150 | InitToggle(uiContent, "TransferAllData", craftSettings.transferAllData, OnTransferAllDataChange, true); 151 | InitToggle(uiContent, "DumpDuplicates", craftSettings.dumpDuplicates, OnDumpDuplicatesChange, true); 152 | } 153 | } 154 | 155 | 156 | private void OnDropOutOfWarpChange(bool arg0) 157 | { 158 | settings.dropOutOfWarp = arg0; 159 | SaveSettings(); 160 | } 161 | private void OnDumpDuplicatesChange(bool arg0) 162 | { 163 | craftSettings.dumpDuplicates = arg0; 164 | SaveSettings(); 165 | Log("OnDumpDuplicatesChange"); 166 | } 167 | 168 | private void OnTransferAllDataChange(bool arg0) 169 | { 170 | craftSettings.transferAllData = arg0; 171 | SaveSettings(); 172 | Log("OnTransferAllDataChange"); 173 | } 174 | 175 | private void OnSpriteFPSChange(float arg0) 176 | { 177 | settings.spriteFPS = arg0; 178 | SaveSettings(); 179 | Log("OnSpriteFPSChange"); 180 | } 181 | 182 | private void OnTransferScienceChange(int arg0) 183 | { 184 | craftSettings.currentContainer = arg0; 185 | Log("OnTransferScienceChange "); 186 | if (craftSettings.currentContainer != 0 && scienceContainers.Count >= craftSettings.currentContainer) 187 | { 188 | StartCoroutine(DisableHighlight(0.25f, ((PartModule)scienceContainers[craftSettings.currentContainer - 1]).part)); 189 | } 190 | SaveSettings(); 191 | } 192 | 193 | private IEnumerator DisableHighlight(float time, Part part) 194 | { 195 | part.SetHighlight(true, false); 196 | yield return new WaitForSeconds(time); 197 | part.SetHighlight(false, false); 198 | } 199 | 200 | private void OnPerCraftSettingChange(bool arg0) 201 | { 202 | settings.perCraftSetting = arg0; 203 | SaveSettings(); 204 | GetCraftSettings(); 205 | Log("OnPerCraftSettingChange"); 206 | } 207 | 208 | private void OnDebugChange(bool arg0) 209 | { 210 | settings.debug = arg0; 211 | SaveSettings(); 212 | Log("OnDebugChange"); 213 | } 214 | 215 | private void OnToolbarChange(bool arg0) 216 | { 217 | if (settings.useKKToolbar != arg0) 218 | { 219 | settings.useKKToolbar = arg0; 220 | SaveSettings(); 221 | ToolbarBase.SetDirty(); 222 | } 223 | Log("OnToolbarChange"); 224 | } 225 | 226 | private void OnHideScienceDialogChange(bool arg0) 227 | { 228 | craftSettings.hideScienceDialog = arg0; 229 | SaveSettings(); 230 | Log("OnHideScienceDialog"); 231 | } 232 | 233 | private void OnResetExperimentsChange(bool arg0) 234 | { 235 | craftSettings.resetExperiments = arg0; 236 | SaveSettings(); 237 | Log("OnResetExperimentsChange"); 238 | } 239 | 240 | private void OnSingleRunExperimentsChange(bool arg0) 241 | { 242 | craftSettings.oneTimeOnly = arg0; 243 | SaveSettings(); 244 | Log("onSingleRunExperimentsChange"); 245 | } 246 | 247 | private void OnThresholdChange(string arg0) 248 | { 249 | craftSettings.threshold = arg0.ToFloat(); 250 | SaveSettings(); 251 | Log("onThresholdChange"); 252 | } 253 | 254 | private void OnToolbar() 255 | { 256 | Log((craftSettings == null), " ", craftSettings.guid, " ", FlightGlobals.ActiveVessel.id); 257 | if (craftSettings == null) 258 | GetCraftSettings(); 259 | if (Input.GetMouseButtonUp(1)) 260 | { 261 | var uiData = GetUIData(settingsUIName); 262 | if (uiData == null || uiData.canvasGroup == null) 263 | return; 264 | settings.showSettings = !settings.showSettings; 265 | if (settings.showSettings) 266 | { 267 | FadeCanvasGroup(uiData.canvasGroup, 1, settings.uiFadeSpeed); 268 | } 269 | else 270 | { 271 | FadeCanvasGroup(uiData.canvasGroup, 0, settings.uiFadeSpeed); 272 | } 273 | } 274 | else 275 | { 276 | craftSettings.runAutoScience = !craftSettings.runAutoScience; 277 | if (!craftSettings.runAutoScience) 278 | { 279 | icon = AssetLoader.GetAsset("icon56", "Icons/AutomatedScienceSampler", "AutomatedScienceSampler/AutomatedScienceSampler");//Utilities.GetTexture("icon56", "AutomatedScienceSampler/Textures"); 280 | } 281 | } 282 | SaveSettings(); 283 | } 284 | 285 | #endregion ui 286 | 287 | private void OnVesselChange(Vessel data) 288 | { 289 | Log("OnVesselChange"); 290 | if (FlightGlobals.ActiveVessel == null) { 291 | Log("ActiveVessel is null! this shouldn't happen!"); 292 | return; 293 | } 294 | GetCraftSettings(); 295 | UpdateShipInformation(); 296 | } 297 | 298 | private void GoingEva(GameEvents.FromToAction parts) 299 | { 300 | Log("GoingEva"); 301 | parentVessel = parts.from.vessel; 302 | nextUpdate = Planetarium.GetUniversalTime() + settings.refreshTime; 303 | } 304 | 305 | private void Update() 306 | { 307 | #region icon 308 | 309 | if (lastFrameCheck + frameCheck < Time.time && craftSettings.runAutoScience) 310 | { 311 | var frame = Time.deltaTime / frameCheck; 312 | if (CurrentFrame + frame < 55) 313 | CurrentFrame += frame; 314 | else 315 | CurrentFrame = 0; 316 | icon = AssetLoader.GetAsset("icon" + (int)CurrentFrame, "Icons/AutomatedScienceSampler", "AutomatedScienceSampler/AutomatedScienceSampler");//Utilities.GetTexture("icon" + (int)CurrentFrame, "ForScienceContinued/Textures"); 317 | lastFrameCheck = Time.time; 318 | } 319 | 320 | #endregion icon 321 | 322 | var isTimeWarping = IsTimeWarping(); 323 | if (!IsReady()) 324 | { 325 | return; 326 | } 327 | if (isTimeWarping) 328 | { 329 | if (!settings.interruptTimeWarp) 330 | { 331 | Log("waiting for next frame"); 332 | return; 333 | } 334 | } 335 | var sw = new System.Diagnostics.Stopwatch(); 336 | sw.Start(); 337 | if (nextUpdate == 0) 338 | {//add some delay so it doesnt run as soon as the vehicle launches 339 | if (!FlightGlobals.ready) 340 | return; 341 | nextUpdate = Planetarium.GetUniversalTime() + settings.refreshTime; 342 | UpdateShipInformation(); 343 | return; 344 | } 345 | 346 | if (!FlightGlobals.ready || !Utilities.canVesselBeControlled(FlightGlobals.ActiveVessel)) 347 | return; 348 | if (Planetarium.GetUniversalTime() < nextUpdate) 349 | return; 350 | nextUpdate = Planetarium.GetUniversalTime() + settings.refreshTime; 351 | 352 | Log(sw.Elapsed.TotalMilliseconds); 353 | foreach (var experiment in experiments) 354 | { 355 | IScienceActivator activator; 356 | if (!activators.TryGetValue(experiment.GetType(), out activator)) 357 | { 358 | Log("Activator for ", experiment.GetType(), " not found! Using default!"); 359 | activator = DefaultActivator.instance; 360 | } 361 | var subject = activator.GetScienceSubject(experiment); 362 | if (subject == null) 363 | { 364 | Log("Subject is null! Skipping."); 365 | continue; 366 | } 367 | var value = activator.GetScienceValue(experiment, shipCotainsExperiments, subject); 368 | if (!isTimeWarping) 369 | { 370 | CheckExperimentOptions(experiment, activator, subject, value); 371 | } 372 | else 373 | { 374 | if (settings.dropOutOfWarp) 375 | { 376 | if (CheckExitTimeWarp(experiment, activator, subject, value)) 377 | { 378 | TimeWarp.SetRate(0, true); 379 | break; 380 | } 381 | } 382 | } 383 | 384 | Log("Experiment checked in: ", sw.Elapsed.TotalMilliseconds); 385 | } 386 | Log("Total: ", sw.Elapsed.TotalMilliseconds); 387 | } 388 | 389 | private static bool IsTimeWarping() 390 | { 391 | return TimeWarp.CurrentRateIndex > 0; 392 | } 393 | 394 | private bool CheckExitTimeWarp(ModuleScienceExperiment experiment, IScienceActivator activator, ScienceSubject subject, float value) 395 | { 396 | if (CanRunExperiment(experiment, activator, value)) 397 | { 398 | Log("exiting timewarp"); 399 | return true; 400 | } 401 | return false; 402 | } 403 | 404 | private void CheckExperimentOptions(ModuleScienceExperiment experiment, IScienceActivator activator, ScienceSubject subject, float value) 405 | { 406 | if (CanRunExperiment(experiment, activator, value)) 407 | { 408 | Log("Deploying ", experiment.part.name, " for :", value, " science! ", subject.id); 409 | activator.DeployExperiment(experiment); 410 | AddToContainer(subject.id); 411 | } 412 | else if (CanTransferExperiment(experiment, activator)) 413 | { 414 | 415 | activator.Transfer(experiment, scienceContainers[craftSettings.currentContainer - 1]); 416 | } 417 | else if (CanResetExperiment(experiment, activator)) 418 | { 419 | activator.Reset(experiment); 420 | } 421 | } 422 | 423 | private static bool CanRunExperiment(ModuleScienceExperiment experiment, IScienceActivator activator, float value) 424 | { 425 | return activator.CanRunExperiment(experiment, value); 426 | } 427 | 428 | private bool CanTransferExperiment(ModuleScienceExperiment experiment, IScienceActivator activator) 429 | { 430 | return BasicTransferCheck() && activator.CanTransfer(experiment, scienceContainers[craftSettings.currentContainer - 1]); 431 | } 432 | 433 | private bool CanResetExperiment(ModuleScienceExperiment experiment, IScienceActivator activator) 434 | { 435 | return craftSettings.resetExperiments && activator.CanReset(experiment); 436 | } 437 | 438 | private bool IsReady() 439 | { 440 | if (!uiElementsReady) 441 | { 442 | Log("UIElements aren't ready"); 443 | return false; 444 | } 445 | if (!FlightGlobals.ready) 446 | { 447 | Log("FlightGlobals aren't ready"); 448 | return false; 449 | } 450 | if (craftSettings == null) 451 | GetCraftSettings(); 452 | 453 | if (!craftSettings.runAutoScience) 454 | { 455 | Log("AutoScience is off"); 456 | return false; 457 | } 458 | if (FlightGlobals.ActiveVessel.packed) 459 | { 460 | Log("Vessel is packed"); 461 | if (!settings.interruptTimeWarp) 462 | return false; 463 | Log("But we want to check if we have experiments to run!"); 464 | } 465 | if (!FlightGlobals.ActiveVessel.IsControllable) 466 | { 467 | Log("Vessel isn't controllable"); 468 | return false; 469 | } 470 | if (!CheckEVA()) 471 | { 472 | Log("EVA isn't ready"); 473 | return false; 474 | } 475 | return true; 476 | } 477 | 478 | private bool BasicTransferCheck() 479 | { 480 | if (craftSettings.currentContainer == 0) 481 | return false; 482 | if (craftSettings.currentContainer > scienceContainers.Count) 483 | return false; 484 | if (((PartModule)scienceContainers[craftSettings.currentContainer - 1]).vessel != FlightGlobals.ActiveVessel) 485 | return false; 486 | return true; 487 | } 488 | 489 | private bool CheckEVA() 490 | { 491 | if (FlightGlobals.ActiveVessel.isEVA) 492 | { 493 | if (kerbalEVAPart == null) 494 | { 495 | var kerbalEVAParts = FlightGlobals.ActiveVessel.FindPartModulesImplementing(); 496 | kerbalEVAPart = kerbalEVAParts.First(); 497 | } 498 | if (craftSettings.doEVAOnlyIfGroundedWhenLanded && (parentVessel.Landed || parentVessel.Splashed) && (kerbalEVAPart.OnALadder || (!FlightGlobals.ActiveVessel.Landed && !FlightGlobals.ActiveVessel.Splashed))) 499 | { 500 | return false; 501 | } 502 | } 503 | 504 | return true; 505 | } 506 | 507 | private void UpdateShipInformation() 508 | { 509 | uiElementsReady = false; 510 | 511 | while (transferScienceUIElement.options.Count > 1) 512 | { 513 | transferScienceUIElement.options.RemoveAt(transferScienceUIElement.options.Count - 1); 514 | } 515 | experiments = FlightGlobals.ActiveVessel.FindPartModulesImplementing(); 516 | //scienceContainers = FlightGlobals.ActiveVessel.FindPartModulesImplementing(); 517 | scienceContainers = FlightGlobals.ActiveVessel.FindPartModulesImplementing(); 518 | for(var i = scienceContainers.Count-1; i >= 0; i--) 519 | { 520 | if (scienceContainers[i].GetType().IsTypeOf(typeof(ModuleScienceExperiment)))//dont want stock ModuleScienceExperiment as a transfer target as these can only contain the experiments results 521 | { 522 | Log("Removing ", (scienceContainers[i] as PartModule).moduleName, " as transfer target"); 523 | scienceContainers.RemoveAt(i); 524 | } 525 | } 526 | shipCotainsExperiments.Clear(); 527 | foreach (var currentContainer in scienceContainers) 528 | { 529 | AddOptionToDropdown(transferScienceUIElement, (currentContainer as PartModule).part.partInfo.title); 530 | foreach (var data in currentContainer.GetData()) 531 | { 532 | AddToContainer(data.subjectID); 533 | } 534 | } 535 | transferScienceUIElement.value = craftSettings.currentContainer; 536 | uiElementsReady = true; 537 | } 538 | 539 | private void AddToContainer(string subjectID, int add = 0) 540 | { 541 | if (shipCotainsExperiments.ContainsKey(subjectID)) 542 | { 543 | Log(subjectID, "_Containing"); 544 | shipCotainsExperiments[subjectID] = shipCotainsExperiments[subjectID] + 1 + add; 545 | } 546 | else 547 | { 548 | Log(subjectID, "_New"); 549 | shipCotainsExperiments.Add(subjectID, add + 1); 550 | } 551 | } 552 | 553 | 554 | #region IToolbar 555 | 556 | public List activeScences 557 | { 558 | get 559 | { 560 | return _activeScences; 561 | } 562 | } 563 | 564 | public UnityAction onClick 565 | { 566 | get 567 | { 568 | return OnToolbar; 569 | } 570 | } 571 | 572 | public Sprite icon 573 | { 574 | get 575 | { 576 | return _icon; 577 | } 578 | private set 579 | { 580 | if (_icon != value) 581 | { 582 | _icon = value; 583 | ToolbarBase.UpdateIcon(this, icon); 584 | } 585 | } 586 | } 587 | 588 | public bool useKKToolbar 589 | { 590 | get 591 | { 592 | return settings.useKKToolbar; 593 | } 594 | } 595 | 596 | #endregion IToolbar 597 | } 598 | } -------------------------------------------------------------------------------- /source/AutomatedScienceSampler/DefaultActivator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace KerboKatz.ASS 6 | { 7 | internal class DefaultActivator : IScienceActivator 8 | { 9 | internal static DefaultActivator instance; 10 | private AutomatedScienceSampler _AutomatedScienceSamplerInstance; 11 | 12 | AutomatedScienceSampler IScienceActivator.AutomatedScienceSampler 13 | { 14 | get { return _AutomatedScienceSamplerInstance; } 15 | set { _AutomatedScienceSamplerInstance = value; } 16 | } 17 | 18 | public bool CanRunExperiment(ModuleScienceExperiment baseExperiment, float currentScienceValue) 19 | { 20 | Log(baseExperiment.experimentID, ": CanRunExperiment"); 21 | if (!baseExperiment.experiment.IsAvailableWhile(ScienceUtil.GetExperimentSituation(FlightGlobals.ActiveVessel), FlightGlobals.currentMainBody))// 22 | { 23 | Log(baseExperiment.experimentID, ": Experiment isn't available in the current situation: ", ScienceUtil.GetExperimentSituation(FlightGlobals.ActiveVessel), "_", FlightGlobals.currentMainBody + "_", baseExperiment.experiment.situationMask); 24 | return false; 25 | } 26 | if (baseExperiment.Inoperable) 27 | { 28 | Log(baseExperiment.experimentID, ": Experiment is inoperable"); 29 | return false; 30 | } 31 | if (baseExperiment.Deployed && !baseExperiment.rerunnable) 32 | { 33 | Log(baseExperiment.experimentID, ": Experiment is deployed"); 34 | return false; 35 | } 36 | 37 | if (!baseExperiment.rerunnable && !_AutomatedScienceSamplerInstance.craftSettings.oneTimeOnly) 38 | { 39 | Log(baseExperiment.experimentID, ": Runing rerunable experiments is disabled"); 40 | return false; 41 | } 42 | if (currentScienceValue < _AutomatedScienceSamplerInstance.craftSettings.threshold) 43 | { 44 | Log(baseExperiment.experimentID, ": Science value is less than cutoff threshold: ", currentScienceValue, "<", _AutomatedScienceSamplerInstance.craftSettings.threshold); 45 | return false; 46 | } 47 | if (baseExperiment.GetData().Length > 0) 48 | { 49 | Log(baseExperiment.experimentID, ": Experiment already contains results!"); 50 | return false; 51 | } 52 | if (!baseExperiment.experiment.IsUnlocked()) 53 | { 54 | Log(baseExperiment.experimentID, ": Experiment is locked"); 55 | return false; 56 | } 57 | return true; 58 | } 59 | 60 | public void DeployExperiment(ModuleScienceExperiment baseExperiment) 61 | { 62 | Log(baseExperiment.experimentID, ": DeployExperiment"); 63 | if (_AutomatedScienceSamplerInstance.craftSettings.hideScienceDialog) 64 | { 65 | var stagingSetting = baseExperiment.useStaging; 66 | baseExperiment.useStaging = true;//work the way around the staging 67 | baseExperiment.OnActive();//run the experiment without causing the report to show up 68 | baseExperiment.useStaging = stagingSetting;//set the staging back 69 | } 70 | else 71 | { 72 | baseExperiment.DeployExperiment(); 73 | } 74 | } 75 | 76 | public ScienceSubject GetScienceSubject(ModuleScienceExperiment baseExperiment) 77 | { 78 | string currentBiome = CurrentBiome(baseExperiment.experiment); 79 | return ResearchAndDevelopment.GetExperimentSubject(baseExperiment.experiment, ScienceUtil.GetExperimentSituation(FlightGlobals.ActiveVessel), FlightGlobals.currentMainBody, currentBiome, ScienceUtil.GetBiomedisplayName(FlightGlobals.currentMainBody, currentBiome)); 80 | } 81 | 82 | public float GetScienceValue(ModuleScienceExperiment baseExperiment, Dictionary shipCotainsExperiments, ScienceSubject currentScienceSubject) 83 | { 84 | return Utilities.Science.GetScienceValue(shipCotainsExperiments, baseExperiment.experiment, currentScienceSubject); 85 | } 86 | 87 | public bool CanReset(ModuleScienceExperiment baseExperiment) 88 | { 89 | Log(baseExperiment.experimentID, ": CanReset"); 90 | if (!baseExperiment.Inoperable) 91 | { 92 | Log(baseExperiment.experimentID, ": Experiment isn't inoperable"); 93 | return false; 94 | } 95 | if (!baseExperiment.Deployed) 96 | { 97 | Log(baseExperiment.experimentID, ": Experiment isn't deployed!"); 98 | return false; 99 | } 100 | if (baseExperiment.GetScienceCount() > 0) 101 | { 102 | Log(baseExperiment.experimentID, ": Experiment has data!"); 103 | return false; 104 | } 105 | 106 | if (!baseExperiment.resettable) 107 | { 108 | Log(baseExperiment.experimentID, ": Experiment isn't resetable"); 109 | return false; 110 | } 111 | bool hasScientist = false; 112 | foreach (var crew in FlightGlobals.ActiveVessel.GetVesselCrew()) 113 | { 114 | if (crew.trait == "Scientist") 115 | { 116 | hasScientist = true; 117 | break; 118 | } 119 | } 120 | if (!hasScientist) 121 | { 122 | Log(baseExperiment.experimentID, ": Vessel has no scientist"); 123 | return false; 124 | } 125 | Log(baseExperiment.experimentID, ": Can reset"); 126 | return true; 127 | } 128 | 129 | public void Reset(ModuleScienceExperiment baseExperiment) 130 | { 131 | Log(baseExperiment.experimentID, ": Reseting experiment"); 132 | baseExperiment.ResetExperiment(); 133 | } 134 | 135 | public bool CanTransfer(ModuleScienceExperiment baseExperiment, IScienceDataContainer moduleScienceContainer) 136 | { 137 | Log(baseExperiment.experimentID, ": CanTransfer"); 138 | 139 | if (moduleScienceContainer == baseExperiment as IScienceDataContainer) 140 | {//no point in transfering to the same container 141 | Log(baseExperiment.experimentID, ": Experiment is same as Container ", baseExperiment.GetScienceCount()); 142 | return false; 143 | } 144 | if (baseExperiment.GetScienceCount() == 0) 145 | { 146 | Log(baseExperiment.experimentID, ": Experiment has no data skiping transfer ", baseExperiment.GetScienceCount()); 147 | return false; 148 | } 149 | if (!baseExperiment.IsRerunnable()) 150 | { 151 | if (!_AutomatedScienceSamplerInstance.craftSettings.transferAllData) 152 | { 153 | Log(baseExperiment.experimentID, ": Experiment isn't rerunnable and transferAllData is turned off."); 154 | return false; 155 | } 156 | } 157 | if (!_AutomatedScienceSamplerInstance.craftSettings.dumpDuplicates) 158 | { 159 | foreach (var data in baseExperiment.GetData()) 160 | { 161 | if (moduleScienceContainer.HasData(data)) 162 | { 163 | Log(baseExperiment.experimentID, ": Target already has experiment and dumping is disabled."); 164 | return false; 165 | } 166 | } 167 | } 168 | Log(baseExperiment.experimentID, ": We can transfer the science!"); 169 | return true; 170 | } 171 | 172 | public void Transfer(ModuleScienceExperiment baseExperiment, IScienceDataContainer moduleScienceContainer) 173 | { 174 | Log(baseExperiment.experimentID, ": transfering"); 175 | moduleScienceContainer.StoreData(baseExperiment, _AutomatedScienceSamplerInstance.craftSettings.dumpDuplicates); 176 | } 177 | 178 | private string CurrentBiome(ScienceExperiment baseExperiment) 179 | { 180 | if (!baseExperiment.BiomeIsRelevantWhile(ScienceUtil.GetExperimentSituation(FlightGlobals.ActiveVessel))) 181 | return string.Empty; 182 | var currentVessel = FlightGlobals.ActiveVessel; 183 | var currentBody = FlightGlobals.currentMainBody; 184 | if (currentVessel != null && currentBody != null) 185 | { 186 | if (currentVessel.isEVA) 187 | { 188 | currentVessel = currentVessel.EVALadderVessel; 189 | } 190 | if (!string.IsNullOrEmpty(currentVessel.landedAt)) 191 | { 192 | //big thanks to xEvilReeperx for this one. 193 | return Vessel.GetLandedAtString(currentVessel.landedAt); 194 | } 195 | else 196 | { 197 | return ScienceUtil.GetExperimentBiome(currentBody, currentVessel.latitude, currentVessel.longitude); 198 | } 199 | } 200 | else 201 | { 202 | Log("currentVessel && currentBody == null"); 203 | } 204 | return string.Empty; 205 | } 206 | 207 | public List GetValidTypes() 208 | { 209 | var types = new List(); 210 | types.Add(typeof(ModuleScienceExperiment)); 211 | return types; 212 | } 213 | private void Log(params object[] msg) 214 | { 215 | var debugStringBuilder = new StringBuilder(); 216 | foreach (var debugString in msg) 217 | { 218 | debugStringBuilder.Append(debugString.ToString()); 219 | } 220 | _AutomatedScienceSamplerInstance.Log("[Default]", debugStringBuilder); 221 | } 222 | } 223 | } -------------------------------------------------------------------------------- /source/AutomatedScienceSampler/IScienceActivator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace KerboKatz.ASS 5 | { 6 | public interface IScienceActivator 7 | { 8 | AutomatedScienceSampler AutomatedScienceSampler { get; set; } 9 | 10 | //float GetScience(); 11 | List GetValidTypes(); 12 | 13 | ScienceSubject GetScienceSubject(ModuleScienceExperiment baseExperimentModule); 14 | 15 | float GetScienceValue(ModuleScienceExperiment baseExperimentModule, Dictionary shipCotainsExperiments, ScienceSubject currentScienceSubject); 16 | 17 | bool CanRunExperiment(ModuleScienceExperiment baseExperimentModule, float currentScienceValue); 18 | 19 | void DeployExperiment(ModuleScienceExperiment baseExperimentModule); 20 | 21 | bool CanReset(ModuleScienceExperiment baseExperimentModule); 22 | 23 | void Reset(ModuleScienceExperiment baseExperimentModule); 24 | 25 | bool CanTransfer(ModuleScienceExperiment baseExperimentModule, IScienceDataContainer moduleScienceContainer); 26 | 27 | void Transfer(ModuleScienceExperiment baseExperimentModule, IScienceDataContainer moduleScienceContainer); 28 | } 29 | } -------------------------------------------------------------------------------- /source/AutomatedScienceSampler/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | [assembly: AssemblyTitle("AutomatedScienceSampler")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("KerboKatz")] 11 | [assembly: AssemblyProduct("AutomatedScienceSampler")] 12 | [assembly: AssemblyCopyright("")] 13 | [assembly: AssemblyTrademark("KerboKatz")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Setting ComVisible to false makes the types in this assembly not visible 17 | // to COM components. If you need to access a type in this assembly from 18 | // COM, set the ComVisible attribute to true on that type. 19 | [assembly: ComVisible(false)] 20 | 21 | // The following GUID is for the ID of the typelib if this project is exposed to COM 22 | [assembly: Guid("bf0c4a9d-d61c-4cbb-999c-51f9a2d68380")] 23 | 24 | // Version information for an assembly consists of the following four values: 25 | // 26 | // Major Version 27 | // Minor Version 28 | // Build Number 29 | // Revision 30 | // 31 | // You can specify all the values or you can default the Build and Revision Numbers 32 | // by using the '*' as shown below: 33 | // [assembly: AssemblyVersion("1.0.*")] 34 | [assembly: AssemblyVersion("1.3.5")] 35 | //[assembly: AssemblyFileVersion("0.26.1.0")] -------------------------------------------------------------------------------- /source/AutomatedScienceSampler/Settings.cs: -------------------------------------------------------------------------------- 1 | using KerboKatz.UI; 2 | using System.Collections.Generic; 3 | 4 | namespace KerboKatz.ASS 5 | { 6 | public class Settings : SettingsBase 7 | { 8 | public bool showSettings = false; 9 | public float spriteFPS = 60; 10 | private Dictionary _craftSettings = new Dictionary(); 11 | public List craftSettings = new List(); 12 | public bool perCraftSetting; 13 | public string lastGUID; 14 | public double refreshTime = 1; 15 | public bool interruptTimeWarp = true; 16 | public bool dropOutOfWarp = false; 17 | public bool useKKToolbar = true; 18 | 19 | protected override void OnLoaded() 20 | { 21 | _craftSettings.Clear(); 22 | foreach (var setting in craftSettings) 23 | { 24 | _craftSettings.Add(setting.guid, setting); 25 | } 26 | } 27 | 28 | protected override void OnSave() 29 | { 30 | craftSettings = new List(_craftSettings.Values); 31 | } 32 | 33 | public PerCraftSetting GetSettingsForCraft(string guid) 34 | { 35 | PerCraftSetting setting; 36 | if (!_craftSettings.TryGetValue(guid, out setting)) 37 | { 38 | if (lastGUID.IsNullOrWhiteSpace()) 39 | { 40 | setting = new PerCraftSetting(); 41 | } 42 | else 43 | { 44 | setting = GetSettingsForCraft(lastGUID).Clone(); 45 | } 46 | setting.guid = guid; 47 | _craftSettings.Add(guid, setting); 48 | } 49 | lastGUID = guid; 50 | return setting; 51 | } 52 | } 53 | 54 | public class PerCraftSetting 55 | { 56 | public string guid; 57 | public float threshold = 2; 58 | public bool runAutoScience = false; 59 | public bool oneTimeOnly = false; 60 | public bool resetExperiments; 61 | public bool hideScienceDialog; 62 | public bool transferAllData; 63 | public bool dumpDuplicates; 64 | public bool doEVAOnlyIfGroundedWhenLanded; 65 | public int currentContainer; 66 | 67 | public PerCraftSetting Clone() 68 | { 69 | var setting = new PerCraftSetting(); 70 | setting.threshold = threshold; 71 | setting.runAutoScience = runAutoScience; 72 | setting.oneTimeOnly = oneTimeOnly; 73 | setting.resetExperiments = resetExperiments; 74 | setting.hideScienceDialog = hideScienceDialog; 75 | setting.transferAllData = transferAllData; 76 | setting.dumpDuplicates = dumpDuplicates; 77 | setting.doEVAOnlyIfGroundedWhenLanded = doEVAOnlyIfGroundedWhenLanded; 78 | return setting; 79 | } 80 | } 81 | } -------------------------------------------------------------------------------- /source/Plugins/DMModuleScienceAnimateGeneric/Activator.cs: -------------------------------------------------------------------------------- 1 | using DMModuleScienceAnimateGeneric; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace KerboKatz.ASS.DMMSAG 7 | { 8 | public class Activator : IScienceActivator 9 | { 10 | private AutomatedScienceSampler _AutomatedScienceSamplerInstance; 11 | 12 | AutomatedScienceSampler IScienceActivator.AutomatedScienceSampler 13 | { 14 | get { return _AutomatedScienceSamplerInstance; } 15 | set { _AutomatedScienceSamplerInstance = value; } 16 | } 17 | 18 | public bool CanRunExperiment(ModuleScienceExperiment baseExperiment, float currentScienceValue) 19 | { 20 | var currentExperiment = baseExperiment as DMModuleScienceAnimateGeneric.DMModuleScienceAnimateGeneric; 21 | if (currentScienceValue < _AutomatedScienceSamplerInstance.craftSettings.threshold) 22 | { 23 | Log(currentExperiment.experimentID, ": Science value is less than cutoff threshold: ", currentScienceValue, "<", _AutomatedScienceSamplerInstance.craftSettings.threshold); 24 | return false; 25 | } 26 | if (!currentExperiment.rerunnable && !_AutomatedScienceSamplerInstance.craftSettings.oneTimeOnly) 27 | { 28 | Log(currentExperiment.experimentID, ": Runing rerunable experiments is disabled"); 29 | return false; 30 | } 31 | if (currentExperiment.Inoperable) 32 | { 33 | Log(currentExperiment.experimentID, ": Experiment is inoperable"); 34 | return false; 35 | } 36 | if (currentExperiment.Deployed) 37 | { 38 | Log(currentExperiment.experimentID, ": Experiment is deployed"); 39 | return false; 40 | } 41 | if (!currentExperiment.experiment.IsUnlocked()) 42 | { 43 | Log(currentExperiment.experimentID, ": Experiment is locked"); 44 | return false; 45 | } 46 | return currentExperiment.canConduct(); 47 | } 48 | 49 | public void DeployExperiment(ModuleScienceExperiment baseExperiment) 50 | { 51 | var currentExperiment = baseExperiment as DMModuleScienceAnimateGeneric.DMModuleScienceAnimateGeneric; 52 | currentExperiment.gatherScienceData(_AutomatedScienceSamplerInstance.craftSettings.hideScienceDialog); 53 | } 54 | 55 | public ScienceSubject GetScienceSubject(ModuleScienceExperiment baseExperiment) 56 | { 57 | var currentExperiment = baseExperiment as DMModuleScienceAnimateGeneric.DMModuleScienceAnimateGeneric; 58 | if (DMSciAnimAPI.isAsteroidGrappled(currentExperiment)) 59 | { 60 | return DMSciAnimAPI.getAsteroidSubject(currentExperiment); 61 | } 62 | else 63 | { 64 | ExperimentSituations situation = ScienceUtil.GetExperimentSituation(FlightGlobals.ActiveVessel); 65 | var biome = currentExperiment.getBiome(situation); 66 | return ResearchAndDevelopment.GetExperimentSubject(ResearchAndDevelopment.GetExperiment(currentExperiment.experimentID), situation, FlightGlobals.currentMainBody, biome, ScienceUtil.GetBiomedisplayName(FlightGlobals.currentMainBody, biome)); 67 | } 68 | } 69 | 70 | public float GetScienceValue(ModuleScienceExperiment baseExperiment, Dictionary shipCotainsExperiments, ScienceSubject currentScienceSubject) 71 | { 72 | var currentExperiment = baseExperiment as DMModuleScienceAnimateGeneric.DMModuleScienceAnimateGeneric; 73 | var scienceExperiment = ResearchAndDevelopment.GetExperiment(baseExperiment.experimentID); 74 | return Utilities.Science.GetScienceValue(shipCotainsExperiments, scienceExperiment, currentScienceSubject); 75 | } 76 | 77 | public bool CanReset(ModuleScienceExperiment baseExperiment) 78 | { 79 | var currentExperiment = baseExperiment as DMModuleScienceAnimateGeneric.DMModuleScienceAnimateGeneric; 80 | if (!currentExperiment.Inoperable) 81 | { 82 | Log(currentExperiment.experimentID, ": Experiment isn't inoperable"); 83 | return false; 84 | } 85 | if (!currentExperiment.Deployed) 86 | { 87 | Log(currentExperiment.experimentID, ": Experiment isn't deployed!"); 88 | return false; 89 | } 90 | if ((currentExperiment as IScienceDataContainer).GetScienceCount() > 0) 91 | { 92 | Log(currentExperiment.experimentID, ": Experiment has data!"); 93 | return false; 94 | } 95 | if (!currentExperiment.resettable) 96 | { 97 | Log(currentExperiment.experimentID, ": Experiment isn't resetable"); 98 | return false; 99 | } 100 | bool hasScientist = false; 101 | foreach (var crew in FlightGlobals.ActiveVessel.GetVesselCrew()) 102 | { 103 | if (crew.trait == "Scientist") 104 | { 105 | hasScientist = true; 106 | break; 107 | } 108 | } 109 | if (!hasScientist) 110 | { 111 | Log(currentExperiment.experimentID, ": Vessel has no scientist"); 112 | return false; 113 | } 114 | return true; 115 | } 116 | 117 | public void Reset(ModuleScienceExperiment baseExperiment) 118 | { 119 | var currentExperiment = baseExperiment as DMModuleScienceAnimateGeneric.DMModuleScienceAnimateGeneric; 120 | Log(currentExperiment.experimentID, ": Reseting experiment"); 121 | currentExperiment.ResetExperiment(); 122 | } 123 | 124 | public bool CanTransfer(ModuleScienceExperiment baseExperiment, IScienceDataContainer moduleScienceContainer) 125 | { 126 | var currentExperiment = baseExperiment as DMModuleScienceAnimateGeneric.DMModuleScienceAnimateGeneric; 127 | if ((currentExperiment as IScienceDataContainer).GetScienceCount() == 0) 128 | { 129 | Log(currentExperiment.experimentID, ": Experiment has no data skiping transfer. Data found: ", (currentExperiment as IScienceDataContainer).GetScienceCount()); 130 | return false; 131 | } 132 | if (!currentExperiment.IsRerunnable()) 133 | { 134 | if (!_AutomatedScienceSamplerInstance.craftSettings.transferAllData) 135 | { 136 | Log(currentExperiment.experimentID, ": Experiment isn't rerunnable and transferAllData is turned off."); 137 | return false; 138 | } 139 | } 140 | if (!_AutomatedScienceSamplerInstance.craftSettings.dumpDuplicates) 141 | { 142 | foreach (var data in (currentExperiment as IScienceDataContainer).GetData()) 143 | { 144 | if (moduleScienceContainer.HasData(data)) 145 | { 146 | Log(currentExperiment.experimentID, ": Target already has experiment and dumping is disabled."); 147 | return false; 148 | } 149 | } 150 | } 151 | Log(currentExperiment.experimentID, ": We can transfer the science!"); 152 | return true; 153 | } 154 | 155 | public void Transfer(ModuleScienceExperiment baseExperiment, IScienceDataContainer moduleScienceContainer) 156 | { 157 | var currentExperiment = baseExperiment as DMModuleScienceAnimateGeneric.DMModuleScienceAnimateGeneric; 158 | Log(currentExperiment.experimentID, ": transfering"); 159 | moduleScienceContainer.StoreData(currentExperiment as DMModuleScienceAnimateGeneric.DMModuleScienceAnimateGeneric, _AutomatedScienceSamplerInstance.craftSettings.dumpDuplicates); 160 | } 161 | 162 | public List GetValidTypes() 163 | { 164 | var types = new List(); 165 | types.Add(typeof(DMModuleScienceAnimateGeneric.DMModuleScienceAnimateGeneric)); 166 | 167 | Utilities.LoopTroughAssemblies((type) => 168 | { 169 | if (type.IsClass && !type.IsAbstract && type.IsSubclassOf(typeof(DMModuleScienceAnimateGeneric.DMModuleScienceAnimateGeneric))) 170 | { 171 | types.Add(type); 172 | } 173 | }); 174 | return types; 175 | } 176 | private void Log(params object[] msg) 177 | { 178 | var debugStringBuilder = new StringBuilder(); 179 | foreach (var debugString in msg) 180 | { 181 | debugStringBuilder.Append(debugString.ToString()); 182 | } 183 | _AutomatedScienceSamplerInstance.Log("[DMagicModuleScienceAnimateGeneric]", debugStringBuilder); 184 | } 185 | } 186 | } -------------------------------------------------------------------------------- /source/Plugins/DMModuleScienceAnimateGeneric/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | [assembly: AssemblyTitle("AutomatedScienceSampler - DMModuleScienceAnimateGeneric Plugin")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("KerboKatz")] 11 | [assembly: AssemblyProduct("AutomatedScienceSampler - DMModuleScienceAnimateGeneric Plugin")] 12 | [assembly: AssemblyCopyright("")] 13 | [assembly: AssemblyTrademark("KerboKatz")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Setting ComVisible to false makes the types in this assembly not visible 17 | // to COM components. If you need to access a type in this assembly from 18 | // COM, set the ComVisible attribute to true on that type. 19 | [assembly: ComVisible(false)] 20 | 21 | // The following GUID is for the ID of the typelib if this project is exposed to COM 22 | [assembly: Guid("7480b6b1-155b-4457-9bc2-23184cefb70a")] 23 | 24 | // Version information for an assembly consists of the following four values: 25 | // 26 | // Major Version 27 | // Minor Version 28 | // Build Number 29 | // Revision 30 | // 31 | // You can specify all the values or you can default the Build and Revision Numbers 32 | // by using the '*' as shown below: 33 | // [assembly: AssemblyVersion("1.0.*")] 34 | [assembly: AssemblyVersion("1.3.5")] 35 | //[assembly: AssemblyFileVersion("0.26.1.0")] -------------------------------------------------------------------------------- /source/Plugins/DMagic Orbital Science/Activator.cs: -------------------------------------------------------------------------------- 1 | using DMagic; 2 | using DMagic.Part_Modules; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | 7 | namespace KerboKatz.ASS.DMOS 8 | { 9 | public class Activator : IScienceActivator 10 | { 11 | private AutomatedScienceSampler _AutomatedScienceSamplerInstance; 12 | 13 | AutomatedScienceSampler IScienceActivator.AutomatedScienceSampler 14 | { 15 | get { return _AutomatedScienceSamplerInstance; } 16 | set { _AutomatedScienceSamplerInstance = value; } 17 | } 18 | 19 | public bool CanRunExperiment(ModuleScienceExperiment baseExperiment, float currentScienceValue) 20 | { 21 | var currentExperiment = baseExperiment as DMModuleScienceAnimate; 22 | if (currentScienceValue < _AutomatedScienceSamplerInstance.craftSettings.threshold) 23 | { 24 | Log(currentExperiment.experimentID, ": Science value is less than cutoff threshold: ", currentScienceValue, "<", _AutomatedScienceSamplerInstance.craftSettings.threshold); 25 | return false; 26 | } 27 | if (!currentExperiment.rerunnable && !_AutomatedScienceSamplerInstance.craftSettings.oneTimeOnly) 28 | { 29 | Log(currentExperiment.experimentID, ": Runing rerunable experiments is disabled"); 30 | return false; 31 | } 32 | if (currentExperiment.Inoperable) 33 | { 34 | Log(currentExperiment.experimentID, ": Experiment is inoperable"); 35 | return false; 36 | } 37 | if (currentExperiment.Deployed) 38 | { 39 | Log(currentExperiment.experimentID, ": Experiment is deployed"); 40 | return false; 41 | } 42 | if (!currentExperiment.experiment.IsUnlocked()) 43 | { 44 | Log(currentExperiment.experimentID, ": Experiment is locked"); 45 | return false; 46 | } 47 | if (!string.IsNullOrEmpty(currentExperiment.animationName)) 48 | { 49 | var anim = currentExperiment.part.FindModelAnimators(currentExperiment.animationName)[0]; 50 | if (anim.isPlaying) 51 | { 52 | Log(currentExperiment.experimentID, ": Animation is playing"); 53 | return false; 54 | } 55 | } 56 | return DMAPI.experimentCanConduct(currentExperiment); 57 | } 58 | 59 | public void DeployExperiment(ModuleScienceExperiment baseExperiment) 60 | { 61 | var currentExperiment = baseExperiment as DMModuleScienceAnimate; 62 | DMAPI.deployDMExperiment(currentExperiment, _AutomatedScienceSamplerInstance.craftSettings.hideScienceDialog); 63 | } 64 | 65 | public ScienceSubject GetScienceSubject(ModuleScienceExperiment baseExperiment) 66 | { 67 | var currentExperiment = baseExperiment as DMModuleScienceAnimate; 68 | if (DMAPI.isAsteroidGrappled(baseExperiment)) 69 | { 70 | return DMAPI.getAsteroidSubject(currentExperiment); 71 | } 72 | else 73 | { 74 | ExperimentSituations situation = ScienceUtil.GetExperimentSituation(FlightGlobals.ActiveVessel); 75 | var biome = DMAPI.getBiome(baseExperiment, situation); 76 | if (biome == null) 77 | { 78 | Log("Biome is null."); 79 | return null; 80 | } 81 | var scienceSubject = ResearchAndDevelopment.GetExperimentSubject(ResearchAndDevelopment.GetExperiment(currentExperiment.experimentID), situation, FlightGlobals.currentMainBody, biome, ScienceUtil.GetBiomedisplayName(FlightGlobals.currentMainBody, biome)); 82 | Log(biome, "_", situation, "_", scienceSubject == null); 83 | return scienceSubject; 84 | } 85 | } 86 | 87 | public float GetScienceValue(ModuleScienceExperiment baseExperiment, Dictionary shipCotainsExperiments, ScienceSubject currentScienceSubject) 88 | { 89 | var currentExperiment = baseExperiment as DMModuleScienceAnimate; 90 | var scienceExperiment = ResearchAndDevelopment.GetExperiment(baseExperiment.experimentID); 91 | return Utilities.Science.GetScienceValue(shipCotainsExperiments, scienceExperiment, currentScienceSubject) * currentExperiment.totalScienceLevel; 92 | /*if (DMAPI.isAsteroidGrappled(currentExperiment)) 93 | { 94 | return Utilities.Science.GetScienceValue(shipCotainsExperiments, scienceExperiment, currentScienceSubject, null, GetNextScienceValue); 95 | } 96 | else 97 | { 98 | return Utilities.Science.GetScienceValue(shipCotainsExperiments, scienceExperiment, currentScienceSubject); 99 | }*/ 100 | } 101 | 102 | public bool CanReset(ModuleScienceExperiment baseExperiment) 103 | { 104 | var currentExperiment = baseExperiment as DMModuleScienceAnimate; 105 | if (!currentExperiment.Inoperable) 106 | { 107 | Log(currentExperiment.experimentID, ": Experiment isn't inoperable"); 108 | return false; 109 | } 110 | if (!currentExperiment.Deployed) 111 | { 112 | Log(currentExperiment.experimentID, ": Experiment isn't deployed!"); 113 | return false; 114 | } 115 | if ((currentExperiment as IScienceDataContainer).GetScienceCount() > 0) 116 | { 117 | Log(currentExperiment.experimentID, ": Experiment has data!"); 118 | return false; 119 | } 120 | if (!currentExperiment.resettable) 121 | { 122 | Log(currentExperiment.experimentID, ": Experiment isn't resetable"); 123 | return false; 124 | } 125 | bool hasScientist = false; 126 | foreach (var crew in FlightGlobals.ActiveVessel.GetVesselCrew()) 127 | { 128 | if (crew.trait == "Scientist") 129 | { 130 | hasScientist = true; 131 | break; 132 | } 133 | } 134 | if (!hasScientist) 135 | { 136 | Log(currentExperiment.experimentID, ": Vessel has no scientist"); 137 | return false; 138 | } 139 | return true; 140 | } 141 | 142 | public void Reset(ModuleScienceExperiment baseExperiment) 143 | { 144 | var currentExperiment = baseExperiment as DMModuleScienceAnimate; 145 | Log(currentExperiment.experimentID, ": Reseting experiment"); 146 | currentExperiment.ResetExperiment(); 147 | } 148 | 149 | public bool CanTransfer(ModuleScienceExperiment baseExperiment, IScienceDataContainer moduleScienceContainer) 150 | { 151 | var currentExperiment = baseExperiment as DMModuleScienceAnimate; 152 | if ((currentExperiment as IScienceDataContainer).GetScienceCount() == 0) 153 | { 154 | Log(currentExperiment.experimentID, ": Experiment has no data skiping transfer. Data found: ", (currentExperiment as IScienceDataContainer).GetScienceCount(), "_", currentExperiment.experimentNumber); 155 | return false; 156 | } 157 | if (!currentExperiment.IsRerunnable()) 158 | { 159 | if (!_AutomatedScienceSamplerInstance.craftSettings.transferAllData) 160 | { 161 | Log(currentExperiment.experimentID, ": Experiment isn't rerunnable and transferAllData is turned off."); 162 | return false; 163 | } 164 | } 165 | if (!_AutomatedScienceSamplerInstance.craftSettings.dumpDuplicates) 166 | { 167 | foreach (var data in (currentExperiment as IScienceDataContainer).GetData()) 168 | { 169 | if (moduleScienceContainer.HasData(data)) 170 | { 171 | Log(currentExperiment.experimentID, ": Target already has experiment and dumping is disabled."); 172 | return false; 173 | } 174 | } 175 | } 176 | Log(currentExperiment.experimentID, ": We can transfer the science!"); 177 | return true; 178 | } 179 | 180 | public void Transfer(ModuleScienceExperiment baseExperiment, IScienceDataContainer moduleScienceContainer) 181 | { 182 | var currentExperiment = baseExperiment as DMModuleScienceAnimate; 183 | Log(currentExperiment.experimentID, ": transfering"); 184 | moduleScienceContainer.StoreData(currentExperiment, _AutomatedScienceSamplerInstance.craftSettings.dumpDuplicates); 185 | } 186 | 187 | public List GetValidTypes() 188 | { 189 | var types = new List(); 190 | types.Add(typeof(DMModuleScienceAnimate)); 191 | 192 | Utilities.LoopTroughAssemblies((type) => 193 | { 194 | if (type.IsClass && !type.IsAbstract && type.IsSubclassOf(typeof(DMModuleScienceAnimate))) 195 | { 196 | types.Add(type); 197 | } 198 | }); 199 | return types; 200 | } 201 | private void Log(params object[] msg) 202 | { 203 | var debugStringBuilder = new StringBuilder(); 204 | foreach (var debugString in msg) 205 | { 206 | debugStringBuilder.Append(debugString.ToString()); 207 | } 208 | _AutomatedScienceSamplerInstance.Log("[DMagicOrbitalScience]", debugStringBuilder); 209 | } 210 | } 211 | } -------------------------------------------------------------------------------- /source/Plugins/DMagic Orbital Science/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | [assembly: AssemblyTitle("AutomatedScienceSampler - DMagic Orbital Science plugin")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("KerboKatz")] 11 | [assembly: AssemblyProduct("AutomatedScienceSampler - DMagic Orbital Science plugin")] 12 | [assembly: AssemblyCopyright("")] 13 | [assembly: AssemblyTrademark("KerboKatz")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Setting ComVisible to false makes the types in this assembly not visible 17 | // to COM components. If you need to access a type in this assembly from 18 | // COM, set the ComVisible attribute to true on that type. 19 | [assembly: ComVisible(false)] 20 | 21 | // The following GUID is for the ID of the typelib if this project is exposed to COM 22 | [assembly: Guid("bfb5e527-fcef-4014-9a0a-0d88f9462da3")] 23 | 24 | // Version information for an assembly consists of the following four values: 25 | // 26 | // Major Version 27 | // Minor Version 28 | // Build Number 29 | // Revision 30 | // 31 | // You can specify all the values or you can default the Build and Revision Numbers 32 | // by using the '*' as shown below: 33 | // [assembly: AssemblyVersion("1.0.*")] 34 | [assembly: AssemblyVersion("1.3.5")] 35 | //[assembly: AssemblyFileVersion("0.26.1.0")] -------------------------------------------------------------------------------- /source/Plugins/Station Science/Activator.cs: -------------------------------------------------------------------------------- 1 | using StationScience; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace KerboKatz.ASS.SS 7 | { 8 | internal class Activator : IScienceActivator 9 | { 10 | private AutomatedScienceSampler _AutomatedScienceSamplerInstance; 11 | 12 | AutomatedScienceSampler IScienceActivator.AutomatedScienceSampler 13 | { 14 | get { return _AutomatedScienceSamplerInstance; } 15 | set { _AutomatedScienceSamplerInstance = value; } 16 | } 17 | 18 | public bool CanRunExperiment(ModuleScienceExperiment baseExperiment, float currentScienceValue) 19 | { 20 | var currentExperiment = baseExperiment as StationExperiment; 21 | var isActive = currentExperiment.Events["StartExperiment"].active; 22 | if (isActive) 23 | { 24 | Log(currentExperiment.experimentID, ": StationExperiment didn't start yet! You might want to start it manually!"); 25 | return false; 26 | } 27 | if (StationExperiment.CheckBoring(FlightGlobals.ActiveVessel, false)) 28 | { 29 | Log(currentExperiment.experimentID, ": StationExperiment says this location is boring!"); 30 | return false; 31 | } 32 | if (!currentExperiment.Finished() && !isActive) 33 | { 34 | Log(currentExperiment.experimentID, ": StationExperiment isn't finished yet!"); 35 | return false; 36 | } 37 | if (!currentExperiment.experiment.IsAvailableWhile(ScienceUtil.GetExperimentSituation(FlightGlobals.ActiveVessel), FlightGlobals.currentMainBody))// 38 | { 39 | Log(currentExperiment.experimentID, ": Experiment isn't available in the current situation: ", ScienceUtil.GetExperimentSituation(FlightGlobals.ActiveVessel), "_", FlightGlobals.currentMainBody + "_", currentExperiment.experiment.situationMask); 40 | return false; 41 | } 42 | if (currentExperiment.Inoperable) 43 | { 44 | Log(currentExperiment.experimentID, ": Experiment is inoperable"); 45 | return false; 46 | } 47 | if (currentExperiment.Deployed) 48 | { 49 | Log(currentExperiment.experimentID, ": Experiment is deployed"); 50 | return false; 51 | } 52 | 53 | if (!currentExperiment.rerunnable && !_AutomatedScienceSamplerInstance.craftSettings.oneTimeOnly) 54 | { 55 | Log(currentExperiment.experimentID, ": Runing rerunable experiments is disabled"); 56 | return false; 57 | } 58 | if (currentScienceValue < _AutomatedScienceSamplerInstance.craftSettings.threshold) 59 | { 60 | Log(currentExperiment.experimentID, ": Science value is less than cutoff threshold: ", currentScienceValue, "<", _AutomatedScienceSamplerInstance.craftSettings.threshold); 61 | return false; 62 | } 63 | if (!currentExperiment.experiment.IsUnlocked()) 64 | { 65 | Log(currentExperiment.experimentID, ": Experiment is locked"); 66 | return false; 67 | } 68 | return true; 69 | } 70 | 71 | public void DeployExperiment(ModuleScienceExperiment baseExperiment) 72 | { 73 | var currentExperiment = baseExperiment as StationExperiment; 74 | if (_AutomatedScienceSamplerInstance.craftSettings.hideScienceDialog) 75 | { 76 | var stagingSetting = currentExperiment.useStaging; 77 | currentExperiment.useStaging = true;//work the way around the staging 78 | currentExperiment.OnActive();//run the experiment without causing the report to show up 79 | currentExperiment.useStaging = stagingSetting;//set the staging back 80 | } 81 | else 82 | { 83 | currentExperiment.DeployExperiment(); 84 | } 85 | } 86 | 87 | public ScienceSubject GetScienceSubject(ModuleScienceExperiment baseExperiment) 88 | { 89 | //experiment.BiomeIsRelevantWhile 90 | string biome = CurrentBiome(baseExperiment.experiment); 91 | return ResearchAndDevelopment.GetExperimentSubject(baseExperiment.experiment, ScienceUtil.GetExperimentSituation(FlightGlobals.ActiveVessel), FlightGlobals.currentMainBody, biome, ScienceUtil.GetBiomedisplayName(FlightGlobals.currentMainBody, biome)); 92 | } 93 | 94 | public float GetScienceValue(ModuleScienceExperiment baseExperiment, Dictionary shipCotainsExperiments, ScienceSubject currentScienceSubject) 95 | { 96 | return Utilities.Science.GetScienceValue(shipCotainsExperiments, baseExperiment.experiment, currentScienceSubject); 97 | } 98 | 99 | public bool CanReset(ModuleScienceExperiment baseExperiment) 100 | { 101 | if (!baseExperiment.Inoperable) 102 | { 103 | Log(baseExperiment.experimentID, ": Experiment isn't inoperable"); 104 | return false; 105 | } 106 | if (!baseExperiment.Deployed) 107 | { 108 | Log(baseExperiment.experimentID, ": Experiment isn't deployed!"); 109 | return false; 110 | } 111 | if (baseExperiment.GetScienceCount() > 0) 112 | { 113 | Log(baseExperiment.experimentID, ": Experiment has data!"); 114 | return false; 115 | } 116 | 117 | if (!baseExperiment.resettable) 118 | { 119 | Log(baseExperiment.experimentID, ": Experiment isn't resetable"); 120 | return false; 121 | } 122 | bool hasScientist = false; 123 | foreach (var crew in FlightGlobals.ActiveVessel.GetVesselCrew()) 124 | { 125 | if (crew.trait == "Scientist") 126 | { 127 | hasScientist = true; 128 | break; 129 | } 130 | } 131 | if (!hasScientist) 132 | { 133 | Log(baseExperiment.experimentID, ": Vessel has no scientist"); 134 | return false; 135 | } 136 | Log(baseExperiment.experimentID, ": Can reset"); 137 | return true; 138 | } 139 | 140 | public void Reset(ModuleScienceExperiment baseExperiment) 141 | { 142 | Log(baseExperiment.experimentID, ": Reseting experiment"); 143 | baseExperiment.ResetExperiment(); 144 | } 145 | 146 | public bool CanTransfer(ModuleScienceExperiment baseExperiment, IScienceDataContainer moduleScienceContainer) 147 | { 148 | if (baseExperiment.GetScienceCount() == 0) 149 | { 150 | Log(baseExperiment.experimentID, ": Experiment has no data skiping transfer ", baseExperiment.GetScienceCount()); 151 | return false; 152 | } 153 | if (!baseExperiment.IsRerunnable()) 154 | { 155 | if (!_AutomatedScienceSamplerInstance.craftSettings.transferAllData) 156 | { 157 | Log(baseExperiment.experimentID, ": Experiment isn't rerunnable and transferAllData is turned off."); 158 | return false; 159 | } 160 | } 161 | if (!_AutomatedScienceSamplerInstance.craftSettings.dumpDuplicates) 162 | { 163 | foreach (var data in baseExperiment.GetData()) 164 | { 165 | if (moduleScienceContainer.HasData(data)) 166 | { 167 | Log(baseExperiment.experimentID, ": Target already has experiment and dumping is disabled."); 168 | return false; 169 | } 170 | } 171 | } 172 | Log(baseExperiment.experimentID, ": We can transfer the science!"); 173 | return true; 174 | } 175 | 176 | public void Transfer(ModuleScienceExperiment baseExperiment, IScienceDataContainer moduleScienceContainer) 177 | { 178 | Log(baseExperiment.experimentID, ": transfering"); 179 | moduleScienceContainer.StoreData(baseExperiment , _AutomatedScienceSamplerInstance.craftSettings.dumpDuplicates); 180 | } 181 | 182 | private string CurrentBiome(ScienceExperiment baseExperiment) 183 | { 184 | if (!baseExperiment.BiomeIsRelevantWhile(ScienceUtil.GetExperimentSituation(FlightGlobals.ActiveVessel))) 185 | return string.Empty; 186 | var currentVessel = FlightGlobals.ActiveVessel; 187 | var currentBody = FlightGlobals.currentMainBody; 188 | if (currentVessel != null && currentBody != null) 189 | { 190 | if (!string.IsNullOrEmpty(currentVessel.landedAt)) 191 | { 192 | //big thanks to xEvilReeperx for this one. 193 | return Vessel.GetLandedAtString(currentVessel.landedAt); 194 | } 195 | else 196 | { 197 | return ScienceUtil.GetExperimentBiome(currentBody, currentVessel.latitude, currentVessel.longitude); 198 | } 199 | } 200 | else 201 | { 202 | Log("currentVessel && currentBody == null"); 203 | } 204 | return string.Empty; 205 | } 206 | 207 | public List GetValidTypes() 208 | { 209 | var types = new List(); 210 | types.Add(typeof(StationExperiment)); 211 | 212 | Utilities.LoopTroughAssemblies((type) => 213 | { 214 | if (type.IsClass && !type.IsAbstract && type.IsSubclassOf(typeof(StationExperiment))) 215 | { 216 | types.Add(type); 217 | } 218 | }); 219 | return types; 220 | } 221 | private void Log(params object[] msg) 222 | { 223 | var debugStringBuilder = new StringBuilder(); 224 | foreach (var debugString in msg) 225 | { 226 | debugStringBuilder.Append(debugString.ToString()); 227 | } 228 | _AutomatedScienceSamplerInstance.Log("[StationScience]", debugStringBuilder); 229 | } 230 | } 231 | } -------------------------------------------------------------------------------- /source/Plugins/Station Science/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | [assembly: AssemblyTitle("AutomatedScienceSampler - Station Science plugin")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("KerboKatz")] 11 | [assembly: AssemblyProduct("AutomatedScienceSampler - Station Science plugin")] 12 | [assembly: AssemblyCopyright("")] 13 | [assembly: AssemblyTrademark("KerboKatz")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Setting ComVisible to false makes the types in this assembly not visible 17 | // to COM components. If you need to access a type in this assembly from 18 | // COM, set the ComVisible attribute to true on that type. 19 | [assembly: ComVisible(false)] 20 | 21 | // The following GUID is for the ID of the typelib if this project is exposed to COM 22 | [assembly: Guid("7dc5e719-8a85-4bfd-b27b-7f95e99849e5")] 23 | 24 | // Version information for an assembly consists of the following four values: 25 | // 26 | // Major Version 27 | // Minor Version 28 | // Build Number 29 | // Revision 30 | // 31 | // You can specify all the values or you can default the Build and Revision Numbers 32 | // by using the '*' as shown below: 33 | // [assembly: AssemblyVersion("1.0.*")] 34 | [assembly: AssemblyVersion("1.3.5")] 35 | //[assembly: AssemblyFileVersion("0.26.1.0")] --------------------------------------------------------------------------------