public void goOffRails()
 {
     _isOffRails = true;
     if (!offRailsInitiliazed) // run once on each offRails activation
     {
         if (rbody == null)
         {
             setupRigidBody();
         }
         if (rbody == null)
         {
             return;
         }
         rbody.isKinematic   = false;
         rbody.velocity      = currentVelocity;
         offRailsInitiliazed = true;
         CraftLoader.setColliderStateInChildren(ghost, true);
         if (offRailsObject == null)
         {
             offRailsObject = ghost.AddComponent <OffRailsObject>();
         }
         else
         {
             offRailsObject.enabled = true;
         }
     }
 }
        public ReplayWindow(Track track) : base("Replay Track: " + track.TrackName)
        {
            bool loadCraft = true;

            if (loadCraft)
            {
                try
                {
                    ghost = CraftLoader.assembleCraft(Utilities.CraftPath + track.VesselName + ".crf", track.ReplayColliders); // --- add the craft file listed in the path, or selected from a menu ---
                }
                catch
                {
                    //Debug.Log("ERROR LOADING CRF, FALLING BACK TO SPHERE");
                    loadCraft = false;
                }
            }

            if (!loadCraft)
            {
                Mesh sphere = MeshFactory.createSphere();
                ghost = MeshFactory.makeMeshGameObject(ref sphere, "Track playback sphere");
                ghost.transform.localScale = new Vector3(track.ConeRadiusToLineWidthFactor * track.LineWidth, track.ConeRadiusToLineWidthFactor * track.LineWidth, track.ConeRadiusToLineWidthFactor * track.LineWidth);
                //ghost.collider.enabled = false;
                ghost.GetComponent <Renderer>().material = new Material(Shader.Find("KSP/Emissive/Diffuse"));
                ghost.GetComponent <Renderer>().material.SetColor("_EmissiveColor", track.LineColor);
            }

            behaviour = ghost.AddComponent <ReplayBehaviour>();
            behaviour.initialize(track, ghost);
            behaviour.enabled = true;

            this.windowPos = new Rect(600f, 50f, 300f, 100f);
        }
        public void Update()
        {
            //Debug.Log("Replay OnUpdate: evaluating track after t = " + currentReplayTime + "s, UT= " + (trackStartUT + currentReplayTime));
            double currentTimeUT = Planetarium.GetUniversalTime();

            if (!animationsInitialised)
            {
                CraftLoader.setLightStateInChildren(ghost, false);
                CraftLoader.setLadderStateInChildren(ghost, false);
                animationsInitialised = true;
            }
            //increment replayTime
            currentReplayTime += playbackFactor * (currentTimeUT - lastUpdateUT);

            if (!isOffRails)
            {
                setGhostToPlaybackAt(trackStartUT + currentReplayTime);
            }

            lastUpdateUT = currentTimeUT;

            //check end reached
            if (currentReplayTime >= totalReplayTime)
            {
                if (track.EndAction == Track.EndActions.LOOP)
                {
                    currentReplayTime = 0;
                }
                else if (track.EndAction == Track.EndActions.OFFRAILS)
                {
                    isOffRails = true;
                }
                // TODO: add DELETE ghost handling
            }
        }
 public void goOnRails()
 {
     _isOffRails         = false;
     offRailsInitiliazed = false;
     Destroy(rbody);
     CraftLoader.setColliderStateInChildren(ghost, false);
     if (offRailsObject != null)
     {
         offRailsObject.enabled = false;
     }
 }
Ejemplo n.º 5
0
        public void continueTrack(Track track)
        {
            Debug.Log("TrackManager continueTrack()");
            stopRecording();

            CraftLoader.saveCraftToFile();

            recording          = true;
            track.SourceVessel = FlightGlobals.ActiveVessel;
            track.VesselName   = track.SourceVessel.name;

            activeTrack = track;
            updateCurrentTrack();
        }
Ejemplo n.º 6
0
        public void startNewTrack()
        {
            Debug.Log("Starting new Track");
            recording = true;


            //create new Track
            activeTrack = new Track(); //initializes with TrackName = activeVessel.Name

            CraftLoader.saveCraftToFile();

            activeTrack.TrackName = Utilities.makeUniqueTrackName(activeTrack.TrackName, ref allTracks, false);
            allTracks.Add(activeTrack);
            updateCurrentTrack();
        }