コード例 #1
0
        public void Awake()
        {
            Debug.Log("TSTGalaxies Galaxies Awake");
            if (Instance != null)
            {
                Destroy(this);
            }
            else
            {
                Instance = this;
            }
            DontDestroyOnLoad(this);

            Debug.Log("TSTGalaxies Starting Galaxies");

            baseTransform = new GameObject();
            baseTransform.transform.localPosition = Vector3.zero;
            baseTransform.transform.localRotation = Quaternion.identity;

            if (ScaledSun.Instance != null)
            {
                baseTransform.transform.parent = ScaledSun.Instance.transform;
                Debug.Log("TSTGalaxies BaseTransform set to the ScaledSun.Instance");
            }
            else
            {
                baseTransform.SetActive(false);
                Debug.Log("TSTGalaxies BaseTransform setactive = false, ScaledSun does not exist");
            }
            if (Utilities.IsKopInstalled)
            {
                baseTransform.transform.parent = FlightGlobals.Bodies[1].transform;
                Debug.Log("TSTGalaxies - Detected Kopernicus - BaseTransform set to Home Planet");
            }

            UrlDir.UrlConfig[] galaxyCfgs = GameDatabase.Instance.GetConfigs("GALAXY");
            foreach (UrlDir.UrlConfig cfg in galaxyCfgs)
            {
                GameObject go = new GameObject(name, typeof(MeshFilter), typeof(MeshRenderer), typeof(TSTGalaxy));
                go.transform.parent = baseTransform.transform;
                TSTGalaxy galaxy = go.GetComponent <TSTGalaxy>();
                galaxy.Load(cfg.config);
                Debug.Log("TSTGalaxies Adding Galaxy " + galaxy.name);
                Galaxies.Add(galaxy);

                GameObject goCB = new GameObject(name, typeof(CelestialBody));
                goCB.transform.parent = go.transform;
                CelestialBody celestialBody = goCB.GetComponent <CelestialBody>();
                celestialBody.bodyName           = galaxy.name;
                celestialBody.bodyDisplayName    = galaxy.displayName;
                celestialBody.transform.position = galaxy.position;
                celestialBody.atmosphere         = false;
                celestialBody.ocean = false;
                celestialBody.timeWarpAltitudeLimits = new float[0];
                celestialBody.Radius       = 500;
                celestialBody.orbitDriver  = null;
                celestialBody.progressTree = null;
                CBGalaxies.Add(celestialBody);
            }
        }
コード例 #2
0
 private TargetableObject(TSTGalaxy galaxy)
 {
     this.galaxy = galaxy;
 }
コード例 #3
0
        private void doScience(TSTGalaxy galaxy, CelestialBody planet)
        {
            ScienceExperiment experiment;
            ScienceSubject subject;
            ScienceData data;
            var experimentSituation = getExperimentSituation();
            string tgtName;
            string tgttheName;
            try
            {
                if (galaxy != null)
                {
                    tgtName = galaxy.name;
                    tgttheName = galaxy.theName;
                }
                else
                {
                    tgtName = planet.name;
                    tgttheName = planet.theName;
                }
                Utilities.Log_Debug("Doing Science for {0}", tgttheName);
                experiment = ResearchAndDevelopment.GetExperiment("TarsierSpaceTech.SpaceTelescope");
                if (experiment == null)
                {
                    Utilities.Log("Unable to find experiment TarsierSpaceTech.SpaceTelescope, Are you missing a config file? Report on forums.");
                    ScreenMessages.PostScreenMessage("TST Unable to find Experiment - Internal Failure. See Log.", 5f,
                        ScreenMessageStyle.UPPER_CENTER);
                    return;
                }
                Utilities.Log_Debug("Got experiment");

                subject = ResearchAndDevelopment.GetExperimentSubject(experiment, experimentSituation, vessel.mainBody, "LookingAt" + tgtName);
                subject.title = "Space Telescope picture of " + tgttheName;
                Utilities.Log_Debug("Got subject, determining science data using {0}", part.name);

                if (experiment.IsAvailableWhile(experimentSituation, vessel.mainBody))
                {
                    if (part.name == "tarsierSpaceTelescope")
                    {
                        if (galaxy != null)
                        {
                            data = new ScienceData(experiment.baseValue/2*subject.dataScale, xmitDataScalar,labBoostScalar,subject.id, subject.title, false, part.flightID);
                        }
                        else
                        {
                            data = new ScienceData(experiment.baseValue * 0.8f * subject.dataScale, xmitDataScalar,labBoostScalar, subject.id, subject.title, false, part.flightID);
                        }
                    }
                    else
                    {
                        if (galaxy != null)
                        {
                            data = new ScienceData(experiment.baseValue * subject.dataScale, xmitDataScalar, labBoostScalar,subject.id, subject.title, false, part.flightID);
                        }
                        else
                        {
                            data = new ScienceData(experiment.baseValue * subject.dataScale, xmitDataScalar, labBoostScalar,subject.id, subject.title, false, part.flightID);
                        }
                    }
                    Utilities.Log_Debug("Got data");
                    data.title = "Tarsier Space Telescope: Orbiting " + vessel.mainBody.theName + " looking at " + tgttheName;
                    _scienceData.Add(data);
                    Utilities.Log_Debug("Added Data Amt= {0}, TransmitValue= {1}, LabBoost= {2}, LabValue= {3}",
                        data.dataAmount.ToString(), data.transmitValue.ToString(), data.labBoost.ToString(),
                        data.labValue.ToString());
                    //If ResearchBodies is installed check if body is already found or not, if it isn't change the screen message to say "Unknown Body"
                    if (Utilities.IsResearchBodiesInstalled && RBWrapper.RBactualAPI.enabled)
                    {
                        var keyvalue = TSTMstStgs.Instance.RBCelestialBodies.FirstOrDefault(a => a.Key.theName == tgttheName);
                        if (keyvalue.Key != null)
                        {
                            if (!keyvalue.Value.isResearched)
                            {
                                tgttheName = "Unknown Body";
                            }
                        }
                    }

                    ScreenMessages.PostScreenMessage("Collected Science for " + tgttheName, 5f,ScreenMessageStyle.UPPER_CENTER);
                }
                else
                {
                    ScreenMessages.PostScreenMessage("Cannot take picture whilst " + experimentSituation, 5f,
                            ScreenMessageStyle.UPPER_CENTER);
                }
            }
            catch (Exception ex)
            {
                if (galaxy != null)
                    Utilities.Log("An error occurred attempting to capture science of {0}", galaxy.theName);
                else if (planet != null)
                {
                    Utilities.Log("An error occurred attempting to capture science of {0}", planet.theName);
                }
                else
                {
                    Utilities.Log("An error occurred attempting to capture science");
                }
                Utilities.Log("Err: " + ex);
                //throw;
            }
        }
コード例 #4
0
        private void TargettingGalWindow(int windowID)
        {
            GUILayout.BeginVertical();
            GalscrollViewVector = GUILayout.BeginScrollView(GalscrollViewVector, GUILayout.Height(300),GUILayout.Width(GUI_WIDTH_SMALL));
            filterContractTargets = GUILayout.Toggle(filterContractTargets,new GUIContent("Show only contract targets","If selected only targets that are the subject of a current contract will be shown"));
            //RSTUtils.Utilities.Log_Debug(String.Format(" - TargettingWindow - TSTGalaxies.Galaxies.Count = {0}", TSTGalaxies.Galaxies.Count));

            var newTarget = 0;
            if (RBWrapper.APIRBReady && RBWrapper.RBactualAPI.enabled)
            {
                newTarget = TSTGalaxies.Galaxies.
                    FindIndex(
                        g => TSTProgressTracker.HasTelescopeCompleted(g) ||
                             (ContractSystem.Instance && ContractSystem.Instance.GetCurrentActiveContracts<TSTTelescopeContract>().Any(t => t.target.name == g.name))
                            ? GUILayout.Button(g.theName)
                            : (filterContractTargets ? false : (TSTMstStgs.Instance.RBCelestialBodies[TSTGalaxies.CBGalaxies.Find(x => x.theName == g.theName)].isResearched ? GUILayout.Button(g.theName): false)));
            }
            else
            {
                newTarget = TSTGalaxies.Galaxies.
                    FindIndex(
                        g => TSTProgressTracker.HasTelescopeCompleted(g) ||
                             (ContractSystem.Instance && ContractSystem.Instance.GetCurrentActiveContracts<TSTTelescopeContract>().Any(t => t.target.name == g.name))
                            ? GUILayout.Button(g.theName) : (filterContractTargets ? false : GUILayout.Button(g.theName)));
            }

            //RSTUtils.Utilities.Log_Debug(String.Format(" - TargettingWindow - newTarget = {0}", newTarget));

            if (newTarget != -1 && newTarget != selectedTargetIndex)
            {
                vessel.targetObject = null;
                FlightGlobals.fetch.SetVesselTarget(null);
                targettingMode = TargettingMode.Galaxy;
                selectedTargetIndex = newTarget;
                galaxyTarget = TSTGalaxies.Galaxies[selectedTargetIndex];
                FlightGlobals.fetch.SetVesselTarget(galaxyTarget);
                Utilities.Log_Debug("Targetting: {0} : {1},layer= {2},scaledpos= {3}", newTarget.ToString(),
                    galaxyTarget.name, galaxyTarget.gameObject.layer.ToString(), galaxyTarget.scaledPosition.ToString());
                Utilities.Log_Debug("pos= {0}", galaxyTarget.position.ToString());
                ScreenMessages.PostScreenMessage("Target: " + galaxyTarget.theName, 5f, ScreenMessageStyle.UPPER_CENTER);
            }
            GUILayout.EndScrollView();
            GUILayout.Space(10);
            showGalTargetsWindow = !GUILayout.Button(new GUIContent("Hide", "Hide this Window"));
            GUILayout.EndVertical();
            if (TSTMstStgs.Instance.TSTsettings.Tooltips)
                Utilities.SetTooltipText();
            GUI.DragWindow();
        }