Exemplo n.º 1
0
        protected override void OnUpdate()
        {
            base.OnUpdate();
            if (lastUpdate > UnityEngine.Time.realtimeSinceStartup + .1)
            {
                return;
            }
            CelestialBody targetBody     = StnSciParameter.getTargetBody(this);
            AvailablePart experimentType = StnSciParameter.getExperimentType(this);

            if (targetBody == null || experimentType == null)
            {
                if (targetBody == null || experimentType == null)
                {
                    Debug.Log("targetBody or experimentType is null");
                    return;
                }
            }
            lastUpdate = UnityEngine.Time.realtimeSinceStartup;
            Vessel vessel = FlightGlobals.ActiveVessel;

            if (vessel != null)
            {
                foreach (Part part in vessel.Parts)
                {
                    if (part.name == experimentType.name)
                    {
                        StationExperiment e = part.FindModuleImplementing <StationExperiment>();
                        if (e != null)
                        {
                            if (e.completed >= this.Root.DateAccepted && e.completed > e.launched)
                            {
                                ScienceData[] data = e.GetData();
                                foreach (ScienceData datum in data)
                                {
                                    if (datum.subjectID.ToLower().Contains("@" + targetBody.name.ToLower() + "inspace"))
                                    {
                                        SetComplete();
                                        return;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            SetIncomplete();
        }
Exemplo n.º 2
0
        private void OnRecovery(Vessel vessel)
        {
            Debug.Log("Recovering " + vessel.vesselName);
            CelestialBody targetBody     = StnSciParameter.getTargetBody(this);
            AvailablePart experimentType = StnSciParameter.getExperimentType(this);

            if (targetBody == null || experimentType == null)
            {
                Debug.Log("targetBody or experimentType is null");
                return;
            }
            foreach (Part part in vessel.Parts)
            {
                if (part.name == experimentType.name)
                {
                    StationExperiment e = part.FindModuleImplementing <StationExperiment>();
                    if (e != null)
                    {
                        if (e.launched >= this.Root.DateAccepted && e.completed >= e.launched)
                        {
                            ScienceData[] data = e.GetData();
                            foreach (ScienceData datum in data)
                            {
                                if (datum.subjectID.ToLower().Contains("@" + targetBody.name.ToLower() + "inspace"))
                                {
                                    StnSciParameter parent = this.Parent as StnSciParameter;
                                    SetComplete();
                                    if (parent != null)
                                    {
                                        parent.Complete();
                                    }
                                    return;
                                }
                            }
                        }
                    }
                }
            }
            SetIncomplete();
        }