public void Jump() { JumpMarker targetMarker = (Context.PlayableDirector.playableAsset as TimelineAsset)?.GetOutputTracks() .SelectMany(t => t.GetMarkers()) .OfType <JumpMarker>() .FirstOrDefault(m => m.name.Equals(_target)); if (targetMarker == null) { Debug.LogWarning($"No matching target JumpMarker with name {_target} found!"); return; } Context.PlayableDirector.Pause(); // prevent markers that are jumped from being executed Context.PlayableDirector.time = targetMarker.time; Context.PlayableDirector.Play(); }
void Update() { if (FlightGlobals.ActiveVessel == null) { return; } if (FlightGlobals.currentMainBody != _body) { return; } // Is the vessel within the sphere of influence? if (FlightGlobals.ship_altitude < influenceAltitude) { if (MapView.MapIsEnabled) { MapView.ExitMapView(); } if (FlightGlobals.ActiveVessel.GetComponent <CameraShake>() == null) { FlightGlobals.ActiveVessel.gameObject.AddComponent <CameraShake>().ShakeAmount = 2; if (!String.IsNullOrEmpty(entryMessage)) { ScreenMessages.PostScreenMessage(entryMessage, entryMsgDuration); } } } else { CameraShake shake = FlightGlobals.ActiveVessel.GetComponent <CameraShake>(); if (shake != null) { Destroy(shake); if (!String.IsNullOrEmpty(exitMessage)) { ScreenMessages.PostScreenMessage(exitMessage, exitMsgDuration); } } return; } // Are we within the jump range? if (FlightGlobals.ship_altitude < jumpMaxAltitude && FlightGlobals.ship_altitude > jumpMinAltitude) { // Disable the log output PDebug.DebugLevel l = PDebug.debugLevel; PDebug.debugLevel = PDebug.DebugLevel.None; for (Int32 i = 0; i < 5; i++) { Vector3 random = UnityEngine.Random.onUnitSphere; GameObject effect = FXMonger.Splash( FlightGlobals.ship_position + random * 50, 1000).effectObj; effect.transform.localScale = Vector3.one * 10; effect.transform.up = -random; } // Update the FXMonger FXMonger[] mongers = FindObjectsOfType <FXMonger>(); for (Int32 i = 0; i < mongers.Length; i++) { mongers[i].SendMessage("LateUpdate"); } PDebug.debugLevel = l; // If the Pe is within the jump range, jump if (FlightGlobals.ship_altitude - _lastAlt > 0) { // Move the vessel to the new orbit if (FlightGlobals.ActiveVessel.GetComponent <JumpMarker>() == null) { MakeOrbit(FlightGlobals.ActiveVessel.orbitDriver, _partner); FlightGlobals.ActiveVessel.gameObject.AddComponent <JumpMarker>(); } } } else { // Heat up the vessel for (Int32 i = 0; i < FlightGlobals.ActiveVessel.Parts.Count; i++) { FlightGlobals.ActiveVessel[i].temperature += heatRate; } // Remove the jump marker if neccessary JumpMarker jump = FlightGlobals.ActiveVessel.GetComponent <JumpMarker>(); if (jump != null) { Destroy(jump); } } _lastAlt = FlightGlobals.ship_altitude; }