Skip to content

Commit

Permalink
Fixes KSP-KOS#1755 - with manual edit.
Browse files Browse the repository at this point in the history
I had to manually edit the things Efratror had in his Pull request
for this issue because the PR was messed up and although it had
the diffs I could read to re-implement the fix, the original
repository they came from didn't seem to be there.
  • Loading branch information
Dunbaratu committed May 6, 2017
1 parent 012d10e commit 00cf2a5
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/kOS/Module/kOSProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public string Tag
private bool firstUpdate = true;
private bool objectsInitialized = false;

public float AdditionalMass { get; set; }

/// How many times have instances of this class been constructed during this process run?
private static int constructorCount;

Expand Down Expand Up @@ -86,14 +88,14 @@ public string Tag
[KSPField(isPersistant = true, guiName = "CPU/Disk Upgrade Cost", guiActive = false, guiActiveEditor = true)]
public float additionalCost = 0F;

[KSPField(isPersistant = false, guiName = "CPU/Disk Upgrade Mass", guiActive = false, guiActiveEditor = true)]
public float additionalMass = 0F;
[KSPField(isPersistant = false, guiName = "CPU/Disk Upgrade Mass", guiActive = false, guiActiveEditor = true, guiUnits = "Kg", guiFormat = "0.00")]
public float additionalMassGui = 0F;

[KSPField(isPersistant = false, guiActive = false, guiActiveEditor = false)]
public float diskSpaceCostFactor = 0.0244140625F; //implies approx 100funds for 4096bytes of diskSpace

[KSPField(isPersistant = false, guiActive = false, guiActiveEditor = false)]
public float diskSpaceMassFactor = 0.0000048829F; //implies approx 0.020kg for 4096bytes of diskSpace
public float diskSpaceMassFactor = 0.0000000048829F; //implies approx 0.020kg for 4096bytes of diskSpace

[KSPField(isPersistant = true, guiActive = false)]
public int MaxPartId = 100;
Expand Down Expand Up @@ -249,15 +251,16 @@ private void UpdateCostAndMass()
{
float spaceDelta = diskSpace - baseDiskSpace;
additionalCost = (float)System.Math.Round(spaceDelta * diskSpaceCostFactor, 0);
additionalMass = spaceDelta * diskSpaceMassFactor;
AdditionalMass = spaceDelta * diskSpaceMassFactor;
additionalMassGui = AdditionalMass * 1000;
}

//implement IPartMassModifier component
public float GetModuleMass(float defaultMass, ModifierStagingSituation sit)
{
// the 'sit' arg is irrelevant to us, but the interface requires it.

return baseModuleMass + additionalMass;
return baseModuleMass + AdditionalMass;
}
//implement IPartMassModifier component
public ModifierChangeWhen GetModuleMassChangeWhen()
Expand Down

0 comments on commit 00cf2a5

Please sign in to comment.