public static Enums.VesselState ConvertVesselState(Vessel.State state) { switch (state) { case Vessel.State.INACTIVE: { return(Enums.VesselState.Inactive); } case Vessel.State.ACTIVE: { return(Enums.VesselState.Active); } case Vessel.State.DEAD: { return(Enums.VesselState.Dead); } default: { throw new ArgumentException("Soundtrack Editor: Invalid vessel state: " + state + "\nCheck for an updated version of Soundtrack Editor."); } } }
public VesselSave(Vessel.State state, string adress, Double3 globalPosition, Double3 globalVelocity, float rotation, float angularVelocity, Vessel.Throttle throttle, Part.Save[] parts, Part.Joint.Save[] joints, List <string> vesselArchivments) { this.globalPosition = globalPosition; this.globalVelocity = globalVelocity; this.rotation = rotation; this.angularVelocity = angularVelocity; this.adress = adress; this.state = state; this.throttle = throttle; this.parts = parts; this.joints = joints; this.vesselArchivments = vesselArchivments; }
public void SetVesselState(Vessel.ToState toState) { if (toState == Vessel.ToState.ToTimewarping) { if (this.state == Vessel.State.RealTime) { this.state = this.GoOnRails(Ref.controller.loadedPlanet, true); base.name = "Vessel (" + this.state.ToString() + ")"; return; } if (this.state == Vessel.State.OnRailsUnloaded) { this.state = Vessel.State.OnRails; } if (this.state == Vessel.State.StationaryUnloaded) { this.state = Vessel.State.Stationary; } this.partsManager.rb2d.gameObject.SetActive(true); } if (toState == Vessel.ToState.ToUnloaded) { if (this.state == Vessel.State.RealTime) { this.state = this.GoOnRails(Ref.controller.loadedPlanet, true); } if (this.state == Vessel.State.OnRails) { this.state = Vessel.State.OnRailsUnloaded; } if (this.state == Vessel.State.Stationary) { this.state = Vessel.State.StationaryUnloaded; } this.partsManager.rb2d.gameObject.SetActive(false); this.partsManager.rb2d.position = Vector3.zero; } if (toState == Vessel.ToState.ToRealTime) { if (this.state == Vessel.State.RealTime) { return; } Ref.planetManager.totalDistanceMoved += 5000.0; this.partsManager.rb2d.gameObject.SetActive(true); this.GoOffRails(); this.state = Vessel.State.RealTime; } base.name = "Vessel (" + this.state.ToString() + ")"; }
public static void LoadForLaunch(GameSaving.GameSave loadedData, Double3 launchPadPosition) { for (int i = 0; i < loadedData.vessels.Count; i++) { if (loadedData.vessels[i].adress == Ref.controller.startAdress && Math.Abs(loadedData.vessels[i].globalPosition.x - launchPadPosition.x) < 10.0 && Math.Abs(loadedData.vessels[i].globalPosition.y - launchPadPosition.y) < 40.0) { loadedData.vessels.RemoveAt(i); i--; } else { Vessel.State state = loadedData.vessels[i].state; if (state != Vessel.State.RealTime) { if (state != Vessel.State.OnRails) { if (state == Vessel.State.Stationary) { loadedData.vessels[i].state = Vessel.State.StationaryUnloaded; } } else { loadedData.vessels[i].state = Vessel.State.OnRailsUnloaded; } } else if ((loadedData.vessels[i].globalPosition - launchPadPosition).magnitude2d > 1000.0 || loadedData.vessels[i].adress != Ref.controller.startAdress) { loadedData.vessels[i].state = ((Math.Abs(loadedData.vessels[i].globalVelocity.x) <= 1.0 && Math.Abs(loadedData.vessels[i].globalVelocity.y) <= 1.0) ? Vessel.State.StationaryUnloaded : Vessel.State.OnRailsUnloaded); } } } Ref.planetManager.SwitchLocation(Ref.GetPlanetByName(Ref.controller.startAdress), launchPadPosition, false, true, 0.0); Ref.planetManager.UpdatePositionOffset(new Double3(0.0, 315000.0)); Ref.velocityOffset = Double3.zero; Ref.controller.globalTime = loadedData.globalTime; Ref.controller.timewarpPhase = 0; Ref.timeWarping = false; foreach (GameSaving.VesselSave vesselToLoad in loadedData.vessels) { GameSaving.LoadVessel(vesselToLoad); } Ref.map.following = new OrbitLines.Target(Ref.GetPlanetByName(Ref.controller.startAdress)); Ref.map.UpdateMapPosition(new Double3(0.0, launchPadPosition.y / 10000.0)); Ref.map.UpdateMapZoom(launchPadPosition.y / 10000.0 / 20.0); Ref.planetManager.UpdateAtmosphereFade(); Ref.controller.warpedTimeCounterUI.text = string.Empty; }
private void Update() { this.CheckLoadDistance(); Double3 @double = this.GetGlobalPosition; if (this.state == Vessel.State.RealTime) { @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)); } 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 = parentBody.mapRefs.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; } } CelestialBodyData[] satellites = Ref.controller.loadedPlanet.satellites; for (int i = 0; i < satellites.Length; i++) { CelestialBodyData celestialBodyData = satellites[i]; 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 = celestialBodyData.mapRefs.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.selectedVessel == this) { Ref.map.UpdateVesselOrbitLines(this.orbits, true); } } 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(); } } }