diff --git a/.mod_data.yml b/.mod_data.yml index 1b2e1cc..eba1399 100644 --- a/.mod_data.yml +++ b/.mod_data.yml @@ -8,7 +8,7 @@ package: - changelog.txt dependencies: # Configure dependencies ModuleManager: - version: 4.1.4 + version: 4.2.1 location: s3 B9PartSwitch: version: 2.18.0 diff --git a/GameData/SpaceDust/Localization/en-us.cfg b/GameData/SpaceDust/Localization/en-us.cfg index e7bd5e9..bcf73f6 100644 --- a/GameData/SpaceDust/Localization/en-us.cfg +++ b/GameData/SpaceDust/Localization/en-us.cfg @@ -116,6 +116,10 @@ Localization #LOC_SpaceDust_ModuleSpaceDustTelescope_Event_EnableTelescope = Start Survey #LOC_SpaceDust_ModuleSpaceDustTelescope_Event_DisableTelescope = Stop Survey + #LOC_SpaceDust_ModuleSpaceDustTelescope_Action_Enable = Start Survey + #LOC_SpaceDust_ModuleSpaceDustTelescope_Action_Disable = Stop Survey + #LOC_SpaceDust_ModuleSpaceDustTelescope_Action_Toggle = Toggle Survey + #LOC_SpaceDust_ModuleSpaceDustTelescope_Instrument_DisplayName = Telescope Instrument #LOC_SpaceDust_ModuleSpaceDustTelescope_Instrument_Info = Instrument Slot @@ -153,6 +157,11 @@ Localization #LOC_SpaceDust_ModuleSpaceDustScanner_Event_EnableScanner = Enable Scanner #LOC_SpaceDust_ModuleSpaceDustScanner_Event_DisableScanner = Disable Scanner + + #LOC_SpaceDust_ModuleSpaceDustScanner_Action_Enable = Enable Scanner + #LOC_SpaceDust_ModuleSpaceDustScanner_Action_Disable = Disable Scanner + #LOC_SpaceDust_ModuleSpaceDustScanner_Action_Toggle = Toggle Scanner + #LOC_SpaceDust_ModuleSpaceDustScanner_Field_Resources_NoPower = Not enough Electric Charge! #LOC_SpaceDust_ModuleSpaceDustScanner_Field_Disabled = Disabled #LOC_SpaceDust_ModuleSpaceDustScanner_Field_Resources_SingleSample = <<1>>: <<2>> u/m³ @@ -167,6 +176,10 @@ Localization #LOC_SpaceDust_ModuleSpaceDustHarvester_Event_EnableScanner = Start Harvesting #LOC_SpaceDust_ModuleSpaceDustHarvester_Event_DisableScanner = Stop Harvesting + #LOC_SpaceDust_ModuleSpaceDustHarvester_Action_Enable = Start Harvesting + #LOC_SpaceDust_ModuleSpaceDustHarvester_Action_Disable = Stop Harvesting + #LOC_SpaceDust_ModuleSpaceDustHarvester_Action_Toggle = Toggle Harvesting + #LOC_SpaceDust_ModuleSpaceDustHarvester_Field_Resources = Harvester #LOC_SpaceDust_ModuleSpaceDustHarvester_Field_Resources_Overheated = Overheated! diff --git a/GameData/SpaceDust/Localization/zh-cn.cfg b/GameData/SpaceDust/Localization/zh-cn.cfg index 37e8215..054a845 100644 --- a/GameData/SpaceDust/Localization/zh-cn.cfg +++ b/GameData/SpaceDust/Localization/zh-cn.cfg @@ -186,5 +186,8 @@ Localization #LOC_SpaceDust_ModuleSpaceDustHarvester_Field_Thermal = 效率 //Efficiency #LOC_SpaceDust_ModuleSpaceDustHarvester_Field_Thermal_Running = <<1>>% //<<1>>% + + #LOC_SpaceDust_ModuleSpaceDustHarvester_Message_Overheated = 过热! 收集器循环达到<<1>>K! //Overheated! Harvester loop temperature exceeded <<1>>K! + } } } diff --git a/GameData/SpaceDust/Parts/Harvesting/spacedust-atmosphere-processor-125-1.cfg b/GameData/SpaceDust/Parts/Harvesting/spacedust-atmosphere-processor-125-1.cfg index 2b8b730..4ac6afb 100644 --- a/GameData/SpaceDust/Parts/Harvesting/spacedust-atmosphere-processor-125-1.cfg +++ b/GameData/SpaceDust/Parts/Harvesting/spacedust-atmosphere-processor-125-1.cfg @@ -72,6 +72,11 @@ PART BaseEfficiency = .25 MinHarvestValue = 0.00000001 } + HARVESTED_RESOURCE + { + Name = LiquidFuel + BaseEfficiency = .25 + } } MODULE diff --git a/GameData/SpaceDust/Plugins/SpaceDust.dll b/GameData/SpaceDust/Plugins/SpaceDust.dll index 27207e6..29fcec6 100644 Binary files a/GameData/SpaceDust/Plugins/SpaceDust.dll and b/GameData/SpaceDust/Plugins/SpaceDust.dll differ diff --git a/GameData/SpaceDust/Versioning/SpaceDust.version b/GameData/SpaceDust/Versioning/SpaceDust.version index 78660f6..20c4ff0 100644 --- a/GameData/SpaceDust/Versioning/SpaceDust.version +++ b/GameData/SpaceDust/Versioning/SpaceDust.version @@ -6,14 +6,14 @@ { "MAJOR":0, "MINOR":4, - "PATCH":2, + "PATCH":3, "BUILD":0 }, "KSP_VERSION": { "MAJOR":1, "MINOR":12, - "PATCH":1 + "PATCH":2 }, "KSP_VERSION_MIN":{ "MAJOR":1, diff --git a/Source/SpaceDust/Modules/ModuleSpaceDustHarvester.cs b/Source/SpaceDust/Modules/ModuleSpaceDustHarvester.cs index 9d96f5a..b6c1db6 100644 --- a/Source/SpaceDust/Modules/ModuleSpaceDustHarvester.cs +++ b/Source/SpaceDust/Modules/ModuleSpaceDustHarvester.cs @@ -111,29 +111,43 @@ public class ModuleSpaceDustHarvester : PartModule [KSPField(isPersistant = false, guiActive = true, guiActiveEditor = false, guiName = "#LOC_SpaceDust_ModuleSpaceDustHarvester_Field_Resources")] public string ScannerUI = ""; - // UI field for showing scan status + // UI field for showing intake speed [KSPField(isPersistant = false, guiActive = true, guiActiveEditor = false, guiName = "#LOC_SpaceDust_ModuleSpaceDustHarvester_Field_IntakeSpeed")] public string IntakeSpeed = ""; - // UI field for showing scan status + // UI field for showing sscoop status [KSPField(isPersistant = false, guiActive = true, guiActiveEditor = false, guiName = "#LOC_SpaceDust_ModuleSpaceDustHarvester_Field_Scoop")] public string ScoopUI = ""; - // UI field for showing scan status + // UI field for showing thermal status [KSPField(isPersistant = false, guiActive = true, guiActiveEditor = false, guiName = "#LOC_SpaceDust_ModuleSpaceDustHarvester_Field_Thermal")] public string ThermalUI = ""; - [KSPEvent(guiActive = true, guiActiveEditor = false, guiName = "#LOC_SpaceDust_ModuleSpaceDustHarvester_Event_EnableScanner", active = true)] + [KSPEvent(guiActive = true, guiActiveEditor = true, guiName = "#LOC_SpaceDust_ModuleSpaceDustHarvester_Event_EnableScanner", active = true)] public void EnableHarvester() { Enabled = true; } - [KSPEvent(guiActive = true, guiActiveEditor = false, guiName = "#LOC_SpaceDust_ModuleSpaceDustHarvester_Event_DisableScanner", active = false)] + [KSPEvent(guiActive = true, guiActiveEditor = true, guiName = "#LOC_SpaceDust_ModuleSpaceDustHarvester_Event_DisableScanner", active = false)] public void DisableHarvester() { Enabled = false; } + // ACTIONS + [KSPAction(guiName = "#LOC_SpaceDust_ModuleSpaceDustHarvester_Action_Enable")] + public void EnableAction(KSPActionParam param) { EnableHarvester(); } + + [KSPAction(guiName = "#LOC_SpaceDust_ModuleSpaceDustHarvester_Action_Disable")] + public void DisableAction(KSPActionParam param) { DisableHarvester(); } + + [KSPAction(guiName = "#LOC_SpaceDust_ModuleSpaceDustHarvester_Action_Toggle")] + public void ToggleAction(KSPActionParam param) + { + if (Enabled) DisableHarvester(); else EnableHarvester(); + } + + public List resources; protected Transform HarvestIntakeTransform; private AnimationState[] harvestState; @@ -216,7 +230,7 @@ public override void OnStart(StartState state) Utils.LogError($"[ModuleSpaceDustHarvester] Couldn't find resource definition for {res.Name}"); } } - + if (Settings.SystemHeatActive) { @@ -233,17 +247,17 @@ public override void OnLoad(ConfigNode node) { resources = new List(); foreach (ConfigNode resNode in node.GetNodes("HARVESTED_RESOURCE")) - { + { HarvestedResource res = new HarvestedResource(resNode); if (res.Name == "" || String.IsNullOrEmpty(res.Name) || res.Name == "undefined") return; - resources.Add(res); + resources.Add(res); } } } - public override void OnUpdate() + public void Update() { if (HighLogic.LoadedSceneIsFlight || HighLogic.LoadedSceneIsEditor) { @@ -252,27 +266,12 @@ public override void OnUpdate() Events["DisableHarvester"].active = Enabled; Events["EnableHarvester"].active = !Enabled; } - if (Enabled && LoopAnimationName != "") - { - foreach (AnimationState anim in loopState) - { - anim.wrapMode = WrapMode.Loop; - anim.speed = 1f; - } - } - else if (LoopAnimationName != "") - { - foreach (AnimationState anim in loopState) - { - anim.wrapMode = WrapMode.Loop; - anim.speed = 0f; - } - } } } void FixedUpdate() { + HandleAnimation(); if (HighLogic.LoadedSceneIsFlight) { string message = ""; @@ -286,9 +285,9 @@ void FixedUpdate() Fields["ThermalUI"].guiActive = Settings.SystemHeatActive; - vessel.GetConnectedResourceTotals(PartResourceLibrary.ElectricityHashcode, out double currentEC, out double maxEC); + vessel.GetConnectedResourceTotals(PartResourceLibrary.ElectricityHashcode, out double currentEC, out double maxEC); double chargeRequest = PowerCost * TimeWarp.fixedDeltaTime; - + // check power if (currentEC > chargeRequest + minResToLeave) { @@ -338,14 +337,7 @@ void FixedUpdate() Fields["IntakeSpeed"].guiActive = false; Fields["ThermalUI"].guiActive = false; } - if (HarvestAnimationName != "") - { - foreach (AnimationState anim in harvestState) - { - anim.speed = 1f; - anim.normalizedTime = Mathf.Clamp(anim.normalizedTime, 0f, 1f); - } - } + } else @@ -358,14 +350,7 @@ void FixedUpdate() Fields["IntakeSpeed"].guiActive = false; Fields["ThermalUI"].guiActive = false; - if (HarvestAnimationName != "") - { - foreach (AnimationState anim in harvestState) - { - anim.speed = -1f; - anim.normalizedTime = Mathf.Clamp(anim.normalizedTime, 0f, 1f); - } - } + } ScannerUI = message; } @@ -378,6 +363,51 @@ void FixedUpdate() } } } + void HandleAnimation() + { + if (HighLogic.LoadedSceneIsEditor || HighLogic.LoadedSceneIsFlight) + { + if (Enabled) + { + if (LoopAnimationName != "") + { + + foreach (AnimationState anim in loopState) + { + anim.wrapMode = WrapMode.Loop; + anim.speed = 1f; + } + } + if (HarvestAnimationName != "") + { + foreach (AnimationState anim in harvestState) + { + anim.speed = 1f; + anim.normalizedTime = Mathf.Clamp(anim.normalizedTime, 0f, 1f); + } + } + } + else + { + if (LoopAnimationName != "") + { + foreach (AnimationState anim in loopState) + { + anim.wrapMode = WrapMode.Loop; + anim.speed = 0f; + } + } + if (HarvestAnimationName != "") + { + foreach (AnimationState anim in harvestState) + { + anim.speed = -1f; + anim.normalizedTime = Mathf.Clamp(anim.normalizedTime, 0f, 1f); + } + } + } + } + } void DoFocusedHarvesting(double scale) { @@ -436,7 +466,7 @@ void DoFocusedHarvesting(double scale) if (ScoopUI == "") ScoopUI = Localizer.Format("#LOC_SpaceDust_ModuleSpaceDustHarvester_Field_Scoop_Resource_None"); } - + if (HarvestType == HarvesterType.Exosphere && part.vessel.atmDensity == 0d) { @@ -480,7 +510,7 @@ void DoFocusedHarvesting(double scale) // $"area {IntakeArea}," + // $"speedstatic {IntakeSpeedStatic}," + // $"worldvel {worldVelocity.magnitude}"); - + double resAmt = resourceSample * intakeVolume * 1d / resources[i].density * resources[i].BaseEfficiency * scale; if (ScoopUI != "") ScoopUI += "\n"; diff --git a/Source/SpaceDust/Modules/ModuleSpaceDustScanner.cs b/Source/SpaceDust/Modules/ModuleSpaceDustScanner.cs index e01e0dd..2968221 100644 --- a/Source/SpaceDust/Modules/ModuleSpaceDustScanner.cs +++ b/Source/SpaceDust/Modules/ModuleSpaceDustScanner.cs @@ -109,18 +109,32 @@ public class ModuleSpaceDustScanner : PartModule [KSPField(isPersistant = false)] public string ScanAnimationName; - [KSPEvent(guiActive = true, guiActiveEditor = false, guiName = "#LOC_SpaceDust_ModuleSpaceDustScanner_Event_EnableScanner", active = true)] + [KSPEvent(guiActive = true, guiActiveEditor = true, guiName = "#LOC_SpaceDust_ModuleSpaceDustScanner_Event_EnableScanner", active = true)] public void EnableScanner() { Enabled = true; } - [KSPEvent(guiActive = true, guiActiveEditor = false, guiName = "#LOC_SpaceDust_ModuleSpaceDustScanner_Event_DisableScanner", active = false)] + [KSPEvent(guiActive = true, guiActiveEditor = true, guiName = "#LOC_SpaceDust_ModuleSpaceDustScanner_Event_DisableScanner", active = false)] public void DisableScanner() { Enabled = false; } + // ACTIONS + [KSPAction(guiName = "#LOC_SpaceDust_ModuleSpaceDustScanner_Action_Enable")] + public void EnableAction(KSPActionParam param) { EnableScanner(); } + + [KSPAction(guiName = "#LOC_SpaceDust_ModuleSpaceDustScanner_Action_Disable")] + public void DisableAction(KSPActionParam param) { DisableScanner(); } + + [KSPAction(guiName = "#LOC_SpaceDust_ModuleSpaceDustScanner_Action_Toggle")] + public void ToggleAction(KSPActionParam param) + { + if (Enabled) DisableScanner(); else EnableScanner(); + } + + private AnimationState[] scanState; private List resources; @@ -196,7 +210,7 @@ public override void OnLoad(ConfigNode node) } } - public override void OnUpdate() + public void Update() { if (HighLogic.LoadedSceneIsFlight || HighLogic.LoadedSceneIsEditor) { @@ -222,6 +236,7 @@ public bool CheckScanSituation() } void FixedUpdate() { + HandleAnimation(); if (HighLogic.LoadedSceneIsFlight) { string message = ""; @@ -340,22 +355,40 @@ void FixedUpdate() } } - if (ScanAnimationName != "") + + } + else + { + CurrentPowerConsumption = 0f; + + message = Localizer.Format(("#LOC_SpaceDust_ModuleSpaceDustScanner_Field_Disabled")); + + } + ScannerUI = message; + } + else + { + CurrentPowerConsumption = -PowerCost; + } + } + + void HandleAnimation() + { + if (HighLogic.LoadedSceneIsEditor || HighLogic.LoadedSceneIsFlight) + if (ScanAnimationName != "") + { + if (Enabled) { + foreach (AnimationState anim in scanState) { anim.speed = 1f; anim.normalizedTime = Mathf.Clamp(anim.normalizedTime, 0f, 1f); } } - } - else - { - CurrentPowerConsumption = 0f; - - message = Localizer.Format(("#LOC_SpaceDust_ModuleSpaceDustScanner_Field_Disabled")); - if (ScanAnimationName != "") + else { + foreach (AnimationState anim in scanState) { anim.speed = -1f; @@ -363,12 +396,6 @@ void FixedUpdate() } } } - ScannerUI = message; - } - else - { - CurrentPowerConsumption = -PowerCost; - } } } } diff --git a/Source/SpaceDust/Modules/ModuleSpaceDustTelescope.cs b/Source/SpaceDust/Modules/ModuleSpaceDustTelescope.cs index 498ea43..ab5f449 100644 --- a/Source/SpaceDust/Modules/ModuleSpaceDustTelescope.cs +++ b/Source/SpaceDust/Modules/ModuleSpaceDustTelescope.cs @@ -96,17 +96,28 @@ public class ModuleSpaceDustTelescope : PartModule [KSPField(isPersistant = false)] public double FieldOfView = 1.8d; - [KSPEvent(guiActive = true, guiActiveEditor = false, guiName = "#LOC_SpaceDust_ModuleSpaceDustTelescope_Event_EnableTelescope", active = true)] + [KSPEvent(guiActive = true, guiActiveEditor = true, guiName = "#LOC_SpaceDust_ModuleSpaceDustTelescope_Event_EnableTelescope", active = true)] public void EnableTelescope() { Enabled = true; } - [KSPEvent(guiActive = true, guiActiveEditor = false, guiName = "#LOC_SpaceDust_ModuleSpaceDustTelescope_Event_DisableTelescope", active = false)] + [KSPEvent(guiActive = true, guiActiveEditor = true, guiName = "#LOC_SpaceDust_ModuleSpaceDustTelescope_Event_DisableTelescope", active = false)] public void DisableTelescope() { Enabled = false; } + // ACTIONS + [KSPAction(guiName = "#LOC_SpaceDust_ModuleSpaceDustTelescope_Action_Enable")] + public void EnableAction(KSPActionParam param) { EnableTelescope(); } + [KSPAction(guiName = "#LOC_SpaceDust_ModuleSpaceDustTelescope_Action_Disable")] + public void DisableAction(KSPActionParam param) { DisableTelescope(); } + + [KSPAction(guiName = "#LOC_SpaceDust_ModuleSpaceDustTelescope_Action_Toggle")] + public void ToggleAction(KSPActionParam param) + { + if (Enabled) DisableTelescope(); else EnableTelescope(); + } private AnimationState[] scanState; private List instrumentSlots; @@ -213,7 +224,7 @@ public void Start() } - public override void OnUpdate() + public void Update() { if (HighLogic.LoadedSceneIsFlight || HighLogic.LoadedSceneIsEditor) { @@ -238,6 +249,7 @@ void SetScanUI(bool on) } void FixedUpdate() { + HandleAnimation(); if (HighLogic.LoadedSceneIsFlight) { if (Enabled) @@ -335,14 +347,6 @@ void FixedUpdate() ScannerUI = Localizer.Format("#LOC_SpaceDust_ModuleSpaceDustTelescope_Field_Status_NoPower"); } - if (ScanAnimationName != "") - { - foreach (AnimationState anim in scanState) - { - anim.speed = 1f; - anim.normalizedTime = Mathf.Clamp(anim.normalizedTime, 0f, 1f); - } - } } else @@ -351,8 +355,27 @@ void FixedUpdate() CurrentPowerConsumption = 0f; ScannerUI = Localizer.Format("#LOC_SpaceDust_ModuleSpaceDustTelescope_Field_Status_Disabled"); SetScanUI(false); - if (ScanAnimationName != "") + + } + } + } + void HandleAnimation() + { + if (HighLogic.LoadedSceneIsEditor || HighLogic.LoadedSceneIsFlight) + if (ScanAnimationName != "") + { + if (Enabled) { + + foreach (AnimationState anim in scanState) + { + anim.speed = 1f; + anim.normalizedTime = Mathf.Clamp(anim.normalizedTime, 0f, 1f); + } + } + else + { + foreach (AnimationState anim in scanState) { anim.speed = -1f; @@ -360,8 +383,6 @@ void FixedUpdate() } } } - } } } - } diff --git a/changelog.txt b/changelog.txt index 61fa87c..b88e6a0 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,9 @@ +v0.4.3 +------ +- Fixed smaller Sift-O-Tron not being able to harvest atmospheric LF +- Added action groups to harvester, scanner, telescope modules +- Made it possible to deploy harvester, scanner, telescope modules in the VAB + v0.4.2 ------ - KSP 1.12 diff --git a/readme.txt b/readme.txt index 4a0f71e..884b453 100644 --- a/readme.txt +++ b/readme.txt @@ -1,5 +1,5 @@ ================ -SPACE DUST 0.4.2 +SPACE DUST 0.4.3 ================ This is a KSP mod designed to overhaul the atmospheric and exospheric mining experience in KSP. It functions both as a framework, providing part modules and distributions to others, and an actual gameplay mod designed to provide a set of parts focused around atmospheric ISRU in the stock system.