Skip to content

Commit

Permalink
Merge pull request #46 from post-kerbin-mining-corporation/dev
Browse files Browse the repository at this point in the history
Release 0.4.3
  • Loading branch information
ChrisAdderley authored Oct 7, 2021
2 parents 4692860 + dbffe66 commit 5f11e20
Show file tree
Hide file tree
Showing 11 changed files with 185 additions and 80 deletions.
2 changes: 1 addition & 1 deletion .mod_data.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions GameData/SpaceDust/Localization/en-us.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 = <b><<1>></b>: <<2>> u/m³
Expand All @@ -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!
Expand Down
3 changes: 3 additions & 0 deletions GameData/SpaceDust/Localization/zh-cn.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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!
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ PART
BaseEfficiency = .25
MinHarvestValue = 0.00000001
}
HARVESTED_RESOURCE
{
Name = LiquidFuel
BaseEfficiency = .25
}

}
MODULE
Expand Down
Binary file modified GameData/SpaceDust/Plugins/SpaceDust.dll
Binary file not shown.
4 changes: 2 additions & 2 deletions GameData/SpaceDust/Versioning/SpaceDust.version
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
120 changes: 75 additions & 45 deletions Source/SpaceDust/Modules/ModuleSpaceDustHarvester.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<HarvestedResource> resources;
protected Transform HarvestIntakeTransform;
private AnimationState[] harvestState;
Expand Down Expand Up @@ -216,7 +230,7 @@ public override void OnStart(StartState state)
Utils.LogError($"[ModuleSpaceDustHarvester] Couldn't find resource definition for {res.Name}");
}
}


if (Settings.SystemHeatActive)
{
Expand All @@ -233,17 +247,17 @@ public override void OnLoad(ConfigNode node)
{
resources = new List<HarvestedResource>();
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)
{
Expand All @@ -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 = "";
Expand All @@ -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)
{
Expand Down Expand Up @@ -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
Expand All @@ -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;
}
Expand All @@ -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)
{

Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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";
Expand Down
Loading

0 comments on commit 5f11e20

Please sign in to comment.