public void SwitchVessel(Vessel newVessel) { if (newVessel == null || newVessel == Ref.mainVessel) { return; } this.viewPositons = Vector2.zero; Vessel mainVessel = Ref.mainVessel; Ref.mainVessel = newVessel; Ref.map.UpdateVesselsMapIcons(); Double3 getGlobalPosition = newVessel.GetGlobalPosition; CelestialBodyData getVesselPlanet = newVessel.GetVesselPlanet; Ref.map.SelectVessel(Ref.selectedVessel, true); this.RepositionFuelIcons(); this.UpdateVesselButtons(); Ref.map.following = new OrbitLines.Target(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; foreach (Vessel vessel in Ref.controller.vessels) { vessel.SetVesselState(Vessel.ToState.ToUnloaded); } Vessel.ToState toState = (Ref.timeWarping && !flag) ? Vessel.ToState.ToTimewarping : Vessel.ToState.ToRealTime; Ref.planetManager.SwitchLocation(getVesselPlanet, getGlobalPosition, false, true, 0.0); if (Ref.timeWarping && flag) { this.timewarpPhase = 1; this.DecelerateTime(); MsgController.ShowMsg("Cannot time warp below: " + newVessel.GetVesselPlanet.minTimewarpHeightKm.ToString() + "km"); } else { if (toState == Vessel.ToState.ToRealTime) { bool flag2 = this.GetEnableVelocityOffset(Ref.mainVessel); 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); } Ref.mainVessel.SetVesselState(toState); } Ref.mainVessel.SetThrottle(new Vessel.Throttle(false, newVessel.throttle.throttleRaw)); if (mainVessel != null) { Ref.map.SelectVessel(mainVessel, false); } Ref.planetManager.totalDistanceMoved += 100000.0; }
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() + ")"; }