Skip to content

Commit

Permalink
Merge pull request #175 from BobPalmer/DEVELOP
Browse files Browse the repository at this point in the history
0.5.10
  • Loading branch information
BobPalmer authored Nov 30, 2016
2 parents e851064 + 3806662 commit 66f45e6
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
0.5.10 - 2016.11.29
-------------------
Fixed decoupler spam

0.5.9 - 2016.11.27
------------------
Even more spam fixed...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"VERSION":{
"MAJOR":0,
"MINOR":5,
"PATCH":9,
"PATCH":10,
"BUILD":0
},
"KSP_VERSION":{
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified Source/USILifeSupport/.vs/USILifeSupport/v14/.suo
Binary file not shown.
47 changes: 27 additions & 20 deletions Source/USILifeSupport/ModuleLifeSupportSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,18 @@ public class ModuleLifeSupportSystem : VesselModule
[KSPField(isPersistant = true)]
public double LastUpdateTime;

private bool isDirty = true;

public void Start()
{
GameEvents.onVesselPartCountChanged.Add(UpdateVessel);
GameEvents.onVesselCrewWasModified.Add(UpdateVessel);
GameEvents.onVesselCrewWasModified.Add(UpdateVessel);
GameEvents.onVesselChange.Add(UpdateVessel);
GameEvents.onVesselPartCountChanged.Add(SetVesselDirty);
GameEvents.onVesselCrewWasModified.Add(SetVesselDirty);
GameEvents.onVesselChange.Add(SetVesselDirty);
}

private void SetVesselDirty(Vessel v)
{
isDirty = true;
}

private VesselSupplyStatus _vStat;
Expand Down Expand Up @@ -44,19 +50,24 @@ public VesselSupplyStatus VesselStatus

public void OnDestroy()
{
GameEvents.onVesselPartCountChanged.Remove(UpdateVessel);
GameEvents.onVesselCrewWasModified.Remove(UpdateVessel);
GameEvents.onVesselCrewWasModified.Remove(UpdateVessel);
GameEvents.onVesselChange.Remove(UpdateVessel);
GameEvents.onVesselPartCountChanged.Remove(SetVesselDirty);
GameEvents.onVesselCrewWasModified.Remove(SetVesselDirty);
GameEvents.onVesselChange.Remove(SetVesselDirty);
}

public void FixedUpdate()
{
if (!HighLogic.LoadedSceneIsFlight || vessel == null)
return;
if (!vessel.loaded)
return;

if (!HighLogic.LoadedSceneIsFlight || vessel == null)
return;
if (isDirty)
{
isDirty = false;
UpdateVesselInfo();
UpdateStatus();
}

if (_currentCrew == 0)
return;
Expand Down Expand Up @@ -91,6 +102,10 @@ public void FixedUpdate()

if (_currentCrew > 0)
{
//Guard clause
if(_crewPart == null)
UpdateVesselInfo();

//we will add a bit of a fudge factor for supplies
var tolerance = deltaTime / 2f;
//nom nom nom!
Expand Down Expand Up @@ -204,23 +219,15 @@ public void FixedUpdate()
}
}

private void UpdateVessel(Vessel thisVessel)
{
if (!HighLogic.LoadedSceneIsFlight || vessel == null)
return;

UpdateVesselInfo();
UpdateStatus();
}

private void UpdateVesselInfo()
{
if (!HighLogic.LoadedSceneIsFlight || vessel == null)
return;

CheckForDeadKerbals();
_currentCrew = vessel.GetCrewCount();
_crewPart = vessel.Parts.First(p => p.CrewCapacity > 0);
if(vessel.GetCrewCapacity() > 0)
_crewPart = vessel.Parts.First(p => p.CrewCapacity > 0);
}

private void UpdateStatus()
Expand Down

0 comments on commit 66f45e6

Please sign in to comment.