diff --git a/FinalFrontierAdapter.csproj b/FinalFrontierAdapter.csproj index 8ae0ecc..2f350a9 100644 --- a/FinalFrontierAdapter.csproj +++ b/FinalFrontierAdapter.csproj @@ -31,38 +31,18 @@ 4 - - False - ..\..\..\1.1.2-0_development\KSP_x64_Data\Managed\Assembly-CSharp.dll - - - False - ..\..\..\1.1.2-0_development\KSP_x64_Data\Managed\Assembly-CSharp-firstpass.dll - - - ..\..\..\1.1.2-0_development\KSP_x64_Data\Managed\KSPAssets.dll + + C:\Users\jpmac\Desktop\Games\SteamLibrary\steamapps\common\Kerbal Space Program\KSP_Data\Managed\Assembly-CSharp.dll - ..\..\..\1.1.2-0_development\KSP_x64_Data\Managed\KSPCore.dll + C:\Users\jpmac\Desktop\Games\SteamLibrary\steamapps\common\Kerbal Space Program\KSP_Data\Managed\KSPCore.dll - ..\..\..\1.1.2-0_development\KSP_x64_Data\Managed\KSPUtil.dll + C:\Users\jpmac\Desktop\Games\SteamLibrary\steamapps\common\Kerbal Space Program\KSP_Data\Managed\KSPUtil.dll - - - - - - - False - ..\..\..\1.1.2-0_development\KSP_x64_Data\Managed\UnityEngine.dll - - - ..\..\..\1.1.2-0_development\KSP_x64_Data\Managed\UnityEngine.Networking.dll - - - ..\..\..\1.1.2-0_development\KSP_x64_Data\Managed\UnityEngine.UI.dll + + C:\Users\jpmac\Desktop\Games\SteamLibrary\steamapps\common\Kerbal Space Program\KSP_Data\Managed\UnityEngine.dll diff --git a/FinalFrontierAdapter.sln b/FinalFrontierAdapter.sln new file mode 100644 index 0000000..af40299 --- /dev/null +++ b/FinalFrontierAdapter.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25123.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FinalFrontierAdapter", "FinalFrontierAdapter.csproj", "{E44ECC7F-0A53-4FFE-87DC-A17DBDB8FF78}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E44ECC7F-0A53-4FFE-87DC-A17DBDB8FF78}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E44ECC7F-0A53-4FFE-87DC-A17DBDB8FF78}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E44ECC7F-0A53-4FFE-87DC-A17DBDB8FF78}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E44ECC7F-0A53-4FFE-87DC-A17DBDB8FF78}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index 33bc760..0d5010f 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -10,7 +10,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("FinalFrontierAdapter")] -[assembly: AssemblyCopyright("Copyright © 2015")] +[assembly: AssemblyCopyright("Copyright © 2016 Nereid & CaptainSwag101")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/src/Example.cs b/src/Example.cs index 9c30944..7adecac 100644 --- a/src/Example.cs +++ b/src/Example.cs @@ -9,10 +9,10 @@ namespace MyPlugin class Example : MonoBehaviour { // place your ribbon png files (size 120x32 pixel) here... - private const String RIBBON_BASE = "MyPluginInGameData/Ribbons/"; + private const string RIBBON_BASE = "MyPluginInGameData/Ribbons/"; // UNIQUE (!) ribbon code - private const String RIBBON_CODE = "KSP"; + private const string RIBBON_CODE = "KSP"; // UNIQUE (!) custom ribbon id (used for custom ribbons only) private const int RIBBON_ID = 1001; @@ -29,7 +29,7 @@ public void Start() // create the adapter this.adapter = new FinalFrontierAdapter(); // plugin to Final Frontier - this.adapter.Plugin(); + this.adapter.TryInstallPlugin(); // optional: log the version of Final Frontier Debug.Log("Final Frontier version: "+adapter.GetVersion()); diff --git a/src/FinalFrontierAdapter.cs b/src/FinalFrontierAdapter.cs index 14f1f9b..1df8eee 100644 --- a/src/FinalFrontierAdapter.cs +++ b/src/FinalFrontierAdapter.cs @@ -7,452 +7,412 @@ namespace MyPlugin { - public class FinalFrontierAdapter - { - private const int DEFAULT_PRESTIGE = -10000; + public class FinalFrontierAdapter + { + private const int DEFAULT_PRESTIGE = -10000; - // ExternalInterface in Final Frontier - private object instanceExternalInterface = null; - // methods of the ExternalInterface - private MethodInfo methodGetVersion = null; - private MethodInfo methodRegisterRibbon = null; - private MethodInfo methodRegisterCustomRibbon = null; - private MethodInfo methodAwardRibbonToKerbalByCode = null; - private MethodInfo methodAwardRibbonToKerbalByRibbon = null; - private MethodInfo methodAwardRibbonToKerbalsByCode = null; - private MethodInfo methodAwardRibbonToKerbalsByRibbon = null; - private MethodInfo methodIsRibbonAwardedToKerbalByCode = null; - private MethodInfo methodIsRibbonAwardedToKerbalByRibbon = null; - private MethodInfo methodGetMissionsFlownForKerbal = null; - private MethodInfo methodGetDockingsForKerbal = null; - private MethodInfo methodResearchForKerbal = null; - private MethodInfo methodTotalMissionTimeForKerbal = null; - private MethodInfo methodGetContractsCompletedForKerbal = null; + // ExternalInterface in Final Frontier + private object instanceExternalInterface = null; + // methods of the ExternalInterface + private MethodInfo methodGetVersion = null; + private MethodInfo methodRegisterRibbon = null; + private MethodInfo methodRegisterCustomRibbon = null; + private MethodInfo methodAwardRibbonToKerbalByCode = null; + private MethodInfo methodAwardRibbonToKerbalByRibbon = null; + private MethodInfo methodAwardRibbonToKerbalsByCode = null; + private MethodInfo methodAwardRibbonToKerbalsByRibbon = null; + private MethodInfo methodIsRibbonAwardedToKerbalByCode = null; + private MethodInfo methodIsRibbonAwardedToKerbalByRibbon = null; + private MethodInfo methodGetMissionsFlownForKerbal = null; + private MethodInfo methodGetDockingsForKerbal = null; + private MethodInfo methodResearchForKerbal = null; + private MethodInfo methodTotalMissionTimeForKerbal = null; + private MethodInfo methodGetContractsCompletedForKerbal = null; - protected Type GetType(String name) - { - return AssemblyLoader.loadedAssemblies - .SelectMany(x => x.assembly.GetExportedTypes()) - .SingleOrDefault(t => t.FullName == name); - } + protected Type GetType(string name) + { + return AssemblyLoader.loadedAssemblies + .SelectMany(x => x.assembly.GetExportedTypes()) + .SingleOrDefault(t => t.FullName == name); + } - private MethodInfo GetMethod(Type type, String name, Type[] parameterTypes) - { - MethodInfo info = type.GetMethod(name, parameterTypes); - if(info==null) - { - String signature = ""; - foreach (Type t in parameterTypes) - { - if(signature.Length>0) signature = signature + ","; - signature = signature +t.Name; - } - Debug.LogError("failed to register method " + name + "(" + signature + ")"); - } - return info; - } + private MethodInfo GetMethod(Type type, string name, Type[] parameterTypes) + { + MethodInfo info = type.GetMethod(name, parameterTypes); + if (info == null) + { + string signature = ""; + foreach (Type t in parameterTypes) + { + if (signature.Length > 0) signature = signature + ","; + signature = signature + t.Name; + } + Debug.LogError("failed to register method " + name + "(" + signature + ")"); + } + return info; + } - private MethodInfo GetMethod(Type type, String name) - { - MethodInfo info = type.GetMethod(name, BindingFlags.Public | BindingFlags.Instance); - if(info==null) - { - Debug.LogError("failed to register method "+name+"()"); - } - return info; - } + private MethodInfo GetMethod(Type type, string name) + { + MethodInfo info = type.GetMethod(name, BindingFlags.Public | BindingFlags.Instance); + if (info == null) + { + Debug.LogError("failed to register method " + name + "()"); + } + return info; + } - private void RegisterMethods(Type type) - { - methodGetVersion = GetMethod(type, "GetVersion"); - methodRegisterRibbon = GetMethod(type, "RegisterRibbon"); - methodRegisterCustomRibbon = GetMethod(type, "RegisterCustomRibbon"); - methodAwardRibbonToKerbalByCode = GetMethod(type, "AwardRibbonToKerbal", new Type[] { typeof(String), typeof(ProtoCrewMember) }); - methodAwardRibbonToKerbalByRibbon = GetMethod(type,"AwardRibbonToKerbal", new Type[] { typeof(object), typeof(ProtoCrewMember) }); - methodAwardRibbonToKerbalsByCode = GetMethod(type, "AwardRibbonToKerbals", new Type[] { typeof(String), typeof(ProtoCrewMember[]) }); - methodAwardRibbonToKerbalsByRibbon = GetMethod(type, "AwardRibbonToKerbals", new Type[] { typeof(object), typeof(ProtoCrewMember[]) }); - methodIsRibbonAwardedToKerbalByCode = GetMethod(type, "IsRibbonAwardedToKerbal", new Type[] { typeof(String), typeof(ProtoCrewMember) }); - methodIsRibbonAwardedToKerbalByRibbon = GetMethod(type, "IsRibbonAwardedToKerbal", new Type[] { typeof(object), typeof(ProtoCrewMember) }); - methodGetMissionsFlownForKerbal = GetMethod(type, "GetMissionsFlownForKerbal"); - methodGetDockingsForKerbal = GetMethod(type, "GetDockingsForKerbal"); - methodResearchForKerbal = GetMethod(type, "GetResearchForKerbal"); - methodTotalMissionTimeForKerbal = GetMethod(type, "GetTotalMissionTimeForKerbal"); - methodGetContractsCompletedForKerbal= GetMethod(type, "GetContractsCompletedForKerbal"); - } + private void RegisterMethods(Type type) + { + methodGetVersion = GetMethod(type, "GetVersion"); + methodRegisterRibbon = GetMethod(type, "RegisterRibbon"); + methodRegisterCustomRibbon = GetMethod(type, "RegisterCustomRibbon"); + methodAwardRibbonToKerbalByCode = GetMethod(type, "AwardRibbonToKerbal", new Type[] { typeof(string), typeof(ProtoCrewMember) }); + methodAwardRibbonToKerbalByRibbon = GetMethod(type, "AwardRibbonToKerbal", new Type[] { typeof(object), typeof(ProtoCrewMember) }); + methodAwardRibbonToKerbalsByCode = GetMethod(type, "AwardRibbonToKerbals", new Type[] { typeof(string), typeof(ProtoCrewMember[]) }); + methodAwardRibbonToKerbalsByRibbon = GetMethod(type, "AwardRibbonToKerbals", new Type[] { typeof(object), typeof(ProtoCrewMember[]) }); + methodIsRibbonAwardedToKerbalByCode = GetMethod(type, "IsRibbonAwardedToKerbal", new Type[] { typeof(string), typeof(ProtoCrewMember) }); + methodIsRibbonAwardedToKerbalByRibbon = GetMethod(type, "IsRibbonAwardedToKerbal", new Type[] { typeof(object), typeof(ProtoCrewMember) }); + methodGetMissionsFlownForKerbal = GetMethod(type, "GetMissionsFlownForKerbal"); + methodGetDockingsForKerbal = GetMethod(type, "GetDockingsForKerbal"); + methodResearchForKerbal = GetMethod(type, "GetResearchForKerbal"); + methodTotalMissionTimeForKerbal = GetMethod(type, "GetTotalMissionTimeForKerbal"); + methodGetContractsCompletedForKerbal = GetMethod(type, "GetContractsCompletedForKerbal"); + } - private void LogFailedMethodAccess(String name, Exception e) - { - Debug.LogError("failed to access method '"+name+"' [" + e.GetType() + "]:" + e.Message); - } + private void LogFailedMethodAccess(string name, Exception e) + { + Debug.LogError("failed to access method '" + name + "' [" + e.GetType() + "]:" + e.Message); + } - // *************************************************************************************************************************************** - // ** ** ** public methods ** ** ** - // *************************************************************************************************************************************** + #region Public Methods - /** - * Test if Final Frontier is installed. - * Returns: - * true, if and only if Final Frontier is installed and succesfully connected to this adapter - */ - public bool IsInstalled() - { - return instanceExternalInterface != null; - } + /// + /// Checks if the Final Frontier plugin is installed. + /// + /// True if the plugin was found and loaded successfully. + public bool IsInstalled() + { + return instanceExternalInterface != null; + } - /** - * Version of final Frontier - * Returns: - * version number of final Frontier - */ - public String GetVersion() - { - if (!IsInstalled()) return "not installed"; - if (methodGetVersion != null) - { - try - { - return (String)methodGetVersion.Invoke(instanceExternalInterface, new object[] {}); - } - catch (Exception e) - { - LogFailedMethodAccess("GetVersion", e); - } - } - return "unknown"; - } + /// + /// Gets the version of the installed Final Frontier plugin. + /// + /// The Final Frontier plugin's version number. + public string GetVersion() + { + if (!IsInstalled()) return "not installed"; + if (methodGetVersion != null) + { + try + { + return (string)methodGetVersion.Invoke(instanceExternalInterface, new object[] { }); + } + catch (Exception e) + { + LogFailedMethodAccess("GetVersion", e); + } + } + return "unknown"; + } - /** - * Connect this adapter to Final Frontier. - */ - public void Plugin() - { - try - { - Type typeExternalInterface = GetType("Nereid.FinalFrontier.ExternalInterface"); - if (typeExternalInterface != null) - { - // create an instance for the external interface - instanceExternalInterface = Activator.CreateInstance(typeExternalInterface); - if (instanceExternalInterface != null) - { - RegisterMethods(typeExternalInterface); - Debug.Log("plugin of Final Frontier successful"); - return; - } - } - instanceExternalInterface = null; - Debug.Log("Final Frontier not installed"); - } - catch(Exception e) - { - Debug.LogError("plugin of Final Frontier Adapater failed: "+e.GetType()+" ('"+e.Message+"')"); - instanceExternalInterface = null; - } - } + /** + * Connect this adapter to Final Frontier. + */ + public void TryInstallPlugin() + { + try + { + Type typeExternalInterface = GetType("Nereid.FinalFrontier.ExternalInterface"); + if (typeExternalInterface != null) + { + // create an instance for the external interface + instanceExternalInterface = Activator.CreateInstance(typeExternalInterface); + if (instanceExternalInterface != null) + { + RegisterMethods(typeExternalInterface); + Debug.Log("Successfully connected to Final Frontier plugin"); + return; + } + } + instanceExternalInterface = null; + Debug.Log("Final Frontier not installed"); + } + catch (Exception e) + { + Debug.LogError("Failed to connect to Final Frontier plugin: " + e.GetType() + " ('" + e.Message + "')"); + instanceExternalInterface = null; + } + } - /** - * Register a ribbon. - * Important: Do not register the same code twice! - * Parameter: - * code : unique code for ribbon. - * pathToRibbonTexture: path to ribbon png file relative to GameData folder (without suffix). - * nmae: name of the ribbon - * description: description text - * first: true, if this ribbon will just awarded as a "first time" ribbon - * prestige: prestige (currently just used for ribbon ordering) - * Returns: - * Registered ribbon or null, if failed - * Throws: - * ArgumentException, if code was already registered - */ - public object RegisterRibbon(String code, String pathToRibbonTexture, String name, String description = "", bool first = false, int prestige = DEFAULT_PRESTIGE) - { - if (IsInstalled() && methodRegisterRibbon != null) - { - try - { - return methodRegisterRibbon.Invoke(instanceExternalInterface, new object[] { code, pathToRibbonTexture, name, description, first, prestige }); - } - catch(Exception e) - { - LogFailedMethodAccess("RegisterRibbon", e); - } - } - return null; - } + /// Register a ribbon. + /// + /// Important: Do not register the same code twice! + /// Unique code for the ribbon. + /// Path to ribbon PNG file (without suffix) relative to GameData folder. + /// Name of the ribbon. + /// The ribbon's description text. + /// If true, this ribbon will just be awarded as a "first time" ribbon. + /// The ribbon's prestige level (currently just used for ribbon ordering). + /// Registered ribbon or null, if failed + /// Thrown if the specified ribbon code was already registered. + public object RegisterRibbon(string code, string pathToRibbonTexture, string name, string description = "", bool first = false, int prestige = DEFAULT_PRESTIGE) + { + if (IsInstalled() && methodRegisterRibbon != null) + { + try + { + return methodRegisterRibbon.Invoke(instanceExternalInterface, new object[] { code, pathToRibbonTexture, name, description, first, prestige }); + } + catch (ArgumentException e) + { + LogFailedMethodAccess("RegisterRibbon", e); + } + } + return null; + } - /** - * Register a custom ribbon. - * Important: Do not register the same id twice! - * Parameter: - * id : unique id for ribbon (valid range start with 1001). - * pathToRibbonTexture: path to ribbon png file relative to GameData folder (without suffix). - * name: name of the ribbon - * description: description text - * prestige: prestige (currently just used for ribbon ordering) - * Returns: - * Registered custom ribbon or null, if failed - * Throws: - * ArgumentException, if id was already registered - */ - public object RegisterCustomRibbon(int id, String pathToRibbonTexture, String name, String description = "", int prestige = DEFAULT_PRESTIGE) - { - if (IsInstalled() && methodRegisterCustomRibbon != null) - { - try - { - return methodRegisterCustomRibbon.Invoke(instanceExternalInterface, new object[] { id, pathToRibbonTexture, name, description, prestige }); - } - catch (Exception e) - { - LogFailedMethodAccess("RegisterCustomRibbon", e); - } - } - return null; - } + /// Register a ribbon. + /// + /// Important: Do not register the same code twice! + /// Unique ID for ribbon (valid IDs start at 1001). + /// Path to ribbon PNG file (without suffix) relative to GameData folder. + /// Name of the ribbon. + /// The ribbon's description text. + /// The ribbon's prestige level (currently just used for ribbon ordering). + /// Registered ribbon or null, if failed + /// Thrown if the specified ID was already registered. + public object RegisterCustomRibbon(int id, string pathToRibbonTexture, string name, string description = "", int prestige = DEFAULT_PRESTIGE) + { + if (IsInstalled() && methodRegisterCustomRibbon != null) + { + try + { + return methodRegisterCustomRibbon.Invoke(instanceExternalInterface, new object[] { id, pathToRibbonTexture, name, description, prestige }); + } + catch (ArgumentException e) + { + LogFailedMethodAccess("RegisterCustomRibbon", e); + } + } + return null; + } - /** - * Award a ribbon to a kerbal. If a ribbon is awarded twice only the first award counts. - * Parameter: - * code: code of the ribbon - * kerbal: kerbal that will be awarded with a ribbon - */ - public void AwardRibbonToKerbal(String code, ProtoCrewMember kerbal) - { - if (IsInstalled() && methodAwardRibbonToKerbalByCode != null) - { - try - { - methodAwardRibbonToKerbalByCode.Invoke(instanceExternalInterface, new object[] { code, kerbal }); - } - catch (Exception e) - { - LogFailedMethodAccess("AwardRibbonToKerbal", e); - } - } - } + /// Award a ribbon to a Kerbal. If a ribbon is awarded twice, only the first award counts. + /// The code of the ribbon to award. + /// The Kerbal that will receive the ribbon. + public void AwardRibbonToKerbal(string code, ProtoCrewMember kerbal) + { + if (IsInstalled() && methodAwardRibbonToKerbalByCode != null) + { + try + { + methodAwardRibbonToKerbalByCode.Invoke(instanceExternalInterface, new object[] { code, kerbal }); + } + catch (Exception e) + { + LogFailedMethodAccess("AwardRibbonToKerbal", e); + } + } + } - /** - * Award a ribbon to a kerbal. If a ribbon is awarded twice only the first award counts. - * Parameter: - * ribbon: ribbon - * kerbal: kerbal that will be awarded with a ribbon - */ - public void AwardRibbonToKerbal(object ribbon, ProtoCrewMember kerbal) - { - if (IsInstalled() && methodAwardRibbonToKerbalByRibbon != null) - { - try - { - methodAwardRibbonToKerbalByRibbon.Invoke(instanceExternalInterface, new object[] { ribbon, kerbal }); - } - catch (Exception e) - { - LogFailedMethodAccess("AwardRibbonToKerbal", e); - } - } - } + /// Award a ribbon to a Kerbal. If a ribbon is awarded twice, only the first award counts. + /// The ribbon to award. + /// The Kerbal that will receive the ribbon. + public void AwardRibbonToKerbal(object ribbon, ProtoCrewMember kerbal) + { + if (IsInstalled() && methodAwardRibbonToKerbalByRibbon != null) + { + try + { + methodAwardRibbonToKerbalByRibbon.Invoke(instanceExternalInterface, new object[] { ribbon, kerbal }); + } + catch (Exception e) + { + LogFailedMethodAccess("AwardRibbonToKerbal", e); + } + } + } - /** - * Award a ribbon to multiple kerbals. If a ribbon is awarded twice only the first award counts. - * Parameter: - * code: code of the ribbon - * kerbal: kerbals that will be awarded with a ribbon - */ - public void AwardRibbonToKerbals(String code, ProtoCrewMember[] kerbals) - { - if (IsInstalled() && methodAwardRibbonToKerbalsByCode != null) - { - try - { - methodAwardRibbonToKerbalsByCode.Invoke(instanceExternalInterface, new object[] { code, kerbals }); - } - catch (Exception e) - { - LogFailedMethodAccess("AwardRibbonToKerbals", e); - } - } - } + /// Award a ribbon to a Kerbal. If a ribbon is awarded twice, only the first award counts. + /// The code of the ribbon to award. + /// The Kerbals that will receive the ribbon. + public void AwardRibbonToKerbals(string code, ProtoCrewMember[] kerbals) + { + if (IsInstalled() && methodAwardRibbonToKerbalsByCode != null) + { + try + { + methodAwardRibbonToKerbalsByCode.Invoke(instanceExternalInterface, new object[] { code, kerbals }); + } + catch (Exception e) + { + LogFailedMethodAccess("AwardRibbonToKerbals", e); + } + } + } - /** - * Award a ribbon to multiple kerbals. If a ribbon is awarded twice only the first award counts. - * Parameter: - * ribbon: ribbon - * kerbals: kerbals that will be awarded with a ribbon - */ - public void AwardRibbonToKerbals(object ribbon, ProtoCrewMember[] kerbals) - { - if (IsInstalled() && methodAwardRibbonToKerbalsByRibbon != null) - { - try - { - methodAwardRibbonToKerbalsByRibbon.Invoke(instanceExternalInterface, new object[] { ribbon, kerbals }); - } - catch (Exception e) - { - LogFailedMethodAccess("AwardRibbonToKerbals", e); - } - } - } + /// Award a ribbon to a Kerbal. If a ribbon is awarded twice, only the first award counts. + /// The ribbon to award. + /// The Kerbals that will receive the ribbon. + public void AwardRibbonToKerbals(object ribbon, ProtoCrewMember[] kerbals) + { + if (IsInstalled() && methodAwardRibbonToKerbalsByRibbon != null) + { + try + { + methodAwardRibbonToKerbalsByRibbon.Invoke(instanceExternalInterface, new object[] { ribbon, kerbals }); + } + catch (Exception e) + { + LogFailedMethodAccess("AwardRibbonToKerbals", e); + } + } + } - /** - * Returns true, if a ribbon is awarded to a kerbal - * Parameter: - * ribbon: ribbon - * kerbal: kerbal that is to check - */ - public bool IsRibbonAwardedToKerbal(object ribbon, ProtoCrewMember kerbal) - { - if (IsInstalled() && methodIsRibbonAwardedToKerbalByRibbon != null) - { - try - { - return (bool)methodIsRibbonAwardedToKerbalByRibbon.Invoke(instanceExternalInterface, new object[] { ribbon, kerbal }); - } - catch (Exception e) - { - LogFailedMethodAccess("IsRibbonAwardedToKerbal", e); - } - } - return false; - } + /// Checks whether a specific ribbon has been awarded to a given Kerbal. + /// Code of the ribbon to check. + /// The Kerbal that will be checked. + /// Whether the ribbon has been awarded to the specified Kerbal. + public bool IsRibbonAwardedToKerbal(string code, ProtoCrewMember kerbal) + { + if (IsInstalled() && methodIsRibbonAwardedToKerbalByCode != null) + { + try + { + return (bool)methodIsRibbonAwardedToKerbalByCode.Invoke(instanceExternalInterface, new object[] { code, kerbal }); + } + catch (Exception e) + { + LogFailedMethodAccess("IsRibbonAwardedToKerbal", e); + } + } + return false; + } - /** - * Returns true, if a ribbon is awarded to a kerbal - * Parameter: - * code: code of the ribbon - * kerbal: kerbal that is to check - */ - public bool IsRibbonAwardedToKerbal(String code, ProtoCrewMember kerbal) - { - if (IsInstalled() && methodIsRibbonAwardedToKerbalByCode != null) - { - try - { - return (bool)methodIsRibbonAwardedToKerbalByCode.Invoke(instanceExternalInterface, new object[] { code, kerbal }); - } - catch (Exception e) - { - LogFailedMethodAccess("IsRibbonAwardedToKerbal", e); - } - } - return false; - } + /// Checks whether a specific ribbon has been awarded to a given Kerbal. + /// The ribbon to check. + /// The Kerbal that will be checked. + /// Whether the ribbon has been awarded to the specified Kerbal. + public bool IsRibbonAwardedToKerbal(object ribbon, ProtoCrewMember kerbal) + { + if (IsInstalled() && methodIsRibbonAwardedToKerbalByRibbon != null) + { + try + { + return (bool)methodIsRibbonAwardedToKerbalByRibbon.Invoke(instanceExternalInterface, new object[] { ribbon, kerbal }); + } + catch (Exception e) + { + LogFailedMethodAccess("IsRibbonAwardedToKerbal", e); + } + } + return false; + } - /** - * Get the number of completed missions for a kerbal. - * Parameter - * kerbal: kerbal that we are interested in - * Returns: - * number of completed missions for the kerbal - */ - public int GetMissionsFlownForKerbal(ProtoCrewMember kerbal) - { - if (IsInstalled() && methodGetMissionsFlownForKerbal != null) - { - try - { - return (int)methodGetMissionsFlownForKerbal.Invoke(instanceExternalInterface, new object[] { kerbal }); - } - catch (Exception e) - { - LogFailedMethodAccess("GetMissionsFlownForKerbal", e); - } - } - return 0; - } + /// Gets the number of completed missions for a Kerbal. + /// The Kerbal that will be checked. + /// The number of missions the given Kerbal has completed. + public int GetMissionsFlownForKerbal(ProtoCrewMember kerbal) + { + if (IsInstalled() && methodGetMissionsFlownForKerbal != null) + { + try + { + return (int)methodGetMissionsFlownForKerbal.Invoke(instanceExternalInterface, new object[] { kerbal }); + } + catch (Exception e) + { + LogFailedMethodAccess("GetMissionsFlownForKerbal", e); + } + } + return 0; + } + + /// Gets the number of successful dockings a Kerbal has performed. + /// The Kerbal that will be checked. + /// The number of dockings the given Kerbal has completed. + public int GetDockingsForKerbal(ProtoCrewMember kerbal) + { + if (IsInstalled() && methodGetDockingsForKerbal != null) + { + try + { + return (int)methodGetDockingsForKerbal.Invoke(instanceExternalInterface, new object[] { kerbal }); + } + catch (Exception e) + { + LogFailedMethodAccess("GetDockingsForKerbal", e); + } + } + return 0; + } + + /// Gets the number of completed contracts for a Kerbal. + /// The Kerbal that will be checked. + /// The number of contracts the given Kerbal has completed. + public int GetContractsCompletedForKerbal(ProtoCrewMember kerbal) + { + if (IsInstalled() && methodGetContractsCompletedForKerbal != null) + { + try + { + return (int)methodGetContractsCompletedForKerbal.Invoke(instanceExternalInterface, new object[] { kerbal }); + } + catch (Exception e) + { + LogFailedMethodAccess("GetContractsCompletedForKerbal", e); + } + } + return 0; + } - /** - * Get the number of dockings for a kerbal. - * Parameter - * kerbal: kerbal that we are interested in - * Returns: - * number of dockings for the kerbal - */ - public int GetDockingsForKerbal(ProtoCrewMember kerbal) - { - if (IsInstalled() && methodGetDockingsForKerbal != null) - { - try - { - return (int)methodGetDockingsForKerbal.Invoke(instanceExternalInterface, new object[] { kerbal }); - } - catch (Exception e) - { - LogFailedMethodAccess("GetDockingsForKerbal", e); - } - } - return 0; - } + /** + * Get the accumulated research points for a kerbal. + * Parameter + * kerbal: kerbal that we are interested in + * Returns: + * accumulated research points of this kerbal + */ + /// Gets the number of research points a Kerbal has accumulated. + /// The Kerbal that will be checked. + /// The number of research points the Kerbal has accumulated. + public double GetResearchForKerbal(ProtoCrewMember kerbal) + { + if (IsInstalled() && methodResearchForKerbal != null) + { + try + { + return (double)methodResearchForKerbal.Invoke(instanceExternalInterface, new object[] { kerbal }); + } + catch (Exception e) + { + LogFailedMethodAccess("GetResearchForKerbal", e); + } + } + return 0; + } - /** - * Get the number of completed contracts for a kerbal. - * Parameter - * kerbal: kerbal that we are interested in - * Returns: - * number of number of completed contracts for the kerbal - */ - public int GetContractsCompletedForKerbal(ProtoCrewMember kerbal) - { - if (IsInstalled() && methodGetContractsCompletedForKerbal != null) - { - try - { - return (int)methodGetContractsCompletedForKerbal.Invoke(instanceExternalInterface, new object[] { kerbal }); - } - catch (Exception e) - { - LogFailedMethodAccess("GetContractsCompletedForKerbal", e); - } - } - return 0; - } - - /** - * Get the accumulated research points for a kerbal. - * Parameter - * kerbal: kerbal that we are interested in - * Returns: - * accumulated research points of this kerbal - */ - public double GetResearchForKerbal(ProtoCrewMember kerbal) - { - if (IsInstalled() && methodResearchForKerbal != null) - { - try - { - return (double)methodResearchForKerbal.Invoke(instanceExternalInterface, new object[] { kerbal }); - } - catch (Exception e) - { - LogFailedMethodAccess("GetResearchForKerbal", e); - } - } - return 0; - } - - /** - * Get the total mission time for a kerbal. - * Parameter - * kerbal: kerbal that we are interested in - * Returns: - * total mission time of this kerbal - */ - public double GetTotalMissionTimeForKerbal(ProtoCrewMember kerbal) - { - if (IsInstalled() && methodTotalMissionTimeForKerbal != null) - { - try - { - return (double)methodTotalMissionTimeForKerbal.Invoke(instanceExternalInterface, new object[] { kerbal }); - } - catch (Exception e) - { - LogFailedMethodAccess("GetTotalMissionTimeForKerbal", e); - } - } - return 0; - } - } + /// Gets the total amount of mission time for a Kerbal. + /// The Kerbal that will be checked. + /// The total mission time of the given Kerbal. + public double GetTotalMissionTimeForKerbal(ProtoCrewMember kerbal) + { + if (IsInstalled() && methodTotalMissionTimeForKerbal != null) + { + try + { + return (double)methodTotalMissionTimeForKerbal.Invoke(instanceExternalInterface, new object[] { kerbal }); + } + catch (Exception e) + { + LogFailedMethodAccess("GetTotalMissionTimeForKerbal", e); + } + } + return 0; + } + #endregion + } }