414 lines
11 KiB
C#
414 lines
11 KiB
C#
using System;
|
|
using System.Collections;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.UI;
|
|
using UnityEngine.Video;
|
|
|
|
// Token: 0x020000CB RID: 203
|
|
public class PlayVideo : MonoBehaviour, IPointerDownHandler, IEventSystemHandler
|
|
{
|
|
// Token: 0x060012A1 RID: 4769 RVA: 0x001683EC File Offset: 0x001665EC
|
|
public void Setup(string type, Cinematics cine)
|
|
{
|
|
if (Links.x.sensory)
|
|
{
|
|
Records.x.SetTypingState(true);
|
|
Records.x.RemoveControls(true);
|
|
}
|
|
this.waitingCinematic = cine;
|
|
this.video.enabled = false;
|
|
this.videoImg.enabled = false;
|
|
if (this.rt != null)
|
|
{
|
|
this.rt.Release();
|
|
}
|
|
RenderTextureFormat renderTextureFormat = RenderTextureFormat.ARGBHalf;
|
|
this.rt = new RenderTexture(this.videoWidth, this.videoHeight, 24, renderTextureFormat);
|
|
this.video.targetTexture = this.rt;
|
|
this.videoImg.texture = this.rt;
|
|
this.done = false;
|
|
this.clicked = false;
|
|
this.clickCount = 0;
|
|
RenderTexture active = RenderTexture.active;
|
|
RenderTexture.active = this.rt;
|
|
GL.Clear(true, true, Color.black);
|
|
RenderTexture.active = active;
|
|
Time.timeScale = 1f;
|
|
this.skipText.enabled = false;
|
|
this.skipText.spriteAsset = Links.x.GetSpriteSheetAsset(Links.x.gameplay.currentSpriteSheetAsset);
|
|
this.str.Clear();
|
|
this.str.Append("Skip ");
|
|
this.str.Append(" <voffset=.4em><size=50><sprite=");
|
|
if (Links.x.mk)
|
|
{
|
|
int keyIconIndex = Links.x.keyControl.GetKeyIconIndex("LMB");
|
|
this.str.Append(keyIconIndex);
|
|
this.str.Append("></size></voffset>");
|
|
}
|
|
else
|
|
{
|
|
int controllerSprite = Links.x.gameplay.GetControllerSprite("Cancel", Links.x.gameplay.controllerName);
|
|
this.str.Append(controllerSprite);
|
|
this.str.Append("></size></voffset>");
|
|
}
|
|
this.skipText.text = this.str.ToString();
|
|
this.video.enabled = false;
|
|
if (type == "Throat")
|
|
{
|
|
if (Records.x.linux)
|
|
{
|
|
this.video.clip = this.throatLinux;
|
|
}
|
|
else if (!Records.x.linux && (Records.x.windows7 || Records.x.alwaysPlayTranscodedVideo))
|
|
{
|
|
this.video.clip = this.throatWindows7;
|
|
}
|
|
else
|
|
{
|
|
this.video.clip = this.throat;
|
|
}
|
|
}
|
|
else if (type == "Standoff")
|
|
{
|
|
if (Records.x.linux)
|
|
{
|
|
this.video.clip = this.standoffLinux;
|
|
}
|
|
else if (!Records.x.linux && (Records.x.windows7 || Records.x.alwaysPlayTranscodedVideo))
|
|
{
|
|
this.video.clip = this.standoffWindows7;
|
|
}
|
|
else
|
|
{
|
|
this.video.clip = this.standoff;
|
|
}
|
|
}
|
|
else if (type == "Flyover")
|
|
{
|
|
if (Records.x.linux)
|
|
{
|
|
this.video.clip = this.flyoverLinux;
|
|
}
|
|
else if (!Records.x.linux && (Records.x.windows7 || Records.x.alwaysPlayTranscodedVideo))
|
|
{
|
|
this.video.clip = this.flyoverWindows7;
|
|
}
|
|
else
|
|
{
|
|
this.video.clip = this.flyover;
|
|
}
|
|
}
|
|
this.video.isLooping = false;
|
|
this.clicked = false;
|
|
this.video.targetTexture = this.rt;
|
|
this.videoImg.texture = this.rt;
|
|
this.videoImg.color = new Color(1f, 1f, 1f, 0f);
|
|
this.blackBackground.color = new Color(0f, 0f, 0f, 0f);
|
|
this.skipText.color = new Color(this.skipText.color.r, this.skipText.color.g, this.skipText.color.b, 0f);
|
|
this.video.SetDirectAudioVolume(0, Links.x.options.musicVolume);
|
|
base.gameObject.SetActive(true);
|
|
this.video.enabled = true;
|
|
this.video.started += this.VideoStarted;
|
|
this.frameCount = (int)this.video.frameCount;
|
|
}
|
|
|
|
// Token: 0x060012A2 RID: 4770 RVA: 0x00168866 File Offset: 0x00166A66
|
|
private void OnDestroy()
|
|
{
|
|
if (this.rt != null)
|
|
{
|
|
this.rt.Release();
|
|
}
|
|
}
|
|
|
|
// Token: 0x060012A3 RID: 4771 RVA: 0x00168884 File Offset: 0x00166A84
|
|
private void Update()
|
|
{
|
|
float num = this.rectTransformBlack.sizeDelta.x;
|
|
float num2 = this.rectTransformBlack.sizeDelta.y;
|
|
float num3 = (float)Screen.width / (float)Screen.height;
|
|
float num4 = 1.7777778f;
|
|
if (num3 != num4)
|
|
{
|
|
if (num3 > num4)
|
|
{
|
|
num = num2 * num4;
|
|
}
|
|
else
|
|
{
|
|
num2 = num / num4;
|
|
}
|
|
}
|
|
this.rectTransform.sizeDelta = new Vector2(num, num2);
|
|
}
|
|
|
|
// Token: 0x060012A4 RID: 4772 RVA: 0x001688EB File Offset: 0x00166AEB
|
|
public void VideoStarted(VideoPlayer vp)
|
|
{
|
|
base.StartCoroutine(this.VideoStarting());
|
|
}
|
|
|
|
// Token: 0x060012A5 RID: 4773 RVA: 0x001688FC File Offset: 0x00166AFC
|
|
private bool Clicked()
|
|
{
|
|
if (Links.x.joy)
|
|
{
|
|
if (Links.x.gameplay.cancelStart)
|
|
{
|
|
this.clicked = true;
|
|
return true;
|
|
}
|
|
}
|
|
else if (Input.GetMouseButtonUp(0) && this.clickCount >= 0)
|
|
{
|
|
this.clicked = true;
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
// Token: 0x060012A6 RID: 4774 RVA: 0x0016894A File Offset: 0x00166B4A
|
|
private IEnumerator VideoStarting()
|
|
{
|
|
Links.x.gaia.FadeOutPlaylist(true, 0.25f);
|
|
Links.x.gaia.FadeOutPlaylist(false, 0.25f);
|
|
if (this.video.clip == this.flyover || this.video.clip == this.flyoverLinux)
|
|
{
|
|
this.video.playbackSpeed = 0f;
|
|
this.textObject.SetActive(true);
|
|
this.skipText.enabled = false;
|
|
float timeToLerp = 1f;
|
|
float percentage = 0f;
|
|
float startTime = Time.time;
|
|
while (percentage < 1f)
|
|
{
|
|
percentage = (Time.time - startTime) / timeToLerp;
|
|
yield return null;
|
|
}
|
|
this.skipText.enabled = true;
|
|
timeToLerp = 0.5f;
|
|
percentage = 0f;
|
|
startTime = Time.time;
|
|
while (percentage < 1f)
|
|
{
|
|
if (this.Clicked())
|
|
{
|
|
break;
|
|
}
|
|
percentage = (Time.time - startTime) / timeToLerp;
|
|
this.skipText.color = Color.Lerp(new Color(this.skipText.color.r, this.skipText.color.g, this.skipText.color.b, 0f), new Color(this.skipText.color.r, this.skipText.color.g, this.skipText.color.b, 1f), percentage);
|
|
yield return null;
|
|
}
|
|
while (this.textObject.activeSelf && !this.Clicked())
|
|
{
|
|
yield return null;
|
|
}
|
|
this.textObject.SetActive(false);
|
|
yield return new WaitForSeconds(0.01f);
|
|
this.clicked = false;
|
|
this.skipText.enabled = false;
|
|
this.video.playbackSpeed = 1f;
|
|
}
|
|
this.videoImg.enabled = true;
|
|
float timeToLerp2 = 0.001f;
|
|
float percentage2 = 0f;
|
|
float startTime2 = Time.time;
|
|
while (percentage2 < 1f)
|
|
{
|
|
percentage2 = (Time.time - startTime2) / timeToLerp2;
|
|
yield return null;
|
|
}
|
|
bool throatVideo = false;
|
|
if (this.video.clip == this.throat || this.video.clip == this.throatLinux)
|
|
{
|
|
throatVideo = true;
|
|
}
|
|
timeToLerp2 = 0.5f;
|
|
percentage2 = 0f;
|
|
startTime2 = Time.time;
|
|
while (percentage2 < 1f)
|
|
{
|
|
percentage2 = (Time.time - startTime2) / timeToLerp2;
|
|
Color color = new Color(1f, 1f, 1f, 0f);
|
|
Color color2 = new Color(0f, 0f, 0f, 0f);
|
|
Color color3 = new Color(1f, 1f, 1f, 1f);
|
|
Color color4 = new Color(0f, 0f, 0f, 1f);
|
|
this.videoImg.color = Color.Lerp(color, color3, percentage2);
|
|
this.blackBackground.color = Color.Lerp(color2, color4, percentage2);
|
|
yield return null;
|
|
}
|
|
timeToLerp2 = 0.5f;
|
|
percentage2 = 0f;
|
|
startTime2 = Time.time;
|
|
while (percentage2 < 1f)
|
|
{
|
|
percentage2 = (Time.time - startTime2) / timeToLerp2;
|
|
yield return null;
|
|
}
|
|
this.skipText.enabled = true;
|
|
timeToLerp2 = 0.5f;
|
|
percentage2 = 0f;
|
|
startTime2 = Time.time;
|
|
while (percentage2 < 1f && !this.Clicked())
|
|
{
|
|
percentage2 = (Time.time - startTime2) / timeToLerp2;
|
|
this.skipText.color = Color.Lerp(new Color(this.skipText.color.r, this.skipText.color.g, this.skipText.color.b, 0f), new Color(this.skipText.color.r, this.skipText.color.g, this.skipText.color.b, 1f), percentage2);
|
|
yield return null;
|
|
}
|
|
int frameTarget = this.frameCount;
|
|
if (throatVideo)
|
|
{
|
|
frameTarget = 2545;
|
|
}
|
|
else
|
|
{
|
|
frameTarget = this.frameCount - 10;
|
|
}
|
|
while (this.video.frame < (long)frameTarget && !this.Clicked() && !this.clicked)
|
|
{
|
|
yield return null;
|
|
}
|
|
this.skipText.enabled = false;
|
|
timeToLerp2 = 0.3f;
|
|
percentage2 = 0f;
|
|
startTime2 = Time.time;
|
|
while (percentage2 < 1f)
|
|
{
|
|
percentage2 = (Time.time - startTime2) / timeToLerp2;
|
|
Color color5 = new Color(1f, 1f, 1f, 0f);
|
|
Color color6 = new Color(0f, 0f, 0f, 0f);
|
|
this.videoImg.color = Color.Lerp(Color.white, color5, percentage2);
|
|
this.blackBackground.color = Color.Lerp(Color.black, color6, percentage2);
|
|
yield return null;
|
|
}
|
|
this.EndReached();
|
|
yield break;
|
|
}
|
|
|
|
// Token: 0x060012A7 RID: 4775 RVA: 0x0016895C File Offset: 0x00166B5C
|
|
public void EndReached()
|
|
{
|
|
if (!this.done)
|
|
{
|
|
this.video.enabled = false;
|
|
this.videoImg.enabled = false;
|
|
if (this.video.clip == this.throat || this.video.clip == this.throatLinux)
|
|
{
|
|
this.waitingCinematic.videoFinished = true;
|
|
}
|
|
else if (this.video.clip == this.standoff || this.video.clip == this.standoffLinux)
|
|
{
|
|
this.waitingCinematic.videoFinished = true;
|
|
}
|
|
else if (this.video.clip == this.flyover || this.video.clip == this.flyoverLinux)
|
|
{
|
|
this.waitingCinematic.videoFinished = true;
|
|
}
|
|
}
|
|
this.video.started -= this.VideoStarted;
|
|
this.done = true;
|
|
if (this.rt != null)
|
|
{
|
|
this.rt.Release();
|
|
}
|
|
base.gameObject.SetActive(false);
|
|
}
|
|
|
|
// Token: 0x060012A8 RID: 4776 RVA: 0x00168A88 File Offset: 0x00166C88
|
|
public void OnPointerDown(PointerEventData eventData)
|
|
{
|
|
if (!this.done)
|
|
{
|
|
this.clickCount++;
|
|
if (this.clickCount > 1 && Time.timeSinceLevelLoad >= this.clickTime + 0.5f)
|
|
{
|
|
this.clickCount = 0;
|
|
}
|
|
if (this.clickCount == 1)
|
|
{
|
|
this.clickTime = Time.timeSinceLevelLoad;
|
|
}
|
|
}
|
|
}
|
|
|
|
// Token: 0x04001ECA RID: 7882
|
|
public VideoPlayer video;
|
|
|
|
// Token: 0x04001ECB RID: 7883
|
|
public VideoClip throat;
|
|
|
|
// Token: 0x04001ECC RID: 7884
|
|
public VideoClip throatLinux;
|
|
|
|
// Token: 0x04001ECD RID: 7885
|
|
public VideoClip throatWindows7;
|
|
|
|
// Token: 0x04001ECE RID: 7886
|
|
public VideoClip standoff;
|
|
|
|
// Token: 0x04001ECF RID: 7887
|
|
public VideoClip standoffLinux;
|
|
|
|
// Token: 0x04001ED0 RID: 7888
|
|
public VideoClip standoffWindows7;
|
|
|
|
// Token: 0x04001ED1 RID: 7889
|
|
public VideoClip flyover;
|
|
|
|
// Token: 0x04001ED2 RID: 7890
|
|
public VideoClip flyoverLinux;
|
|
|
|
// Token: 0x04001ED3 RID: 7891
|
|
public VideoClip flyoverWindows7;
|
|
|
|
// Token: 0x04001ED4 RID: 7892
|
|
public RawImage videoImg;
|
|
|
|
// Token: 0x04001ED5 RID: 7893
|
|
public Image blackBackground;
|
|
|
|
// Token: 0x04001ED6 RID: 7894
|
|
private int clickCount;
|
|
|
|
// Token: 0x04001ED7 RID: 7895
|
|
private float clickTime;
|
|
|
|
// Token: 0x04001ED8 RID: 7896
|
|
private bool done;
|
|
|
|
// Token: 0x04001ED9 RID: 7897
|
|
public Cinematics waitingCinematic;
|
|
|
|
// Token: 0x04001EDA RID: 7898
|
|
public int frameCount = 100;
|
|
|
|
// Token: 0x04001EDB RID: 7899
|
|
public TextMeshProUGUI skipText;
|
|
|
|
// Token: 0x04001EDC RID: 7900
|
|
private bool clicked;
|
|
|
|
// Token: 0x04001EDD RID: 7901
|
|
private StringFast str = new StringFast(32);
|
|
|
|
// Token: 0x04001EDE RID: 7902
|
|
public RectTransform rectTransform;
|
|
|
|
// Token: 0x04001EDF RID: 7903
|
|
public RectTransform rectTransformBlack;
|
|
|
|
// Token: 0x04001EE0 RID: 7904
|
|
public int videoWidth;
|
|
|
|
// Token: 0x04001EE1 RID: 7905
|
|
public int videoHeight;
|
|
|
|
// Token: 0x04001EE2 RID: 7906
|
|
public GameObject textObject;
|
|
|
|
// Token: 0x04001EE3 RID: 7907
|
|
private RenderTexture rt;
|
|
}
|