Inheritance: ContractParameter, PartRelated, BodyRelated
 protected override void OnUpdate()
 {
     base.OnUpdate();
     if (lastUpdate > UnityEngine.Time.realtimeSinceStartup + .1)
         return;
     lastUpdate = UnityEngine.Time.realtimeSinceStartup;
     Vessel vessel = FlightGlobals.ActiveVessel;
     AvailablePart experimentType = StnSciParameter.getExperimentType(this);
     if (experimentType == null)
         return;
     if (vessel != null)
         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)
                     {
                         SetComplete();
                         return;
                     }
                 }
             }
         }
     SetIncomplete();
 }
示例#2
0
        private void OnVesselSituationChange(GameEvents.HostedFromToAction <Vessel, Vessel.Situations> arg)
        {
            Debug.Log("OnVesselSituationChanged");
            if (!((arg.from == Vessel.Situations.LANDED || arg.from == Vessel.Situations.PRELAUNCH) &&
                  (arg.to == Vessel.Situations.FLYING || arg.to == Vessel.Situations.SUB_ORBITAL)))
            {
                return;
            }
            if (arg.host.mainBody.theName != "Kerbin")
            {
                return;
            }
            AvailablePart experimentType = StnSciParameter.getExperimentType(this);

            if (experimentType == null)
            {
                return;
            }
            foreach (Part part in arg.host.Parts)
            {
                if (part.name == experimentType.name)
                {
                    StationExperiment e = part.FindModuleImplementing <StationExperiment>();
                    if (e != null && e.launched == 0)
                    {
                        e.launched = (float)Planetarium.GetUniversalTime();
                    }
                }
            }
        }
 protected override string GetTitle()
 {
     AvailablePart experimentType = StnSciParameter.getExperimentType(this);
     if (experimentType == null)
         return Localizer.Format("#autoLOC_StatSciNewPod_TitleA");
     return Localizer.Format("#autoLOC_StatSciNewPod_TitleB", experimentType.title);
 }
        private void OnRecovered(ProtoVessel pv, bool dummy)
        {
            CelestialBody targetBody     = StnSciParameter.getTargetBody(this);
            AvailablePart experimentType = StnSciParameter.getExperimentType(this);

            if (targetBody == null || experimentType == null)
            {
                return;
            }
            foreach (ProtoPartSnapshot part in pv.protoPartSnapshots)
            {
                if (part.partName == experimentType.name)
                {
                    foreach (ProtoPartModuleSnapshot module in part.modules)
                    {
                        if (module.moduleName == "StationExperiment")
                        {
                            ConfigNode cn = module.moduleValues;
                            if (!cn.HasValue("launched") || !cn.HasValue("completed"))
                            {
                                continue;
                            }
                            float launched, completed;
                            try
                            {
                                launched  = float.Parse(cn.GetValue("launched"));
                                completed = float.Parse(cn.GetValue("completed"));
                            }
                            catch (Exception e)
                            {
                                StnSciScenario.LogError(e.ToString());
                                continue;
                            }
                            if (launched >= this.Root.DateAccepted && completed >= launched)
                            {
                                foreach (ConfigNode datum in cn.GetNodes("ScienceData"))
                                {
                                    if (!datum.HasValue("subjectID"))
                                    {
                                        continue;
                                    }
                                    string subjectID = datum.GetValue("subjectID");
                                    if (subjectID.ToLower().Contains("@" + targetBody.name.ToLower() + "inspace"))
                                    {
                                        StnSciParameter parent = this.Parent as StnSciParameter;
                                        SetComplete();
                                        if (parent != null)
                                        {
                                            parent.Complete();
                                        }
                                        return;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
 protected override string GetTitle()
 {
     CelestialBody targetBody = StnSciParameter.getTargetBody(this);
     if (targetBody == null)
         return Localizer.Format("#autoLOC_StatSciDoExp_TitleA");
     else
         return Localizer.Format("#autoLOC_StatSciDoExp_TitleB", targetBody.GetDisplayName());
 }
示例#6
0
        protected override string GetTitle()
        {
            AvailablePart experimentType = StnSciParameter.getExperimentType(this);

            if (experimentType == null)
            {
                return("Launch new experiment pod");
            }
            return("Launch new " + experimentType.title);
        }
示例#7
0
        protected override string GetTitle()
        {
            CelestialBody targetBody = StnSciParameter.getTargetBody(this);

            if (targetBody == null)
            {
                return("Complete in orbit");
            }
            else
            {
                return("Complete in orbit around " + targetBody.theName);
            }
        }
示例#8
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();
        }
 private void OnVesselCreate(Vessel vessel)
 {
     AvailablePart experimentType = StnSciParameter.getExperimentType(this);
     if (experimentType == null)
         return;
     foreach (Part part in vessel.Parts)
     {
         if (part.name == experimentType.name)
         {
             StationExperiment e = part.FindModuleImplementing<StationExperiment>();
             if (e != null)
             {
                 e.launched = (float)Planetarium.GetUniversalTime();
             }
         }
     }
 }
 private void OnLaunch(EventReport report)
 {
     AvailablePart experimentType = StnSciParameter.getExperimentType(this);
     if (experimentType == null)
         return;
     Vessel vessel = FlightGlobals.ActiveVessel;
     foreach (Part part in vessel.Parts)
     {
         if (part.name == experimentType.name)
         {
             StationExperiment e = part.FindModuleImplementing<StationExperiment>();
             if (e != null && e.launched == 0)
             {
                 e.launched = (float)Planetarium.GetUniversalTime();
             }
         }
     }
 }
示例#11
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();
        }