diff --git a/FOR_RELEASE/GameData/000_USITools/CHANGELOG.txt b/FOR_RELEASE/GameData/000_USITools/CHANGELOG.txt index 8e637b9..eabc09d 100644 --- a/FOR_RELEASE/GameData/000_USITools/CHANGELOG.txt +++ b/FOR_RELEASE/GameData/000_USITools/CHANGELOG.txt @@ -1,3 +1,7 @@ +0.8.8 - 2017.01.01 +------------------- +Dependency Updates + 0.8.7 - (KSP 1.2.2) ------------------- Updates for KSP 1.2.2 diff --git a/FOR_RELEASE/GameData/000_USITools/USITools.dll b/FOR_RELEASE/GameData/000_USITools/USITools.dll index 8f65cb8..75c280b 100644 Binary files a/FOR_RELEASE/GameData/000_USITools/USITools.dll and b/FOR_RELEASE/GameData/000_USITools/USITools.dll differ diff --git a/FOR_RELEASE/GameData/000_USITools/USITools.dll.mdb b/FOR_RELEASE/GameData/000_USITools/USITools.dll.mdb index 9927a83..25e5238 100644 Binary files a/FOR_RELEASE/GameData/000_USITools/USITools.dll.mdb and b/FOR_RELEASE/GameData/000_USITools/USITools.dll.mdb differ diff --git a/FOR_RELEASE/GameData/000_USITools/USITools.pdb b/FOR_RELEASE/GameData/000_USITools/USITools.pdb index be3280d..dfe15b1 100644 Binary files a/FOR_RELEASE/GameData/000_USITools/USITools.pdb and b/FOR_RELEASE/GameData/000_USITools/USITools.pdb differ diff --git a/FOR_RELEASE/GameData/000_USITools/USITools.version b/FOR_RELEASE/GameData/000_USITools/USITools.version index 83420de..8b2bb10 100644 --- a/FOR_RELEASE/GameData/000_USITools/USITools.version +++ b/FOR_RELEASE/GameData/000_USITools/USITools.version @@ -10,7 +10,7 @@ "VERSION":{ "MAJOR":0, "MINOR":8, - "PATCH":7, + "PATCH":8, "BUILD":0 }, "KSP_VERSION":{ diff --git a/FOR_RELEASE/GameData/CommunityResourcePack/Asteroid.cfg b/FOR_RELEASE/GameData/CommunityResourcePack/Asteroid.cfg index 2fce0f5..0adce62 100644 --- a/FOR_RELEASE/GameData/CommunityResourcePack/Asteroid.cfg +++ b/FOR_RELEASE/GameData/CommunityResourcePack/Asteroid.cfg @@ -26,7 +26,22 @@ lowRange = 50 highRange = 75 } - + MODULE + { + name = ModuleAsteroidResource + resourceName = Silicates + presenceChance = 80 + lowRange = 50 + highRange = 75 + } + MODULE + { + name = ModuleAsteroidResource + resourceName = Hydrates + presenceChance = 80 + lowRange = 50 + highRange = 75 + } MODULE { name = ModuleAsteroidResource @@ -34,6 +49,14 @@ presenceChance = 25 lowRange = 1 highRange = 10 + } + MODULE + { + name = ModuleAsteroidResource + resourceName = Gypsum + presenceChance = 25 + lowRange = 1 + highRange = 10 } MODULE @@ -72,6 +95,23 @@ highRange = 10 } + MODULE + { + name = ModuleAsteroidResource + resourceName = ExoticMinerals + presenceChance = 80 + lowRange = 1 + highRange = 30 + } + MODULE + { + name = ModuleAsteroidResource + resourceName = RareMetals + presenceChance = 80 + lowRange = 1 + highRange = 30 + } + MODULE { name = ModuleAsteroidResource @@ -89,5 +129,4 @@ presenceChance = 100 resourceName = Rock } - } \ No newline at end of file diff --git a/FOR_RELEASE/GameData/CommunityResourcePack/AsteroidScannerSetup.cfg b/FOR_RELEASE/GameData/CommunityResourcePack/AsteroidScannerSetup.cfg index 3edc18a..e69de29 100644 --- a/FOR_RELEASE/GameData/CommunityResourcePack/AsteroidScannerSetup.cfg +++ b/FOR_RELEASE/GameData/CommunityResourcePack/AsteroidScannerSetup.cfg @@ -1,65 +0,0 @@ -@PART[SurfaceScanner] -{ - MODULE - { - name = ModuleAnalysisResource - resourceName = Water - abundance = 0 - } - - MODULE - { - name = ModuleAnalysisResource - resourceName = MetallicOre - abundance = 0 - } - - MODULE - { - name = ModuleAnalysisResource - resourceName = Substrate - abundance = 0 - } - - MODULE - { - name = ModuleAnalysisResource - resourceName = Minerals - abundance = 0 - } - - MODULE - { - name = ModuleAnalysisResource - resourceName = Karbonite - abundance = 0 - } - - MODULE - { - name = ModuleAnalysisResource - resourceName = Karborundum - abundance = 0 - } - - MODULE - { - name = ModuleAnalysisResource - resourceName = Uraninite - abundance = 0 - } - - MODULE - { - name = ModuleAnalysisResource - resourceName = XenonGas - abundance = 0 - } - - MODULE - { - name = ModuleAnalysisResource - resourceName = ArgonGas - abundance = 0 - } -} \ No newline at end of file diff --git a/FOR_RELEASE/GameData/CommunityResourcePack/CHANGELOG.txt b/FOR_RELEASE/GameData/CommunityResourcePack/CHANGELOG.txt index 6cea488..cdf10b2 100644 --- a/FOR_RELEASE/GameData/CommunityResourcePack/CHANGELOG.txt +++ b/FOR_RELEASE/GameData/CommunityResourcePack/CHANGELOG.txt @@ -1,3 +1,7 @@ +0.6.5 - (2017.01.01) +-------------------- +Updated asteroid and scanner settings + 0.6.4 - (KSP 1.2.2) ------------------- Added Decaborane as a resource diff --git a/FOR_RELEASE/GameData/CommunityResourcePack/CRP.version b/FOR_RELEASE/GameData/CommunityResourcePack/CRP.version index 25020b2..db3fe2f 100644 --- a/FOR_RELEASE/GameData/CommunityResourcePack/CRP.version +++ b/FOR_RELEASE/GameData/CommunityResourcePack/CRP.version @@ -10,7 +10,7 @@ "VERSION":{ "MAJOR":0, "MINOR":6, - "PATCH":4, + "PATCH":5, "BUILD":0 }, "KSP_VERSION":{ diff --git a/FOR_RELEASE/GameData/CommunityResourcePack/CommonResources.cfg b/FOR_RELEASE/GameData/CommunityResourcePack/CommonResources.cfg index 68efeca..4298e55 100644 --- a/FOR_RELEASE/GameData/CommunityResourcePack/CommonResources.cfg +++ b/FOR_RELEASE/GameData/CommunityResourcePack/CommonResources.cfg @@ -99,6 +99,7 @@ RESOURCE_DEFINITION volume = 1 } + RESOURCE_DEFINITION { name = Dirt @@ -525,6 +526,18 @@ RESOURCE_DEFINITION volume = 1 } +RESOURCE_DEFINITION +{ + name = ResourceLode + density = 0.005 + flowMode = ALL_VESSEL + transfer = NONE + unitCost = 250 + isTweakable = true + isVisible = true + volume = 1 +} + RESOURCE_DEFINITION { name = DepletedUranium // Depleted fuel to preserve mass when burned, can be recycled diff --git a/FOR_RELEASE/GameData/CommunityResourcePack/SurfaceScanner.cfg b/FOR_RELEASE/GameData/CommunityResourcePack/SurfaceScanner.cfg new file mode 100644 index 0000000..a796661 --- /dev/null +++ b/FOR_RELEASE/GameData/CommunityResourcePack/SurfaceScanner.cfg @@ -0,0 +1,101 @@ +@PART[SurfaceScanner] +{ + MODULE + { + name = ModuleResourceScanner + ScannerType = 0 + ResourceName = Dirt + MaxAbundanceAltitude = 1000 + RequiresUnlock = false + } + MODULE + { + name = ModuleResourceScanner + ScannerType = 0 + ResourceName = ExoticMinerals + MaxAbundanceAltitude = 1000 + RequiresUnlock = false + } + MODULE + { + name = ModuleResourceScanner + ScannerType = 0 + ResourceName = Gypsum + MaxAbundanceAltitude = 1000 + RequiresUnlock = false + } + MODULE + { + name = ModuleResourceScanner + ScannerType = 0 + ResourceName = Hydrates + MaxAbundanceAltitude = 1000 + RequiresUnlock = false + } + MODULE + { + name = ModuleResourceScanner + ScannerType = 0 + ResourceName = Karbonite + MaxAbundanceAltitude = 1000 + RequiresUnlock = false + } + MODULE + { + name = ModuleResourceScanner + ScannerType = 0 + ResourceName = MetallicOre + MaxAbundanceAltitude = 1000 + RequiresUnlock = false + } + MODULE + { + name = ModuleResourceScanner + ScannerType = 0 + ResourceName = Minerals + MaxAbundanceAltitude = 1000 + RequiresUnlock = false + } + MODULE + { + name = ModuleResourceScanner + ScannerType = 0 + ResourceName = RareMetals + MaxAbundanceAltitude = 1000 + RequiresUnlock = false + } + MODULE + { + name = ModuleResourceScanner + ScannerType = 0 + ResourceName = Silicates + MaxAbundanceAltitude = 1000 + RequiresUnlock = false + } + MODULE + { + name = ModuleResourceScanner + ScannerType = 0 + ResourceName = Substrate + MaxAbundanceAltitude = 1000 + RequiresUnlock = false + } + MODULE + { + name = ModuleResourceScanner + ScannerType = 0 + ResourceName = Uraninite + MaxAbundanceAltitude = 1000 + RequiresUnlock = false + } + MODULE + { + name = ModuleResourceScanner + ScannerType = 0 + ResourceName = Water + MaxAbundanceAltitude = 1000 + RequiresUnlock = false + } + + +} \ No newline at end of file diff --git a/FOR_RELEASE/GameData/UmbraSpaceIndustries/LifeSupport/Assets/NomTank.dds b/FOR_RELEASE/GameData/UmbraSpaceIndustries/LifeSupport/Assets/NomTank.dds index c0c2d40..eb4f2e0 100644 Binary files a/FOR_RELEASE/GameData/UmbraSpaceIndustries/LifeSupport/Assets/NomTank.dds and b/FOR_RELEASE/GameData/UmbraSpaceIndustries/LifeSupport/Assets/NomTank.dds differ diff --git a/FOR_RELEASE/GameData/UmbraSpaceIndustries/LifeSupport/Assets/NomTank_N.dds b/FOR_RELEASE/GameData/UmbraSpaceIndustries/LifeSupport/Assets/NomTank_N.dds new file mode 100644 index 0000000..790dab5 Binary files /dev/null and b/FOR_RELEASE/GameData/UmbraSpaceIndustries/LifeSupport/Assets/NomTank_N.dds differ diff --git a/FOR_RELEASE/GameData/UmbraSpaceIndustries/LifeSupport/ChangeLog.txt b/FOR_RELEASE/GameData/UmbraSpaceIndustries/LifeSupport/ChangeLog.txt index 6758aae..a836f0e 100644 --- a/FOR_RELEASE/GameData/UmbraSpaceIndustries/LifeSupport/ChangeLog.txt +++ b/FOR_RELEASE/GameData/UmbraSpaceIndustries/LifeSupport/ChangeLog.txt @@ -1,3 +1,17 @@ +0.5.15 - 2017.01.01 +------------------- +Dependency Updates +Fixed an issue where the timer for unloaded vessels was not reflecting the 15 day grace period. +Better caching of hab data to prevent some physics bubble oddities +When crew go mutinous, a few supplies are shaken out. This will help prevent catastrophic mutiny cascades. Which, while entertaining, were a bit more destructive than anticipated. +Nom tanks got their normal map back +Habitation EC costs have been reduced. +The life support window in the VAB correctly shows recyclers only when loaded in the case of configurable bays. +Fixed Nom-O-Matic 5000 cost +Several rounds of bug fixes around timers, etc. + + + 0.5.14 - (KSP 1.2.2) ------------------- Updates for KSP 1.2.2 diff --git a/FOR_RELEASE/GameData/UmbraSpaceIndustries/LifeSupport/LSModule.cfg b/FOR_RELEASE/GameData/UmbraSpaceIndustries/LifeSupport/LSModule.cfg index 4702c10..41ce65b 100644 --- a/FOR_RELEASE/GameData/UmbraSpaceIndustries/LifeSupport/LSModule.cfg +++ b/FOR_RELEASE/GameData/UmbraSpaceIndustries/LifeSupport/LSModule.cfg @@ -24,7 +24,7 @@ INPUT_RESOURCE { ResourceName = ElectricCharge - Ratio = 5.25 + Ratio = 0.525 } } @@ -60,7 +60,7 @@ INPUT_RESOURCE { ResourceName = ElectricCharge - Ratio = 0.825 + Ratio = 0.0825 } } diff --git a/FOR_RELEASE/GameData/UmbraSpaceIndustries/LifeSupport/Parts/Greenhouse_MiniCupola.cfg b/FOR_RELEASE/GameData/UmbraSpaceIndustries/LifeSupport/Parts/Greenhouse_MiniCupola.cfg index 2388a1e..3ed9b98 100644 --- a/FOR_RELEASE/GameData/UmbraSpaceIndustries/LifeSupport/Parts/Greenhouse_MiniCupola.cfg +++ b/FOR_RELEASE/GameData/UmbraSpaceIndustries/LifeSupport/Parts/Greenhouse_MiniCupola.cfg @@ -8,7 +8,7 @@ PART node_stack_bottom = 0,0,0,0,-1,0 TechRequired = survivability entryCost = 1000 - cost = 100 + cost = 700 category = none subcategory = 0 title = Nom-O-Matic 5000 diff --git a/FOR_RELEASE/GameData/UmbraSpaceIndustries/LifeSupport/Parts/SmCupola.cfg b/FOR_RELEASE/GameData/UmbraSpaceIndustries/LifeSupport/Parts/SmCupola.cfg index e76460f..93941f3 100644 --- a/FOR_RELEASE/GameData/UmbraSpaceIndustries/LifeSupport/Parts/SmCupola.cfg +++ b/FOR_RELEASE/GameData/UmbraSpaceIndustries/LifeSupport/Parts/SmCupola.cfg @@ -42,7 +42,7 @@ PART INPUT_RESOURCE { ResourceName = ElectricCharge - Ratio = 0.175 + Ratio = 0.0175 } } } diff --git a/FOR_RELEASE/GameData/UmbraSpaceIndustries/LifeSupport/Parts/ViewingCupola.cfg b/FOR_RELEASE/GameData/UmbraSpaceIndustries/LifeSupport/Parts/ViewingCupola.cfg index db475fe..761e805 100644 --- a/FOR_RELEASE/GameData/UmbraSpaceIndustries/LifeSupport/Parts/ViewingCupola.cfg +++ b/FOR_RELEASE/GameData/UmbraSpaceIndustries/LifeSupport/Parts/ViewingCupola.cfg @@ -52,7 +52,7 @@ PART INPUT_RESOURCE { ResourceName = ElectricCharge - Ratio = 0.125 + Ratio = 0.0125 } } } diff --git a/FOR_RELEASE/GameData/UmbraSpaceIndustries/LifeSupport/USI-LS.version b/FOR_RELEASE/GameData/UmbraSpaceIndustries/LifeSupport/USI-LS.version index 5a911f0..313e78b 100644 --- a/FOR_RELEASE/GameData/UmbraSpaceIndustries/LifeSupport/USI-LS.version +++ b/FOR_RELEASE/GameData/UmbraSpaceIndustries/LifeSupport/USI-LS.version @@ -10,7 +10,7 @@ "VERSION":{ "MAJOR":0, "MINOR":5, - "PATCH":14, + "PATCH":15, "BUILD":0 }, "KSP_VERSION":{ diff --git a/FOR_RELEASE/GameData/UmbraSpaceIndustries/LifeSupport/USILifeSupport.dll b/FOR_RELEASE/GameData/UmbraSpaceIndustries/LifeSupport/USILifeSupport.dll index 8c8f4d2..b2068f6 100644 Binary files a/FOR_RELEASE/GameData/UmbraSpaceIndustries/LifeSupport/USILifeSupport.dll and b/FOR_RELEASE/GameData/UmbraSpaceIndustries/LifeSupport/USILifeSupport.dll differ diff --git a/FOR_RELEASE/GameData/UmbraSpaceIndustries/LifeSupport/USILifeSupport.dll.mdb b/FOR_RELEASE/GameData/UmbraSpaceIndustries/LifeSupport/USILifeSupport.dll.mdb index 1328a31..e5b4352 100644 Binary files a/FOR_RELEASE/GameData/UmbraSpaceIndustries/LifeSupport/USILifeSupport.dll.mdb and b/FOR_RELEASE/GameData/UmbraSpaceIndustries/LifeSupport/USILifeSupport.dll.mdb differ diff --git a/FOR_RELEASE/GameData/UmbraSpaceIndustries/LifeSupport/USILifeSupport.pdb b/FOR_RELEASE/GameData/UmbraSpaceIndustries/LifeSupport/USILifeSupport.pdb index c1387a3..e6aee15 100644 Binary files a/FOR_RELEASE/GameData/UmbraSpaceIndustries/LifeSupport/USILifeSupport.pdb and b/FOR_RELEASE/GameData/UmbraSpaceIndustries/LifeSupport/USILifeSupport.pdb differ diff --git a/Source/USILifeSupport/.vs/USILifeSupport/v14/.suo b/Source/USILifeSupport/.vs/USILifeSupport/v14/.suo index 306a94d..7b8ecb2 100644 Binary files a/Source/USILifeSupport/.vs/USILifeSupport/v14/.suo and b/Source/USILifeSupport/.vs/USILifeSupport/v14/.suo differ diff --git a/Source/USILifeSupport/LifeSupportManager.cs b/Source/USILifeSupport/LifeSupportManager.cs index 36ce440..1c4f4ab 100644 --- a/Source/USILifeSupport/LifeSupportManager.cs +++ b/Source/USILifeSupport/LifeSupportManager.cs @@ -50,6 +50,7 @@ public List VesselSupplyInfo _VesselSupplyInfo = new List(); _VesselSupplyInfo.AddRange(LifeSupportScenario.Instance.settings.GetVesselInfo()); } + return _VesselSupplyInfo; } } @@ -150,6 +151,7 @@ public VesselSupplyStatus FetchVessel(string vesselId) v.RecyclerMultiplier = 1; v.CrewCap = 0; v.VesselHabMultiplier = 0; + v.CachedHabTime = 0; v.ExtraHabSpace = 0; v.SuppliesLeft = 0f; v.ECLeft = 0f; @@ -255,20 +257,27 @@ internal static double GetRecyclerMultiplier(Vessel vessel) } - internal static double GetTotalHabTime(VesselSupplyStatus sourceVessel) + internal static double GetTotalHabTime(VesselSupplyStatus sourceVessel, Vessel vsl) { int numSharedVessels = 0; - return GetTotalHabTime(sourceVessel, out numSharedVessels); + return GetTotalHabTime(sourceVessel, vsl, out numSharedVessels); } - internal static double GetTotalHabTime(VesselSupplyStatus sourceVessel, out int numSharedVessels) + internal static double GetTotalHabTime(VesselSupplyStatus sourceVessel, Vessel vsl, out int numSharedVessels) { - var vsl = FlightGlobals.Vessels.FirstOrDefault(v => v.id.ToString() == sourceVessel.VesselId); - double totHabSpace = (LifeSupportScenario.Instance.settings.GetSettings().BaseHabTime * sourceVessel.CrewCap) + sourceVessel.ExtraHabSpace; + //In the event that a vessel is not loaded, we just return the cached value. + if (!vsl.loaded) + { + numSharedVessels = 0; + return sourceVessel.CachedHabTime; + } + + double totHabSpace = sourceVessel.ExtraHabSpace; double totHabMult = sourceVessel.VesselHabMultiplier; int totCurCrew = sourceVessel.NumCrew; int totMaxCrew = sourceVessel.CrewCap; + numSharedVessels = 0; var vList = LogisticsTools.GetNearbyVessels((float)LifeSupportScenario.Instance.settings.GetSettings().HabRange, false, vsl, false); @@ -288,19 +297,22 @@ internal static double GetTotalHabTime(VesselSupplyStatus sourceVessel, out int hList.Add(v); } } + totHabSpace += (LifeSupportScenario.Instance.settings.GetSettings().BaseHabTime * totMaxCrew); foreach (var v in hList) { // Calculate HabSpace and HabMult after we know totCurCrew and totMaxCrew - totHabSpace += (LifeSupportScenario.Instance.settings.GetSettings().BaseHabTime * totMaxCrew) + CalculateVesselHabExtraTime(v); - totHabMult += CalculateVesselHabMultiplier(v, totCurCrew); + totHabSpace += CalculateVesselHabExtraTime(v); + totHabMult *= Math.Min(1,CalculateVesselHabMultiplier(v, totCurCrew)); } + totHabMult += USI_GlobalBonuses.Instance.GetHabBonus(vsl.mainBody.flightGlobalsIndex); double habTotal = totHabSpace / (double)totCurCrew * (totHabMult + 1) * LifeSupportScenario.Instance.settings.GetSettings().HabMultiplier; //print(String.Format("THS: {0} TC:{1} THM: {2} HM: {3}", totHabSpace, totCurCrew, totHabMult, LifeSupportScenario.Instance.settings.GetSettings().HabMultiplier)); - - return Math.Max(0,habTotal * LifeSupportUtilities.SecondsPerMonth()); - } + sourceVessel.CachedHabTime = Math.Max(0, habTotal * LifeSupportUtilities.SecondsPerMonth()); + LifeSupportManager.Instance.TrackVessel(sourceVessel); + return sourceVessel.CachedHabTime; + } internal static double GetRecyclerMultiplierForParts(List pList, int crewCount) { @@ -352,7 +364,6 @@ public static double CalculateVesselHabMultiplier(Vessel v, int numCrew) var habMulti = 0d; foreach (var hab in v.FindPartModulesImplementing()) { - //Lastly. Some modules act more as 'multipliers', dramatically extending a hab's workable lifespan. habMulti += (hab.HabMultiplier * Math.Min(1, hab.CrewCapacity / numCrew)); } return habMulti; diff --git a/Source/USILifeSupport/LifeSupportMonitor.cs b/Source/USILifeSupport/LifeSupportMonitor.cs index 0b41b55..f54173b 100644 --- a/Source/USILifeSupport/LifeSupportMonitor.cs +++ b/Source/USILifeSupport/LifeSupportMonitor.cs @@ -299,11 +299,22 @@ private List UpdateGUIStats() var vesselList = new List(); vesselList.AddRange(LifeSupportManager.Instance.VesselSupplyInfo); - - foreach (var vsl in vesselList) + var vlCount = vesselList.Count; + for(int i = 0; i < vlCount; ++i) { + var vsl = vesselList[i]; var vstat = new LifeSupportVesselDisplayStat(); - Vessel thisVessel = FlightGlobals.Vessels.First(v => v.id.ToString() == vsl.VesselId); + var vCount = FlightGlobals.Vessels.Count; + Vessel thisVessel = null; + for (int x = 0; x < vCount; ++x) + { + var tmpV = FlightGlobals.Vessels[x]; + if (tmpV.id.ToString() == vsl.VesselId) + { + thisVessel = tmpV; + break; + } + } double supmult = LifeSupportScenario.Instance.settings.GetSettings().SupplyAmount * Convert.ToDouble(vsl.NumCrew) * vsl.RecyclerMultiplier; var supPerDay = secondsPerDay*supmult; var estFood = supmult*(Planetarium.GetUniversalTime() - vsl.LastFeeding); @@ -313,11 +324,15 @@ private List UpdateGUIStats() var estEC = ecmult * (Planetarium.GetUniversalTime() - vsl.LastECCheck); int numSharedHabVessels = 0; - var habTime = LifeSupportManager.GetTotalHabTime(vsl, out numSharedHabVessels); + var habTime = LifeSupportManager.GetTotalHabTime(vsl, thisVessel, out numSharedHabVessels); var supAmount = GetResourceInVessel(thisVessel,"Supplies"); - if(supAmount == 0) + var calcSup = supAmount; + if (supAmount == 0) + { supAmount = Math.Max(0, (vsl.SuppliesLeft * supmult) - estFood); + calcSup = (vsl.SuppliesLeft*supmult) - estFood; + } var ecAmount = GetResourceInVessel(thisVessel,"ElectricCharge"); if (ecAmount == 0) @@ -365,6 +380,16 @@ private List UpdateGUIStats() { var cStat = new LifeSupportCrewDisplayStat(); var cls = LifeSupportManager.Instance.FetchKerbal(c); + //Guard clause in case we just changed vessels + if (cls.CurrentVesselId != thisVessel.id.ToString() + && cls.PreviousVesselId != thisVessel.id.ToString()) + { + cls.PreviousVesselId = cls.CurrentVesselId; + cls.CurrentVesselId = thisVessel.id.ToString(); + cls.TimeEnteredVessel = Planetarium.GetUniversalTime(); + LifeSupportManager.Instance.TrackKerbal(cls); + } + cStat.CrewName = String.Format("{0} ({1})", c.name,c.experienceTrait.Title.Substring(0,1)); var ecLeft = (ecAmount / ecPerDay * secondsPerDay) + LifeSupportScenario.Instance.settings.GetSettings().ECTime; @@ -391,12 +416,7 @@ private List UpdateGUIStats() cStat.ECLabel = String.Format("{1}",lblEC,lblECTime); - var snacksLeft = (supAmount / supPerDay * secondsPerDay) + LifeSupportScenario.Instance.settings.GetSettings().SupplyTime; - if (supAmount <= LifeSupportScenario.Instance.settings.GetSettings().SupplyAmount && !LifeSupportManager.IsOnKerbin(thisVessel)) - { - snacksLeft = cls.LastMeal - Planetarium.GetUniversalTime() + LifeSupportScenario.Instance.settings.GetSettings().SupplyTime; - } - + var snacksLeft = (calcSup/supPerDay*secondsPerDay) + LifeSupportScenario.Instance.settings.GetSettings().SupplyTime; var lblSupTime = LifeSupportUtilities.SecondsToKerbinTime(snacksLeft); var lblSup = "6FFF00"; @@ -461,8 +481,8 @@ private List UpdateGUIStats() crewHomeString = "expired"; } cStat.HomeLabel = String.Format("{1}", lblHome, crewHomeString); - - + + LifeSupportManager.Instance.TrackKerbal(cls); vstat.crew.Add(cStat); } statList.Add(vstat); diff --git a/Source/USILifeSupport/LifeSupportMonitor_Editor.cs b/Source/USILifeSupport/LifeSupportMonitor_Editor.cs index 7b7332c..91343d5 100644 --- a/Source/USILifeSupport/LifeSupportMonitor_Editor.cs +++ b/Source/USILifeSupport/LifeSupportMonitor_Editor.cs @@ -188,11 +188,27 @@ private void UpdateGUIInfo(ShipConstruct ship) { foreach (var p in EditorLogic.fetch.ship.parts) { - var mod = p.FindModuleImplementing(); - if (mod == null) - continue; - - recyclers.Add(mod); + var rec = p.Modules.GetModule(); + if (rec != null) + { + var conList = p.Modules.GetModules(); + var bayList = p.Modules.GetModules(); + if (bayList == null || bayList.Count == 0) + { + recyclers.Add(rec); + } + else + { + foreach (var bay in bayList) + { + var con = conList[bay.currentLoadout] as ModuleLifeSupportRecycler; + if (con != null) + { + recyclers.Add(con); + } + } + } + } } var recyclerMultiplier_curCrew = LifeSupportManager.GetRecyclerMultiplierForParts(EditorLogic.fetch.ship.parts, curCrew); var recyclerMultiplier_maxCrew = LifeSupportManager.GetRecyclerMultiplierForParts(EditorLogic.fetch.ship.parts, maxCrew); @@ -312,7 +328,7 @@ private void GenerateWindow() GUILayout.Label(CTag(LifeSupportScenario.Instance.settings.GetSettings().BaseHabTime.ToString(), fadeColor), _labelStyle, GUILayout.Width(c2)); GUILayout.Label(CTag(maxCrew.ToString(), crewColor), _labelStyle, GUILayout.Width(c3)); GUILayout.Label(CTag(extraHabTime.ToString(), textColor), _labelStyle, GUILayout.Width(c4)); - GUILayout.Label(CTag(habMult.ToString(), textColor), _labelStyle, GUILayout.Width(c5)); + GUILayout.Label(CTag("(1+" + (habMult-1d) +")", textColor), _labelStyle, GUILayout.Width(c5)); GUILayout.Label(CTag(Math.Max(1, curCrew).ToString(), crewColor), _labelStyle, GUILayout.Width(c6)); GUILayout.Label(CTag(LifeSupportScenario.Instance.settings.GetSettings().HabMultiplier.ToString(), fadeColor), _labelStyle, GUILayout.Width(c7)); GUILayout.EndHorizontal(); @@ -322,7 +338,7 @@ private void GenerateWindow() GUILayout.Label(CTag(LifeSupportScenario.Instance.settings.GetSettings().BaseHabTime.ToString(), fadeColor), _labelStyle, GUILayout.Width(c2)); GUILayout.Label(CTag(maxCrew.ToString(), crewColor), _labelStyle, GUILayout.Width(c3)); GUILayout.Label(CTag(extraHabTime.ToString(), textColor), _labelStyle, GUILayout.Width(c4)); - GUILayout.Label(CTag(habMult.ToString(), textColor), _labelStyle, GUILayout.Width(c5)); + GUILayout.Label(CTag("(1+" + (habMult - 1d) + ")", textColor), _labelStyle, GUILayout.Width(c5)); GUILayout.Label(CTag(Math.Max(1, maxCrew).ToString(), crewColor), _labelStyle, GUILayout.Width(c6)); GUILayout.Label(CTag(LifeSupportScenario.Instance.settings.GetSettings().HabMultiplier.ToString(), fadeColor), _labelStyle, GUILayout.Width(c7)); GUILayout.EndHorizontal(); diff --git a/Source/USILifeSupport/LifeSupportPersistance.cs b/Source/USILifeSupport/LifeSupportPersistance.cs index 1ea4a1e..ab5ee0d 100644 --- a/Source/USILifeSupport/LifeSupportPersistance.cs +++ b/Source/USILifeSupport/LifeSupportPersistance.cs @@ -141,8 +141,9 @@ public List GetStatusInfo() public List GetVesselInfo() { - return _VesselInfo ?? (_VesselInfo = SetupVesselInfo()); - + if (_VesselInfo == null) + _VesselInfo = SetupVesselInfo(); + return _VesselInfo; } public LifeSupportConfig GetSettings() @@ -195,8 +196,10 @@ public void Save(ConfigNode node) if (_VesselInfo != null) { - foreach (VesselSupplyStatus r in _VesselInfo) + var count = _VesselInfo.Count; + for(int i = 0; i < count; ++i) { + var r = _VesselInfo[i]; if (string.IsNullOrEmpty(r.VesselName)) continue; var rNode = new ConfigNode("VESSEL_DATA"); @@ -209,6 +212,7 @@ public void Save(ConfigNode node) rNode.AddValue("CrewCap", r.CrewCap); rNode.AddValue("ExtraHabSpace", r.ExtraHabSpace); rNode.AddValue("VesselHabMultiplier", r.VesselHabMultiplier); + rNode.AddValue("CachedHabTime", r.CachedHabTime); rNode.AddValue("LastFeeding", r.LastFeeding); rNode.AddValue("LastECCheck", r.LastECCheck); SettingsNode.AddNode(rNode); @@ -400,6 +404,7 @@ public void SaveVesselNode(VesselSupplyStatus status) vesselInfo.CrewCap = status.CrewCap; vesselInfo.ExtraHabSpace = status.ExtraHabSpace; vesselInfo.VesselHabMultiplier = status.VesselHabMultiplier; + vesselInfo.CachedHabTime = status.CachedHabTime; vesselInfo.SuppliesLeft = status.SuppliesLeft; vesselInfo.ECLeft = status.ECLeft; } diff --git a/Source/USILifeSupport/ModuleLifeSupportSystem.cs b/Source/USILifeSupport/ModuleLifeSupportSystem.cs index a9a0f55..3c6090f 100644 --- a/Source/USILifeSupport/ModuleLifeSupportSystem.cs +++ b/Source/USILifeSupport/ModuleLifeSupportSystem.cs @@ -11,7 +11,6 @@ public class ModuleLifeSupportSystem : VesselModule public double LastUpdateTime; private bool isDirty = true; - public void Start() { GameEvents.onVesselPartCountChanged.Add(SetVesselDirty); @@ -31,6 +30,7 @@ private void SetVesselDirty(Vessel v) private Part _crewPart; protected IResourceBroker _resBroker; protected ResourceConverter _resConverter; + private int _partCount; public ResourceConverter ResConverter { @@ -50,11 +50,13 @@ public VesselSupplyStatus VesselStatus public void OnDestroy() { - //GameEvents.onVesselPartCountChanged.Remove(SetVesselDirty); - //GameEvents.onVesselCrewWasModified.Remove(SetVesselDirty); - //GameEvents.onVesselChange.Remove(SetVesselDirty); + GameEvents.onVesselPartCountChanged.Remove(SetVesselDirty); + GameEvents.onVesselCrewWasModified.Remove(SetVesselDirty); + GameEvents.onVesselChange.Remove(SetVesselDirty); } + bool refreshVesselTime = false; + public void FixedUpdate() { if (!HighLogic.LoadedSceneIsFlight || vessel == null) @@ -62,6 +64,16 @@ public void FixedUpdate() if (!vessel.loaded) return; + if (_partCount != vessel.parts.Count) + { + if (_partCount > 0) + { + refreshVesselTime = true; + } + _partCount = vessel.parts.Count; + } + + if (isDirty) { isDirty = false; @@ -81,6 +93,7 @@ public void FixedUpdate() //Check our time double deltaTime = GetDeltaTime(); + bool isCatchup = deltaTime -1 > TimeWarp.fixedDeltaTime; if (deltaTime < ResourceUtilities.FLOAT_TOLERANCE * 10) return; @@ -113,25 +126,29 @@ public void FixedUpdate() 1f); ConverterResults resultEC = ResConverter.ProcessRecipe(deltaTime, ECRecipe, _crewPart, null, 1f); - foreach (var c in vessel.GetVesselCrew()) + #region Long Loop - Crew + if (isLongLoop) { - bool isGrouchyHab = false; - bool isGrouchySupplies = false; - bool isGrouchyEC = false; - //Fetch them from the queue - var k = LifeSupportManager.Instance.FetchKerbal(c); - //Update our stuff - - #region Long Loop - Crew - - if (isLongLoop) + //Ensure status is current + UpdateStatus(); + foreach (var c in vessel.GetVesselCrew()) { - //Ensure status is current - UpdateStatus(); - //First - Hab effects. + bool isGrouchyHab = false; + bool isGrouchySupplies = false; + bool isGrouchyEC = false; + //Fetch them from the queue + var k = LifeSupportManager.Instance.FetchKerbal(c); + //Update our stuff + if (refreshVesselTime) + { + k.TimeEnteredVessel = Planetarium.GetUniversalTime(); + refreshVesselTime = false; + LifeSupportManager.Instance.TrackKerbal(k); + } + //First - Hab effects. if (!offKerbin) { - var habTime = LifeSupportManager.GetTotalHabTime(VesselStatus); + var habTime = LifeSupportManager.GetTotalHabTime(VesselStatus, vessel); k.LastAtHome = Planetarium.GetUniversalTime(); k.MaxOffKerbinTime = habTime + k.LastAtHome; k.TimeEnteredVessel = Planetarium.GetUniversalTime(); @@ -145,6 +162,7 @@ public void FixedUpdate() k.PreviousVesselId = k.CurrentVesselId; k.CurrentVesselId = vessel.id.ToString(); + LifeSupportManager.Instance.TrackKerbal(k); } isGrouchyHab = CheckHabSideEffects(k); } @@ -178,7 +196,7 @@ public void FixedUpdate() k.LastUpdate = Planetarium.GetUniversalTime(); - if (isGrouchyEC) + if (isGrouchyEC & !isCatchup) { ApplyEffect(k, c, LifeSupportManager.isVet(k.KerbalName) @@ -186,7 +204,7 @@ public void FixedUpdate() : LifeSupportScenario.Instance.settings.GetSettings().NoSupplyEffect, "power loss"); } - else if (isGrouchySupplies) + else if (isGrouchySupplies & !isCatchup) { ApplyEffect(k, c, LifeSupportManager.isVet(k.KerbalName) @@ -194,7 +212,7 @@ public void FixedUpdate() : LifeSupportScenario.Instance.settings.GetSettings().NoSupplyEffect, "lack of supplies"); } - else if (isGrouchyHab) + else if (isGrouchyHab & !isCatchup) { ApplyEffect(k, c, LifeSupportManager.isVet(k.KerbalName) @@ -208,20 +226,19 @@ public void FixedUpdate() } LifeSupportManager.Instance.TrackKerbal(k); } - - #endregion - Crew - - var supAmount = _resBroker.AmountAvailable(_crewPart, "Supplies", deltaTime, - ResourceFlowMode.ALL_VESSEL); - var ecAmount = _resBroker.AmountAvailable(_crewPart, "ElectricCharge", deltaTime, - ResourceFlowMode.ALL_VESSEL); - VesselStatus.SuppliesLeft = supAmount/ - LifeSupportScenario.Instance.settings.GetSettings().SupplyAmount/ - _currentCrew/ - VesselStatus.RecyclerMultiplier; - VesselStatus.ECLeft = ecAmount/LifeSupportScenario.Instance.settings.GetSettings().ECAmount/ - _currentCrew; } + #endregion - Crew + + var supAmount = _resBroker.AmountAvailable(_crewPart, "Supplies", deltaTime, + ResourceFlowMode.ALL_VESSEL); + var ecAmount = _resBroker.AmountAvailable(_crewPart, "ElectricCharge", deltaTime, + ResourceFlowMode.ALL_VESSEL); + VesselStatus.SuppliesLeft = supAmount / + LifeSupportScenario.Instance.settings.GetSettings().SupplyAmount / + _currentCrew / + VesselStatus.RecyclerMultiplier; + VesselStatus.ECLeft = ecAmount / LifeSupportScenario.Instance.settings.GetSettings().ECAmount / + _currentCrew; } else { @@ -253,11 +270,44 @@ private void UpdateStatus() UpdateStatus(VesselStatus); } + private double _lastUpdate; + private void UpdateStatus(VesselSupplyStatus v) { - v.RecyclerMultiplier = (float)LifeSupportManager.GetRecyclerMultiplier(vessel); - v.ExtraHabSpace = (float)LifeSupportManager.CalculateVesselHabExtraTime(vessel); - v.VesselHabMultiplier = (float)LifeSupportManager.CalculateVesselHabMultiplier(vessel,_currentCrew); + if (_lastUpdate < ResourceUtilities.FLOAT_TOLERANCE) + _lastUpdate = Planetarium.GetUniversalTime(); + + bool fullRefresh = false; + + if (Planetarium.GetUniversalTime() > _lastUpdate + 5d) //A reasonable time for easing in everything + { + fullRefresh = true; + _lastUpdate = Planetarium.GetUniversalTime(); + } + + var newRecMult = (float)LifeSupportManager.GetRecyclerMultiplier(vessel); + var newSpace = (float)LifeSupportManager.CalculateVesselHabExtraTime(vessel); + var newHabMult = (float)LifeSupportManager.CalculateVesselHabMultiplier(vessel, _currentCrew); + //If we're the active vessel, and we're past easing, we always take calc values. + //Otherwise, let's use the cache. + var useCur = fullRefresh && vessel.id == FlightGlobals.ActiveVessel.id; + + //Start with intelligent defaults. + if (v.RecyclerMultiplier < ResourceUtilities.FLOAT_TOLERANCE) + v.RecyclerMultiplier = 1f; + if (newRecMult < ResourceUtilities.FLOAT_TOLERANCE) + newRecMult = 1f; + //And take the lowest (non-zero) + if (useCur || newRecMult < v.RecyclerMultiplier) + v.RecyclerMultiplier = newRecMult; + + //Hab we want the best ones. + if (useCur || newSpace > v.ExtraHabSpace) + v.ExtraHabSpace = newSpace; + + if (useCur || newHabMult > v.VesselHabMultiplier) + v.VesselHabMultiplier = newHabMult; + LifeSupportManager.Instance.TrackVessel(v); } @@ -361,9 +411,10 @@ private void CheckVesselId() newV.LastECCheck = oldV.LastECCheck; newV.LastUpdate = oldV.LastUpdate; newV.NumCrew = oldV.NumCrew; - newV.RecyclerMultiplier = oldV.NumCrew; + newV.RecyclerMultiplier = oldV.RecyclerMultiplier; newV.CrewCap = oldV.CrewCap; newV.VesselHabMultiplier = oldV.VesselHabMultiplier; + newV.CachedHabTime = oldV.CachedHabTime; newV.ExtraHabSpace = oldV.ExtraHabSpace; newV.SuppliesLeft = oldV.SuppliesLeft; newV.ECLeft = oldV.ECLeft; @@ -417,7 +468,7 @@ private ConversionRecipe GenerateSupplyRecipe() //Two recipes are executed. One for EC, one for Supplies. var recipe = new ConversionRecipe(); var numCrew = _currentCrew; - var recPercent = VesselStatus.RecyclerMultiplier; + var recPercent = VesselStatus.RecyclerMultiplier; var supAmount = LifeSupportScenario.Instance.settings.GetSettings().SupplyAmount; var scrapAmount = LifeSupportScenario.Instance.settings.GetSettings().WasteAmount; var supRatio = supAmount * numCrew * recPercent; @@ -465,7 +516,7 @@ private bool CheckECSideEffects(LifeSupportStatus kStat) private bool CheckHabSideEffects(LifeSupportStatus kStat) { - var habTime = LifeSupportManager.GetTotalHabTime(VesselStatus); + var habTime = LifeSupportManager.GetTotalHabTime(VesselStatus, vessel); if (kStat.LastAtHome < 1) kStat.LastAtHome = Planetarium.GetUniversalTime(); if (habTime + kStat.LastAtHome > kStat.MaxOffKerbinTime) @@ -531,6 +582,7 @@ private void ApplyEffect(LifeSupportStatus kStat, ProtoCrewMember crew, int effe kStat.IsGrouchy = true; LifeSupportManager.Instance.TrackKerbal(kStat); ClipRandomPart(); + SpawnExtraSupplies(100f); } break; case 3: //Return to KSC @@ -559,6 +611,11 @@ private void ApplyEffect(LifeSupportStatus kStat, ProtoCrewMember crew, int effe ScreenMessages.PostScreenMessage(msg, 5f, ScreenMessageStyle.UPPER_CENTER); } + private void SpawnExtraSupplies(float sup) + { + ResBroker.StoreResource(vessel.rootPart, "Supplies", sup, TimeWarp.deltaTime, ResourceFlowMode.ALL_VESSEL); + } + private void RemoveCrewFromPart(ProtoCrewMember crew) { foreach (var p in vessel.parts.Where(p => p.CrewCapacity > 0)) diff --git a/Source/USILifeSupport/VesselSupplyStatus.cs b/Source/USILifeSupport/VesselSupplyStatus.cs index 84a396b..3434053 100644 --- a/Source/USILifeSupport/VesselSupplyStatus.cs +++ b/Source/USILifeSupport/VesselSupplyStatus.cs @@ -12,6 +12,7 @@ public class VesselSupplyStatus public int CrewCap { get; set; } public double ExtraHabSpace { get; set; } public double VesselHabMultiplier { get; set; } + public double CachedHabTime { get; set; } public double SuppliesLeft { get; set; } public double ECLeft { get; set; } public double LastFeeding { get; set; }