Skip to content

Commit

Permalink
Merge pull request #90 from BobPalmer/DEVELOP
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
BobPalmer committed Mar 3, 2016
2 parents 99ba630 + 72ecf3a commit c60f46f
Show file tree
Hide file tree
Showing 17 changed files with 504 additions and 254 deletions.
5 changes: 5 additions & 0 deletions FOR_RELEASE/GameData/000_USITools/CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
0.6.3 - 2016.03.02
------------------
Logistics pulls are now restricted to warehouses
Warehouses can be toggled

0.6.2 - 2016.02.05
------------------
Added support for Blizzy's Toolbar (thanks nanathan!)
Expand Down
Binary file modified FOR_RELEASE/GameData/000_USITools/USITools.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion FOR_RELEASE/GameData/000_USITools/USITools.version
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"VERSION":{
"MAJOR":0,
"MINOR":6,
"PATCH":2,
"PATCH":3,
"BUILD":0
},
"KSP_VERSION":{
Expand Down
Binary file removed FOR_RELEASE/GameData/ModuleManager.2.6.17.dll
Binary file not shown.
Binary file added FOR_RELEASE/GameData/ModuleManager.2.6.18.dll
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
0.3.13 - 2016.03.02
-------------------
Remove ReplacementParts input ressource from MPL (thanks far-lobyte!)
Fixed issue with empty vessels and supply consumption upon Kerbals entering (thanks JPLRepo!)
added more info to the VAB info windows (Thanks bennord!)
Orbiting/Splashed/Landed should display correctly now.
Both hab time and homesickness time are shown. When either timer expires, the habitation effect takes place.
Corrected an issue that was causing hab time to incorrectly reset.
Fixed an issue where supply consumption was out of sync with recyclers/etc. during catch-up mechanics.
Fixed an issue causing diminishing returns for recyclers
Fixed an issue where certain settings were not having effects

0.3.12 - 2016.02.13
-------------------
Various display bug fixes

0.3.11 - 2016.02.08
-------------------
Increased default hab multiplier by 5x (this will remain as the default for MKS-Lite, but not for UKS which will use the default of 1x)
Fixed an issue where recyclers were not shutting off (boo!)

0.3.10 - 2016.02.08
-------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,6 @@
ResourceName = ElectricCharge
Ratio = 1
}
INPUT_RESOURCE
{
ResourceName = ReplacementParts
Ratio = 0.00001
}
}

MODULE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"VERSION":{
"MAJOR":0,
"MINOR":3,
"PATCH":11,
"PATCH":13,
"BUILD":0
},
"KSP_VERSION":{
Expand Down
Binary file not shown.
Binary file not shown.
108 changes: 53 additions & 55 deletions Source/USILifeSupport/LifeSupportManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,19 @@ public bool IsVesselTracked(string vesselId)

public void UntrackKerbal(string kname)
{
if (!IsKerbalTracked(kname))
return;
var kerbal = LifeSupportInfo.First(k => k.KerbalName == kname);
LifeSupportInfo.Remove(kerbal);
//For saving to our scenario data
LifeSupportScenario.Instance.settings.DeleteStatusNode(kerbal);
try
{
if (!IsKerbalTracked(kname))
return;
var kerbal = LifeSupportInfo.First(k => k.KerbalName == kname);
LifeSupportInfo.Remove(kerbal);
//For saving to our scenario data
LifeSupportScenario.Instance.settings.DeleteStatusNode(kname);
}
catch (Exception ex)
{
print(String.Format("ERROR {0} IN UntrackKerbal", ex.Message));
}
}
public LifeSupportStatus FetchKerbal(ProtoCrewMember crew)
{
Expand All @@ -84,9 +91,10 @@ public LifeSupportStatus FetchKerbal(ProtoCrewMember crew)
k.KerbalName = crew.name;
k.LastMeal = Planetarium.GetUniversalTime();
k.LastOnKerbin = Planetarium.GetUniversalTime();
k.MaxOffKerbinTime = Planetarium.GetUniversalTime() + 972000000;
k.MaxOffKerbinTime = 648000;
k.TimeEnteredVessel = Planetarium.GetUniversalTime();
k.LastVesselId = "??UNKNOWN??";
k.CurrentVesselId = "?UNKNOWN?";
k.PreviousVesselId = "??UNKNOWN??";
k.LastUpdate = Planetarium.GetUniversalTime();
k.IsGrouchy = false;
k.OldTrait = crew.experienceTrait.Title;
Expand All @@ -99,55 +107,33 @@ public LifeSupportStatus FetchKerbal(ProtoCrewMember crew)

public void TrackKerbal(LifeSupportStatus status)
{
LifeSupportStatus kerbInfo =
LifeSupportInfo.FirstOrDefault(n => n.KerbalName == status.KerbalName);
if (kerbInfo == null)
if (LifeSupportInfo.All(n => n.KerbalName != status.KerbalName))
{
kerbInfo = new LifeSupportStatus();
kerbInfo.KerbalName = status.KerbalName;
LifeSupportInfo.Add(kerbInfo);
LifeSupportInfo.Add(status);
}
kerbInfo.LastMeal = status.LastMeal;
kerbInfo.LastOnKerbin = status.LastOnKerbin;
kerbInfo.MaxOffKerbinTime = status.MaxOffKerbinTime;
kerbInfo.LastVesselId = status.LastVesselId;
kerbInfo.TimeEnteredVessel = status.TimeEnteredVessel;
kerbInfo.LastUpdate = status.LastUpdate;
kerbInfo.IsGrouchy = status.IsGrouchy;
kerbInfo.OldTrait = status.OldTrait;
LifeSupportScenario.Instance.settings.SaveStatusNode(kerbInfo);
LifeSupportScenario.Instance.settings.SaveStatusNode(status);
}

public void TrackVessel(VesselSupplyStatus status)
{
VesselSupplyStatus vesselInfo =
VesselSupplyInfo.FirstOrDefault(n => n.VesselId == status.VesselId);
if (vesselInfo == null)
{
vesselInfo = new VesselSupplyStatus();
vesselInfo.VesselId = status.VesselId;
VesselSupplyInfo.Add(vesselInfo);
}
vesselInfo.VesselName = status.VesselName;
vesselInfo.LastFeeding = status.LastFeeding;
vesselInfo.LastUpdate = status.LastUpdate;
vesselInfo.NumCrew = status.NumCrew;
vesselInfo.RecyclerMultiplier = status.RecyclerMultiplier;
vesselInfo.CrewCap = status.CrewCap;
vesselInfo.ExtraHabSpace = status.ExtraHabSpace;
vesselInfo.VesselHabMultiplier = status.VesselHabMultiplier;
vesselInfo.SuppliesLeft = status.SuppliesLeft;
LifeSupportScenario.Instance.settings.SaveVesselNode(vesselInfo);
if(VesselSupplyInfo.All(n => n.VesselId != status.VesselId))
VesselSupplyInfo.Add(status);
LifeSupportScenario.Instance.settings.SaveVesselNode(status);
}

public void UntrackVessel(string vesselId)
{
//print("Untracking " + vesselId);
if (!IsVesselTracked(vesselId))
return;

//print("Finding " + vesselId);
var vInfo = VesselSupplyInfo.First(v => v.VesselId == vesselId);
//print("Removing " + vesselId);
VesselSupplyInfo.Remove(vInfo);
//For saving to our scenario data
LifeSupportScenario.Instance.settings.DeleteVesselNode(vInfo);
//print("Deleting " + vesselId);
LifeSupportScenario.Instance.settings.DeleteVesselNode(vesselId);
}
public VesselSupplyStatus FetchVessel(string vesselId)
{
Expand Down Expand Up @@ -183,19 +169,28 @@ internal void UpdateVesselStats()
{
//Clear stuff that is gone.
var badIDs = new List<string>();
foreach (var vInfo in LifeSupportManager.Instance.VesselSupplyInfo)
foreach (var vInfo in Instance.VesselSupplyInfo)
{
//print("Checking " + vInfo.VesselId);
var vsl = FlightGlobals.Vessels.FirstOrDefault(v => v.id.ToString() == vInfo.VesselId);
if(vsl == null || vInfo.NumCrew == 0)
//print("Finding vessel " + vInfo.VesselId);
if (vsl == null || vInfo.NumCrew == 0)
{
//print("Adding bad ID " + vInfo.VesselId);
badIDs.Add(vInfo.VesselId);
}
// else
//{
//print("Found " + vInfo.VesselId);
//}
}

//print("START COUNT: " + Instance.VesselSupplyInfo.Count);
foreach (var id in badIDs)
{
LifeSupportManager.Instance.UntrackVessel(id);
//print("Removing " + id);
Instance.UntrackVessel(id);
}
//print("END COUNT: " + Instance.VesselSupplyInfo.Count);
}

private static int GetColonyCrewCount(Vessel vsl)
Expand All @@ -215,7 +210,7 @@ internal static double GetRecyclerMultiplier(Vessel vessel)
return 1d;

var recyclerCap = 0f;
var recyclerVal = 1f;
var recyclerTot = 0f;
var crewCount = GetColonyCrewCount(vessel);

foreach (var r in vessel.FindPartModulesImplementing<ModuleLifeSupportRecycler>())
Expand All @@ -228,7 +223,7 @@ internal static double GetRecyclerMultiplier(Vessel vessel)
if (r.CrewCapacity < crewCount)
recPercent *= r.CrewCapacity/(float) crewCount;

recyclerVal *= (1f - recPercent);
recyclerTot += recPercent;
}
}

Expand All @@ -245,11 +240,13 @@ internal static double GetRecyclerMultiplier(Vessel vessel)
if (r.CrewCapacity < crewCount)
recPercent *= r.CrewCapacity / (float)crewCount;

recyclerVal *= (1f - recPercent);
recyclerTot += recPercent;
}
}
}
return Math.Max(recyclerVal, (1f - recyclerCap));
//Inverse because this is a multiplier - low is good!
double retVal = 1d - (Math.Min(recyclerTot, recyclerCap));
return retVal;
}


Expand Down Expand Up @@ -277,7 +274,7 @@ internal static double GetTotalHabTime(VesselSupplyStatus sourceVessel)
double habTotal = totHabSpace / totCurCrew * (totHabMult + 1) * LifeSupportSetup.Instance.LSConfig.HabMultiplier;
//print(String.Format("THS: {0} TC:{1} THM: {2} HM: {3}", totHabSpace, totCurCrew, totHabMult, LifeSupportSetup.Instance.LSConfig.HabMultiplier));

return habTotal * (60d * 60d * 6d * 30d);
return Math.Max(0,habTotal * (60d * 60d * 6d * 30d));
}

internal static double GetRecyclerMultiplierForParts(List<Part> pList, int crewCount)
Expand All @@ -286,7 +283,7 @@ internal static double GetRecyclerMultiplierForParts(List<Part> pList, int crewC
return 1d;

var recyclerCap = 0f;
var recyclerVal = 1f;
var recyclerTot = 0f;

foreach (var p in pList)
{
Expand All @@ -303,10 +300,11 @@ internal static double GetRecyclerMultiplierForParts(List<Part> pList, int crewC
if (mod.CrewCapacity < crewCount)
recPercent *= mod.CrewCapacity / (float)crewCount;

recyclerVal *= (1f - recPercent);
recyclerTot += recPercent;
}

return Math.Max(recyclerVal, (1f - recyclerCap));
//Inverse because this is a multiplier - low is good!
double retVal = 1d - (Math.Min(recyclerTot, recyclerCap));
return retVal;
}
public static bool IsOnKerbin(Vessel v)
{
Expand Down
Loading

0 comments on commit c60f46f

Please sign in to comment.