From c7397fae0a215d66e05a2f66d8f2c0b2607f3e7a Mon Sep 17 00:00:00 2001 From: DMagic Date: Tue, 13 Jun 2017 09:34:59 -0400 Subject: [PATCH 1/5] Version --- GameData/DMagicOrbitalScience/DMagicOrbitalScience.version | 4 ++-- Source/Properties/AssemblyInfo.cs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/GameData/DMagicOrbitalScience/DMagicOrbitalScience.version b/GameData/DMagicOrbitalScience/DMagicOrbitalScience.version index 8041b40..cd40cbf 100644 --- a/GameData/DMagicOrbitalScience/DMagicOrbitalScience.version +++ b/GameData/DMagicOrbitalScience/DMagicOrbitalScience.version @@ -1,7 +1,7 @@ { "NAME":"DMagic Orbital Science", "URL":"https://raw.githubusercontent.com/DMagic1/Orbital-Science/master/GameData/DMagicOrbitalScience/DMagicOrbitalScience.version", - "DOWNLOAD":"https://spacedock.info/mod/128/DMagic%20Orbital%20Science/download/1.3.9", + "DOWNLOAD":"https://spacedock.info/mod/128/DMagic%20Orbital%20Science", "GITHUB":{ "USERNAME":"DMagic1", "REPOSITORY":"Orbital-Science", @@ -11,7 +11,7 @@ "MAJOR":1, "MINOR":3, "PATCH":0, - "BUILD":9 + "BUILD":10 }, "KSP_VERSION":{ "MAJOR":1, diff --git a/Source/Properties/AssemblyInfo.cs b/Source/Properties/AssemblyInfo.cs index 34b5397..16606bb 100644 --- a/Source/Properties/AssemblyInfo.cs +++ b/Source/Properties/AssemblyInfo.cs @@ -19,7 +19,7 @@ // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("5428988e-53a6-4d8e-8af4-014572513e22")] -[assembly: AssemblyVersion("1.3.0.9")] -[assembly: AssemblyFileVersion("1.3.0.9")] -[assembly: AssemblyInformationalVersion("v1.3.9")] +[assembly: AssemblyVersion("1.3.0.10")] +[assembly: AssemblyFileVersion("1.3.0.10")] +[assembly: AssemblyInformationalVersion("v1.3.10")] [assembly: KSPAssembly("DMagic", 1, 4)] From 5c55170db262acf1fa59ae1ba1ca7ab375c611e6 Mon Sep 17 00:00:00 2001 From: DMagic Date: Tue, 13 Jun 2017 09:35:16 -0400 Subject: [PATCH 2/5] Fix errors in ground detection --- Source/Part Modules/DMSeismicHammer.cs | 35 ++++++++++---------------- Source/Part Modules/DMXRayDiffract.cs | 30 +++++++++------------- 2 files changed, 25 insertions(+), 40 deletions(-) diff --git a/Source/Part Modules/DMSeismicHammer.cs b/Source/Part Modules/DMSeismicHammer.cs index 61a7be6..660f4f2 100644 --- a/Source/Part Modules/DMSeismicHammer.cs +++ b/Source/Part Modules/DMSeismicHammer.cs @@ -707,38 +707,29 @@ private bool rayImpact(bool b, Transform t, float s, float max, out float d) Vector3 p = t.position; Ray r = new Ray(p, -1f * t.forward); d = 0f; + int layer = 32769; - Physics.Raycast(r, out hit, max * s); + Physics.Raycast(r, out hit, max * s, layer); if (hit.collider != null) { if (b) { - Part a = Part.FromGO(hit.transform.gameObject) ?? hit.transform.gameObject.GetComponentInParent(); - - if (a != null) - { - if (a.Modules.Contains("ModuleAsteroid")) - { - d = hit.distance; - return true; - } - } - } - else - { - Transform hitT = hit.collider.transform; - int i = 0; //Just to prevent this from getting stuck in a loop - while (hitT != null && i < 30) + if (hit.collider.gameObject.layer == 0) { - if (hitT == vessel.mainBody.bodyTransform) + Part a = Part.FromGO(hit.transform.gameObject) ?? hit.transform.gameObject.GetComponentInParent(); + + if (a != null) { - d = hit.distance; - return true; + if (a.Modules.Contains("ModuleAsteroid")) + { + d = hit.distance; + return true; + } } - hitT = hitT.parent; - i++; } } + else if (hit.collider.gameObject.layer == 15) + return true; } return false; } diff --git a/Source/Part Modules/DMXRayDiffract.cs b/Source/Part Modules/DMXRayDiffract.cs index a0f3b91..8e85cdc 100644 --- a/Source/Part Modules/DMXRayDiffract.cs +++ b/Source/Part Modules/DMXRayDiffract.cs @@ -70,32 +70,26 @@ private bool drillImpact(bool b) Vector3 p = t.position; Ray r = new Ray(p, -1f * t.forward); float scale = part.rescaleFactor * drillLength * modelTransform.localScale.y; + int layer = 32769; - Physics.Raycast(r, out hit, drillLength * scale); + Physics.Raycast(r, out hit, drillLength * scale, layer); if (hit.collider != null) { if (b) { - Part a = Part.FromGO(hit.transform.gameObject) ?? hit.transform.gameObject.GetComponentInParent(); - - if (a != null) + if (hit.collider.gameObject.layer == 0) { - if (a.Modules.Contains("ModuleAsteroid")) - return true; - } - } - else - { - Transform hitT = hit.collider.transform; - int i = 0; //Just to prevent this from getting stuck in a loop - while (hitT != null && i < 200) - { - if (hitT == vessel.mainBody.bodyTransform) - return true; - hitT = hitT.parent; - i++; + Part a = Part.FromGO(hit.transform.gameObject) ?? hit.transform.gameObject.GetComponentInParent(); + + if (a != null) + { + if (a.Modules.Contains("ModuleAsteroid")) + return true; + } } } + else if (hit.collider.gameObject.layer == 15) + return true; } return false; } From 58c9326599f12608a15cc2b816b56a69e8a6ac44 Mon Sep 17 00:00:00 2001 From: DMagic Date: Tue, 13 Jun 2017 09:35:40 -0400 Subject: [PATCH 3/5] Add option to disable science functions or antenna functions --- Source/Part Modules/DMSIGINT.cs | 42 +++++++++++++++++++++++---- Source/Part Modules/DMSoilMoisture.cs | 36 +++++++++++++++++++++-- 2 files changed, 69 insertions(+), 9 deletions(-) diff --git a/Source/Part Modules/DMSIGINT.cs b/Source/Part Modules/DMSIGINT.cs index 56ff724..fde6b61 100644 --- a/Source/Part Modules/DMSIGINT.cs +++ b/Source/Part Modules/DMSIGINT.cs @@ -47,6 +47,10 @@ public class DMSIGINT : DMBreakablePart, IDMSurvey, IScalarModule public bool allowTransmission = true; [KSPField(guiActive = true, guiName = "Science Transmission")] public string scienceTransmission = "Enabled"; + [KSPField] + public bool noScience = false; + [KSPField] + public bool noAntenna = false; private readonly string[] dishTransformNames = new string[7] { "dish_Armature.000", "dish_Armature.001", "dish_Armature.002", "dish_Armature.003", "focalColumn", "dishCenter", "focalHead" }; private readonly string[] dishMeshNames = new string[7] { "dish_Mesh.000", "dish_Mesh.001", "dish_Mesh.002", "dish_Mesh.003", "focalColumn", "dishCenter", "focalHead" }; @@ -74,7 +78,7 @@ public override void OnStart(PartModule.StartState state) base.OnStart(state); - if (scienceExp != null) + if (scienceExp != null && !noScience) { sitMask = (int)scienceExp.situationMask; bioMask = sitMask; @@ -84,8 +88,22 @@ public override void OnStart(PartModule.StartState state) scalarStep = 1 / anim[animationName].length; Events["fixPart"].guiName = "Fix Dish"; + Fields["scienceTransmission"].guiActive = !noAntenna; + Events["ToggleScienceTransmission"].active = !noAntenna; Events["ToggleScienceTransmission"].guiName = allowTransmission ? "Disable Science Transmission" : "Enable Science Transmission"; - scienceTransmission = allowTransmission ? "Enabled" : "Disabled"; + scienceTransmission = allowTransmission && !noAntenna ? "Enabled" : "Disabled"; + + if (noScience) + { + Actions["DeployAction"].active = false; + Events["CollectDataExternalEvent"].active = false; + Events["ResetExperimentExternal"].active = false; + Events["ResetExperiment"].active = false; + Events["DeployExperiment"].active = false; + Events["TransferDataEvent"].active = false; + Events["CleanUpExperimentExternal"].active = false; + Deployed = true; + } if (useFairings) { @@ -357,7 +375,7 @@ public bool CanMove { get { - if (!allowTransmission) + if (!allowTransmission || noAntenna) return false; if (anim.IsPlaying(animationName)) @@ -377,7 +395,7 @@ public float GetScalar { get { - if (!allowTransmission) + if (!allowTransmission || noAntenna) return 0; if (broken) @@ -467,9 +485,21 @@ public string ScalarModuleID get { return "dmsigint"; } } - public override void OnUpdate() + protected override void Update() { - base.OnUpdate(); + base.Update(); + + if (noScience) + { + Events["CollectDataExternalEvent"].active = false; + Events["ResetExperimentExternal"].active = false; + Events["ResetExperiment"].active = false; + Events["DeployExperiment"].active = false; + Events["DeployExperimentExternal"].active = false; + Events["TransferDataEvent"].active = false; + Events["CleanUpExperimentExternal"].active = false; + Deployed = true; + } if (!moving) return; diff --git a/Source/Part Modules/DMSoilMoisture.cs b/Source/Part Modules/DMSoilMoisture.cs index bf8280e..0d1476b 100644 --- a/Source/Part Modules/DMSoilMoisture.cs +++ b/Source/Part Modules/DMSoilMoisture.cs @@ -40,6 +40,10 @@ class DMSoilMoisture: DMModuleScienceAnimate, IScalarModule public bool allowTransmission = true; [KSPField(guiActive = true, guiName = "Science Transmission")] public string scienceTransmission = "Enabled"; + [KSPField] + public bool noScience = false; + [KSPField] + public bool noAntenna = false; private bool fullyDeployed = false; private bool rotating = false; @@ -71,8 +75,22 @@ public override void OnStart(PartModule.StartState state) scalar = 1; } + Fields["scienceTransmission"].guiActive = !noAntenna; + Events["ToggleScienceTransmission"].active = !noAntenna; Events["ToggleScienceTransmission"].guiName = allowTransmission ? "Disable Science Transmission" : "Enable Science Transmission"; - scienceTransmission = allowTransmission ? "Enabled" : "Disabled"; + scienceTransmission = allowTransmission && !noAntenna ? "Enabled" : "Disabled"; + + if (noScience) + { + Actions["DeployAction"].active = false; + Events["CollectDataExternalEvent"].active = false; + Events["ResetExperimentExternal"].active = false; + Events["ResetExperiment"].active = false; + Events["DeployExperiment"].active = false; + Events["TransferDataEvent"].active = false; + Events["CleanUpExperimentExternal"].active = false; + Deployed = true; + } if (anim != null && anim[animationName] != null) scalarStep = 1 / anim[animationName].length; @@ -84,6 +102,18 @@ protected override void Update() if (HighLogic.LoadedSceneIsFlight) { + if (noScience) + { + Events["CollectDataExternalEvent"].active = false; + Events["ResetExperimentExternal"].active = false; + Events["ResetExperiment"].active = false; + Events["DeployExperiment"].active = false; + Events["DeployExperimentExternal"].active = false; + Events["TransferDataEvent"].active = false; + Events["CleanUpExperimentExternal"].active = false; + Deployed = true; + } + if (IsDeployed && fullyDeployed) { rotating = true; @@ -190,7 +220,7 @@ public bool CanMove { get { - if (!allowTransmission) + if (!allowTransmission || noAntenna) return false; if (anim.IsPlaying(animationName)) @@ -210,7 +240,7 @@ public float GetScalar { get { - if (!allowTransmission) + if (!allowTransmission || noAntenna) return 0; return scalar; From fb3df428da2bdaae3b9e783caa93dbd571aa504c Mon Sep 17 00:00:00 2001 From: DMagic Date: Tue, 13 Jun 2017 09:35:49 -0400 Subject: [PATCH 4/5] Check for null experiment --- Source/Part Modules/DMModuleScienceAnimate.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Source/Part Modules/DMModuleScienceAnimate.cs b/Source/Part Modules/DMModuleScienceAnimate.cs index ffefa2a..3d0d7e4 100644 --- a/Source/Part Modules/DMModuleScienceAnimate.cs +++ b/Source/Part Modules/DMModuleScienceAnimate.cs @@ -369,7 +369,7 @@ private void setup() enviroList = this.part.FindModulesImplementing(); if (waitForAnimationTime == -1 && animSpeed != 0) waitForAnimationTime = anim[animationName].length / animSpeed; - if (experimentID != null) + if (!string.IsNullOrEmpty(experimentID)) { scienceExp = ResearchAndDevelopment.GetExperiment(experimentID); if (scienceExp != null) @@ -1017,6 +1017,12 @@ public virtual bool canConduct() failMessage = customFailMessage; return false; } + else if (scienceExp == null) + { + failMessage = "Error: Science Experiment Definition Invalid"; + Debug.LogError("[DMOS] Something Went Wrong Here; Null Experiment Returned; Please Report This On The KSP Forum With Output.log Data"); + return false; + } else if (scienceExp.requireAtmosphere && !vessel.mainBody.atmosphere) { failMessage = customFailMessage; From 5302c2866c48220974cf9b0832fda085cb70cc50 Mon Sep 17 00:00:00 2001 From: DMagic Date: Tue, 13 Jun 2017 09:35:55 -0400 Subject: [PATCH 5/5] Changes --- GameData/DMagicOrbitalScience/Change Log.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/GameData/DMagicOrbitalScience/Change Log.txt b/GameData/DMagicOrbitalScience/Change Log.txt index 1bab830..1840f26 100644 --- a/GameData/DMagicOrbitalScience/Change Log.txt +++ b/GameData/DMagicOrbitalScience/Change Log.txt @@ -1,4 +1,9 @@ -v1.3.9 +v1.3.10 +- Fix error in ground detection for XRay and Seismic experiments + +- Add options to disable the science functions or antenna functions for SIGINT and Soil Moisture + +v1.3.9 - Updated for KSP 1.3 - Fix several bugs with SIGINT and Soil Moisture antenna usage