public void Initialize()
 {
     if (!Smapi.GetModRegistry().IsLoaded(CjbItemSpawnerID))
     {
         return;
     }
     MenuEvents.MenuChanged += OnMenuChanged;
 }
 private EntoaroxFrameworkСompatibilityLayout()
 {
     UseCompatibility = Smapi.GetModRegistry().IsLoaded(EntoaroxFrameworkID);
     if (UseCompatibility)
     {
         Log.Trace("Found Entoarox Framework. Used compatibility mode.");
     }
     GameEvents.LoadContent += GameEventsOnLoadContent;
 }
Beispiel #3
0
        /// <summary>
        /// This method will set up the ShipManifest object and wrap all the methods/functions
        /// </summary>
        /// <returns>
        /// Bool indicating success of call
        /// </returns>
        public static bool InitSmWrapper()
        {
            try
            {
                //reset the internal objects
                _smWrapped      = false;
                ActualSm        = null;
                ShipManifestApi = null;
                LogFormatted("Attempting to Grab ShipManifest Types...");

                //find the base type
                SmType = AssemblyLoader.loadedAssemblies
                         .Select(a => a.assembly.GetExportedTypes())
                         .SelectMany(t => t)
                         .FirstOrDefault(t => t.FullName == "ShipManifest.SMAddon");

                if (SmType == null)
                {
                    return(false);
                }

                LogFormatted("ShipManifest Version:{0}", SmType.Assembly.GetName().Version.ToString());

                //now the KerbalInfo Type
                TransferCrewType = AssemblyLoader.loadedAssemblies
                                   .Select(a => a.assembly.GetExportedTypes())
                                   .SelectMany(t => t)
                                   .FirstOrDefault(t => t.FullName == "ShipManifest.Process.TransferCrew");

                if (TransferCrewType == null)
                {
                    return(false);
                }

                //now grab the running instance
                LogFormatted("Got Assembly Types, grabbing Instance");
                try
                {
                    ActualSm = SmType.GetField("Instance", BindingFlags.Public | BindingFlags.Static).GetValue(null);
                }
                catch (Exception)
                {
                    LogFormatted("No Instance found - most likely you have an old ShipManifest installed");
                    return(false);
                }
                if (ActualSm == null)
                {
                    LogFormatted("Failed grabbing SMAddon Instance");
                    return(false);
                }

                //If we get this far we can set up the local object and its methods/functions
                LogFormatted("Got Instance, Creating Wrapper Objects");
                ShipManifestApi = new Smapi(ActualSm);
                _smWrapped      = true;
                return(true);
            }
            catch (Exception ex)
            {
                LogFormatted("Unable to setup InitSMrapper Reflection");
                LogFormatted("Exception: {0}", ex);
                _smWrapped = false;
                return(false);
            }
        }