コード例 #1
0
 void OnLinkBroken(KAS.IKasLinkEvent evt)
 {
     if (evt.source.part.vessel == FlightGlobals.ActiveVessel ||
         evt.target.part.vessel == FlightGlobals.ActiveVessel)
     {
         StartCoroutine(WaitAndRebuildSets(FlightGlobals.ActiveVessel));
     }
 }
コード例 #2
0
        public static bool Initialize()
        {
            if (!inited)
            {
                inited = true;                 // do this only once, assemblies won't change
                AssemblyLoader.LoadedAssembly KASAPIasm    = null;
                AssemblyLoader.LoadedAssembly KASasm       = null;
                AssemblyLoader.LoadedAssembly KASLegacyasm = null;

                foreach (var la in AssemblyLoader.loadedAssemblies)
                {
                    if (la.assembly.GetName().Name.Equals("KAS-API-v1", StringComparison.InvariantCultureIgnoreCase))
                    {
                        KASAPIasm = la;
                    }
                    else if (la.assembly.GetName().Name.Equals("KAS", StringComparison.InvariantCultureIgnoreCase))
                    {
                        if (KASLegacyasm == null)
                        {
                            KASLegacyasm = la;
                        }
                        else
                        {
                            KASasm = la;
                        }
                    }
                }
                haveKAS = false;
                if (KASAPIasm != null && KASasm != null)
                {
                    haveKAS = true;
                    ILinkPeer.Initialize(KASAPIasm.assembly);
                    ILinkSource.Initialize(KASAPIasm.assembly);
                    ILinkTarget.Initialize(KASAPIasm.assembly);
                    ILinkJoint.Initialize(KASAPIasm.assembly);
                    IKasLinkEvent.Initialize(KASAPIasm.assembly);
                    IKasEvents.Initialize(KASAPIasm.assembly);

                    KASJointCableBase.Initialize(KASasm.assembly);
                }
                if (KASLegacyasm != null)
                {
                    haveKAS = true;
                    KASModuleStrut.Initialize(KASLegacyasm.assembly);
                }
            }

            return(haveKAS);
        }
コード例 #3
0
        public static bool Initialize()
        {
            if (!inited)
            {
                inited = true;                 // do this only once, assemblies won't change
                AssemblyLoader.LoadedAssembly KASAPIasm    = null;
                AssemblyLoader.LoadedAssembly KASasm       = null;
                AssemblyLoader.LoadedAssembly KASLegacyasm = null;
                int apiVersion = 0;

                foreach (var la in AssemblyLoader.loadedAssemblies)
                {
                    string asmName = la.assembly.GetName().Name;
                    if (asmName.Equals("KAS-API-v2", StringComparison.InvariantCultureIgnoreCase))
                    {
                        KASAPIasm  = la;
                        apiVersion = 2;
                    }
                    else if (asmName.Equals("KAS-API-v1", StringComparison.InvariantCultureIgnoreCase))
                    {
                        KASAPIasm  = la;
                        apiVersion = 1;
                    }
                    else if (asmName.Equals("KAS", StringComparison.InvariantCultureIgnoreCase))
                    {
                        if (KASLegacyasm == null)
                        {
                            KASLegacyasm = la;
                        }
                        else
                        {
                            KASasm = la;
                        }
                    }
                }
                haveKAS = false;
                if (apiVersion == 2)
                {
                    // With API version 2, legacy has gone away and now there's
                    // just the API dll and the main dll
                    // however, the main dll gets picked up as legacy
                    KASasm       = KASLegacyasm;
                    KASLegacyasm = null;
                }
                if (KASAPIasm != null && KASasm != null)
                {
                    haveKAS = true;
                    ILinkPeer.Initialize(KASAPIasm.assembly);
                    ILinkSource.Initialize(KASAPIasm.assembly);
                    ILinkTarget.Initialize(KASAPIasm.assembly);
                    ILinkJoint.Initialize(KASAPIasm.assembly);
                    IKasLinkEvent.Initialize(KASAPIasm.assembly);
                    IKasEvents.Initialize(KASAPIasm.assembly);

                    KASJointCableBase.Initialize(KASasm.assembly);
                }
                if (KASLegacyasm != null)
                {
                    haveKAS = true;
                    KASModuleStrut.Initialize(KASLegacyasm.assembly);
                }
            }

            return(haveKAS);
        }