private void DoEvent(Suffixed.Part.PartValue part, StringValue eventname) { CheckEvaController(); var mypart = part.Part; PartModule mypartmodule = null; Debug.LogWarning("kOS-EVA: [DOEVENT] part: " + mypart.name + "dst: " + Math.Round((mypart.transform.position - kerbaleva.vessel.rootPart.transform.position).magnitude, 2)); if (Vector3d.Magnitude(mypart.transform.position - kerbaleva.vessel.rootPart.transform.position) < 2.5) { Debug.LogWarning("kOS-EVA: [DOEVENT] distance ok:"); PartModule[] allpartmodules = mypart.GetComponents <PartModule>(); foreach (var pm in allpartmodules) { if (pm.Events.Where(x => x.GUIName.ToLower().StartsWith(eventname.ToLower())).FirstOrDefault() == null) { continue; } Debug.Log("kOS-EVA: [DOEVENT] Partmodule found:" + pm.moduleName); mypartmodule = pm; } if (mypartmodule == null) { Debug.LogWarning("kOS-EVA: [DOEVENT] Partmodule not found "); return; } BaseEvent my_event = mypartmodule.Events.Where(x => x.GUIName.ToLower().StartsWith(eventname.ToLower())).FirstOrDefault(); if (my_event == null) { Debug.LogWarning("kOS-EVA: [DOEVENT] Event not found "); return; } else { Debug.Log("kOS-EVA: [DOEVENT] Invoking:" + my_event.GUIName); my_event.Invoke(); } } else { Debug.LogWarning("kOS-EVA: [DOEVENT] Part Out of Range: " + Math.Round(Vector3d.Magnitude(mypart.transform.position - shared.Vessel.rootPart.transform.position), 2) + " > 2.5"); } }
private void BoardPart(Suffixed.Part.PartValue toboard) { CheckEvaController(); kerbaleva.BoardPart(toboard.Part); }