Beispiel #1
0
 public void Update()
 {
     if (this.m_nativeContext != IntPtr.Zero && !this.m_hasFinished)
     {
         IntPtr nativeTextureContext = MovieMaterial.GetNativeTextureContext(this.m_nativeContext);
         if (nativeTextureContext != this.m_nativeTextureContext)
         {
             this.DestroyTextures();
             this.AllocateTexures();
             this.m_nativeTextureContext = nativeTextureContext;
         }
         this.m_hasFinished = MovieMaterial.HasFinished(this.m_nativeContext);
         if (!this.m_hasFinished)
         {
             if (this.advance)
             {
                 double elapsedTime = this.m_elapsedTime;
                 float  num         = Mathf.Max(this.playSpeed, 0f);
                 bool   flag        = false;
                 flag |= this.isFMV;
                 if (flag)
                 {
                     if (this.preciseTimeCycleCounter == 0)
                     {
                         this.m_elapsedTime += 0.066 * (double)this.playSpeed;
                     }
                     else
                     {
                         this.m_elapsedTime += 0.067 * (double)this.playSpeed;
                     }
                     if (this.preciseTimeCycleCounter == 2)
                     {
                         this.preciseTimeCycleCounter = 0;
                     }
                     else
                     {
                         this.preciseTimeCycleCounter++;
                     }
                 }
                 else
                 {
                     this.m_elapsedTime += (double)(Mathf.Min(Time.deltaTime, 0.067f) * num);
                 }
                 if (this.shouldSync)
                 {
                     SoundLib.SeekMovieAudio(this.movieKey, this.PlayPosition);
                     this.shouldSync = false;
                 }
                 if (this.playSpeed > 1f)
                 {
                     this.syncElapsed += Time.deltaTime;
                     if (this.syncElapsed >= 4f)
                     {
                         SoundLib.SeekMovieAudio(this.movieKey, this.PlayPosition);
                         this.syncElapsed = 0f;
                     }
                 }
             }
         }
         else
         {
             if (this.loopCount - 1 <= 0 && this.loopCount != -1)
             {
                 SoundLib.StopMovieMusic(this.movieKey, false);
                 if (this.OnFinished != null)
                 {
                     this.m_elapsedTime = MovieMaterial.GetDecodedFrameTime(this.m_nativeContext);
                     this.OnFinished();
                 }
                 return;
             }
             if (this.loopCount != -1)
             {
                 this.loopCount--;
             }
             this.m_elapsedTime %= MovieMaterial.GetDecodedFrameTime(this.m_nativeContext);
             MovieMaterial.Seek(this.m_nativeContext, 0.0, false);
             this.m_hasFinished = false;
         }
         MovieMaterial.SetTargetDisplayDecodeTime(this.m_nativeContext, this.m_elapsedTime);
         if (!this.getFirstFrame)
         {
             double uploadedFrameTime = MovieMaterial.GetUploadedFrameTime(this.m_nativeContext);
             double num2 = 0.066666666666666666;
             if (uploadedFrameTime > num2)
             {
                 this.m_elapsedTime           = 0.0;
                 this.preciseTimeCycleCounter = 0;
                 this.getFirstFrame           = true;
                 if (this.Material != null)
                 {
                     this.Material.SetColor("_TintColor", this.tintColor);
                 }
                 if (this.advance)
                 {
                     SoundLib.PlayMovieMusic(this.movieKey, 0);
                 }
             }
         }
     }
 }