Пример #1
0
 public LowRezPlanet(CelestialBodyData planet)
 {
     PlanetManager.Chunck chunck = new PlanetManager.Chunck(0.0, (double)planet.terrainData.heightMaps[0].heightMap.HeightDataArray.Length, 0, planet, planet.terrainData.detailLevels, null, false, false);
     this.planet                      = planet;
     this.meshHolder                  = chunck.chunckTransform;
     this.meshHolder.localScale       = Vector3.one / 10000f;
     this.meshHolder.gameObject.layer = LayerMask.NameToLayer("Scaled Space");
     this.meshHolder.name             = planet.bodyName + " Scaled";
     this.meshHolder.parent           = Ref.planetManager.scaledHolder;
     if (!planet.atmosphereData.hasAtmosphere)
     {
         return;
     }
     PlanetManager.LowRezPlanets.LowRezPlanet.CreateAtmosphere(this.meshHolder, planet, planet.atmosphereData.gradientHightMultiplier, "Scaled Space", (planet.type != CelestialBodyData.Type.Star) ? "Back" : "Default", (planet.type != CelestialBodyData.Type.Star) ? 0 : 500, planet.GenerateAtmosphereTexture());
 }
Пример #2
0
    private void SwitchFollowingBody(CelestialBodyData newFollow)
    {
        Double3 a = Double3.zero;

        if (newFollow.parentBody == this.following)
        {
            a = -newFollow.GetPosOut(Ref.controller.globalTime);
        }
        if (this.following.parentBody == newFollow)
        {
            a = this.following.GetPosOut(Ref.controller.globalTime);
        }
        this.mapPosition += a / 10000.0;
        this.following    = newFollow;
    }
Пример #3
0
    private Transform CreateScaledTerrain(CelestialBodyData planet, Transform parent)
    {
        Transform chunckTransform = new PlanetManager.Chunck(16.0, (double)planet.terrainData.heightMaps[0].heightMap.HeightDataArray.Length, planet.terrainData.mapDetailLevelId, planet, planet.terrainData.detailLevels, base.transform, true, false).chunckTransform;

        chunckTransform.gameObject.layer = base.gameObject.layer;
        chunckTransform.localScale       = Vector3.one * 1.0001f / 10000f;
        chunckTransform.parent           = parent;
        chunckTransform.localPosition    = Vector3.zero;
        MeshRenderer component = chunckTransform.GetComponent <MeshRenderer>();

        component.sortingOrder     = 10;
        component.sortingLayerName = "Map";
        chunckTransform.name       = "Mesh ( " + planet.bodyName + ")";
        return(chunckTransform);
    }
Пример #4
0
 private void LoadPlanetAtmosphere(CelestialBodyData newPlanet)
 {
     this.atmosphereRenderer.gameObject.SetActive(newPlanet.atmosphereData.hasAtmosphere);
     this.atmosphereRenderer.transform.localScale = Vector3.one * ((!newPlanet.atmosphereData.hasAtmosphere) ? 1f : ((float)(newPlanet.atmosphereData.atmosphereHeightM * newPlanet.atmosphereData.gradientHightMultiplier + newPlanet.radius)));
     if (newPlanet.atmosphereData.hasAtmosphere)
     {
         Mesh      mesh = this.atmosphereRenderer.GetComponent <MeshFilter>().mesh;
         Vector2[] uv   = mesh.uv;
         uv[0]   = new Vector2(1f + (float)(newPlanet.radius / (newPlanet.atmosphereData.atmosphereHeightM * newPlanet.atmosphereData.gradientHightMultiplier)), 0f);
         mesh.uv = uv;
         this.atmosphereRenderer.sortingLayerName = ((newPlanet.type != CelestialBodyData.Type.Star) ? "Back" : "Default");
         this.atmosphereRenderer.sortingOrder     = ((newPlanet.type != CelestialBodyData.Type.Star) ? 0 : 500);
         this.atmosphereRenderer.sharedMaterial.SetTexture("_MainTex", newPlanet.GenerateAtmosphereTexture());
     }
 }
Пример #5
0
    public bool UpdatePass()
    {
        List <Orbit.Pass> list = new List <Orbit.Pass>();

        CelestialBodyData[] satellites = this.planet.satellites;
        for (int i = 0; i < satellites.Length; i++)
        {
            CelestialBodyData celestialBodyData = satellites[i];
            if (this.CanPasSOI(celestialBodyData.orbitData.orbitHeightM, celestialBodyData.orbitData.SOI))
            {
                list.AddRange(this.CreatePasses(false, this.calculatePassesTime, Ref.controller.globalTime + this._period * 0.995, celestialBodyData));
            }
        }
        this.calculatePassesTime = Ref.controller.globalTime + this._period * 0.995;
        return(this.ProcessPasses(this.SortPasses(list)));
    }
Пример #6
0
    private void SwitchFollowingBody(CelestialBodyData newFollow)
    {
        Double3 @double = Double3.zero;

        if (newFollow.parentBody == this.following.targetPlanet)
        {
            @double = -newFollow.GetPosOut(Ref.controller.globalTime);
        }
        if (this.following.targetPlanet.parentBody == newFollow)
        {
            @double = this.following.targetPlanet.GetPosOut(Ref.controller.globalTime);
        }
        MonoBehaviour.print(@double);
        this.mapPosition += @double / 10000.0;
        this.following    = new OrbitLines.Target(newFollow);
    }
Пример #7
0
    public static void Create(int _seed)
    {
        Random            random    = new Random(_seed);
        int               planets   = random.Next(3, 9);
        CelestialBodyData starData  = StarFactory.CreateData(ref random);
        Star              star      = StarFactory.Create(starData, null);
        float             minRadius = random.Next(20, 30);

        for (int i = 0; i < planets; i++)
        {
            CelestialBodyData planetData = PlanetFactory.CreateData(ref random, minRadius);
            minRadius = planetData.OrbitingRadius + 20;
            Planet planet = PlanetFactory.Create(planetData, star);
            PlanetLineFactory.CreateLine(planet.OrbitingRadius, planet.Parent.transform);
        }
    }
Пример #8
0
    public void OnClickEmpty(Vector2 clickPosWorld)
    {
        CelestialBodyData celestialBodyData = this.PointCastMapPlanets(clickPosWorld);

        if (celestialBodyData != null)
        {
            this.SelectCelestilaBodyAsTarget(celestialBodyData);
            return;
        }
        Vessel vessel = this.PointCastVessels(clickPosWorld);

        if (vessel != null)
        {
            Ref.map.SelectVessel(vessel, true);
            return;
        }
    }
Пример #9
0
    public void InitializeMap()
    {
        this.ellipsePoints = new Vector3[this.vesselOrbitLinePrefab.GetChild(0).GetComponent <LineRenderer>().positionCount];
        for (int i = 0; i < this.ellipsePoints.Length; i++)
        {
            this.ellipsePoints[i] = this.vesselOrbitLinePrefab.GetChild(0).GetComponent <LineRenderer>().GetPosition(i);
            Vector3[] expr_5C_cp_0 = this.ellipsePoints;
            int       expr_5C_cp_1 = i;
            expr_5C_cp_0[expr_5C_cp_1].y = expr_5C_cp_0[expr_5C_cp_1].y * 0.5f;
            this.ellipsePoints[i]        = this.ellipsePoints[i].normalized;
        }
        this.orbitLines = this.CreateVesselOrbitLines(3, "Selected vessel orbit line");
        int num = 0;

        Ref.solarSystemRoot.mapAdressId = num;
        num++;
        Ref.solarSystemRoot.mapRefs.holder = UnityEngine.Object.Instantiate <Transform>(this.planetHolderPrefab);
        Ref.solarSystemRoot.mapRefs.holder.gameObject.layer = base.gameObject.layer;
        Ref.solarSystemRoot.mapRefs.holder.parent           = base.transform;
        Ref.solarSystemRoot.mapRefs.holder.localPosition    = Vector3.zero;
        Ref.solarSystemRoot.mapRefs.holder.name             = "Sun holder ( Map)";
        Ref.solarSystemRoot.mapRefs.nameIconText            = this.CreateNameIcon(Ref.solarSystemRoot.bodyName, Ref.solarSystemRoot.mapRefs.holder).GetComponent <TextMesh>();
        base.transform.GetChild(0).position = Ref.solarSystemRoot.mapRefs.holder.position;
        base.transform.GetChild(0).parent   = Ref.solarSystemRoot.mapRefs.holder;
        this.CreateScaledTerrain(Ref.solarSystemRoot, Ref.solarSystemRoot.mapRefs.holder);
        CelestialBodyData[] satellites = Ref.solarSystemRoot.satellites;
        for (int j = 0; j < satellites.Length; j++)
        {
            CelestialBodyData celestialBodyData = satellites[j];
            celestialBodyData.mapAdressId = num;
            num++;
            this.CreateMapCelestialBody(celestialBodyData, base.transform, Ref.solarSystemRoot.mapRefs.holder, 200);
            CelestialBodyData[] satellites2 = celestialBodyData.satellites;
            for (int k = 0; k < satellites2.Length; k++)
            {
                CelestialBodyData celestialBodyData2 = satellites2[k];
                celestialBodyData2.mapAdressId = num;
                num++;
                this.CreateMapCelestialBody(celestialBodyData2, celestialBodyData.mapRefs.holder, celestialBodyData.mapRefs.holder, 100);
            }
        }
        this.following = Ref.GetPlanetByName(Ref.controller.startAdress);
        this.UpdateMapZoom(-this.mapPosition.z);
        this.GetTransferType();
        this.GenerateTransferWindowMarker(this.transferWindow.localMarkerMesh, 0.05f, -0.005f, 1f, null);
    }
Пример #10
0
            public static void CreateAtmosphere(Transform parent, CelestialBodyData planet, double multiplier, string layer, string sortingLayer, int sortingOrder, Texture2D tex)
            {
                Transform transform = UnityEngine.Object.Instantiate <Transform>(Ref.planetManager.atmosphereRenderer.transform, parent);

                transform.gameObject.SetActive(true);
                transform.gameObject.layer     = LayerMask.NameToLayer(layer);
                transform.localPosition        = Vector3.forward * 0.4f;
                transform.transform.localScale = Vector3.one * (float)(planet.atmosphereData.atmosphereHeightM * multiplier + planet.radius);
                Mesh mesh = transform.GetComponent <MeshFilter>().mesh;

                Vector2[] uv = mesh.uv;
                uv[0]   = new Vector2(1f + (float)(planet.radius / (planet.atmosphereData.atmosphereHeightM * multiplier)), 0f);
                mesh.uv = uv;
                transform.GetComponent <MeshRenderer>().sortingLayerName = sortingLayer;
                transform.GetComponent <MeshRenderer>().sortingOrder     = sortingOrder;
                transform.GetComponent <MeshRenderer>().material.SetTexture("_MainTex", tex);
            }
Пример #11
0
    public void OnClickEmpty(Vector2 clickPosWorld)
    {
        CelestialBodyData celestialBodyData = this.PointCastMapPlanets(clickPosWorld);

        if (celestialBodyData != null)
        {
            Ref.map.SelectCelestilaBodyTarget(celestialBodyData);
        }
        else
        {
            Vessel vessel = Ref.map.PointCastVessels(clickPosWorld);
            if (vessel != null)
            {
                Ref.map.SelectVessel(vessel);
            }
        }
    }
Пример #12
0
 private bool GetClosestApproach(List <Orbit> orbits, CelestialBodyData targetingPlanet)
 {
     for (int i = 0; i < orbits.Count; i++)
     {
         if (orbits[i].orbitType != Orbit.Type.Encounter)
         {
             if (orbits[i].planet == targetingPlanet)
             {
                 return(this.CalculateClosestApproach(orbits[i], targetingPlanet));
             }
             if (orbits[i].planet == targetingPlanet.parentBody)
             {
                 return(this.CalculateClosestApproach(orbits[i], targetingPlanet));
             }
         }
     }
     return(false);
 }
Пример #13
0
        public Chunck(double from, double size, int LODId, CelestialBodyData planet, CelestialBodyData.TerrainData.DetailLevel[] detailLevels, Transform parent, bool forMap, bool offset)
        {
            this.from        = from;
            this.LODId       = LODId;
            this.topSizeHalf = (double)detailLevels[LODId].angularSize / planet.terrainData.unitToAngle * 0.5;
            float num = (float)from / (float)planet.terrainData.heightMaps[0].heightMap.HeightDataArray.Length * 360f + detailLevels[LODId].angularSize * 0.5f;

            this.topPosition                   = new Double3(Math.Cos((double)(num * 0.0174532924f)), Math.Sin((double)(num * 0.0174532924f))) * (planet.radius + planet.terrainData.maxTerrainHeight);
            this.chunckTransform               = UnityEngine.Object.Instantiate <Transform>(Ref.planetManager.chunckPrefab).transform;
            this.chunckTransform.parent        = parent;
            this.chunckTransform.localPosition = Vector3.zero;
            PlanetManager.TerrainPoints terrainPoints = planet.GetTerrainPoints(from, size, detailLevels[LODId].LOD, offset);
            this.GenerateMesh(this.chunckTransform, terrainPoints, this.GenerateIndices(terrainPoints.points.Length), from, 1f / (float)((double)planet.terrainData.heightMaps[0].heightMap.HeightDataArray.Length * detailLevels[LODId].LOD), 1f / (float)detailLevels[LODId].LOD, "Default", 10, planet, forMap);
            if (offset)
            {
                this.chunckPosOffset = terrainPoints.points[0];
            }
        }
Пример #14
0
        public static TransferWindow.Data GetTransferType(Vessel vessel, CelestialBodyData target)
        {
            if (target == null || vessel == null)
            {
                return(TransferWindow.Data.Empty());
            }
            CelestialBodyData getVesselPlanet = vessel.GetVesselPlanet;

            if (target == null || getVesselPlanet.type == CelestialBodyData.Type.Star || target.type == CelestialBodyData.Type.Star)
            {
                return(TransferWindow.Data.Empty());
            }
            if (getVesselPlanet == target)
            {
                return(TransferWindow.Data.Empty());
            }
            if (getVesselPlanet == target.parentBody)
            {
                return(new TransferWindow.Data(TransferWindow.TransferType.ToSatellite, getVesselPlanet, target, null, null));
            }
            if (getVesselPlanet.parentBody == target)
            {
                return(new TransferWindow.Data(TransferWindow.TransferType.ToParent, getVesselPlanet, target, null, null));
            }
            if (getVesselPlanet.parentBody == target.parentBody)
            {
                return(new TransferWindow.Data(TransferWindow.TransferType.ToNeighbour, getVesselPlanet, target, getVesselPlanet, target));
            }
            if (getVesselPlanet.parentBody.parentBody == target.parentBody && getVesselPlanet.parentBody != target)
            {
                return(new TransferWindow.Data(TransferWindow.TransferType.ToNeighbour, getVesselPlanet, target, getVesselPlanet.parentBody, target));
            }
            if (getVesselPlanet.parentBody == target.parentBody.parentBody && getVesselPlanet != target.parentBody)
            {
                return(new TransferWindow.Data(TransferWindow.TransferType.ToNeighbour, getVesselPlanet, target, getVesselPlanet, target.parentBody));
            }
            if (getVesselPlanet.parentBody.parentBody == target.parentBody.parentBody)
            {
                return(new TransferWindow.Data(TransferWindow.TransferType.ToNeighbour, getVesselPlanet, target, getVesselPlanet.parentBody, target.parentBody));
            }
            return(TransferWindow.Data.Empty());
        }
Пример #15
0
    private Map.Refs CreateMapCelestialBody(CelestialBodyData celestialBody, Transform holderParent, int orbitLineResolution, bool createTerrain, bool createSOI, bool createAtmosphere)
    {
        Transform transform = UnityEngine.Object.Instantiate <Transform>(this.planetHolderPrefab, holderParent);

        transform.gameObject.layer = base.gameObject.layer;
        transform.name             = celestialBody.bodyName + " holder ( Map)";
        if (createTerrain)
        {
            this.CreateScaledTerrain(celestialBody, transform);
        }
        if (createSOI)
        {
            this.CreateCircle(transform, (float)(celestialBody.orbitData.SOI / 10000.0), new Color(1f, 1f, 1f, 0.025f), 0, "SOI");
        }
        if (createAtmosphere)
        {
            this.CreateCircle(transform, (float)((celestialBody.radius + celestialBody.atmosphereData.atmosphereHeightM) / 10000.0), new Color(1f, 1f, 1f, 0.06f), 1, "Atmosphere");
        }
        return(new Map.Refs(transform, (orbitLineResolution <= 0) ? null : this.CreatePlanetOrbitLine(this.mapRefs[celestialBody.parentBody].holder, celestialBody.orbitData.orbitHeightM, celestialBody.bodyName, orbitLineResolution, celestialBody.type), this.CreateNameIcon(celestialBody.bodyName, transform).GetComponent <TextMesh>()));
    }
Пример #16
0
 public void UpdateCameraRotation(Vector3 camRotation)
 {
     if (Ref.solarSystemRoot.mapRefs.nameIconText.transform.localEulerAngles == camRotation)
     {
         return;
     }
     Ref.solarSystemRoot.mapRefs.nameIconText.transform.localEulerAngles = camRotation;
     CelestialBodyData[] satellites = Ref.solarSystemRoot.satellites;
     for (int i = 0; i < satellites.Length; i++)
     {
         CelestialBodyData celestialBodyData = satellites[i];
         celestialBodyData.mapRefs.nameIconText.transform.localEulerAngles = camRotation;
         CelestialBodyData[] satellites2 = celestialBodyData.satellites;
         for (int j = 0; j < satellites2.Length; j++)
         {
             CelestialBodyData celestialBodyData2 = satellites2[j];
             celestialBodyData2.mapRefs.nameIconText.transform.localEulerAngles = camRotation;
         }
     }
 }
Пример #17
0
 private bool ProcessPasses(List <Orbit.Pass> passes)
 {
     for (int i = 0; i < passes.Count; i++)
     {
         double num = this.ProcessPasss(passes[i]);
         if (num > 0.0)
         {
             this.orbitEndTime        = num;
             this.endTrueAnomaly      = this.GetTrueAnomalyOut(num);
             this.orbitType           = Orbit.Type.Encounter;
             this.nextPlanet          = passes[i].passPlanet;
             this.calculatePassesTime = double.PositiveInfinity;
             return(true);
         }
         if (num < 0.0 && this.calculatePassesTime != double.PositiveInfinity)
         {
             this.calculatePassesTime = -num;
         }
     }
     return(false);
 }
Пример #18
0
    private void Start()
    {
        Color color = this.atmosphereRenderer.sharedMaterial.color;

        this.atmosphereRenderer.sharedMaterial.color = Color.white;
        this.lowRezPlanets = new PlanetManager.LowRezPlanets();
        this.lowRezPlanets.planets.Add(new PlanetManager.LowRezPlanets.LowRezPlanet(Ref.solarSystemRoot));
        CelestialBodyData[] satellites = Ref.solarSystemRoot.satellites;
        for (int i = 0; i < satellites.Length; i++)
        {
            CelestialBodyData celestialBodyData = satellites[i];
            this.lowRezPlanets.planets.Add(new PlanetManager.LowRezPlanets.LowRezPlanet(celestialBodyData));
            CelestialBodyData[] satellites2 = celestialBodyData.satellites;
            for (int j = 0; j < satellites2.Length; j++)
            {
                CelestialBodyData planet = satellites2[j];
                this.lowRezPlanets.planets.Add(new PlanetManager.LowRezPlanets.LowRezPlanet(planet));
            }
        }
        this.atmosphereRenderer.sharedMaterial.color = color;
    }
Пример #19
0
 private void Awake()
 {
     r                   = this;
     Ref.cam             = this.Camera;
     Ref.inputController = this.InputController;
     Ref.saving          = this.Saving;
     Ref.warning         = this.Warning;
     Ref.currentScene    = this.CurrentScene;
     Ref.lastScene       = this.LastScene;
     Ref.controller      = this.Controller;
     Ref.planetManager   = this.PlanetManager;
     Ref.map             = this.Map;
     Ref.solarSystemRoot = this.SolarSystemRoot;
     Ref.partShader      = this.PartShader;
     if (Ref.myModLoader == null)
     {
         Ref.myModLoader = new ModLoader();
         Ref.myModLoader.startLoadProcedure();
     }
     this.enabled = true;
     this.gameObject.SetActive(true);
 }
Пример #20
0
    private void IniciateGameScene()
    {
        this.updatedPersistantTime = Time.time + 10f;
        CelestialBodyData planetByName = Ref.GetPlanetByName(this.startAdress);
        Double3           @double      = new Double3(-450.0, planetByName.radius + 30.0);

        Ref.map.InitializeMap();
        this.cheatEnabledText.text = ((!Ref.infiniteFuel) ? string.Empty : "\n Infinite Fuel: On") + ((!Ref.noDrag) ? string.Empty : "\n No Drag: On") + ((!Ref.unbreakableParts) ? string.Empty : "\n Unbreakable Parts: On") + ((!Ref.noGravity) ? string.Empty : "\n No Gravity: On");
        GameSaving.GameSave gameSave = GameSaving.GameSave.LoadPersistant();
        if (Ref.lastScene == Ref.SceneType.Build)
        {
            if (gameSave != null && gameSave.vessels.Count > 0)
            {
                gameSave.velocityOffset   = Double3.zero;
                gameSave.selectedVesselId = -1;
                GameSaving.LoadForLaunch(gameSave, @double);
                MonoBehaviour.print("There is a Persistant-Save, and a Rocket To Create");
            }
            else
            {
                MonoBehaviour.print("There is No Persistant-Save, created rocket into new scene empty scene");
                Ref.planetManager.SwitchLocation(planetByName, @double, false, true, 0.0);
                Ref.map.following = new OrbitLines.Target(planetByName);
                Ref.map.UpdateMapPosition(new Double3(0.0, @double.y / 10000.0));
                Ref.map.UpdateMapZoom(@double.y / 10000.0 / 20.0);
            }
            this.CreatePartsFromBuild(@double);
            Ref.mainVessel.SetThrottle(new Vessel.Throttle(false, 0.65f));
            Ref.mapView = false;
            Ref.controller.SetCameraDistance(23f);
        }
        else if (gameSave != null)
        {
            GameSaving.LoadGame(gameSave);
            MonoBehaviour.print("No rocket to create, loaded persistant");
        }
    }
Пример #21
0
    public Vessel.State GoOnRails(CelestialBodyData initialPlanet, bool reCenter)
    {
        if (reCenter)
        {
            this.partsManager.ReCenter();
        }
        Double3 getGlobalPosition = this.GetGlobalPosition;
        Double3 getGlobalVelocity = this.GetGlobalVelocity;

        this.partsManager.rb2d.bodyType = RigidbodyType2D.Static;
        foreach (EngineModule engineModule in this.partsManager.engineModules)
        {
            if (engineModule.nozzleMove != null)
            {
                engineModule.nozzleMove.SetTargetTime(0f);
            }
            engineModule.UpdateEngineThrottle(this.throttle);
        }
        this.stationaryData.posToPlane = getGlobalPosition;
        this.stationaryData.planet     = initialPlanet;
        if (Math.Abs(getGlobalVelocity.x) < 0.3 && Math.Abs(getGlobalVelocity.y) < 0.3)
        {
            this.orbits.Clear();
            this.mapIcon.localPosition = (this.stationaryData.posToPlane / 10000.0).toVector3;
            return(Vessel.State.Stationary);
        }
        this.orbits = Orbit.CalculateOrbits(getGlobalPosition, getGlobalVelocity, initialPlanet);
        if (double.IsNaN(this.orbits[0].meanMotion))
        {
            MonoBehaviour.print("Cannot orbit NaN, went stationary instead");
            this.orbits.Clear();
            this.mapIcon.localPosition = (this.stationaryData.posToPlane / 10000.0).toVector3;
            return(Vessel.State.Stationary);
        }
        this.CheckOrbitArchivments(this.orbits[0]);
        return(Vessel.State.OnRails);
    }
Пример #22
0
    public void SwitchVessel(Vessel newVessel)
    {
        if (newVessel == null || newVessel == Ref.mainVessel)
        {
            return;
        }
        Ref.mainVessel = newVessel;
        Ref.map.UpdateVesselsMapIcons();
        Double3           getGlobalPosition = newVessel.GetGlobalPosition;
        CelestialBodyData getVesselPlanet   = newVessel.GetVesselPlanet;

        Ref.map.SelectVessel(Ref.selectedVessel);
        this.RepositionFuelIcons();
        this.UpdateVesselButtons();
        Ref.map.following = newVessel.GetVesselPlanet;
        Ref.map.UpdateMapPosition(newVessel.GetGlobalPosition / 10000.0);
        Ref.map.UpdateMapZoom(Ref.map.mapPosition.z);
        newVessel.SetThrottle(newVessel.throttle);
        bool flag = newVessel.GetGlobalPosition.magnitude2d < newVessel.GetVesselPlanet.radius + newVessel.GetVesselPlanet.minTimewarpHeightKm * 1000.0;

        Vessel.ToState toState = (Ref.timeWarping && !flag) ? Vessel.ToState.ToTimewarping : Vessel.ToState.ToRealTime;
        Ref.planetManager.SwitchLocation(getVesselPlanet, getGlobalPosition, false, true);
        bool   flag2 = toState == Vessel.ToState.ToRealTime && this.GetEnableVelocityOffset(newVessel);
        double x     = (!flag2) ? 0.0 : (Math.Floor((Math.Abs(Ref.mainVessel.GetGlobalVelocity.x) + 25.0) / 50.0) * 50.0 * (double)Math.Sign(Ref.mainVessel.GetGlobalVelocity.x));
        double y     = (!flag2) ? 0.0 : (Math.Floor((Math.Abs(Ref.mainVessel.GetGlobalVelocity.y) + 25.0) / 50.0) * 50.0 * (double)Math.Sign(Ref.mainVessel.GetGlobalVelocity.y));

        Ref.velocityOffset = new Double3(x, y);
        if (Ref.timeWarping && flag)
        {
            this.timewarpPhase = 1;
            this.DecelerateTime();
            Ref.controller.ShowMsg("Cannot time warp below: " + newVessel.GetVesselPlanet.minTimewarpHeightKm.ToString() + "km");
        }
        Ref.mainVessel.SetThrottle(new Vessel.Throttle(false, newVessel.throttle.throttleRaw));
        newVessel.SetVesselState(toState);
        Ref.planetManager.totalDistanceMoved += 100000.0;
    }
Пример #23
0
    private static void UpdateLocalTransferWindowMarker(ref bool show, ref MeshFilter meshFilterOrbit, double ejectionOrbitHeight, Orbit orbit, TransferWindow.Data transferWindow)
    {
        if (transferWindow.departure.type == CelestialBodyData.Type.Star || (transferWindow.transferType == TransferWindow.TransferType.ToNeighbour && transferWindow.departure != transferWindow.firstNeighbour))
        {
            return;
        }
        if (transferWindow.transferType == TransferWindow.TransferType.ToNeighbour || transferWindow.transferType == TransferWindow.TransferType.ToParent)
        {
            CelestialBodyData celestialBodyData = (transferWindow.transferType != TransferWindow.TransferType.ToNeighbour) ? transferWindow.departure : transferWindow.firstNeighbour;
            double            orbitHeightM      = celestialBodyData.orbitData.orbitHeightM;
            double            num        = (transferWindow.transferType != TransferWindow.TransferType.ToNeighbour) ? (transferWindow.target.radius + transferWindow.target.atmosphereData.atmosphereHeightM) : transferWindow.secondNeighbour.orbitData.orbitHeightM;
            double            num2       = Math.Min(num, orbitHeightM);
            double            num3       = (orbitHeightM + num) * 0.5;
            double            e          = 1.0 - num2 / num3;
            double            mass       = celestialBodyData.parentBody.mass;
            double            meanMotion = Kepler.GetMeanMotion(Kepler.GetPeriod(e, num3, mass), e, mass, num3);
            bool   flag           = num > orbitHeightM;
            double magnitude2d    = Kepler.GetVelocity(num3, orbitHeightM, meanMotion, (!flag) ? 3.1415926535897931 : 0.0, (!flag) ? 3.1415926535897931 : 0.0, e, 0.0).magnitude2d;
            double escapeVelocity = magnitude2d - -celestialBodyData.orbitData.orbitalVelocity;
            float  num4           = (float)(Kepler.GetEjectionAngle(escapeVelocity, ejectionOrbitHeight, celestialBodyData.mass, celestialBodyData.orbitData.SOI) * (double)Math.Sign(-orbit.meanMotion) + ((!flag) ? 3.1415926535897931 : 0.0));
            float  ejectionAngle  = num4 + (float)(Ref.controller.globalTime * celestialBodyData.orbitData._meanMotion) - 1.57079637f;
            TransferWindow.GenerateMeshOrbitTW(ref meshFilterOrbit, ref show, ejectionAngle, orbit);
            return;
        }
        if (transferWindow.transferType != TransferWindow.TransferType.ToSatellite)
        {
            return;
        }
        if (ejectionOrbitHeight > transferWindow.target.orbitData.orbitHeightM * 0.75)
        {
            return;
        }
        float num5           = (float)Kepler.GetPhaseAngle(ejectionOrbitHeight, transferWindow.target.orbitData.orbitHeightM);
        float ejectionAngle2 = num5 + (float)(Ref.controller.globalTime * transferWindow.target.orbitData._meanMotion);

        TransferWindow.GenerateMeshOrbitTW(ref meshFilterOrbit, ref show, ejectionAngle2, orbit);
    }
Пример #24
0
    private void Update()
    {
        this.CheckLoadDistance();
        Double3 @double = this.GetGlobalPosition;
        bool    flag    = this.state == Vessel.State.RealTime;

        if (flag)
        {
            @double = Ref.positionOffset + this.partsManager.rb2d.worldCenterOfMass;
            if (Time.time > this.archivmentCheckTime)
            {
                this.archivmentCheckTime = Time.time + 1f;
                this.CheckForArchivments();
                this.CheckOrbitArchivments(new Orbit(@double, this.GetGlobalVelocity, Ref.controller.loadedPlanet));
            }


            bool flag3 = this.OnSurface && !this.castedHook;
            if (flag3)
            {
                new MyVesselLandedHook(this, Ref.controller.loadedPlanet.parentBody).executeDefault();
                this.castedHook = true;
            }
            else
            {
                bool flag4 = !this.OnSurface && this.castedHook;
                if (flag4)
                {
                    this.castedHook = false;
                }
            }


            if (@double.sqrMagnitude2d > Ref.controller.loadedPlanet.orbitData.SOI * Ref.controller.loadedPlanet.orbitData.SOI)
            {
                this.AddArchivment("Escaped " + Ref.controller.loadedPlanet.bodyName + " sphere of influence");
                CelestialBodyData parentBody = Ref.controller.loadedPlanet.parentBody;
                this.mapIcon.parent = Ref.map.mapRefs[parentBody].holder;
                if (Ref.mainVessel == this)
                {
                    Ref.controller.EnterTimeWarpMode();
                    this.EnterNextOrbit();
                    Ref.controller.ExitTimeWarpMode();
                    @double = this.GetGlobalPosition;
                }
                else
                {
                    this.partsManager.ReCenter();
                    Double3 posIn = Ref.controller.loadedPlanet.GetPosOut(Ref.controller.globalTime) + @double;
                    Double3 velIn = Ref.controller.loadedPlanet.GetVelOut(Ref.controller.globalTime) + this.GetGlobalVelocity;
                    this.partsManager.rb2d.bodyType = RigidbodyType2D.Static;
                    this.partsManager.rb2d.gameObject.SetActive(false);
                    this.orbits = Orbit.CalculateOrbits(posIn, velIn, parentBody);
                    this.state  = Vessel.State.OnRailsUnloaded;
                }
            }
            foreach (CelestialBodyData celestialBodyData in Ref.controller.loadedPlanet.satellites)
            {
                Double3 double2 = @double - celestialBodyData.GetPosOut(Ref.controller.globalTime);
                if (double2.sqrMagnitude2d < celestialBodyData.orbitData.SOI * celestialBodyData.orbitData.SOI)
                {
                    this.AddArchivment("Entered " + celestialBodyData.bodyName + " sphere of influence");
                    this.mapIcon.parent = Ref.map.mapRefs[celestialBodyData].holder;
                    Double3 posIn2 = double2;
                    Double3 velIn2 = this.GetGlobalVelocity - celestialBodyData.GetVelOut(Ref.controller.globalTime);
                    if (Ref.mainVessel == this)
                    {
                        Ref.controller.EnterTimeWarpMode();
                        this.EnterNextOrbit();
                        Ref.controller.ExitTimeWarpMode();
                        @double = this.GetGlobalPosition;
                    }
                    else
                    {
                        this.partsManager.ReCenter();
                        this.partsManager.rb2d.bodyType = RigidbodyType2D.Static;
                        this.partsManager.rb2d.gameObject.SetActive(false);
                        this.orbits = Orbit.CalculateOrbits(posIn2, velIn2, celestialBodyData);
                        this.state  = Vessel.State.OnRailsUnloaded;
                    }
                }
            }
            if (Ref.mapView)
            {
                this.mapIcon.localPosition = (@double / 10000.0).toVector3;
                this.mapIcon.localRotation = this.partsManager.parts[0].transform.rotation;
            }
        }
        else if (this.state == Vessel.State.OnRails || this.state == Vessel.State.OnRailsUnloaded)
        {
            if (this.orbits[0].orbitEndTime < Ref.controller.globalTime)
            {
                this.EnterNextOrbit();
                @double = this.GetGlobalPosition;
            }
            if (this.orbits[0].calculatePassesTime != double.PositiveInfinity && Ref.controller.globalTime > this.orbits[0].calculatePassesTime - this.orbits[0]._period * 0.9 && this.orbits[0].UpdatePass())
            {
                this.orbits = Orbit.CalculateOrbits(this.orbits);
            }
            if (Ref.mapView)
            {
                this.mapIcon.localPosition = (@double / 10000.0).toVector3;
            }
            else if (this.state == Vessel.State.OnRails)
            {
                base.transform.position = (@double - Ref.positionOffset).toVector3;
            }
            if (Ref.mainVessel != this && @double.magnitude2d - this.orbits[0].planet.radius < this.orbits[0].planet.GetTerrainSampleAtAngle(Math.Atan2(@double.y, @double.x) * 57.2958))
            {
                this.DestroyVessel();
            }
        }
    }
Пример #25
0
 public void FullyLoadTerrain(CelestialBodyData newPlanet)
 {
     this.UpdateChuncksLoading(newPlanet.terrainData.detailLevels);
 }
Пример #26
0
        private void GenerateMesh(Transform chunckTrans, PlanetManager.TerrainPoints terrainPoints, int[] indices, double fromForUV, float traingleAngularSizeOf1, float texMultiplier, string sortingLayer, int orderInLayer, CelestialBodyData planet, bool map)
        {
            Mesh mesh = chunckTrans.GetComponent <MeshFilter>().mesh;

            mesh.Clear();
            mesh.vertices  = terrainPoints.points;
            mesh.triangles = indices;
            mesh.RecalculateNormals();
            mesh.RecalculateBounds();
            Vector2[] array = new Vector2[terrainPoints.points.Length];
            for (int i = 0; i < terrainPoints.points.Length - 1; i++)
            {
                array[i + 1] = new Vector2((float)(fromForUV % 10.0) + (float)i * texMultiplier, 0f);
            }
            array[0] = Vector3.up;
            mesh.uv  = array;
            Vector2[] array2 = new Vector2[terrainPoints.points.Length];
            double    num    = fromForUV / (double)((float)planet.terrainData.heightMaps[0].heightMap.HeightDataArray.Length);

            for (int j = 0; j < terrainPoints.points.Length - 1; j++)
            {
                array2[j + 1] = new Vector2((float)num + (float)j * traingleAngularSizeOf1, 1f);
            }
            array2[0] = Vector3.zero;
            mesh.uv2  = array2;
            mesh.uv3  = terrainPoints.uvOthers;
            MeshRenderer component = chunckTrans.GetComponent <MeshRenderer>();

            component.sortingLayerName = sortingLayer;
            component.sortingOrder     = orderInLayer;
            if (map)
            {
                component.material       = planet.terrainData.mapMaterial;
                component.material.color = planet.terrainData.mapColor;
            }
            else
            {
                component.sharedMaterial = planet.terrainData.terrainMaterial;
            }
        }
Пример #27
0
 public MyVesselLandedHook(Vessel v, CelestialBodyData b)
 {
     this.vessel = v;
     this.body   = b;
 }
Пример #28
0
    public Orbit(Double3 posIn, Double3 velIn, double timeIn, CelestialBodyData planet, CelestialBodyData lastPlanet)
    {
        this.planet = planet;
        this.timeIn = timeIn;
        double  mass    = planet.mass;
        Double3 b       = Double3.Cross2d(posIn, velIn);
        Double3 @double = Double3.Cross(velIn, b) / mass - posIn.normalized2d;

        this.eccentricity        = @double.magnitude2d;
        this.argumentOfPeriapsis = Math.Atan2(@double.y, @double.x);
        this.semiMajorAxis       = -mass / (2.0 * (Math.Pow(velIn.magnitude2d, 2.0) / 2.0 - mass / posIn.magnitude2d));
        this.periapsis           = this.semiMajorAxis * (1.0 - this.eccentricity);
        this.apoapsis            = ((this.eccentricity >= 1.0) ? double.PositiveInfinity : (this.semiMajorAxis * (1.0 + this.eccentricity)));
        this.semiLatusRectum     = Kepler.GetSemiLatusRectum(this.periapsis, this.eccentricity);
        this._period             = Kepler.GetPeriod(this.eccentricity, this.semiMajorAxis, mass);
        this.meanMotion          = Kepler.GetMeanMotion(this._period, this.eccentricity, mass, this.semiMajorAxis) * (double)Math.Sign(b.z);
        double trueAnomalyAtRadius = Kepler.GetTrueAnomalyAtRadius(posIn.magnitude2d, this.semiLatusRectum, this.eccentricity);
        double num = Kepler.GetMeanAnomaly(this.eccentricity, trueAnomalyAtRadius, posIn, this.argumentOfPeriapsis) / this.meanMotion;

        if (this.apoapsis > planet.orbitData.SOI || this.eccentricity >= 1.0)
        {
            this._period = 0.0;
        }
        this.periapsisPassageTime = timeIn + num - this._period * 10.0;
        this.GetOrbitType(timeIn, lastPlanet);
        this.stopTimeWarpTime = this.GetStopTimeWarpTime();
    }
Пример #29
0
 public Target(CelestialBodyData targetPlanet)
 {
     this.targetType   = OrbitLines.Target.Type.CelestialBody;
     this.targetPlanet = targetPlanet;
 }
Пример #30
0
    private List <Orbit.Pass> CreatePass(double passStartTime, double passEndTime, double cutStartTime, double cutEndTime, bool isEscape, CelestialBodyData satellite)
    {
        List <Orbit.Pass> list = new List <Orbit.Pass>();

        if (cutStartTime < passEndTime && cutEndTime > passStartTime)
        {
            list.Add(new Orbit.Pass((cutStartTime >= passStartTime) ? cutStartTime : passStartTime, (cutEndTime <= passEndTime) ? cutEndTime : passEndTime, satellite));
        }
        if (!isEscape && cutStartTime < passEndTime + this._period && cutEndTime > passStartTime + this._period)
        {
            list.Add(new Orbit.Pass((cutStartTime >= passStartTime + this._period) ? cutStartTime : (passStartTime + this._period), (cutEndTime <= passEndTime + this._period) ? cutEndTime : (passEndTime + this._period), satellite));
        }
        return(list);
    }