Skip to content

Commit

Permalink
Fixed exceptions in Editor. Fixed Failure Rates in Editor being off.
Browse files Browse the repository at this point in the history
  • Loading branch information
severedsolo committed Jun 11, 2017
1 parent 483992f commit 7f837ad
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions UPFM/Untitled Part Failure Mod/BaseFailureModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,16 @@ private void Initialise()
if (generation == 0)
{
generation = (ScrapYardWrapper.GetBuildCount(part, ScrapYardWrapper.TrackType.NEW) - SYP.TimesRecovered);
if (HighLogic.LoadedSceneIsEditor) generation++;
if (HighLogic.LoadedSceneIsEditor && SYP.TimesRecovered == 0) generation++;
}
if (generation < 1) generation = 1;
if (hasFailed)
{
Events["RepairChecks"].active = true;
return;
}
Debug.Log("[UPFM]: " + part.name + " has initialised");
if (FailCheck(true))
if(part != null) Debug.Log("[UPFM]: " + part.name + " has initialised");
if (FailCheck(true) && !HighLogic.LoadedSceneIsEditor)
{
failureTime = Planetarium.GetUniversalTime() + (maxTimeToFailure*UnityEngine.Random.value);
willFail = true;
Expand Down Expand Up @@ -120,7 +120,7 @@ bool FailCheck(bool recalcChance)
if (SYP.TimesRecovered > 0) chanceOfFailure = chanceOfFailure * ((SYP.TimesRecovered / expectedLifetime));

}
Debug.Log("[UPFM]: Chances of "+part.name+" failing calculated to be " + chanceOfFailure * 100 + "%");
if(part != null) Debug.Log("[UPFM]: Chances of "+part.name+" failing calculated to be " + chanceOfFailure * 100 + "%");
if (UnityEngine.Random.value < chanceOfFailure) return true;
return false;
}
Expand Down

0 comments on commit 7f837ad

Please sign in to comment.