public void SetTime(float time)
 {
     //if (ChartEditor.Instance.currentState == ChartEditor.State.Editor)
     {
         Vector3 pos = initPos;
         pos.y += ChartEditor.TimeToWorldYPosition(time);
         transform.position = pos;
     }
 }
    public void PlayingMovement()
    {
        float   speed          = Globals.gameSettings.hyperspeed;
        Vector3 pos            = transform.position;
        float   deltaTime      = Time.deltaTime;
        float   positionOffset = initPos.y;

        {
            float timeBeforeMovement = ChartEditor.WorldYPositionToTime(pos.y - positionOffset);
            float timeAfterMovement  = timeBeforeMovement + deltaTime * Globals.gameSettings.gameSpeed;

            // Make sure we're staying in sync with the audio
            {
                SongAudioManager songAudioManager = editor.currentSongAudio;

                AudioStream stream = null;

                for (int i = 0; i < EnumX <Song.AudioInstrument> .Count; ++i)
                {
                    Song.AudioInstrument audio = (Song.AudioInstrument)i;
                    if (AudioManager.StreamIsValid(songAudioManager.GetAudioStream(audio)))
                    {
                        stream = songAudioManager.GetAudioStream(audio);
                        break;
                    }
                }

                if (AudioManager.StreamIsValid(stream) && stream.IsPlaying())
                {
                    float audioTimePosition = stream.CurrentPositionInSeconds() - editor.services.totalSongAudioOffset;
                    float desyncAmount      = audioTimePosition - timeAfterMovement;

                    if (Mathf.Abs(desyncAmount) > DESYNCLENIENCE)
                    {
                        timeAfterMovement += desyncAmount;
                    }
                }
            }

            float maxChangeInTimeAllowed = Application.targetFrameRate > 0 ? 2.0f / Application.targetFrameRate : 1.0f / 120.0f;

            float totalChangeInTime = timeAfterMovement - timeBeforeMovement;

            float newTimePosition = ChartEditor.TimeToWorldYPosition(timeBeforeMovement + totalChangeInTime);
            pos.y = newTimePosition + positionOffset;
        }

        selfTransform.position = pos;
        explicitChartPos       = null;

        lastUpdatedRealTime = Time.time;
    }
    void UpdatePosBasedTimelineHandle()
    {
        if (editor.currentChart != null)
        {
            float endYPos       = ChartEditor.TimeToWorldYPosition(editor.currentSongLength);
            float totalDistance = endYPos - initPos.y - strikeLine.localPosition.y;

            if (totalDistance > 0)
            {
                float currentDistance = timeline.handlePos * totalDistance;

                transform.position = initPos + new Vector3(0, currentDistance, 0);
            }
            else
            {
                timeline.handlePos = 0;
                transform.position = initPos;
            }
        }
    }
    void UpdateTimelineHandleBasedPos()
    {
        if (editor.currentChart != null)
        {
            // Front cap
            if (editor.currentState == ChartEditor.State.Editor)
            {
                if (transform.position.y < initPos.y)
                {
                    transform.position = initPos;
                }
            }

            float endYPos       = ChartEditor.TimeToWorldYPosition(editor.currentSongLength);
            float totalDistance = endYPos - initPos.y - strikeLine.localPosition.y;

            if (transform.position.y + strikeLine.localPosition.y > endYPos)
            {
                transform.position = new Vector3(transform.position.x, endYPos - strikeLine.localPosition.y, transform.position.z);
            }

            float currentDistance = transform.position.y - initPos.y;

            //if (Globals.applicationMode != ChartEditor.State.Playing)
            //{
            if (totalDistance > 0)
            {
                timeline.handlePos = currentDistance / totalDistance;
            }
            else
            {
                timeline.handlePos = 0;
            }
            //}
        }
    }
 public static float TickToWorldYPosition(this Song song, uint position, float resolution)
 {
     return(ChartEditor.TimeToWorldYPosition(song.TickToTime(position, resolution)));
 }