Example #1
0
        void Start()
        {
            Debug.Log("[CorrectCoL]: Starting!");

            if (!far_searched)
            {
                foreach (var a in AppDomain.CurrentDomain.GetAssemblies())
                {
                    if (a.GetName().Name.Equals("FerramAerospaceResearch"))
                    {
                        far_found = true;
                        break;
                    }
                }
                far_searched = true;
            }
            if (far_found)
            {
                Debug.Log("[CorrectCoL]: FAR found, disabling itself!");
                GameObject.Destroy(this.gameObject);
                return;
            }

            overlays = EditorVesselOverlays.fetch;
            if (overlays == null)
            {
                Debug.Log("[CorrectCoL]: overlays is null!");
                GameObject.Destroy(this.gameObject);
                return;
            }
            old_CoL_marker = overlays.CoLmarker;
            if (old_CoL_marker == null)
            {
                Debug.Log("[CorrectCoL]: CoL_marker is null!");
                GameObject.Destroy(this.gameObject);
                return;
            }
            bodylift_curves = PhysicsGlobals.GetLiftingSurfaceCurve("BodyLift");
            if (new_CoL_marker == null)
            {
                new_CoL_marker                 = this.gameObject.AddComponent <CoLMarkerFull>();
                CoLMarkerFull.lift_curves      = bodylift_curves;
                new_CoL_marker.posMarkerObject = (GameObject)GameObject.Instantiate(old_CoL_marker.dirMarkerObject);
                new_CoL_marker.posMarkerObject.transform.parent     = new_CoL_marker.transform;
                new_CoL_marker.posMarkerObject.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f);
                new_CoL_marker.posMarkerObject.SetActive(false);
                new_CoL_marker.posMarkerObject.layer = 2;
                foreach (Transform child in new_CoL_marker.posMarkerObject.transform)
                {
                    child.gameObject.layer = 2;
                }
                GameEvents.onEditorRestart.Add(new EventVoid.OnEvent(TurnOffCoL));
                // should be called once, so let's deserialize graph here too
                GraphWindow.load_settings();
                GraphWindow.init_textures(true);
                GraphWindow.init_reflections();

                clickEvent = new Button.ButtonClickedEvent();
                clickEvent.AddListener(ToggleCoL);
            }
            GameEvents.onGUIApplicationLauncherReady.Add(onAppLauncherLoad);
            GameEvents.onGUIApplicationLauncherUnreadifying.Add(onAppLauncherUnload);
            onAppLauncherLoad();
            GraphWindow.shown      = false;
            new_CoL_marker.enabled = false;
            old_CoL_marker.gameObject.SetActive(false);
            overlays.toggleCoLbtn.onClick = clickEvent;
            //overlays.toggleCoLbtn.methodToInvoke = "ToggleCoL";
        }
Example #2
0
        void Start()
        {
            Debug.Log("[CorrectCoL]: Starting!");

            if (!far_searched)
            {
                foreach (var a in AppDomain.CurrentDomain.GetAssemblies())
                {
                    if (a.GetName().Name.Equals("FerramAerospaceResearch"))
                    {
                        far_found = true;
                        break;
                    }
                }
                far_searched = true;
            }
            if (far_found)
            {
                Debug.Log("[CorrectCoL]: FAR found, disabling itself!");
                GameObject.Destroy(this.gameObject);
                return;
            }

            overlays = EditorVesselOverlays.fetch;
            if (overlays == null)
            {
                Debug.Log("[CorrectCoL]: overlays is null!");
                GameObject.Destroy(this.gameObject);
                return;
            }
            old_CoL_marker = overlays.CoLmarker;
            if (old_CoL_marker == null)
            {
                Debug.Log("[CorrectCoL]: CoL_marker is null!");
                GameObject.Destroy(this.gameObject);
                return;
            }
            bodylift_curves = PhysicsGlobals.GetLiftingSurfaceCurve("BodyLift");
            if (new_CoL_marker == null)
            {
                new_CoL_marker = this.gameObject.AddComponent<CoLMarkerFull>();
                CoLMarkerFull.lift_curves = bodylift_curves;
                new_CoL_marker.posMarkerObject = (GameObject)GameObject.Instantiate(old_CoL_marker.dirMarkerObject);
                new_CoL_marker.posMarkerObject.transform.parent = new_CoL_marker.transform;
                new_CoL_marker.posMarkerObject.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f);
                new_CoL_marker.posMarkerObject.SetActive(false);
                new_CoL_marker.posMarkerObject.layer = 2;
                foreach (Transform child in new_CoL_marker.posMarkerObject.transform)
                {
                    child.gameObject.layer = 2;
                }
                GameEvents.onEditorRestart.Add(new EventVoid.OnEvent(TurnOffCoL));
                // should be called once, so let's deserialize graph here too                
                GraphWindow.load_settings();
                GraphWindow.init_textures(true);
                GraphWindow.init_reflections();

                clickEvent = new Button.ButtonClickedEvent();
                clickEvent.AddListener(ToggleCoL);
            }
            GameEvents.onGUIApplicationLauncherReady.Add(onAppLauncherLoad);
            GameEvents.onGUIApplicationLauncherUnreadifying.Add(onAppLauncherUnload);
            onAppLauncherLoad();
            GraphWindow.shown = false;
            new_CoL_marker.enabled = false;
            old_CoL_marker.gameObject.SetActive(false);
            overlays.toggleCoLbtn.onClick = clickEvent;
            //overlays.toggleCoLbtn.methodToInvoke = "ToggleCoL";
        }