public static SteeringManager DeepCopy(SteeringManager oldInstance, SharedObjects shared) { SteeringManager instance = SteeringManagerProvider.GetInstance(shared); instance.ShowAngularVectors = oldInstance.ShowAngularVectors; instance.ShowFacingVectors = oldInstance.ShowFacingVectors; instance.ShowRCSVectors = oldInstance.ShowRCSVectors; instance.ShowThrustVectors = oldInstance.ShowThrustVectors; instance.ShowSteeringStats = oldInstance.ShowSteeringStats; instance.WriteCSVFiles = oldInstance.WriteCSVFiles; instance.MaxStoppingTime = oldInstance.MaxStoppingTime; instance.pitchPI.Ts = oldInstance.pitchPI.Ts; instance.yawPI.Ts = oldInstance.yawPI.Ts; instance.rollPI.Ts = oldInstance.rollPI.Ts; instance.pitchPI.Loop = PIDLoop.DeepCopy(oldInstance.pitchPI.Loop); instance.yawPI.Loop = PIDLoop.DeepCopy(oldInstance.yawPI.Loop); instance.rollPI.Loop = PIDLoop.DeepCopy(oldInstance.rollPI.Loop); instance.pitchRatePI = PIDLoop.DeepCopy(oldInstance.pitchRatePI); instance.yawRatePI = PIDLoop.DeepCopy(oldInstance.yawRatePI); instance.rollRatePI = PIDLoop.DeepCopy(oldInstance.rollRatePI); instance.PitchTorqueAdjust = oldInstance.PitchTorqueAdjust; instance.PitchTorqueFactor = oldInstance.PitchTorqueFactor; instance.RollTorqueAdjust = oldInstance.RollTorqueAdjust; instance.RollTorqueFactor = oldInstance.RollTorqueFactor; instance.YawTorqueAdjust = oldInstance.YawTorqueAdjust; instance.YawTorqueFactor = oldInstance.YawTorqueFactor; return instance; }
public static SteeringManager SwapInstance(SharedObjects shared, SteeringManager oldInstance) { if (shared.Vessel == oldInstance.Vessel) return oldInstance; if (oldInstance.SubscribedParts.Contains(shared.KSPPart.flightID)) oldInstance.SubscribedParts.Remove(shared.KSPPart.flightID); SteeringManager instance = SteeringManager.DeepCopy(oldInstance, shared); if (oldInstance.Enabled) { if (oldInstance.PartId == shared.KSPPart.flightID) { oldInstance.DisableControl(); instance.EnableControl(shared); instance.Value = oldInstance.Value; } } return instance; }
public static SteeringManager GetInstance(SharedObjects shared) { string key = shared.Vessel.id.ToString(); if (AllInstances.Keys.Contains(key)) { SteeringManager instance = AllInstances[key]; if (!instance.SubscribedParts.Contains(shared.KSPPart.flightID)) { AllInstances[key].SubscribedParts.Add(shared.KSPPart.flightID); } return AllInstances[key]; } SteeringManager sm = new SteeringManager(shared); sm.SubscribedParts.Add(shared.KSPPart.flightID); AllInstances.Add(key, sm); return sm; }
public void UpdateFlightControl(Vessel vessel) { control = GetControllerByVessel(vessel); if (steeringManager != null) { steeringManager = SteeringManagerProvider.SwapInstance(shared, steeringManager); steeringManager.Update(vessel); } }
public void Dispose() { Enabled = false; if (steeringManager != null) { SteeringManagerProvider.RemoveInstance(shared.Vessel); steeringManager = null; } }
public FlightCtrlParam(string name, SharedObjects sharedObjects) { this.name = name; shared = sharedObjects; control = GetControllerByVessel(sharedObjects.Vessel); binding = sharedObjects.BindingMgr; Enabled = false; value = null; if (string.Equals(name, "steering", StringComparison.CurrentCultureIgnoreCase)) { steeringManager = SteeringManagerProvider.GetInstance(sharedObjects); } HookEvents(); }