/// <summary> /// Generates a list of all processorModules included on the parentVessel. /// </summary> private void HarvestParts() { var proccessorModules = parentVessel.FindPartModulesImplementing <kOSProcessor>(); foreach (var proc in proccessorModules) { childParts.Add(proc.part.flightID); uint id = proc.part.flightID; if (partLookup.ContainsKey(id) && partLookup[id].ID != ID) { // If the part is already known and not associated with this module, then // it is appearing as a result of a staging or undocking event (or something // similar). As such, we need to copy the information from the flight parameters // on the originating module. foreach (string key in flightControlParameters.Keys) { if (partLookup[id].HasFlightControlParameter(key)) { // Only copy the data if the previous vessel module still has the parameter. IFlightControlParameter paramDestination = flightControlParameters[key]; IFlightControlParameter paramOrigin = partLookup[id].GetFlightControlParameter(key); // We only want to copy the parameters themselves once (because they are vessel dependent // not part dependent) but we still need to iterate through each part since "control" // itself is part dependent. if (partLookup[id].ID != BaseId) { paramDestination.CopyFrom(paramOrigin); } if (paramOrigin.Enabled && paramOrigin.ControlPartId == id) { // If this parameter was previously controlled by this part, re-enable // control, copy it's Value setpoint, and disable control on the old parameter. SharedObjects shared = paramOrigin.GetShared(); paramDestination.EnableControl(shared); paramDestination.UpdateValue(paramOrigin.GetValue(), shared); paramOrigin.DisableControl(); } } } baseId = partLookup[id].ID; // Keep track of which vessel the parameters are based on. } partLookup[id] = this; } partCount = parentVessel.Parts.Count; }
private void SteerByWire(FlightCtrlState c) { IFlightControlParameter param = kOSVesselModule.GetInstance(shared.Vessel).GetFlightControlParameter("steering"); if (Enabled) { if (!param.Enabled) { param.EnableControl(shared); } } else { if (param.Enabled && param.ControlPartId == shared.KSPPart.flightID) { param.DisableControl(shared); } } }