diff --git a/GameData/DMagicOrbitalScience/Change Log.txt b/GameData/DMagicOrbitalScience/Change Log.txt index 6daa792..62adc04 100644 --- a/GameData/DMagicOrbitalScience/Change Log.txt +++ b/GameData/DMagicOrbitalScience/Change Log.txt @@ -1,15 +1,30 @@ +v1.2.3 +- Updated for KSP 1.1 final release + +v1.2.2 +- Updated for KSP 1.1.1215 + +- Fix SIGINT size issues +- Add empty transforms in recon cameras for TST usage +- Fix some issues with science labs + +v1.2.1 +- Updated for KSP 1.1.1183 + +- Broken SIGINT dish no longer able to collect science + v1.2 -- Added three new parts based on orbital recconnaisance satellites +- Added three new parts based on orbital reconnaissance satellites - All parts have pseudo-biome support; northern and southern hemispheres - Each part conducts an anomaly scan of the planet; used for anomaly contracts and the anomaly instrument - Single-Camera small recon satellite - 1.25m telescope - - Two film cannisters + - Two film canisters - Two-camera stereo recon satellite - 2.5m telescope - - Four film cannisters + - Four film canisters - Radio signals intelligence dish - 2.5m instrument; expands to 3m in the center @@ -35,7 +50,7 @@ v1.2 - Seismic impact hammer no longer makes a minimum distance check - Impact hammer collider removed; no longer a threat of catapulting your vessel - Seismic sensor pod crash tolerance increased; decouple strength lowered - - Seismic sensor pod cose, mass and size reduced + - Seismic sensor pod cost, mass and size reduced - Seismic settings found in GameData/DMagicOrbitalScience/Resources/DMSeismicSettings.cfg - Fix scaling issues for all parts diff --git a/GameData/DMagicOrbitalScience/DMagicOrbitalScience.version b/GameData/DMagicOrbitalScience/DMagicOrbitalScience.version index 47d2c04..6e394b1 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.2", + "URL":"https://raw.githubusercontent.com/DMagic1/Orbital-Science/dev/GameData/DMagicOrbitalScience/DMagicOrbitalScience.version", + "DOWNLOAD":"https://spacedock.info/mod/128/DMagic%20Orbital%20Science/download/1.2.3", "GITHUB":{ "USERNAME":"DMagic1", "REPOSITORY":"Orbital-Science", @@ -10,22 +10,22 @@ "VERSION":{ "MAJOR":1, "MINOR":2, - "PATCH":0, + "PATCH":3, "BUILD":0 }, "KSP_VERSION":{ "MAJOR":1, - "MINOR":0, - "PATCH":5 + "MINOR":1, + "PATCH":0 }, "KSP_VERSION_MIN":{ "MAJOR":1, - "MINOR":0, - "PATCH":5 + "MINOR":1, + "PATCH":0 }, "KSP_VERSION_MAX":{ "MAJOR":1, - "MINOR":0, - "PATCH":5 + "MINOR":1, + "PATCH":0 } } diff --git a/GameData/DMagicOrbitalScience/Installation ReadMe.txt b/GameData/DMagicOrbitalScience/Installation ReadMe.txt index 1809950..e5a651d 100644 --- a/GameData/DMagicOrbitalScience/Installation ReadMe.txt +++ b/GameData/DMagicOrbitalScience/Installation ReadMe.txt @@ -1,4 +1,4 @@ -Version 1.2 +Version 1.2.3 KSP Forum thread: http://forum.kerbalspaceprogram.com/index.php?/topic/59009-1 Installation: diff --git a/GameData/DMagicOrbitalScience/OversizeScience/LargeRecon.cfg b/GameData/DMagicOrbitalScience/OversizeScience/LargeRecon.cfg index e265be6..3fb0691 100644 --- a/GameData/DMagicOrbitalScience/OversizeScience/LargeRecon.cfg +++ b/GameData/DMagicOrbitalScience/OversizeScience/LargeRecon.cfg @@ -57,6 +57,8 @@ MODULE animationName = reconDeploy loopingAnimName = scopes + + openDoorsOnly = false filmCannisterName = cannister diff --git a/GameData/DMagicOrbitalScience/OversizeScience/LargeRecon.mu b/GameData/DMagicOrbitalScience/OversizeScience/LargeRecon.mu index 32c993a..bf7c22b 100644 Binary files a/GameData/DMagicOrbitalScience/OversizeScience/LargeRecon.mu and b/GameData/DMagicOrbitalScience/OversizeScience/LargeRecon.mu differ diff --git a/GameData/DMagicOrbitalScience/OversizeScience/SIGINT.cfg b/GameData/DMagicOrbitalScience/OversizeScience/SIGINT.cfg index 95d8a91..6fdc67e 100644 --- a/GameData/DMagicOrbitalScience/OversizeScience/SIGINT.cfg +++ b/GameData/DMagicOrbitalScience/OversizeScience/SIGINT.cfg @@ -79,8 +79,8 @@ MODULE startEventGUIName = Deploy Dish showStartEvent = true endEventGUIName = Retract Dish - showEndEvent = true - showEditorEvents = false + showEndEvent = false + showEditorEvents = true showToggleEvent = false toggleEventGUIName = Toggle Dish diff --git a/GameData/DMagicOrbitalScience/OversizeScience/SIGINT.mu b/GameData/DMagicOrbitalScience/OversizeScience/SIGINT.mu index 35365ce..145f600 100644 Binary files a/GameData/DMagicOrbitalScience/OversizeScience/SIGINT.mu and b/GameData/DMagicOrbitalScience/OversizeScience/SIGINT.mu differ diff --git a/GameData/DMagicOrbitalScience/OversizeScience/SmallRecon.cfg b/GameData/DMagicOrbitalScience/OversizeScience/SmallRecon.cfg index 5f03db3..eb2a2af 100644 --- a/GameData/DMagicOrbitalScience/OversizeScience/SmallRecon.cfg +++ b/GameData/DMagicOrbitalScience/OversizeScience/SmallRecon.cfg @@ -57,6 +57,8 @@ MODULE animationName = reconDeploy loopingAnimName = scope + + openDoorsOnly = false filmCannisterName = cannister diff --git a/GameData/DMagicOrbitalScience/OversizeScience/SmallRecon.mu b/GameData/DMagicOrbitalScience/OversizeScience/SmallRecon.mu index e6feec3..f636b95 100644 Binary files a/GameData/DMagicOrbitalScience/OversizeScience/SmallRecon.mu and b/GameData/DMagicOrbitalScience/OversizeScience/SmallRecon.mu differ diff --git a/Source/Contracts/DMMagneticSurveyContract.cs b/Source/Contracts/DMMagneticSurveyContract.cs index 57e3a45..edac1a3 100644 --- a/Source/Contracts/DMMagneticSurveyContract.cs +++ b/Source/Contracts/DMMagneticSurveyContract.cs @@ -245,7 +245,7 @@ protected override bool Generate() this.agent = AgentList.Instance.GetAgentRandom(); base.SetExpiry(DMContractDefs.DMMagnetic.Expire.MinimumExpireDays, DMContractDefs.DMMagnetic.Expire.MaximumExpireDays); - base.SetDeadlineDays((float)(time / KSPUtil.KerbinDay) * DMContractDefs.DMMagnetic.Expire.DeadlineModifier * (this.GetDestinationWeight(body) / 1.8f) * primaryModifier, null); + base.SetDeadlineDays((float)(time / ((KSPUtil.DefaultDateTimeFormatter)KSPUtil.dateTimeFormatter).KerbinDay) * DMContractDefs.DMMagnetic.Expire.DeadlineModifier * (this.GetDestinationWeight(body) / 1.8f) * primaryModifier, null); base.SetReputation(DMContractDefs.DMMagnetic.Reputation.BaseReward * Mod, DMContractDefs.DMMagnetic.Reputation.BaseFailure * Mod, null); base.SetFunds(DMContractDefs.DMMagnetic.Funds.BaseAdvance * Mod, DMContractDefs.DMMagnetic.Funds.BaseReward * Mod, DMContractDefs.DMMagnetic.Funds.BaseFailure * Mod, body); base.SetScience(DMContractDefs.DMMagnetic.Science.BaseReward * Mod, body); diff --git a/Source/Contracts/DMReconContract.cs b/Source/Contracts/DMReconContract.cs index e0768c7..4f52595 100644 --- a/Source/Contracts/DMReconContract.cs +++ b/Source/Contracts/DMReconContract.cs @@ -270,7 +270,7 @@ protected override bool Generate() this.agent = AgentList.Instance.GetAgentRandom(); base.SetExpiry(DMContractDefs.DMRecon.Expire.MinimumExpireDays, DMContractDefs.DMRecon.Expire.MaximumExpireDays); - base.SetDeadlineDays((float)(time / KSPUtil.KerbinDay) * DMContractDefs.DMRecon.Expire.DeadlineModifier * (this.GetDestinationWeight(body) / 1.4f) * primaryModifier, null); + base.SetDeadlineDays((float)(time / ((KSPUtil.DefaultDateTimeFormatter)KSPUtil.dateTimeFormatter).KerbinDay) * DMContractDefs.DMRecon.Expire.DeadlineModifier * (this.GetDestinationWeight(body) / 1.4f) * primaryModifier, null); base.SetReputation(DMContractDefs.DMRecon.Reputation.BaseReward * Mod, DMContractDefs.DMRecon.Reputation.BaseFailure * Mod, null); base.SetFunds(DMContractDefs.DMRecon.Funds.BaseAdvance * Mod, DMContractDefs.DMRecon.Funds.BaseReward * Mod, DMContractDefs.DMRecon.Funds.BaseFailure * Mod, body); base.SetScience(DMContractDefs.DMRecon.Science.BaseReward * Mod, body); diff --git a/Source/DMConfigLoader.cs b/Source/DMConfigLoader.cs index 63504a5..5ab70ec 100644 --- a/Source/DMConfigLoader.cs +++ b/Source/DMConfigLoader.cs @@ -54,7 +54,6 @@ private void Start() seismicLoad(); configLoad(); hackWaypointIcons(); - fixPartIcons(); loaded = true; } diff --git a/Source/DMSeismicHandler.cs b/Source/DMSeismicHandler.cs index bf16c61..de7c68e 100644 --- a/Source/DMSeismicHandler.cs +++ b/Source/DMSeismicHandler.cs @@ -64,7 +64,6 @@ public static DMSeismicHandler Instance private Dictionary hammers = new Dictionary(); private static string bodyNameFixed = "Eeloo"; - private const string potato = "PotatoRoid"; private void Start() { @@ -403,7 +402,7 @@ public static ScienceData makeData(DMSeismometerValues sensor, float score, Scie sub.title = exp.experimentTitle + string.Format(" from {0}'s {1}", body.theName, biome); } - return new ScienceData(science, 1f, 1f, sub.id, sub.title, false, sensor.ID); + return new ScienceData(science, 1f, v.VesselValues.ScienceReturn.value, sub.id, sub.title, false, sensor.ID); } private static void registerDMScience(DMAsteroidScience newAst, ScienceExperiment exp, ScienceSubject sub) diff --git a/Source/DMUtils.cs b/Source/DMUtils.cs index fb6cf49..b3b6954 100644 --- a/Source/DMUtils.cs +++ b/Source/DMUtils.cs @@ -293,9 +293,9 @@ internal static double bearing(double lat1, double lon1, double lat2, double lon internal static double timeInDays(double D) { if (GameSettings.KERBIN_TIME) - D /= KSPUtil.KerbinDay; + D /= ((KSPUtil.DefaultDateTimeFormatter)KSPUtil.dateTimeFormatter).KerbinDay; else - D /= KSPUtil.EarthDay; + D /= ((KSPUtil.DefaultDateTimeFormatter)KSPUtil.dateTimeFormatter).EarthDay; return D; } diff --git a/Source/DMagicOrbital.csproj b/Source/DMagicOrbital.csproj index dafe7e0..a403a11 100644 --- a/Source/DMagicOrbital.csproj +++ b/Source/DMagicOrbital.csproj @@ -39,12 +39,24 @@ - ..\..\KSP Dev\Kerbal Space Program\KSP_Data\Managed\Assembly-CSharp.dll + ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program\KSP_x64_Data\Managed\Assembly-CSharp.dll + False + + + ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program\KSP_x64_Data\Managed\Assembly-CSharp-firstpass.dll + False + + + ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program\KSP_x64_Data\Managed\KSPUtil.dll False - ..\..\KSP Dev\Kerbal Space Program\KSP_Data\Managed\UnityEngine.dll + ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program\KSP_x64_Data\Managed\UnityEngine.dll + False + + + ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program\KSP_x64_Data\Managed\UnityEngine.UI.dll False diff --git a/Source/Parameters/DMPartRequestParameter.cs b/Source/Parameters/DMPartRequestParameter.cs index 10f7e2c..3bb097a 100644 --- a/Source/Parameters/DMPartRequestParameter.cs +++ b/Source/Parameters/DMPartRequestParameter.cs @@ -291,7 +291,7 @@ private Waypoint setupNewWaypoint(Vessel v) wp.altitude = 0; wp.index = 0; wp.id = "dmVessel"; - wp.size = new Vector2(32, 32); + wp.iconSize = 32; wp.seed = SystemUtilities.SuperSeed(this.Root); wp.isOnSurface = false; wp.isNavigatable = false; diff --git a/Source/Parameters/DMSpecificOrbitParameter.cs b/Source/Parameters/DMSpecificOrbitParameter.cs index a7750d9..261cbbd 100644 --- a/Source/Parameters/DMSpecificOrbitParameter.cs +++ b/Source/Parameters/DMSpecificOrbitParameter.cs @@ -49,6 +49,7 @@ public class DMSpecificOrbitParameter : SpecificOrbitParameter private bool orbitLoaded; private bool orbitTested; private DMLongOrbitParameter root; + private Orbit KSCOrbit = null; public DMSpecificOrbitParameter() { } @@ -66,23 +67,14 @@ public DMSpecificOrbitParameter(OrbitType orbitType, double inclination, double deviation = deviationWindow; root = r; disableOnStateChange = false; - setupOrbit(); - testOrbit(); } - private void setupOrbit() + private void setupOrbit(bool ksc) { - orbitDriver = new OrbitDriver(); - orbitDriver.orbit = new Orbit(); - orbitDriver.orbit.referenceBody = body; - orbitDriver.orbit.inclination = inc; - orbitDriver.orbit.eccentricity = ecc; - orbitDriver.orbit.argumentOfPeriapsis = aop; - orbitDriver.orbit.semiMajorAxis = sma; - orbitDriver.orbit.LAN = lan; - orbitDriver.orbit.meanAnomalyAtEpoch = mae; - orbitDriver.orbit.epoch = epo; - orbitDriver.orbit.Init(); + if (ksc) + KSCOrbit = new Orbit(inc, ecc, sma, lan, aop, mae, epo, body); + else + orbitRenderer = ContractOrbitRenderer.Setup(Root, new Orbit(inc, ecc, sma, lan, aop, mae, epo, body)); orbitLoaded = true; } @@ -97,17 +89,29 @@ protected override void OnUpdate() if (!orbitTested) { - orbitLoaded = testOrbit(); + setupOrbit(HighLogic.LoadedScene == GameScenes.SPACECENTER); + orbitLoaded = testOrbit(HighLogic.LoadedScene == GameScenes.SPACECENTER); orbitTested = true; } if (!orbitLoaded) return; - if (orbitDriver.orbit == null) + if (HighLogic.LoadedScene != GameScenes.SPACECENTER) { - this.SetIncomplete(); - return; + if (orbitRenderer == null) + return; + + if (orbitRenderer.driver == null) + return; + + if (orbitRenderer.driver.orbit == null) + return; + } + else + { + if (KSCOrbit == null) + return; } if (root == null) @@ -123,7 +127,7 @@ protected override void OnUpdate() if (v == null) continue; - if (VesselUtilities.VesselAtOrbit(orbitDriver.orbit, deviationWindow, v)) + if (VesselUtilities.VesselAtOrbit(HighLogic.LoadedScene == GameScenes.SPACECENTER ? KSCOrbit : orbitRenderer.driver.orbit, deviationWindow, v)) { this.SetComplete(); return; @@ -172,25 +176,30 @@ protected override void OnLoad(ConfigNode node) epo = node.parse("epoch", (double)0); lan = node.parse("lan", (double)0); deviation = node.parse("deviationWindow", (double)10); - setupOrbit(); + setupOrbit(true); } if (this.Root.ContractState == Contract.State.Active) - orbitLoaded = testOrbit(); + orbitLoaded = testOrbit(HighLogic.LoadedScene == GameScenes.SPACECENTER); } - private bool testOrbit() + private bool testOrbit(bool ksc) { try { - double d = orbitDriver.orbit.inclination; + double d = 0; + if (ksc) + d = KSCOrbit.inclination; + else + d = orbitRenderer.driver.orbit.inclination; orbitTested = true; DMUtils.DebugLog("Orbit Checks Out..."); return true; } catch (Exception e) { - Debug.LogError("[DM] Error detected in setting up long term recon orbit parameter; deactivating\n" + e.StackTrace); + if (!HighLogic.LoadedSceneIsEditor) + Debug.LogError("[DM] Error detected in setting up long term recon orbit parameter; deactivating\n" + e.StackTrace); return false; } } diff --git a/Source/Part Modules/DMAsteroidScanner.cs b/Source/Part Modules/DMAsteroidScanner.cs index 445ca60..da14f17 100644 --- a/Source/Part Modules/DMAsteroidScanner.cs +++ b/Source/Part Modules/DMAsteroidScanner.cs @@ -34,6 +34,7 @@ using System.Linq; using UnityEngine; using DMagic.Scenario; +using KSP.UI.Screens.Flight.Dialogs; namespace DMagic.Part_Modules { @@ -773,7 +774,7 @@ private ScienceData makeScience(float dist, ModuleAsteroid m) registerDMScience(ast, sub); body.bodyName = asteroidBodyNameFixed; - data = new ScienceData(multiplier * exp.baseValue * sub.dataScale, transmitValue, 0f, sub.id, dataTitle, false, part.flightID); + data = new ScienceData(multiplier * exp.baseValue * sub.dataScale, transmitValue, vessel.VesselValues.ScienceReturn.value, sub.id, dataTitle, false, part.flightID); return data; } @@ -810,7 +811,7 @@ private void experimentResultsPage(ScienceData data) { if (scienceReports.Count > 0) { - ExperimentResultDialogPage page = new ExperimentResultDialogPage(part, data, transmitValue, 0f, false, "", true, ModuleScienceLab.IsLabData(vessel, data), new Callback(onDiscardData), new Callback(onKeepData), new Callback(onTransmitData), new Callback(onSendToLab)); + ExperimentResultDialogPage page = new ExperimentResultDialogPage(part, data, transmitValue, 0f, false, "", true, new ScienceLabSearch(vessel, data), new Callback(onDiscardData), new Callback(onKeepData), new Callback(onTransmitData), new Callback(onSendToLab)); ExperimentsResultDialog.DisplayResult(page); } } diff --git a/Source/Part Modules/DMBasicScienceModule.cs b/Source/Part Modules/DMBasicScienceModule.cs index f5541df..08cd234 100644 --- a/Source/Part Modules/DMBasicScienceModule.cs +++ b/Source/Part Modules/DMBasicScienceModule.cs @@ -33,6 +33,7 @@ using System.Collections.Generic; using System.Linq; using UnityEngine; +using KSP.UI.Screens.Flight.Dialogs; namespace DMagic.Part_Modules { @@ -355,7 +356,7 @@ private void experimentResultsPage(ScienceData data) { if (scienceReports.Count > 0) { - ExperimentResultDialogPage page = new ExperimentResultDialogPage(part, data, transmitValue, 0f, false, "", true, ModuleScienceLab.IsLabData(vessel, data), new Callback(onDiscardData), new Callback(onKeepData), new Callback(onTransmitData), new Callback(onSendToLab)); + ExperimentResultDialogPage page = new ExperimentResultDialogPage(part, data, transmitValue, 0f, false, "", true, new ScienceLabSearch(vessel, data), new Callback(onDiscardData), new Callback(onKeepData), new Callback(onTransmitData), new Callback(onSendToLab)); ExperimentsResultDialog.DisplayResult(page); } } diff --git a/Source/Part Modules/DMBathymetry.cs b/Source/Part Modules/DMBathymetry.cs index a15bd2a..97b6748 100644 --- a/Source/Part Modules/DMBathymetry.cs +++ b/Source/Part Modules/DMBathymetry.cs @@ -76,10 +76,13 @@ public override void OnStart(PartModule.StartState state) Transform redLightT = part.FindModelTransform(redLightMaterial); Transform blueLightT = part.FindModelTransform(blueLightMaterial); - if (redLightT != null && redLightT.renderer != null) - redLightMat = redLightT.renderer.material; - if (blueLightT != null && blueLightT.renderer != null) - blueLightMat = blueLightT.renderer.material; + Renderer redLightR = redLightT.GetComponent(); + Renderer blueLightR = blueLightT.GetComponent(); + + if (redLightT != null && redLightR != null) + redLightMat = redLightR.material; + if (blueLightT != null && blueLightR != null) + blueLightMat = blueLightR.material; if (redLight != null) redLight.enabled = false; diff --git a/Source/Part Modules/DMBreakablePart.cs b/Source/Part Modules/DMBreakablePart.cs index 31184e6..cd96464 100644 --- a/Source/Part Modules/DMBreakablePart.cs +++ b/Source/Part Modules/DMBreakablePart.cs @@ -118,6 +118,17 @@ public override void OnFixedUpdate() checkForces(); } + protected override bool canConduct() + { + if (broken) + { + failMessage = "This instrument is broken; the experiment can't be conducted"; + return false; + } + + return base.canConduct(); + } + public override void deployEvent() { base.deployEvent(); @@ -266,16 +277,18 @@ private void breakObjects() DMUtils.DebugLog("Breaking Object [{0}]...", o.name); + Rigidbody partRigid = part.GetComponent(); + Vector3 randomAngular = new Vector3((float)DMUtils.rand.NextDouble() * 3, (float)DMUtils.rand.NextDouble() * 3, (float)DMUtils.rand.NextDouble() * 3); DMUtils.DebugLog("Random Angular: [{0:F4}]", randomAngular); DMUtils.DebugLog("Old Angular: [{0:F4}]", r.angularVelocity); - r.angularVelocity = part.rigidbody.angularVelocity + randomAngular; + r.angularVelocity = partRigid.angularVelocity + randomAngular; DMUtils.DebugLog("New Angular: [{0:F4}]", r.angularVelocity); Vector3 randomVel = new Vector3(((float)DMUtils.rand.NextDouble() * 8) - 4, ((float)DMUtils.rand.NextDouble() * 8) - 4, ((float)DMUtils.rand.NextDouble() * 8) - 4); DMUtils.DebugLog("Random Velocity: [{0:F4}]", randomVel); - Vector3 localCOM = vessel.findWorldCenterOfMass() - part.rigidbody.worldCenterOfMass; + Vector3 localCOM = vessel.findWorldCenterOfMass() - partRigid.worldCenterOfMass; DMUtils.DebugLog("Old Velocity: [{0:F4}]", r.velocity); - r.velocity = part.rigidbody.velocity + randomVel + Vector3.Cross(localCOM, rigidbody.angularVelocity); + r.velocity = partRigid.velocity + randomVel + Vector3.Cross(localCOM, r.angularVelocity); DMUtils.DebugLog("New Velocity: [{0:F4}]", r.velocity); r.mass = componentMass; r.useGravity = false; diff --git a/Source/Part Modules/DMMagBoomModule.cs b/Source/Part Modules/DMMagBoomModule.cs index db082f6..c6b0fb1 100644 --- a/Source/Part Modules/DMMagBoomModule.cs +++ b/Source/Part Modules/DMMagBoomModule.cs @@ -142,7 +142,8 @@ public void Update() if (Time.deltaTime != 0) deltaTime = TimeWarp.deltaTime / Time.deltaTime; if (deltaTime > 10) deltaTime = 10; - if (((Time.time * deltaTime) - lastUpdate) > updateInterval) + float dTime = Time.time * deltaTime; + if (dTime - lastUpdate > updateInterval || dTime < updateInterval) { lastUpdate = Time.time; if (primaryModule.IsDeployed && runMagnetometer) @@ -310,42 +311,43 @@ public void Update() { currentAnomalies = DMAnomalyList.getAnomalyStorage(vessel.mainBody.name); - if (currentAnomalies == null) - return; - - for (int a = 0; a < currentAnomalies.AnomalyCount; a++) - //foreach (DMAnomalyObject anom in DMScienceScenario.SciScenario.anomalyList.anomObjects()) + if (currentAnomalies != null) { - DMAnomalyObject anom = currentAnomalies.getAnomaly(a); + for (int a = 0; a < currentAnomalies.AnomalyCount; a++) + //foreach (DMAnomalyObject anom in DMScienceScenario.SciScenario.anomalyList.anomObjects()) + { + DMAnomalyObject anom = currentAnomalies.getAnomaly(a); - if (anom == null) - continue; + if (anom == null) + continue; - //foreach (DMAnomalyObject anom in DMScienceScenario.SciScenario.anomalyList.anomObjects()) - //{ - DMAnomalyList.updateAnomaly(vessel, anom); - if (anom.VDistance < 100000) - Cities.Add(anom); + //foreach (DMAnomalyObject anom in DMScienceScenario.SciScenario.anomalyList.anomObjects()) + //{ + DMAnomalyList.updateAnomaly(vessel, anom); + if (anom.VDistance < 100000) + Cities.Add(anom); + } } } else { currentAnomalies = DMAnomalyList.getAnomalyStorage(vessel.mainBody.name); - if (currentAnomalies == null) - return; - - for (int a = 0; a < currentAnomalies.AnomalyCount; a++) + if (currentAnomalies != null) { - //foreach (DMAnomalyObject anom in DMScienceScenario.SciScenario.anomalyList.anomObjects()) - //{ - DMAnomalyObject anom = currentAnomalies.getAnomaly(a); - if (anom == null) - continue; + for (int a = 0; a < currentAnomalies.AnomalyCount; a++) + { + //foreach (DMAnomalyObject anom in DMScienceScenario.SciScenario.anomalyList.anomObjects()) + //{ + DMAnomalyObject anom = currentAnomalies.getAnomaly(a); - if (anom.VDistance < 100000) - Cities.Add(anom); + if (anom == null) + continue; + + if (anom.VDistance < 100000) + Cities.Add(anom); + } } } diff --git a/Source/Part Modules/DMModuleScienceAnimate.cs b/Source/Part Modules/DMModuleScienceAnimate.cs index 5d3d8f7..b062cd7 100644 --- a/Source/Part Modules/DMModuleScienceAnimate.cs +++ b/Source/Part Modules/DMModuleScienceAnimate.cs @@ -34,6 +34,7 @@ using System.Linq; using UnityEngine; using DMagic.Scenario; +using KSP.UI.Screens.Flight.Dialogs; namespace DMagic.Part_Modules { @@ -231,8 +232,10 @@ public override void OnLoad(ConfigNode node) } } - protected virtual void Update() + new protected virtual void Update() { + base.Update(); + if (HighLogic.LoadedSceneIsFlight) { //Durrrr, gameEvents sure are helpful.... @@ -476,7 +479,7 @@ public void deployAction(KSPActionParam param) public virtual void retractEvent() { if (oneWayAnimation) return; - if (oneShot) return; + if (oneShot && !HighLogic.LoadedSceneIsEditor) return; primaryAnimator(-1f * animSpeed, 1f, WrapMode.Default, animationName, anim); IsDeployed = false; if (USScience) @@ -619,15 +622,14 @@ public virtual void editorRetractEvent() { if (FlightGlobals.ActiveVessel.parts[0].protoModuleCrew[0].experienceLevel >= resetLevel) { - ResetExperiment(); Inoperable = false; - ScreenMessages.PostScreenMessage(string.Format("[0]: Media Restored. Module is operational again.", experiment.experimentTitle), 6f, ScreenMessageStyle.UPPER_LEFT); + ScreenMessages.PostScreenMessage(string.Format("[{0}]: Media Restored. Module is operational again.", scienceExp.experimentTitle), 6f, ScreenMessageStyle.UPPER_LEFT); } else - ScreenMessages.PostScreenMessage(string.Format("[0]: A level " + resetLevel + " scientist is required to reset this experiment.", experiment.experimentTitle), 6f, ScreenMessageStyle.UPPER_LEFT); + ScreenMessages.PostScreenMessage(string.Format("[{0}]: A level " + resetLevel + " scientist is required to reset this experiment.", scienceExp.experimentTitle), 6f, ScreenMessageStyle.UPPER_LEFT); } else - ScreenMessages.PostScreenMessage(string.Format("[0]: A scientist is needed to reset this experiment.", experiment.experimentTitle), 6f, ScreenMessageStyle.UPPER_LEFT); + ScreenMessages.PostScreenMessage(string.Format("[{0}]: A scientist is needed to reset this experiment.", scienceExp.experimentTitle), 6f, ScreenMessageStyle.UPPER_LEFT); } } @@ -950,7 +952,7 @@ private ScienceData makeScience(float boost, ExperimentSituations vesselSituatio sub.scienceCap = scienceExp.scienceCap * sub.subjectValue; } - data = new ScienceData(scienceExp.baseValue * sub.dataScale, xmitDataScalar, 1f, sub.id, sub.title, false, part.flightID); + data = new ScienceData(scienceExp.baseValue * sub.dataScale, xmitDataScalar, vessel.VesselValues.ScienceReturn.value, sub.id, sub.title, false, part.flightID); return data; } @@ -990,7 +992,7 @@ private void newResultPage() if (storedScienceReports.Count > 0) { ScienceData data = storedScienceReports[dataIndex]; - ExperimentResultDialogPage page = new ExperimentResultDialogPage(part, data, data.transmitValue, labDataBoost, (experimentsReturned >= (experimentLimit - 1)) && !rerunnable, transmitWarningText, true, ModuleScienceLab.IsLabData(vessel, data), new Callback(onDiscardData), new Callback(onKeepData), new Callback(onTransmitData), new Callback(onSendToLab)); + ExperimentResultDialogPage page = new ExperimentResultDialogPage(part, data, data.transmitValue, 0, (experimentsReturned >= (experimentLimit - 1)) && !rerunnable, transmitWarningText, true, new ScienceLabSearch(vessel, data), new Callback(onDiscardData), new Callback(onKeepData), new Callback(onTransmitData), new Callback(onSendToLab)); ExperimentsResultDialog.DisplayResult(page); } } @@ -1022,7 +1024,7 @@ private void initialResultsPage() if (scienceReports.Count > 0) { ScienceData data = scienceReports[0]; - ExperimentResultDialogPage page = new ExperimentResultDialogPage(part, data, data.transmitValue, labDataBoost, (experimentsReturned >= (experimentLimit - 1)) && !rerunnable, transmitWarningText, true, ModuleScienceLab.IsLabData(vessel, data), new Callback(onDiscardInitialData), new Callback(onKeepInitialData), new Callback(onTransmitInitialData), new Callback(onSendInitialToLab)); + ExperimentResultDialogPage page = new ExperimentResultDialogPage(part, data, data.transmitValue, 0, (experimentsReturned >= (experimentLimit - 1)) && !rerunnable, transmitWarningText, true, new ScienceLabSearch(vessel, data), new Callback(onDiscardInitialData), new Callback(onKeepInitialData), new Callback(onTransmitInitialData), new Callback(onSendInitialToLab)); ExperimentsResultDialog.DisplayResult(page); } } @@ -1067,9 +1069,15 @@ private void onTransmitData(ScienceData data) private void onSendToLab(ScienceData data) { - List labList = vessel.FindPartModulesImplementing(); - if (checkLabOps() && storedScienceReports.Count > 0) - labList.OrderBy(ScienceUtil.GetLabScore).First().StartCoroutine(labList.First().ProcessData(data, new Callback(onComplete))); + ScienceLabSearch labSearch = new ScienceLabSearch(vessel, data); + + if (labSearch.NextLabForDataFound) + { + StartCoroutine(labSearch.NextLabForData.ProcessData(data, new Callback(onComplete))); + + Inoperable = !IsRerunnable(); + Deployed = Inoperable; + } else ScreenMessages.PostScreenMessage("No operational lab modules on this vessel. Cannot analyze data.", 4f, ScreenMessageStyle.UPPER_CENTER); } @@ -1079,17 +1087,6 @@ protected virtual void onComplete(ScienceData data) ReviewData(); } - private bool checkLabOps() - { - List labList = vessel.FindPartModulesImplementing(); - for (int i = 0; i < labList.Count; i++) - { - if (labList[i].IsOperational()) - return true; - } - return false; - } - private void onDiscardInitialData(ScienceData data) { if (scienceReports.Count > 0) @@ -1144,9 +1141,15 @@ private void onTransmitInitialData(ScienceData data) private void onSendInitialToLab(ScienceData data) { - List labList = vessel.FindPartModulesImplementing(); - if (checkLabOps() && scienceReports.Count > 0) - labList.OrderBy(ScienceUtil.GetLabScore).First().StartCoroutine(labList.First().ProcessData(data, new Callback(onInitialComplete))); + ScienceLabSearch labSearch = new ScienceLabSearch(vessel, data); + + if (labSearch.NextLabForDataFound) + { + StartCoroutine(labSearch.NextLabForData.ProcessData(data, new Callback(onInitialComplete))); + + Inoperable = !IsRerunnable(); + Deployed = Inoperable; + } else ScreenMessages.PostScreenMessage("No operational lab modules on this vessel. Cannot analyze data.", 4f, ScreenMessageStyle.UPPER_CENTER); } diff --git a/Source/Part Modules/DMReconScope.cs b/Source/Part Modules/DMReconScope.cs index 3a7e7ec..64cf6ae 100644 --- a/Source/Part Modules/DMReconScope.cs +++ b/Source/Part Modules/DMReconScope.cs @@ -43,6 +43,8 @@ public class DMReconScope : DMModuleScienceAnimate, IDMSurvey public string loopingAnimName = ""; [KSPField] public string filmCannisterName = "cannister"; + [KSPField] + public bool openDoorsOnly = false; private Animation loopingAnim; private bool windingDown; @@ -60,6 +62,15 @@ public override void OnStart(PartModule.StartState state) startLoopingAnimation(1f); setCannisterObjects(); + + if (openDoorsOnly) + { + DMUtils.Logging("Setting Door Only Status..."); + Events["openDoors"].active = !IsDeployed; + Events["closeDoors"].active = IsDeployed; + Actions["openDoorsAction"].active = true; + Actions["closeDoorsAction"].active = true; + } } private void setCannisterObjects() @@ -180,17 +191,69 @@ protected override void onLabReset() } } + [KSPEvent(guiActive = true, guiName = "Open Camera Doors", active = false)] + public void openDoors() + { + base.deployEvent(); + + Events["openDoors"].active = false; + Events["closeDoors"].active = true; + } + + [KSPAction("Open Camera Doors")] + public void openDoorsAction() + { + openDoors(); + } + + [KSPEvent(guiActive = true, guiName = "Close Camera Doors", active = false)] + public void closeDoors() + { + if (loopingAnim != null) + { + if (loopingAnim.IsPlaying(loopingAnimName)) + { + if (windingUp) + return; + + if (windingDown) + return; + + StartCoroutine(stopLooping()); + + return; + } + } + + base.retractEvent(); + + Events["openDoors"].active = true; + Events["closeDoors"].active = false; + } + + [KSPAction("Close Camera Doors")] + public void closeDoorsAction() + { + closeDoors(); + } + public override void deployEvent() { if (windingDown) return; + if (windingUp) + return; + base.deployEvent(); if (HighLogic.LoadedSceneIsEditor) return; StartCoroutine(startLooping(waitForAnimationTime)); + + Events["openDoors"].active = false; + Events["closeDoors"].active = openDoorsOnly; } private IEnumerator startLooping(float time) @@ -220,6 +283,9 @@ public override void retractEvent() if (windingUp) return; + if (windingDown) + return; + StartCoroutine(stopLooping()); } @@ -233,6 +299,9 @@ private IEnumerator stopLooping() yield return new WaitForSeconds(time); + Events["openDoors"].active = openDoorsOnly; + Events["closeDoors"].active = false; + windingDown = false; base.retractEvent(); diff --git a/Source/Part Modules/DMRoverGooMat.cs b/Source/Part Modules/DMRoverGooMat.cs index 0df87b5..31a9a5c 100644 --- a/Source/Part Modules/DMRoverGooMat.cs +++ b/Source/Part Modules/DMRoverGooMat.cs @@ -48,10 +48,10 @@ public override void OnStart(PartModule.StartState state) protected override void onLabReset() { - base.onLabReset(); - if (IsDeployed) sampleAnimator(-2f, 1f, (anim2[sampleAnim].length / 2f)); + + base.onLabReset(); } public override void deployEvent() diff --git a/Source/Part Modules/DMSIGINT.cs b/Source/Part Modules/DMSIGINT.cs index 7275c33..9fecbba 100644 --- a/Source/Part Modules/DMSIGINT.cs +++ b/Source/Part Modules/DMSIGINT.cs @@ -52,12 +52,6 @@ public override void OnStart(PartModule.StartState state) base.OnStart(state); Events["fixPart"].guiName = "Fix Dish"; - - if (state != StartState.Editor) - return; - - //Turn off the dish renderer so that the editor size check doesn't come out wrong - setTransformState(false); } private void assignTransforms() diff --git a/Source/Part Modules/DMSeismicHammer.cs b/Source/Part Modules/DMSeismicHammer.cs index 27a17f9..5af727e 100644 --- a/Source/Part Modules/DMSeismicHammer.cs +++ b/Source/Part Modules/DMSeismicHammer.cs @@ -105,20 +105,28 @@ public override void OnStart(PartModule.StartState state) Transform s1 = part.FindModelTransform("SensorLight.000"); Transform s2 = part.FindModelTransform("SensorLight.001"); - if (l1 != null && l1.renderer != null) - scoreLightOne = l1.renderer.material; - if (l2 != null && l2.renderer != null) - scoreLightTwo = l2.renderer.material; - if (l3 != null && l3.renderer != null) - scoreLightThree = l3.renderer.material; - if (l4 != null && l4.renderer != null) - scoreLightFour = l4.renderer.material; - if (l4 != null && l5.renderer != null) - scoreLightFive = l5.renderer.material; - if (s1 != null && s1.renderer != null) - signalLightOne = s1.renderer.material; - if (s2 != null && s2.renderer != null) - signalLightTwo = s2.renderer.material; + Renderer r1 = l1.GetComponent(); + Renderer r2 = l2.GetComponent(); + Renderer r3 = l3.GetComponent(); + Renderer r4 = l4.GetComponent(); + Renderer r5 = l5.GetComponent(); + Renderer r6 = s1.GetComponent(); + Renderer r7 = s2.GetComponent(); + + if (l1 != null && r1 != null) + scoreLightOne = r1.material; + if (l2 != null && r2 != null) + scoreLightTwo = r2.material; + if (l3 != null && r3 != null) + scoreLightThree = r3.material; + if (l4 != null && r4 != null) + scoreLightFour = r4.material; + if (l4 != null && r5 != null) + scoreLightFive = r5.material; + if (s1 != null && r6 != null) + signalLightOne = r6.material; + if (s2 != null && r7 != null) + signalLightTwo = r6.material; } public override string GetInfo() @@ -587,7 +595,7 @@ private IEnumerator RunThumper() { while (Anim.IsPlaying(hammerAnimation) && Anim[hammerAnimation].normalizedTime < 0.65f && ExtensionTransform.localPosition.z > targetPosition) { - DMUtils.Logging("Drill Position: {0:N5}", ExtensionTransform.localPosition.z); + DMUtils.DebugLog("Drill Position: {0:N5}", ExtensionTransform.localPosition.z); extension(Vector3.back, TimeWarp.deltaTime); yield return null; } diff --git a/Source/Part Modules/DMSeismicSensor.cs b/Source/Part Modules/DMSeismicSensor.cs index 60a453e..c0c8743 100644 --- a/Source/Part Modules/DMSeismicSensor.cs +++ b/Source/Part Modules/DMSeismicSensor.cs @@ -83,18 +83,25 @@ public override void OnStart(PartModule.StartState state) Transform l5 = part.FindModelTransform("SignalLight.000"); Transform s1 = part.FindModelTransform("SignalLight01"); - if (l1 != null && l1.renderer != null) - scoreLightOne = l1.renderer.material; - if (l2 != null && l2.renderer != null) - scoreLightTwo = l2.renderer.material; - if (l3 != null && l3.renderer != null) - scoreLightThree = l3.renderer.material; - if (l4 != null && l4.renderer != null) - scoreLightFour = l4.renderer.material; - if (l4 != null && l5.renderer != null) - scoreLightFive = l5.renderer.material; - if (s1 != null && s1.renderer != null) - signalLightOne = s1.renderer.material; + Renderer r1 = l1.GetComponent(); + Renderer r2 = l2.GetComponent(); + Renderer r3 = l3.GetComponent(); + Renderer r4 = l4.GetComponent(); + Renderer r5 = l5.GetComponent(); + Renderer r6 = s1.GetComponent(); + + if (l1 != null && r1 != null) + scoreLightOne = r1.material; + if (l2 != null && r2 != null) + scoreLightTwo = r2.material; + if (l3 != null && r3 != null) + scoreLightThree = r3.material; + if (l4 != null && r4 != null) + scoreLightFour = r4.material; + if (l4 != null && r5 != null) + scoreLightFive = r5.material; + if (s1 != null && r6 != null) + signalLightOne = r6.material; } public override string GetInfo() diff --git a/Source/Properties/AssemblyInfo.cs b/Source/Properties/AssemblyInfo.cs index 5545132..5f19006 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.2.0.0")] -[assembly: AssemblyFileVersion("1.2.0.0")] -[assembly: AssemblyInformationalVersion("v1.2")] +[assembly: AssemblyVersion("1.2.0.3")] +[assembly: AssemblyFileVersion("1.2.0.3")] +[assembly: AssemblyInformationalVersion("v1.2.3")] [assembly: KSPAssembly("DMagic", 1, 4)]