Skip to content

Commit

Permalink
Science labs can now reset experiments (#146)
Browse files Browse the repository at this point in the history
* Science: Labs can now reset experiments

* CHANGELOG.md: Add Science lab reset details

* Build: Release dll (v.1.7.2)
  • Loading branch information
PiezPiedPy authored and steamport committed Jul 17, 2018
1 parent 352ecbd commit 4d9da4c
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 21 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

### Changes since the last release

* Science labs can now reset experiments (PiezPiedPy)
* CryoTanks are now simulated in the background also fuel boiloff is simulated in the planner (PiezPiedPy)
* Reverted the Quick'n'dirty fix for GPOSpeedFuelPump because that one is fixed now with v1.8.14 (Gordon Dry)
* Added a fix to make sure there is a module Reliability for parachutes, also for RealChute/RealChuteFAR (Gordon Dry)
Expand Down
Binary file modified GameData/Kerbalism/Kerbalism.dll
Binary file not shown.
4 changes: 2 additions & 2 deletions GameData/Kerbalism/Profiles/Default.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -658,8 +658,8 @@ PARTUPGRADE
}
}

// boost Mk3 Shuttle cockpit Nitrogen storage
@PART[mk3Cockpit_Shuttle]:NEEDS[ProfileDefault]:FOR[Kerbalism]
// boost Mk3 Shuttle cockpit and Science Lab Nitrogen storage
@PART[mk3Cockpit_Shuttle,Large_Crewed_Lab]:NEEDS[ProfileDefault]:FOR[Kerbalism]
{
@MODULE[Configure]
{
Expand Down
11 changes: 0 additions & 11 deletions GameData/Kerbalism/System/Planner.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,6 @@
}


@PART[*]:HAS[@MODULE[ModuleScienceConverter]]:AFTER[Kerbalism]
{
MODULE
{
name = PlannerController
title = science
considered = true
}
}


@PART[*]:HAS[@MODULE[ModuleActiveRadiator]]:FOR[Kerbalism]
{
MODULE
Expand Down
6 changes: 3 additions & 3 deletions GameData/Kerbalism/System/Science.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
// Replace stock lab with our own
// ============================================================================

@PART[*]:HAS[@MODULE[ModuleScienceLab]]:NEEDS[FeatureScience]:FINAL
@PART[*]:HAS[@MODULE[ModuleScienceLab]]:NEEDS[FeatureScience]:FOR[zzzKerbalism]
{
!MODULE[ModuleScienceLab] {}
!MODULE[ModuleScienceConverter] {}
Expand All @@ -52,7 +52,7 @@
// Remove stock science data containers
// ============================================================================

@PART[*]:HAS[@MODULE[ModuleScienceContainer]]:NEEDS[FeatureScience]:FOR[Kerbalism]
@PART[*]:HAS[@MODULE[ModuleScienceContainer]]:NEEDS[FeatureScience]:FOR[zzzKerbalism]
{
!MODULE[ModuleScienceContainer] {}
}
Expand All @@ -74,7 +74,7 @@
// ============================================================================

// note: this also should support DMagic and Universal Storage experiment parts
@PART[*]:HAS[@MODULE[*ModuleScience*]]:NEEDS[FeatureScience]:FOR[Kerbalism]
@PART[*]:HAS[@MODULE[*ModuleScience*]]:NEEDS[FeatureScience]:FOR[zzzKerbalism]
{
@MODULE[*ModuleScience*]:HAS[#experimentID[crewReport]] { @xmitDataScalar = 1 }
@MODULE[*ModuleScience*]:HAS[#experimentID[evaReport]] { @xmitDataScalar = 1 }
Expand Down
31 changes: 26 additions & 5 deletions src/Modules/Laboratory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ namespace KERBALISM
{


public sealed class Laboratory : PartModule, IModuleInfo, ISpecifics, IContractObjectiveModule
public sealed class Laboratory: PartModule, IModuleInfo, ISpecifics, IContractObjectiveModule
{
// config
[KSPField] public double ec_rate; // ec consumed per-second
[KSPField] public double analysis_rate; // analysis speed in Mb/s
[KSPField] public string researcher = string.Empty; // required crew for analysis
[KSPField] public bool cleaner = true; // can clean experiments

// persistence
[KSPField(isPersistant = true)] public bool running; // true if the lab is active
Expand Down Expand Up @@ -40,11 +41,12 @@ public void Update()
if (Lib.IsFlight())
{
Events["Toggle"].guiName = Lib.StatusToggle("Lab", status);

// if a cleaner and either a researcher is not required, or the researcher is present
if (cleaner && (!researcher_cs || researcher_cs.Check(part.protoModuleCrew))) Events["CleanExperiments"].active = true;
else Events["CleanExperiments"].active = false;
}
else
{
Events["Toggle"].guiName = Lib.StatusToggle("Lab", running ? "enabled" : "disabled");
}
else Events["Toggle"].guiName = Lib.StatusToggle("Lab", running ? "enabled" : "disabled");
}


Expand Down Expand Up @@ -146,6 +148,24 @@ public void Toggle()
running = !running;
}

[KSPEvent(guiActive = true, guiActiveEditor = false, guiName = "Clean Experiments", active = true)]
public void CleanExperiments()
{
List<ModuleScienceExperiment> modules = vessel.FindPartModulesImplementing<ModuleScienceExperiment>();
bool message = false;
foreach (ModuleScienceExperiment m in modules)
{
if (m.resettable && m.Inoperable)
{
m.ResetExperiment();
message = true;
}
}
// inform the user
if (message) Message.Post("Vessel experiments have been cleaned.");
}



// action groups
[KSPAction("#KERBALISM_Laboratory_Action")] public void Action(KSPActionParam param) { Toggle(); }
Expand All @@ -162,6 +182,7 @@ public Specifics Specs()
{
Specifics specs = new Specifics();
specs.Add("Researcher", new CrewSpecs(researcher).Info());
if (cleaner) specs.Add("Can clean experiments");
specs.Add("EC rate", Lib.HumanReadableRate(ec_rate));
specs.Add("Analysis rate", Lib.HumanReadableDataRate(analysis_rate));
return specs;
Expand Down

0 comments on commit 4d9da4c

Please sign in to comment.