Inheritance: ContractParameter, PartRelated, BodyRelated
Ejemplo n.º 1
0
 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();
 }
Ejemplo n.º 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();
                    }
                }
            }
        }
Ejemplo n.º 3
0
 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);
 }
Ejemplo n.º 4
0
        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;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 5
0
 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());
 }
Ejemplo n.º 6
0
        protected override string GetTitle()
        {
            AvailablePart experimentType = StnSciParameter.getExperimentType(this);

            if (experimentType == null)
            {
                return("Launch new experiment pod");
            }
            return("Launch new " + experimentType.title);
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 9
0
 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();
             }
         }
     }
 }
Ejemplo n.º 10
0
 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();
             }
         }
     }
 }
Ejemplo n.º 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();
        }