Skip to content

Commit

Permalink
Add Volume property
Browse files Browse the repository at this point in the history
  • Loading branch information
siimav committed May 31, 2023
1 parent 97588f2 commit 675f7d4
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions Source/ROLib/Modules/ModuleROTank.cs
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@ private ModelDefinitionVariantSet GetVariantSet(ModelDefinitionLayoutOptions def

#endregion Private Variables

public float Volume { get; private set; }

internal void ModelChangedHandler(bool pushNodes)
{
if (validateNose || validateMount)
Expand Down Expand Up @@ -874,8 +876,8 @@ private void UpdateTankVolume(bool lw)
{
if (!lw)
{
float totalVol = noseModule.moduleVolume + coreModule.moduleVolume + mountModule.moduleVolume;
SendVolumeChangedEvent(totalVol);
Volume = noseModule.moduleVolume + coreModule.moduleVolume + mountModule.moduleVolume;
SendVolumeChangedEvent(Volume);
return;
}

Expand All @@ -893,10 +895,10 @@ private void UpdateTankVolume(bool lw)

// Calculate the volume of the main tank
float r = currentDiameter / 2;
float effectiveVolume = (ROLUtils.EllipsoidVolume(r, r, r / 2) + ROLUtils.CylinderVolume(r, EffectiveCylinderLength())) * 1000f;
effectiveVolume += noseAdditionalVol + mountAdditionalVol;
Volume = (ROLUtils.EllipsoidVolume(r, r, r / 2) + ROLUtils.CylinderVolume(r, EffectiveCylinderLength())) * 1000f;
Volume += noseAdditionalVol + mountAdditionalVol;

ROLModInterop.RealFuelsVolumeUpdate(part, effectiveVolume);
ROLModInterop.RealFuelsVolumeUpdate(part, Volume);
}

public void SendVolumeChangedEvent(float newVol)
Expand Down

0 comments on commit 675f7d4

Please sign in to comment.