public override void OnStart(PartModule.StartState state) { Logs.dbg("On Start " + state.ToString()); }
private void FixedUpdate() { // Find all resources in the network partResources.Clear(); foreach (Vessel vessel in FlightGlobals.VesselsLoaded) { if (!String.IsNullOrEmpty(InSituation.NetworkEligible(vessel))) { Logs.dbg("{0} ineligible\n", vessel.GetDisplayName()); continue; } LogisticsModule lm = vessel.FindPartModuleImplementing <LogisticsModule> (); if (lm != null && !lm.IsActive) { Logs.dbg("{0} not pluged in\n", vessel.GetDisplayName()); continue; } foreach (Part part in vessel.parts) { if (part.State == PartStates.DEAD) { Logs.dbg("{0} is dead on {1}\n", part.partName, vessel.GetDisplayName()); continue; } foreach (PartResource resource in part.Resources) { if (resource.info.resourceTransferMode == ResourceTransferMode.NONE || resource._flowMode == PartResource.FlowMode.None || !resource._flowState) { Logs.dbg("{3}'s {2}'s {1} can't flow", resource.resourceName, part.partName, vessel.vesselName); continue; } partResources.Add(resource); } } } // Create a resource pool resourcePool.Clear(); foreach (var resource in partResources) { if (!resourcePool.ContainsKey(resource.info.name)) { resourcePool.Add(resource.info.name, resource.amount); } else { resourcePool [resource.info.name] += resource.amount; } } // Spread resources evenly foreach (var resource in resourcePool) { double value = resource.Value; if (requested) { if (requestPool.ContainsKey(resource.Key)) { value -= requestPool [resource.Key]; } } var resList = partResources.FindAll(r => r.info.name == resource.Key); // Don't waste time on single one // if (resList.Count == 1) // continue; ShareResource(resList, value); } if (requested) { TransferResources(); requested = false; } }