예제 #1
0
        internal override void Awake()
        {
            base.Awake();

            if (Instance)
            {
                Destroy(Instance);
            }
            Instance = this;

            // Fetch Celestial Bodies per TransferWindowPlanner method:
            cbStar = FlightGlobals.Bodies.FirstOrDefault(x => x.referenceBody == x.referenceBody);
            BodyParseChildren(cbStar);
            // Filter to only include planets with Atmospheres
            lstPlanets.RemoveAll(x => x.CB.atmosphere != true);

            int planetIndex = lstPlanets.FindIndex(x => x.CB == FlightGlobals.GetHomeBody());

            body = lstPlanets[planetIndex].CB;

            ddlPlanet = new DropDownList(lstPlanets.Select(p => p.NameFormatted), planetIndex, this);
            ddlPlanet.OnSelectionChanged += OnPlanetSelected;
            ddlManager.AddDDL(ddlPlanet);

            GameEvents.onEditorLoad.Add(OnVesselLoaded);
            GameEvents.onEditorNewShipDialogDismiss.Add(OnNewVessel);
            GameEvents.onEditorPodPicked.Add(OnRootChanged);
        }
예제 #2
0
        public override void OnStart(StartState state)
        {
            GameEvents.onVesselWasModified.Add(OnVesselWasModified);

            saveHeatConductivity           = part.heatConductivity;
            saveSkinInternalConductionMult = part.skinInternalConductionMult;
            saveEmissiveConstant           = part.emissiveConstant;
            saveAbsorptiveConstant         = part.absorptiveConstant;

            CelestialBody homeWorld = FlightGlobals.GetHomeBody();

            if (homeWorld != null)
            {
                dayLength = homeWorld.solarDayLength;
            }

            if (insulationDeployModuleIndex >= 0 && part.Modules.Count > insulationDeployModuleIndex)
            {
                if (part.Modules[insulationDeployModuleIndex] is IScalarModule)
                {
                    insulationScalarModule = part.Modules[insulationDeployModuleIndex] as IScalarModule;
                    insulationScalarModule.OnStop.Add(OnInsulationChanged);
                }
            }

            UpdateResources();
            UpdatePreLaunch();
            UpdateUI();
        }
        public override void OnStart(PartModule.StartState state)
        {
            if (state == StartState.Editor)
            {
                return;
            }

            megaJouleSolarPowerSupplyField = Fields["megaJouleSolarPowerSupply"];
            solarMaxSupplyField            = Fields["solarMaxSupply"];

            // calculate Astronomical unit on homeworld semiMajorAxis when missing
            if (astronomicalUnit == 0)
            {
                astronomicalUnit = FlightGlobals.GetHomeBody().orbit.semiMajorAxis;
            }

            _microwavePowerReceiver = part.FindModuleImplementing <BeamedPowerReceiver>();

            _solarPanel = (ModuleDeployableSolarPanel)this.part.FindModuleImplementing <ModuleDeployableSolarPanel>();
            if (_solarPanel == null)
            {
                return;
            }

            if (this.part.FindModuleImplementing <ModuleJettison>() == null)
            {
                UnityEngine.Debug.Log("[KSPI]: FNSolarPanelWasteHeatModule Force Activated  " + part.name);
                part.force_activate();
            }

            String[] resources_to_supply = { ResourceManager.FNRESOURCE_MEGAJOULES };
            this.resources_to_supply = resources_to_supply;
            base.OnStart(state);

            if (_solarPanel.resourceName == ResourceManager.FNRESOURCE_MEGAJOULES)
            {
                _outputType = ResourceType.megajoule;
            }
            else if (_solarPanel.resourceName == ResourceManager.STOCK_RESOURCE_ELECTRICCHARGE)
            {
                _outputType = ResourceType.electricCharge;
            }
            else
            {
                _outputType = ResourceType.other;
            }

            // only manage power buffer when microwave receiver is not available
            if (_outputType != ResourceType.other && _microwavePowerReceiver == null)
            {
                _resourceBuffers = new ResourceBuffers();
                _resourceBuffers.AddConfiguration(new ResourceBuffers.TimeBasedConfig(ResourceManager.FNRESOURCE_MEGAJOULES));
                _resourceBuffers.AddConfiguration(new ResourceBuffers.TimeBasedConfig(ResourceManager.STOCK_RESOURCE_ELECTRICCHARGE));
                _resourceBuffers.UpdateVariable(ResourceManager.FNRESOURCE_MEGAJOULES, (double)(decimal)(_outputType == ResourceType.electricCharge ? _solarPanel.chargeRate * 0.001f : _solarPanel.chargeRate));
                _resourceBuffers.UpdateVariable(ResourceManager.STOCK_RESOURCE_ELECTRICCHARGE, (double)(decimal)(_outputType == ResourceType.electricCharge ? _solarPanel.chargeRate : _solarPanel.chargeRate * 1000));
                _resourceBuffers.Init(part);
            }

            _stars = KopernicusHelper.Stars;
        }
예제 #4
0
        private DialogGUILabel GetDeltaVString(PlanetDeltaV planet, string situation)
        {
            int    deltaV = -1;
            string s;

            // ReSharper disable once SwitchStatementMissingSomeCases
            switch (situation)
            {
            case "Flyby: ":
                deltaV = planet.EscapeDv;
                if (_returnTrip)
                {
                    deltaV += planet.ReturnFromFlybyDv;
                }
                break;

            case "Orbiting: ":
                deltaV = planet.OrbitDv;
                if (_returnTrip)
                {
                    deltaV += planet.ReturnFromOrbitDv;
                }
                break;

            case "Landing: ":
                deltaV = planet.LandDv;
                if (_returnTrip)
                {
                    deltaV += planet.ReturnFromLandingDv;
                }
                break;

            case "Synchronous Orbit: ":
                deltaV = planet.SynchronousDv;
                break;
            }

            deltaV -= _utilities.ConvertBodyToPlanetDeltaV(FlightGlobals.GetHomeBody()).OrbitDv;
            UIStyle style              = _utilities.GenerateStyle(deltaV, false);
            string  status             = _utilities.VesselStatus(deltaV, situation, planet);
            double  shortFallOrDeficit = Math.Round(Math.Abs(deltaV - FlightGlobals.ActiveVessel.VesselDeltaV.TotalDeltaVVac), 0);

            if (status == "NO")
            {
                status = status + " (" + shortFallOrDeficit + "m/s short)";
            }
            else
            {
                status = status + " (+" + shortFallOrDeficit + "m/s)";
            }
            if (_utilities.SituationValid(planet.RelatedBody, situation))
            {
                s = " | " + situation + status;
            }
            else
            {
                s = " | " + situation + "N/A";
            }
            return(new DialogGUILabel(s, style));
        }
        public void Awake()
        {
            rect = this.GetComponent <RectTransform>();

            EnablePlanner  = GameObject.Find("EnablePlanner").GetComponent <Toggle>();
            DetectAntennas = GameObject.Find("DetectAntennas").GetComponent <Toggle>();
            DetectAntennas.onValueChanged.AddListener(delegate { onDetectAntennasValueChanged(DetectAntennas); });
            DetectRelays = GameObject.Find("DetectRelays").GetComponent <Toggle>();
            DetectRelays.onValueChanged.AddListener(delegate { onDetectRelaysValueChanged(DetectRelays); });

            CelestialBodies = GameObject.Find("PlannerPlanetDropdown").GetComponent <Dropdown>();
            CelestialBodies.onValueChanged.AddListener(delegate { onDropdownMenuValueChanged(CelestialBodies.value); });

            DistanceSlider = GameObject.Find("PlannerDistanceSlider").GetComponent <Slider>();
            DistanceSlider.onValueChanged.AddListener(delegate { onSliderValueChanged(DistanceSlider.value); });
            DistanceSliderLabel = GameObject.Find("CurrentDistance").GetComponent <Text>();

            DataRate                = GameObject.Find("PlannerDataRate");
            CurrentDataRateLabel    = DataRate.GetChild("CurrentDataRate").GetComponent <Text>();
            MaxDataRateLabel        = DataRate.GetChild("MaxDataRate").GetComponent <Text>();
            SignalStrengthLabel     = GameObject.Find("PlannerStrength").GetChild("signalstrength").GetComponent <Text>();
            ActiveTransmittersLabel = GameObject.Find("PlannerActiveTransmitters").GetChild("activeantennas").GetComponent <Text>();

            DSNLevel = ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.TrackingStation);
            DSNPower = GameVariables.Instance.GetDSNRange(DSNLevel);

            Bodies.ResearchBodiesAPI = Bodies.VerifyResearchBodiesAPI();
            celestialBodies          = Bodies.GetCelestialBodies();

            FillDropdownMenu(celestialBodies);

            ChangeSliderValues(Convert.ToSingle(Bodies.getMinDistance(FlightGlobals.GetHomeBody(), celestialBodies[0])),
                               Convert.ToSingle(Bodies.getMaxDistance(FlightGlobals.GetHomeBody(), celestialBodies[0])));
        }
예제 #6
0
        public void Start()
        {
            DontDestroyOnLoad(this);
            centerScreen = new Vector2(Screen.width / 2f, Screen.height / 2f);

            // load textures :
            circleGreenTex  = (Texture)GameDatabase.Instance.GetTexture("AntennaHelper/Textures/circle_green_a_1024", false);
            circleYellowTex = (Texture)GameDatabase.Instance.GetTexture("AntennaHelper/Textures/circle_yellow_a_1024", false);
            circleOrangeTex = (Texture)GameDatabase.Instance.GetTexture("AntennaHelper/Textures/circle_orange_a_1024", false);
            circleRedTex    = (Texture)GameDatabase.Instance.GetTexture("AntennaHelper/Textures/circle_red_a_1024", false);

            toolbarButtonTexSatOn  = (Texture)GameDatabase.Instance.GetTexture("AntennaHelper/Textures/icon_sat_on", false);
            toolbarButtonTexDishOn = (Texture)GameDatabase.Instance.GetTexture("AntennaHelper/Textures/icon_dish_on", false);
            toolbarButtonTexOff    = (Texture)GameDatabase.Instance.GetTexture("AntennaHelper/Textures/icon_off", false);
            signalPerDistanceTex   = (Texture)GameDatabase.Instance.GetTexture("AntennaHelper/Textures/signal_per_distance", false);

            homePlanet = FlightGlobals.GetHomeBody();

            signalPlanetList = new List <MyTuple> ();
            foreach (CelestialBody moon in homePlanet.orbitingBodies)
            {
                signalPlanetList.Add(new MyTuple(moon.bodyName, moon.orbit.PeR, moon.orbit.ApR));
            }
            foreach (CelestialBody planet in FlightGlobals.Bodies[0].orbitingBodies)
            {
                if (planet != homePlanet)
                {
                    signalPlanetList.Add(GetDistancePlanet(homePlanet, planet));
                }
            }
        }
예제 #7
0
        public float thrust(float throttle, float pressurekPa, float machNumber, float atmDensity)
        {
            double fuelFlow = evaluateFuelFlow(atmDensity, machNumber, throttle);
            float  isp      = engine.atmosphereCurve.Evaluate(pressurekPa / (float)FlightGlobals.GetHomeBody().GetPressure(0));

            return((float)(fuelFlow * isp * 9.82));
        }
예제 #8
0
        private void RollEvent()
        {
            if (HighLogic.CurrentGame.Mode != Game.Modes.CAREER)
            {
                return;
            }
            if (!SettingsClass.Instance.RandomEventsEnabled || Utilities.Instance.Randomise.NextDouble() > SettingsClass.Instance.RandomEventChance)
            {
                return;
            }
            if (cooldownTimer > Planetarium.GetUniversalTime())
            {
                return;
            }
            LoadEvents();
            RandomEventBase e = loadedEvents.ElementAt(Utilities.Instance.Randomise.Next(0, loadedEvents.Count));

            Debug.Log("[Bureaucracy]: Attempting to Fire Event " + e.Name);
            if (!e.EventCanFire())
            {
                return;
            }
            Debug.Log("[Bureaucracy]: EventCanFire");
            e.OnEventFire();
            cooldownTimer = Planetarium.GetUniversalTime() + FlightGlobals.GetHomeBody().solarDayLength * 30;
        }
예제 #9
0
        private void CheckEVAKerbals()
        {
            if (!HighLogic.LoadedSceneIsFlight)
            {
                return;
            }

            var vList = GetNearbyVessels(2000, false, FlightGlobals.ActiveVessel, false);

            foreach (var v in vList.Where(v => v.isEVA))
            {
                if (v.mainBody == FlightGlobals.GetHomeBody())
                {
                    if (v.altitude < LifeSupportScenario.Instance.settings.GetSettings().HomeWorldAltitude)
                    {
                        continue;
                    }
                }

                var c = v.GetVesselCrew().First();
                //Check their status.
                var k = LifeSupportManager.Instance.FetchKerbal(c);
                if (v.missionTime > LifeSupportScenario.Instance.settings.GetSettings().EVATime)
                {
                    print("Applying EVA Effect");
                    ApplyEVAEffect(k, c, v,
                                   LifeSupportManager.isVet(k.KerbalName)
                            ? LifeSupportScenario.Instance.settings.GetSettings().EVAEffectVets
                            : LifeSupportScenario.Instance.settings.GetSettings().EVAEffect);
                }
            }
        }
예제 #10
0
        public bool IsResearchAllowed(Vessel vessel, out string reasonWhyNot)
        {
            if (this.maxTierLimit)
            {
                reasonWhyNot = $"Maximum tier reached";
                return(false);
            }

            if (this.notNearHome && IsNearKerbin(vessel))
            {
                reasonWhyNot = $"Too near {FlightGlobals.GetHomeBody().name}";
                return(false);
            }

            if (this.notRemotelyCloseToHome && IsAnywhereCloseToKerbin(vessel))
            {
                reasonWhyNot = $"Too near {FlightGlobals.GetHomeBody().name}";
                return(false);
            }

            if (this.bodies != null)
            {
                if (this.bodies.Contains(vessel.mainBody.name))
                {
                    reasonWhyNot = "On an easy world";
                    return(false);
                }
            }

            reasonWhyNot = null;
            return(true);
        }
예제 #11
0
        private static GameObject GetHeaderObject(CelestialBody body, bool moon)
        {
            if (body == null || body.scaledBody == null || Tracking_RDWatch.RDPlanetPrefab == null)
            {
                return(null);
            }

            string bodyName = body.bodyName;

            if (body == FlightGlobals.GetHomeBody())
            {
                bodyName = "Kerbin";
            }

            PSystemBody pBody = GetBody(bodyName, PSystemManager.Instance.systemPrefab.rootBody);

            if (pBody == null)
            {
                return(null);
            }

            GameObject obj = UnityEngine.Object.Instantiate(pBody.scaledVersion);

            UnityEngine.Object.DestroyImmediate(obj.GetComponent <ScaledSpaceFader>());
            UnityEngine.Object.DestroyImmediate(obj.GetComponent <MaterialSetDirection>());
            UnityEngine.Object.DestroyImmediate(obj.GetComponent <SphereCollider>());
            UnityEngine.Object.DestroyImmediate(GameObject.Find(obj.name + "/Atmosphere"));

            RDPlanetListItemContainer planet = GameObject.Instantiate(Tracking_RDWatch.RDPlanetPrefab);

            planet.Setup(body.bodyName, body.displayName, obj, false, 0, moon ? 0.8f : 1, 44, 0, null);
            planet.SetSelectionCallback(new RDPlanetListItemContainer.SelectionCallback(FakeCallback));

            RectTransform pRect = planet.transform as RectTransform;

            pRect.anchoredPosition = new Vector2(2, -2);
            pRect.sizeDelta        = new Vector2(-4, -4);

            RawImage      raw  = planet.planetRawImage;
            RectTransform rect = raw.transform as RectTransform;

            rect.pivot            = new Vector2(0, 1);
            rect.anchoredPosition = new Vector2(4, -2);
            rect.sizeDelta        = new Vector2(0, -4);

            UnityEngine.Object.DestroyImmediate(planet.label_planetName.gameObject);

            if (!Tracking_Controller.Instance.LightAdded)
            {
                Light light = Tracking_Controller.Instance.NewTrackingList.AddComponent <Light>();
                light.type        = LightType.Directional;
                light.intensity   = 1.2f;
                light.range       = 1000;
                light.cullingMask = planet.thumbnailCameraMask;

                Tracking_Controller.Instance.LightAdded = true;
            }

            return(planet.gameObject);
        }
예제 #12
0
        public void ApplyPhysics()
        {
            if (!FlightGlobals.ready)
            {
                return;
            }

            if (SolarIntensityAtHomeMultiplier == 0)
            {
                CelestialBody homeBody = FlightGlobals.GetHomeBody();

                if (homeBody == null)
                {
                    return;
                }

                while (KopernicusStar.Stars.All(s => s.sun != homeBody.referenceBody) && homeBody.referenceBody != null)
                {
                    homeBody = homeBody.referenceBody;
                }

                SolarIntensityAtHomeMultiplier = Math.Pow(homeBody.orbit.semiMajorAxis, 2) * 4 * 3.14159265358979;
            }

            PhysicsGlobals.SolarLuminosityAtHome = solarLuminosity;
            PhysicsGlobals.SolarInsolationAtHome = solarInsolation;
            PhysicsGlobals.RadiationFactor       = radiationFactor;

            FieldInfo SolarLuminosity = typeof(PhysicsGlobals).GetField("solarLuminosity", BindingFlags.Instance | BindingFlags.NonPublic);

            SolarLuminosity.SetValue(PhysicsGlobals.Instance, SolarIntensityAtHomeMultiplier * PhysicsGlobals.SolarLuminosityAtHome);
        }
예제 #13
0
 private void Awake()
 {
     id          = Guid.NewGuid().GetHashCode();
     windowStyle = new GUIStyle(HighLogic.Skin.window);
     // skin = HighLogic.Skin;
     ReferenceBody = FlightGlobals.GetHomeBody();
 }
 public ReferenceFrameSelector(
     ManagerInterface manager,
     IntPtr plugin,
     Callback on_change,
     string name) : base(manager)
 {
     plugin_    = plugin;
     on_change_ = on_change;
     name_      = name;
     frame_type = FrameType.BODY_CENTRED_NON_ROTATING;
     expanded_  = new Dictionary <CelestialBody, bool>();
     foreach (CelestialBody celestial in FlightGlobals.Bodies)
     {
         if (!celestial.is_leaf() && !celestial.is_root())
         {
             expanded_.Add(celestial, false);
         }
     }
     selected_celestial =
         FlightGlobals.currentMainBody ?? FlightGlobals.GetHomeBody();
     for (CelestialBody celestial = selected_celestial;
          celestial.orbit != null;
          celestial = celestial.orbit.referenceBody)
     {
         if (!celestial.is_leaf())
         {
             expanded_[celestial] = true;
         }
     }
     on_change_(FrameParameters());
     window_rectangle_.x = UnityEngine.Screen.width / 2;
     window_rectangle_.y = UnityEngine.Screen.height / 3;
 }
예제 #15
0
파일: Sim.cs 프로젝트: DanvanNaos/Kerbalism
        // --------------------------------------------------------------------------
        // GRAVIOLI
        // --------------------------------------------------------------------------

        public static double Graviolis(Vessel v)
        {
            double dist = Vector3d.Distance(v.GetWorldPos3D(), FlightGlobals.Bodies[0].position);
            double au   = dist / FlightGlobals.GetHomeBody().orbit.semiMajorAxis;

            return(1.0 - Math.Min(au, 1.0)); // 0 at 1AU -> 1 at sun position
        }
예제 #16
0
        void GroupFixer(object mod, Vector3 REFvector)
        {
            // Moves the group
            Vector3 PQSposition = ((Vector3)GetPosition(mod));

            Debug.Log("SigmaDimensions.City2Fixer", "        > Group center position = " + REFvector + ", (LAT: " + new LatLon(REFvector).lat + ", LON: " + new LatLon(REFvector).lon + ")");
            Debug.Log("SigmaDimensions.City2Fixer", "        > Mod original position = " + PQSposition + ", (LAT: " + new LatLon(PQSposition).lat + ", LON: " + new LatLon(PQSposition).lon + ")");

            if (body == FlightGlobals.GetHomeBody() && REFvector == new Vector3(157000, -1000, -570000))
            {
                PQSCity KSC = body.GetComponentsInChildren <PQSCity>().FirstOrDefault(m => m.name == "KSC");
                MoveGroup(mod, KSC.repositionRadial, KSC.reorientFinalAngle - (-15), 0, 64.7846885412);
                REFvector = KSC.repositionRadial; // Change the REFvector the the new position for Lerping
            }
            else if (body.Has("PQSCityGroupsMove"))
            {
                var MovesInfo = body.Get <Dictionary <Vector3, KeyValuePair <Vector3, NumericParser <double>[]> > >("PQSCityGroupsMove");

                if (MovesInfo.ContainsKey(REFvector))
                {
                    var info = MovesInfo[REFvector];
                    MoveGroup(mod, info.Key, (float)info.Value[0], info.Value[1], info.Value[2]);
                    REFvector = info.Key; // Change the REFvector the the new position for Lerping
                }
            }

            // Update PQSposition
            PQSposition = ((Vector3)GetPosition(mod));

            // Spread or Shrinks the group to account for Resize
            Vector3 NEWvector = Vector3.LerpUnclamped(REFvector.normalized, PQSposition.normalized, (float)(resizeBuildings / resize));

            SetPosition(mod, NEWvector);
            Debug.Log("SigmaDimensions.City2Fixer", "        > Mod lerped position   = " + (Vector3)GetPosition(mod) + ", (LAT: " + new LatLon((Vector3)GetPosition(mod)).lat + ", LON: " + new LatLon((Vector3)GetPosition(mod)).lon + ")");
        }
예제 #17
0
  // return true if body is relevant to the player
  // - body: reference body of the planetary system
  bool body_is_relevant(CelestialBody body)
  {
    // special case: home system is always relevant
    // note: we deal with the case of a planet mod setting homebody as a moon
    if (body == Lib.PlanetarySystem(FlightGlobals.GetHomeBody())) return true;

    // for each vessel
    foreach(Vessel v in FlightGlobals.Vessels)
    {
      // if inside the system
      if (Lib.PlanetarySystem(v.mainBody) == body)
      {
        // skip invalid vessels
        if (!Lib.IsVessel(v)) continue;

        // skip resque missions
        if (Lib.IsResqueMission(v)) continue;

        // skip dead eva kerbal
        if (EVA.IsDead(v)) continue;

        // body is relevant
        return true;
      }
    }
    return false;
  }
예제 #18
0
        private void Awake()
        {
            // Don't run if Kopernicus isn't compatible
            if (!CompatibilityChecker.IsCompatible())
            {
                Destroy(this);
                return;
            }

            // Make sure the runtime utility isn't killed
            DontDestroyOnLoad(this);
            //Load our settings
            KopernicusConfig.loadMainSettings();
            // Init the runtime logging
            new Logger("Kopernicus.Runtime", true).SetAsActive();

            // Add handlers
            GameEvents.OnMapEntered.Add(() => OnMapEntered());
            GameEvents.onLevelWasLoaded.Add(s => OnLevelWasLoaded(s));
            GameEvents.onProtoVesselLoad.Add(d => TransformBodyReferencesOnLoad(d));
            GameEvents.onProtoVesselSave.Add(d => TransformBodyReferencesOnSave(d));

            // Add Callback only if necessary
            if (FlightGlobals.GetHomeBody().atmospherePressureSeaLevel != 101.324996948242)
            {
                KbApp_PlanetParameters.CallbackAfterActivate += CallbackAfterActivate;
            }

            // Log
            Logger.Default.Log("[Kopernicus] RuntimeUtility Started");
            Logger.Default.Flush();
        }
예제 #19
0
  Signal()
  {
    // enable global access
    instance = this;

    // keep it alive
    DontDestroyOnLoad(this);

    // determine nearest and furthest planets from home body
    CelestialBody sun = Sim.Sun();
    CelestialBody home = Lib.PlanetarySystem(FlightGlobals.GetHomeBody());
    CelestialBody near = null;
    CelestialBody far = null;
    double min_dist = double.MaxValue;
    double max_dist = double.MinValue;
    foreach(CelestialBody body in FlightGlobals.Bodies)
    {
      if (body == sun || body == home) continue;
      if (body.referenceBody != sun) continue;
      double dist = Math.Abs(home.orbit.semiMajorAxis - body.orbit.semiMajorAxis);
      if (dist < min_dist) { min_dist = dist; near = body; }
      if (dist > max_dist) { max_dist = dist; far = body; }
    }
    range_values.Add("orbit", home.sphereOfInfluence * 1.05);
    range_values.Add("home", home.sphereOfInfluence * 4.0 * 1.05);
    range_values.Add("near", (Sim.Apoapsis(home) + Sim.Apoapsis(near)) * 1.6);
    range_values.Add("far", (Sim.Apoapsis(home) + Sim.Apoapsis(far)) * 1.1);
    range_values.Add("extreme", (Sim.Apoapsis(home) + Sim.Apoapsis(far)) * 4.0);
  }
예제 #20
0
 void Awake()
 {
     if (FlightGlobals.GetHomeBody()?.atmosphericAmbientColor != null)
     {
         RenderSettings.ambientLight = FlightGlobals.GetHomeBody().atmosphericAmbientColor;
     }
 }
예제 #21
0
        public void Start()
        {
            if (ResonantOrbitCalculator_Persistent.Instance.lastSelectedPlanet == "")
            {
                ResonantOrbitCalculator_Persistent.Instance.lastSelectedPlanet = FlightGlobals.GetHomeBody().name;
            }
            PlanetSelection.setSelectedBody(ResonantOrbitCalculator_Persistent.Instance.lastSelectedPlanet);
            GUI.color = new Color(0.85f, 0.85f, 0.85f, 1);

            winStyle = new GUIStyle(HighLogic.Skin.window);
            winStyle.active.background = winStyle.normal.background;
            Texture2D tex = winStyle.normal.background; //.CreateReadable();

            var pixels = tex.GetPixels32();

            for (int i = 0; i < pixels.Length; ++i)
            {
                pixels[i].a = 255;
            }

            tex.SetPixels32(pixels);
            tex.Apply();

            winStyle.active.background  = tex;
            winStyle.focused.background = tex;
            winStyle.normal.background  = tex;
        }
예제 #22
0
 private void openDialog(PlanningNodeModel toEdit)
 {
     if (editDialog == null)
     {
         editDialog              = new PlanningNodeEditDialog(toEdit, CanEdit);
         editDialog.CloseDialog += () => launcher.SetFalse(true);
         editDialog.NewNode     += () => {
             var nd = new PlanningNodeModel(
                 renderer.vessel?.mainBody ?? FlightGlobals.GetHomeBody(),
                 renderer.vessel);
             PlanningNodesManager.Instance.nodes.Add(nd);
             editNode(nd);
         };
         editDialog.DeleteNode += () => {
             PlanningNodesManager.Instance.nodes.Remove(editDialog.editingNode);
             OnNodeDeleted();
         };
         editDialog.PrevNode    += () => editNode(PlanningNodesManager.Instance.PrevNode(renderer.vessel, editDialog.editingNode));
         editDialog.NextNode    += () => editNode(PlanningNodesManager.Instance.NextNode(renderer.vessel, editDialog.editingNode));
         editDialog.BodyChanged += OnBodyChanged;
         editDialog.WarpTo      += WarpTo;
         editDialog.Show(launcher.GetAnchor());
     }
     else
     {
         // Already open, just switch to this node
         editDialog.editingNode = toEdit;
     }
 }
예제 #23
0
 public void Start()
 {
     GameEvents.onVesselWasModified.Add(OnVesselWasModified);
     homeAltAboveSun = FlightGlobals.getAltitudeAtPos(FlightGlobals.GetHomeBody().position, FlightGlobals.Bodies[0]);
     Fields["exposureDisplay"].guiActive = debug;
     UpdateResources();
     UpdatePreLaunch();
 }
예제 #24
0
 public void UpdateMainBody()
 {
     EffectChange(() => {
         frame_type         = FrameType.BODY_CENTRED_NON_ROTATING;
         selected_celestial =
             FlightGlobals.currentMainBody ?? FlightGlobals.GetHomeBody();
     });
 }
예제 #25
0
 // Patch the KSC light animation
 private static void PatchTimeOfDayAnimation()
 {
     TimeOfDayAnimation[] animations = Resources.FindObjectsOfTypeAll <TimeOfDayAnimation>();
     for (Int32 i = 0; i < animations.Length; i++)
     {
         animations[i].target = KopernicusStar.GetBrightest(FlightGlobals.GetHomeBody()).gameObject.transform;
     }
 }
예제 #26
0
 // return year length
 public static double DaysInYear()
 {
     if (!FlightGlobals.ready)
     {
         return(426.0);
     }
     return(Math.Floor(FlightGlobals.GetHomeBody().orbit.period / (HoursInDay() * 60.0 * 60.0)));
 }
예제 #27
0
 public GUIOrbitEditor(MissionProfile missionProfile)
 {
     // TODO: Maybe add a switch for complex and simple orbits, the complex editor might also include an option to copy an orbit from a reference-object ...
     this.body                = FlightGlobals.GetHomeBody();
     this.missionProfile      = missionProfile;
     this.altitudeSelector    = new GUIRichValueSelector("Altitude", Math.Floor(this.missionProfile.maxAltitude), "m", Math.Ceiling(this.missionProfile.minAltitude), Math.Floor(this.missionProfile.maxAltitude), true, "#,##0");
     this.inclinationSelector = new GUIRichValueSelector("Inclination", 0, "°", -180, 180, true, "+0.00;-0.00");
 }
        public override void OnStart(PartModule.StartState state)
        {
            if (state == StartState.Editor)
            {
                return;
            }

            // calculate Astronomical unit on homeworld semiMajorAxis when missing
            if (astronomicalUnit == 0)
            {
                astronomicalUnit = FlightGlobals.GetHomeBody().orbit.semiMajorAxis;
            }

            _microwavePowerReceiver = part.FindModuleImplementing <BeamedPowerReceiver>();

            _solarPanel = (ModuleDeployableSolarPanel)this.part.FindModuleImplementing <ModuleDeployableSolarPanel>();
            if (_solarPanel == null)
            {
                return;
            }

            part.force_activate();

            String[] resources_to_supply = { ResourceManager.FNRESOURCE_MEGAJOULES };
            this.resources_to_supply = resources_to_supply;
            base.OnStart(state);

            if (_solarPanel.resourceName == ResourceManager.FNRESOURCE_MEGAJOULES)
            {
                outputType = ResourceType.megajoule;
            }
            else if (_solarPanel.resourceName == ResourceManager.STOCK_RESOURCE_ELECTRICCHARGE)
            {
                outputType = ResourceType.electricCharge;
            }
            else
            {
                outputType = ResourceType.other;
            }

            mockInputResource      = new ModuleResource();
            mockInputResource.name = _solarPanel.resourceName;
            mockInputResource.id   = _solarPanel.resourceName.GetHashCode();
            _solarPanel.resHandler.inputResources.Add(mockInputResource);

            // only manager power buffer when microwave receiver is not available
            if (outputType != ResourceType.other && _microwavePowerReceiver == null)
            {
                _resourceBuffers = new ResourceBuffers();
                _resourceBuffers.AddConfiguration(new ResourceBuffers.TimeBasedConfig(ResourceManager.FNRESOURCE_MEGAJOULES));
                _resourceBuffers.AddConfiguration(new ResourceBuffers.TimeBasedConfig(ResourceManager.STOCK_RESOURCE_ELECTRICCHARGE));
                _resourceBuffers.UpdateVariable(ResourceManager.FNRESOURCE_MEGAJOULES, (double)(decimal)(outputType == ResourceType.electricCharge ? _solarPanel.chargeRate * 0.001f : _solarPanel.chargeRate));
                _resourceBuffers.UpdateVariable(ResourceManager.STOCK_RESOURCE_ELECTRICCHARGE, (double)(decimal)(outputType == ResourceType.electricCharge ? _solarPanel.chargeRate : _solarPanel.chargeRate * 1000));
                _resourceBuffers.Init(this.part);
            }

            stars = KopernicusHelper.Stars;
        }
예제 #29
0
        private IEnumerator Start()
        {
            // This represents our starting orbit
            driver = gameObject.AddComponent <OrbitDriver>();
            driver.lowerCamVsSmaRatio = 0.0001f;
            driver.upperCamVsSmaRatio = 999999;
            // Without this everything crashes and our app launcher deletes itself
            driver.SetOrbitMode(OrbitDriver.UpdateMode.UPDATE);

            // Just enough of a Vessel to not crash
            fakeVessel             = gameObject.AddComponent <Vessel>();
            fakeVessel.vesselName  = "DUMMY";
            fakeVessel.orbitDriver = driver;
            fakeVessel.parts       = new List <Part>();
            fakeVessel.protoVessel = new ProtoVessel(fakeVessel);
            // Try to avoid immediately crashing into the Sun in tracking station
            fakeVessel.altitude = FlightGlobals.GetHomeBody().sphereOfInfluence;
            fakeVessel.GoOnRails();
            driver.vessel = fakeVessel;

            // This calculates the conic patches, including after maneuvers
            solver            = gameObject.AddComponent <PatchedConicSolver>();
            solver.obtDriver  = driver;
            solver.targetBody = FlightGlobals.ActiveVessel?.targetObject as CelestialBody;

            // This draws the solver's calculated info
            conicRenderer        = gameObject.AddComponent <PatchedConicRenderer>();
            conicRenderer.solver = solver;

            if (canEdit)
            {
                // This thing shows the close approach markers, only works in map view
                targeter = gameObject.AddComponent <OrbitTargeter>();
                targeter.SetTarget(solver.targetBody?.orbitDriver);
            }

            GameEvents.onManeuverNodeSelected.Add(OnManeuverNodeSelected);

            // HACK: Let the stock objects finish initializing before we finish our initialization
            yield return(new WaitForEndOfFrame());

            if (conicRenderer != null)
            {
                while (conicRenderer.relativeTo == null)
                {
                    if (!HighLogic.LoadedSceneIsFlight)
                    {
                        yield break;
                    }
                    yield return(null);
                }
            }

            conicRenderer.solver = solver;

            StartCoroutine(SwitchTo(editingNode));
        }
예제 #30
0
        protected double ProgressTime()
        {
            //How long since the last update?
            double timeElapsed = Planetarium.GetUniversalTime() - Bureaucracy.Instance.lastProgressUpdate;

            //convert that into days
            timeElapsed /= FlightGlobals.GetHomeBody().solarDayLength;
            return(timeElapsed);
        }