void Update() { if (_exceptionsThrown.Count > 0) { for (int i = 0; i < _exceptionsThrown.Count; i++) { FARLogger.Exception(_exceptionsThrown[i]); } _exceptionsThrown.Clear(); } if (_debugMessages.Count > 0) { System.Text.StringBuilder sB = new System.Text.StringBuilder(); for (int i = 0; i < _debugMessages.Count; i++) { sB.AppendLine(_debugMessages[i]); } _debugMessages.Clear(); FARLogger.Info("" + sB.ToString()); } }
public void ExecuteTask(CoroutineTask task) { try { task.Result = StartCoroutine(task.Action()); } catch (Exception e) { FARLogger.Exception(e, "Caught exception while starting coroutine"); } CompleteTask(task); }
public static void ExecuteTask(Task task) { try { task.Action(); } catch (Exception e) { FARLogger.Exception(e, "Caught exception while executing task"); } CompleteTask(task); }
private void Update() { if (_exceptionsThrown.Count > 0) { foreach (Exception exception in _exceptionsThrown) { FARLogger.Exception(exception); } _exceptionsThrown.Clear(); } UpdateInfo(); UpdateDebug(); }
void Update() { if (_exceptionsThrown.Count > 0) { for (int i = 0; i < _exceptionsThrown.Count; i++) { FARLogger.Exception(_exceptionsThrown[i]); } _exceptionsThrown.Clear(); } UpdateInfo(); UpdateDebug(); }
public void TransformBasis(Matrix4x4 newThisToVesselMatrix) { try { Matrix4x4 tempMatrix = newThisToVesselMatrix * meshLocalToWorld; //Matrix4x4 tempMatrix = thisToVesselMatrix.inverse; //thisToVesselMatrix = newThisToVesselMatrix * meshLocalToWorld; //tempMatrix = thisToVesselMatrix * tempMatrix; //bounds = TransformBounds(bounds, tempMatrix); Vector3 low, high; low = Vector3.one * float.PositiveInfinity; high = Vector3.one * float.NegativeInfinity; for (int i = 0; i < vertices.Length; i++) { Vector3 vert = tempMatrix.MultiplyPoint3x4(meshLocalVerts[i]);// = Vector3.zero; float tmpTestVert = vert.x + vert.y + vert.z; if (float.IsNaN(tmpTestVert) || float.IsInfinity(tmpTestVert)) { ThreadSafeDebugLogger.Instance.RegisterMessage("Transform error in " + module.part.partInfo.title); valid = false; } else { valid = true; } vertices[i] = vert; low = Vector3.Min(low, vert); high = Vector3.Max(high, vert); } bounds = new Bounds(0.5f * (high + low), high - low); } catch (Exception e) { FARLogger.Exception(e); } finally { module.DecrementMeshesToUpdate(); } }
public void TransformBasis(Matrix4x4 newThisToVesselMatrix) { try { // ReSharper disable once InconsistentlySynchronizedField Matrix4x4 tempMatrix = newThisToVesselMatrix * meshLocalToWorld; Vector3 low = Vector3.one * float.PositiveInfinity; Vector3 high = Vector3.one * float.NegativeInfinity; for (int i = 0; i < vertices.Length; i++) { Vector3 vert = tempMatrix.MultiplyPoint3x4(meshLocalVerts[i]); float tmpTestVert = vert.x + vert.y + vert.z; if (float.IsNaN(tmpTestVert) || float.IsInfinity(tmpTestVert)) { ThreadSafeDebugLogger.Error("Transform error in " + module.part.partInfo.title); valid = false; } else { valid = true; } vertices[i] = vert; low = Vector3.Min(low, vert); high = Vector3.Max(high, vert); } bounds = new Bounds(0.5f * (high + low), high - low); } catch (Exception e) { FARLogger.Exception(e); } finally { module.DecrementMeshesToUpdate(); } }
void ToggleGear() { List <Part> partsList = EditorLogic.SortedShipList; for (int i = 0; i < partsList.Count; i++) { Part p = partsList[i]; if (p.Modules.Contains <ModuleWheelDeployment>()) { ModuleWheelDeployment l = p.Modules.GetModule <ModuleWheelDeployment>(); l.ActionToggle(new KSPActionParam(KSPActionGroup.Gear, gearToggle ? KSPActionType.Activate : KSPActionType.Deactivate)); } if (p.Modules.Contains("FSwheel")) { PartModule m = p.Modules["FSwheel"]; MethodInfo method = m.GetType().GetMethod("animate", BindingFlags.Instance | BindingFlags.NonPublic); method.Invoke(m, gearToggle ? new object[] { "Deploy" } : new object[] { "Retract" }); } if (p.Modules.Contains("FSBDwheel")) { PartModule m = p.Modules["FSBDwheel"]; MethodInfo method = m.GetType().GetMethod("animate", BindingFlags.Instance | BindingFlags.NonPublic); method.Invoke(m, gearToggle ? new object[] { "Deploy" } : new object[] { "Retract" }); } if (p.Modules.Contains("KSPWheelAdjustableGear")) { PartModule m = p.Modules["KSPWheelAdjustableGear"]; MethodInfo method = m.GetType().GetMethod("deploy", BindingFlags.Instance | BindingFlags.Public); try { method.Invoke(m, null); } catch (Exception e) { FARLogger.Exception(e); //we just catch and print this ourselves to allow things to continue working, since there seems to be a bug in KSPWheels as of this writing } } } gearToggle = !gearToggle; }
private void ToggleGearDeploymentOnKSPWheelPM(PartModule pm, string methodName) { MethodInfo method = pm.GetType().GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public); var action = new KSPActionParam(KSPActionGroup.Gear, gearToggle ? KSPActionType.Activate : KSPActionType.Deactivate); try { if (method == null) { FARLogger.Error($"{pm.GetType().Name} does not have method '{methodName}'"); } else { method.Invoke(pm, new[] { action }); } } catch (Exception e) { //we just catch and print this ourselves to allow things to continue working, since there seems to be a bug in KSPWheels as of this writing FARLogger.Exception(e); } }
private void ToggleGear() { List <Part> partsList = EditorLogic.SortedShipList; foreach (Part p in partsList) { if (p.Modules.Contains <ModuleWheelDeployment>()) { ModuleWheelDeployment l = p.Modules.GetModule <ModuleWheelDeployment>(); l.ActionToggle(new KSPActionParam(KSPActionGroup.Gear, gearToggle ? KSPActionType.Activate : KSPActionType.Deactivate)); } if (p.Modules.Contains("FSwheel")) { PartModule m = p.Modules["FSwheel"]; MethodInfo method = m.GetType().GetMethod("animate", BindingFlags.Instance | BindingFlags.NonPublic); if (method == null) { FARLogger.Error("FSwheel does not have method 'animate"); } else { method.Invoke(m, gearToggle ? new object[] { "Deploy" } : new object[] { "Retract" }); } } if (p.Modules.Contains("FSBDwheel")) { PartModule m = p.Modules["FSBDwheel"]; MethodInfo method = m.GetType().GetMethod("animate", BindingFlags.Instance | BindingFlags.NonPublic); if (method == null) { FARLogger.Error("FSBDwheel does not have method 'animate"); } else { method.Invoke(m, gearToggle ? new object[] { "Deploy" } : new object[] { "Retract" }); } } // ReSharper disable once InvertIf if (p.Modules.Contains("KSPWheelAdjustableGear")) { PartModule m = p.Modules["KSPWheelAdjustableGear"]; MethodInfo method = m.GetType().GetMethod("deploy", BindingFlags.Instance | BindingFlags.Public); try { if (method == null) { FARLogger.Error("KSPWheelAdjustableGear does not have method 'animate"); } else { method.Invoke(m, null); } } catch (Exception e) { //we just catch and print this ourselves to allow things to continue working, since there seems to be a bug in KSPWheels as of this writing FARLogger.Exception(e); } } } gearToggle = !gearToggle; }