Exemple #1
0
        public static void Initialize()
        {
            rtAvailable = false;
            try
            {
                Debug.Log("[PR] Initializing RemoteTech wrapper.");
                rtUtil_t = Reflection.GetExportedType("RemoteTech", "RemoteTech.RTUtil");
                if (rtUtil_t == null)
                {
                    return;
                }
                MethodInfo GetSignalProcessor_t = rtUtil_t.GetMethod("GetSignalProcessor", BindingFlags.Static | BindingFlags.Public);
                if (GetSignalProcessor_t == null)
                {
                    return;
                }
                GetSignalProcessor = Reflection.CreateFunc <Vessel>(GetSignalProcessor_t);
                if (GetSignalProcessor == null)
                {
                    return;
                }
                rtISigProc_t = Reflection.GetExportedType("RemoteTech", "RemoteTech.Modules.ModuleSPU");
                if (rtISigProc_t == null)
                {
                    return;
                }
                spFliCom_t = rtISigProc_t.GetProperty("FlightComputer", BindingFlags.Instance | BindingFlags.Public);
                if (spFliCom_t == null)
                {
                    return;
                }
                rtFliCom_t = Reflection.GetExportedType("RemoteTech", "RemoteTech.FlightComputer.FlightComputer");
                if (rtFliCom_t == null)
                {
                    return;
                }
                fcAttCom_t = rtFliCom_t.GetProperty("currentFlightMode", BindingFlags.Instance | BindingFlags.Public);
                if (fcAttCom_t == null)
                {
                    return;
                }
                rtAttCom_t = Reflection.GetExportedType("RemoteTech", "RemoteTech.FlightComputer.Commands.AttitudeCommand");
                if (rtAttCom_t == null)
                {
                    return;
                }
                acMode_t = rtAttCom_t.GetField("Mode", BindingFlags.Instance | BindingFlags.Public);
                if (acMode_t == null)
                {
                    return;
                }

                fcControllable_t = rtFliCom_t.GetProperty("InputAllowed", BindingFlags.Instance | BindingFlags.Public);
                if (fcControllable_t == null)
                {
                    return;
                }


                rtAvailable = true;
                Debug.Log("[PR] RemoteTech reflection successfull!");
            }
            catch
            {
                Debug.LogWarning("[PR] RemoteTech exception.");
            }
        }
Exemple #2
0
        /* MONOBEHAVIOUR METHODS */
        public static void Initialize()
        {
            Debug.Log("[PR] Initializing MechJeb wrapper...");
            mjAvailable = false;
            try
            {
                mjCore_t = Reflection.GetExportedType("MechJeb2", "MuMech.MechJebCore");
                if (mjCore_t == null)
                {
                    return;
                }

                mjVesselExtensions_t = Reflection.GetExportedType("MechJeb2", "MuMech.VesselExtensions");
                if (mjVesselExtensions_t == null)
                {
                    return;
                }

                Type mjModuleSmartass_t = Reflection.GetExportedType("MechJeb2", "MuMech.MechJebModuleSmartASS");
                if (mjModuleSmartass_t == null)
                {
                    return;
                }

                saTarget_t = mjModuleSmartass_t.GetField("target", BindingFlags.Instance | BindingFlags.Public);
                if (saTarget_t == null)
                {
                    return;
                }

                MethodInfo GetMasterMechJeb_t = mjVesselExtensions_t.GetMethod("GetMasterMechJeb", BindingFlags.Static | BindingFlags.Public);
                if (GetMasterMechJeb_t == null)
                {
                    return;
                }
                GetMasterMechJeb = Reflection.CreateFunc <Vessel>(GetMasterMechJeb_t);
                if (GetMasterMechJeb == null)
                {
                    return;
                }

                MethodInfo GetComputerModule_t = mjCore_t.GetMethod("GetComputerModule", new Type[] { typeof(string) });
                if (GetComputerModule_t == null)
                {
                    return;
                }
                GetComputerModule = Reflection.CreateFunc <object, string>(GetComputerModule_t);
                if (GetComputerModule == null)
                {
                    return;
                }

                Type mjComputerModule_t = Reflection.GetExportedType("MechJeb2", "MuMech.ComputerModule");
                if (mjComputerModule_t == null)
                {
                    return;
                }
                PropertyInfo mjModuleEnabledProperty = mjComputerModule_t.GetProperty("enabled", BindingFlags.Instance | BindingFlags.Public);
                MethodInfo   mjModuleEnabled         = null;
                if (mjModuleEnabledProperty != null)
                {
                    mjModuleEnabled = mjModuleEnabledProperty.GetGetMethod();
                }
                if (mjModuleEnabled == null)
                {
                    return;
                }
                ModuleEnabled = Reflection.CreateFuncBool <object>(mjModuleEnabled);


                mjAvailable = true;
                Debug.Log("[PR] MechJeb reflection successfull!");
            }
            catch
            {
                Debug.LogWarning("[PR] MechJeb exception.");
            }
        }