/// <summary> /// Gets a collection of <see cref="BaseAction"/> assigned to a <see cref="KSPActionGroup"/> /// </summary> /// <param name="group">The <see cref="KSPActionGroup"/> to get the action assignments for.</param> /// <returns>A collection of <see cref="BaseAction"/> assigned to the <see cref="KSPActionGroup"/>.</returns> public static List <BaseAction> GetBaseActionAttachedToActionGroup(KSPActionGroup group) { var ret = new List <BaseAction>(); foreach (Part part in VesselManager.Instance.Parts) { foreach (BaseAction action in part.Actions) { if (group.ContainsAction(action)) { ret.Add(action); } } foreach (PartModule module in part.Modules) { foreach (BaseAction action in module.Actions) { if (group.ContainsAction(action)) { ret.Add(action); } } } } return(ret); }
/// <summary> /// Returns a list of base actions that exist for the provided parts in the provided action group. /// </summary> /// <param name="parts">A list of part to get base actions from.</param> /// <param name="group">The action group to filter actions by.</param> /// <returns>The base actions available to the parts that are in the action group.</returns> public static ICollection <BaseAction> FromParts(IEnumerable <Part> parts, KSPActionGroup group) { IEnumerable <BaseAction> list = FromParts(parts); var ret = new List <BaseAction>(); foreach (BaseAction action in list) { if (group.ContainsAction(action)) { ret.Add(action); } } return(ret); }