Closed hellsmith closed 8 years ago
i changed the section for myself so that every extra recycler gets counted in but at a lesser extent. i would like to make a check for the Settings.cfg but i don't know how.
anyway, here is what i changed that function into. maybe you can use some of that code.
class ConverterSupport { public int crewSupport; public float recyclerPercent; public string recyclerName;
public ConverterSupport(int crewSupport,float recyclerPercent,string recyclerName)
{
this.crewSupport = crewSupport;
this.recyclerPercent = recyclerPercent;
this.recyclerName = recyclerName;
}
}
internal static double GetRecyclerMultiplier(Vessel vessel)
{
if (!LifeSupportSetup.Instance.LSConfig.EnableRecyclers)
return 1d;
Dictionary<string, ConverterSupport> recAbility = new Dictionary<string, ConverterSupport>();
var crewCount = vessel.GetCrewCount();
foreach (var r in vessel.FindPartModulesImplementing<ModuleLifeSupportRecycler>())
{
if (r.IsActivated)
{
if (recAbility.ContainsKey(r.part.name))
{
recAbility[r.part.name].crewSupport += r.CrewCapacity;
}
else
{
recAbility.Add(r.part.name, new ConverterSupport(r.CrewCapacity,r.RecyclePercent,r.part.name));
}
}
}
var vList = LogisticsTools.GetNearbyVessels((float)LifeSupportSetup.Instance.LSConfig.HabRange, false, vessel, true);
foreach (var v in vList)
{
crewCount += v.GetCrewCount();
foreach (var r in v.FindPartModulesImplementing<ModuleLifeSupportRecycler>())
{
if (r.IsActivated)
{
if (recAbility.ContainsKey(r.part.name))
{
recAbility[r.part.name].crewSupport += r.CrewCapacity;
}
else
{
recAbility.Add(r.part.name, new ConverterSupport(r.CrewCapacity, r.RecyclePercent, r.part.name));
}
}
}
}
string bestConverter = null;
float bestPercent = 0;
foreach(ConverterSupport crewSup in recAbility.Values)
{
float effectiveRecAbility = crewSup.recyclerPercent;
if (crewSup.crewSupport / (float)crewCount < 1)
effectiveRecAbility = crewSup.crewSupport * effectiveRecAbility / (float)crewCount;
if (bestPercent < effectiveRecAbility)
{
bestPercent = effectiveRecAbility;
bestConverter = crewSup.recyclerName;
}
}
double percentRecycled = bestPercent;
if(bestConverter != null)
recAbility.Remove(bestConverter);
bestPercent = 0;
float extraModuleCoeff = 0.5f;
//float extraModuleCoeff = LifeSupportSetup.Instance.LSConfig.ExtraRecyclerCoeff;
while (recAbility.Count > 0)
{
foreach (ConverterSupport crewSup in recAbility.Values)
{
float effectiveRecAbility = crewSup.recyclerPercent;
if (crewSup.crewSupport / (float)crewCount < 1)
effectiveRecAbility = crewSup.crewSupport * effectiveRecAbility / (float)crewCount;
if (bestPercent < effectiveRecAbility)
{
bestPercent = effectiveRecAbility;
bestConverter = crewSup.recyclerName;
}
}
percentRecycled = (1f-(float)percentRecycled) * bestPercent * extraModuleCoeff + percentRecycled;
recAbility.Remove(bestConverter);
bestPercent = 0;
}
return (1d-percentRecycled);
}
Sorted in the next release, and should be related to the full percentage just because of the additive effect of recyclers (for example, a pioneer module is intended to be landed on it's own but hook up to an entire colony).
Crew isnt counted for the whole colony but only for single vessel when checked for recycler capacity
LifeSupportManager -> line 202
in both cases only the pioneer module with cap for 5 kerbals and 75% recyclerate is active
in the second picture philman (cool name, indeed) left the main building and went into the generator. the pioneer recycles for all of them but now only considers the 5 in the own vessel. whereas philman's vessel checks for other lifesupport vessels and finds the pioneer.