Ejemplo n.º 1
0
        public override void OnStart(StartState state)
        {
            CacheStrings();
            base.OnStart(state);
            if (state == StartState.Editor)
            {
                _inEditor = true;
            }
            Utilities.Log_Debug("Starting ChemCam");
            _lookTransform = Utilities.FindChildRecursive(transform, "CameraTransform");
            if (state != StartState.Editor)
            {
                _camera = _lookTransform.gameObject.AddComponent <TSTCameraModule>();
                Utilities.Log_Debug("Adding Lazer");
                _lazerTransform   = Utilities.FindChildRecursive(transform, "LazerTransform");
                _lazerObj         = _lazerTransform.gameObject.AddComponent <LineRenderer>();
                _lazerObj.enabled = false;
                //_lazerObj.castShadows = false;
                _lazerObj.shadowCastingMode = ShadowCastingMode.Off;
                _lazerObj.receiveShadows    = false;
                _lazerObj.SetWidth(0.01f, 0.01f);
                _lazerObj.SetPosition(0, new Vector3(0, 0, 0));
                _lazerObj.SetPosition(1, new Vector3(0, 0, 5));
                _lazerObj.useWorldSpace  = false;
                _lazerObj.material       = new Material(Shader.Find("Particles/Additive"));
                _lazerObj.material.color = Color.red;
                _lazerObj.SetColors(Color.red, Color.red);
            }

            Utilities.Log_Debug("Finding Camera Transforms");
            _headTransform     = Utilities.FindChildRecursive(transform, "CamBody");
            _upperArmTransform = Utilities.FindChildRecursive(transform, "ArmUpper");

            Utilities.Log_Debug("Finding Animation Object");
            _animationObj = Utilities.FindChildRecursive(transform, "ChemCam").GetComponent <Animation>();

            PlanetNames  = Utilities.GetCelestialBodyNames();
            CHMCwindowID = Utilities.getnextrandomInt();

            if (state != StartState.Editor)
            {
                viewfinder.LoadImage(Properties.Resources.viewfinder);
                Utilities.Log_Debug("Adding Input Callback");
                _vessel = vessel;
                vessel.OnAutopilotUpdate += handleInput;
                GameEvents.onVesselChange.Add(refreshFlghtInptHandler);
                GameEvents.onVesselDestroy.Add(removeFlghtInptHandler);
                GameEvents.OnVesselRecoveryRequested.Add(removeFlghtInptHandler);
                Utilities.Log_Debug("Added Input Callback");
            }
            Events["eventOpenCamera"].active    = true;
            Actions["actionOpenCamera"].active  = true;
            Events["eventCloseCamera"].active   = false;
            Actions["actionCloseCamera"].active = false;
            updateAvailableEvents();
            if (Active)
            {
                StartCoroutine(openCamera());
            }
        }
Ejemplo n.º 2
0
        private void Update()
        {
            bool            ExternalControl = false;
            TSTCameraModule ActiveOptics    = null;

            foreach (Part p in FlightGlobals.ActiveVessel.Parts)
            {
                TSTSpaceTelescope tstSpcTel = p.GetComponent <TSTSpaceTelescope>();
                if (tstSpcTel != null)
                {
                    TSTCameraModule tstCam = tstSpcTel._camera;
                    if (tstCam != null)
                    {
                        if (!TSTCam.Contains(tstCam))
                        {
                            TSTCam.Add(tstCam);
                        }
                    }
                }
            }

            foreach (TSTCameraModule tstCam in TSTCam)
            {
                //Check for when optics is null, this avoids an unknown exception
                if (tstCam != null && tstCam.Enabled)
                {
                    ExternalControl = true;
                    ActiveOptics    = tstCam;
                }
            }

            if (DOEPresent)
            {
                try
                {
                    //SetDOEFOV(ExternalControl, ActiveOptics);

                    if (DOEWrapper.APIReady)
                    {
                        DOEWrapper.DOEapi.SetExternalFOVControl(ExternalControl);
                        if (ExternalControl)
                        {
                            DOEWrapper.DOEapi.SetFOV(ActiveOptics.fov);
                        }
                    }
                }
                catch
                {
                    Debug.Log("TST: Wrong DOE library version - disabled.");
                    DOEPresent = false;
                }
            }
        }
Ejemplo n.º 3
0
        private void Start()
        {
            if (TSTCam == null)
            {
                Debug.Log("TST: DOEWrapper: Uh-oh, we have a problem. If you see this error, then you're gonna have a bad day.");
            }

            else
            {
                foreach (Part p in FlightGlobals.ActiveVessel.Parts)
                {
                    TSTCameraModule tstCam = p.GetComponent <TSTCameraModule>();
                    if (tstCam != null)
                    {
                        if (!TSTCam.Contains(tstCam))
                        {
                            TSTCam.Add(tstCam);
                        }
                    }
                }
            }
            DOEPresent = DOEWrapper.InitDOEWrapper();
            // DOEPresent = AssemblyLoader.loadedAssemblies.Any(a => a.assembly.GetName().Name == "DistantObject");
        }
        public override void OnStart(StartState state)
        {
            base.OnStart(state);
            Utilities.Log_Debug("TSTTel Starting Telescope");
            part.CoMOffset = part.attachNodes[0].position;
            if (state == StartState.Editor)
            {
                _inEditor = true;
                return;
            }
            _baseTransform = Utilities.FindChildRecursive(transform, baseTransformName);
            cameraTransform = Utilities.FindChildRecursive(transform, cameraTransformName);
            _lookTransform = Utilities.FindChildRecursive(transform, lookTransformName);
            _animationTransform = Utilities.FindChildRecursive(transform, animationTransformName);
            zeroRotation = cameraTransform.localRotation;
            _camera = cameraTransform.gameObject.AddComponent<TSTCameraModule>();

            //_animation = _baseTransform.animation;
            if (_animationTransform != null)
            {
                _animationOpen = animationNameOpen == "" ? _animationTransform.GetComponent<Animation>() : Utilities.FindAnimChildRecursive(_animationTransform, animationNameOpen);
                _animationClose = animationNameClose == "" ? _animationTransform.GetComponent<Animation>() : Utilities.FindAnimChildRecursive(_animationTransform, animationNameClose);
            }

            //Set start-up Event state for this module.
            if (!Active) //camera is not active on startup
            {
                activeonStartup = false;
                Events["eventOpenCamera"].active = true;
                Events["eventCloseCamera"].active = false;
                Events["eventShowGUI"].active = false;
            }
            else //Camera is active on startup
            {
                activeonStartup = true;
                Events["eventOpenCamera"].active = false;
                Events["eventCloseCamera"].active = true;
                Events["eventShowGUI"].active = true;
            }
            Events["eventControlFromHere"].active = false;
            Events["eventReviewScience"].active = false;

            //Check if override or disable fields are supplied and if so set flags to process them in OnUpdate (have to wait for the other
            // part modules to start first, so can't do them here).
            if (overrideModuleName != "" && (overrideEventNameOpen != "" || overrideEventNameClose != ""))
            {
                overrideEvents = true;
                overrideEventsProcessed = false;
            }
            if (disableModuleName != "" && disableEventName != "")
            {
                disableEvents = true;
                disableEventsProcessed = false;
            }

            for (var i = 0; i < targets_raw.Count; i++)
            {
                var tex = new Texture2D(40, 40);
                tex.LoadImage(targets_raw[i]);
                targets.Add(tex);
            }

            CAMwindowID = Utilities.getnextrandomInt();
            GALwindowID = Utilities.getnextrandomInt();
            BODwindowID = Utilities.getnextrandomInt();
            Utilities.Log_Debug("TSTTel On end start");
            StartCoroutine(setSASParams());
            Utilities.Log_Debug("TSTTel Adding Input Callback");
            _vessel = vessel;
            _vessel.OnAutopilotUpdate += onFlightInput;
            GameEvents.onVesselChange.Add(refreshFlightInputHandler);
            GameEvents.onVesselDestroy.Add(removeFlightInputHandler);
            GameEvents.OnVesselRecoveryRequested.Add(removeFlightInputHandler);
            Utilities.Log_Debug("TSTTel Added Input Callback");
            //if (Active) //Moved to OnUpdate so we can process any override/disable event parameters correctly.
            //    StartCoroutine(openCamera());
        }
        public override void OnStart(StartState state)
        {
            base.OnStart(state);
            if (state == StartState.Editor)
            {
                _inEditor = true;
                return;
            }

            Utilities.Log_Debug("Starting ChemCam");
            _lookTransform = Utilities.FindChildRecursive(transform,"CameraTransform");
            _camera=_lookTransform.gameObject.AddComponent<TSTCameraModule>();

            Utilities.Log_Debug("Adding Lazer");
            _lazerTransform = Utilities.FindChildRecursive(transform, "LazerTransform");
            _lazerObj = _lazerTransform.gameObject.AddComponent<LineRenderer>();
            _lazerObj.enabled = false;
            //_lazerObj.castShadows = false;
            _lazerObj.shadowCastingMode = ShadowCastingMode.Off;
            _lazerObj.receiveShadows = false;
            _lazerObj.SetWidth(0.01f, 0.01f);
            _lazerObj.SetPosition(0, new Vector3(0, 0, 0));
            _lazerObj.SetPosition(1, new Vector3(0, 0, 5));
            _lazerObj.useWorldSpace = false;
            _lazerObj.material = new Material(Shader.Find("Particles/Additive"));
            _lazerObj.material.color = Color.red;
            _lazerObj.SetColors(Color.red, Color.red);

            Utilities.Log_Debug("Finding Camera Transforms");
            _headTransform = Utilities.FindChildRecursive(transform, "CamBody");
            _upperArmTransform = Utilities.FindChildRecursive(transform, "ArmUpper");

            Utilities.Log_Debug("Finding Animation Object");
            _animationObj = Utilities.FindChildRecursive(transform, "ChemCam").GetComponent<Animation>();

            viewfinder.LoadImage(Resources.viewfinder);

            PlanetNames = (from CelestialBody b in FlightGlobals.Bodies select b.name).ToList();
            CHMCwindowID = Utilities.getnextrandomInt();

            Utilities.Log_Debug("Adding Input Callback");
            _vessel = vessel;
            vessel.OnAutopilotUpdate += handleInput;
            GameEvents.onVesselChange.Add(refreshFlghtInptHandler);
            GameEvents.onVesselDestroy.Add(removeFlghtInptHandler);
            GameEvents.OnVesselRecoveryRequested.Add(removeFlghtInptHandler);
            Utilities.Log_Debug("Added Input Callback");

            Events["eventOpenCamera"].active = true;
            Actions["actionOpenCamera"].active = true;
            Events["eventCloseCamera"].active = false;
            Actions["actionCloseCamera"].active = false;
            updateAvailableEvents();
            if (Active)
                StartCoroutine(openCamera());
        }