Files
BepInEx/Projects/BanquetForFools/Source/Assembly-CSharp/Vignettes.cs
2025-05-21 20:40:04 +02:00

754 lines
21 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using Colorful;
using DarkTonic.MasterAudio;
using Kino;
using MagicaCloth2;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
// Token: 0x02000056 RID: 86
public class Vignettes : MonoBehaviour
{
// Token: 0x06000B00 RID: 2816 RVA: 0x000DADD0 File Offset: 0x000D8FD0
private void Awake()
{
this.cam.enabled = true;
foreach (object obj in base.transform)
{
Transform transform = (Transform)obj;
if (transform != base.transform && transform.name != "Camera")
{
transform.gameObject.SetActive(false);
}
}
this.lookAtObject = new GameObject("Look at");
this.lookAtObject.transform.parent = base.transform;
this.cameraObscurance.enabled = true;
base.StartCoroutine(this.ObsOff());
}
// Token: 0x06000B01 RID: 2817 RVA: 0x000DAE9C File Offset: 0x000D909C
private IEnumerator ObsOff()
{
this.Setup(null, "Vignette_GarrisonExteriorA");
this.cameraObscurance.enabled = true;
yield return new WaitForSeconds(0.2f);
this.Setup(null, "Vignette_BanquetIsland_Start");
this.cameraObscurance.enabled = true;
yield return new WaitForSeconds(0.2f);
this.cam.enabled = false;
this.cameraObscurance.enabled = false;
this.End();
yield break;
}
// Token: 0x06000B02 RID: 2818 RVA: 0x000DAEAB File Offset: 0x000D90AB
public void NewDialogue()
{
this.newDialogue = true;
}
// Token: 0x06000B03 RID: 2819 RVA: 0x000DAEB4 File Offset: 0x000D90B4
public void Setup(Character vignetteCharacter, string vignetteName)
{
if (!vignetteCharacter)
{
return;
}
if (QualitySettings.antiAliasing == 0)
{
this.cam.targetTexture = this.noAA;
}
else if (QualitySettings.antiAliasing == 2)
{
this.cam.targetTexture = this.aa2;
}
else if (QualitySettings.antiAliasing == 4)
{
this.cam.targetTexture = this.aa4;
}
else if (QualitySettings.antiAliasing == 8)
{
this.cam.targetTexture = this.aa8;
}
this.dialogueVignette.texture = this.cam.targetTexture;
if (vignetteName.Contains("SemizenStatue"))
{
vignetteCharacter = null;
}
if ((vignetteName == "Vignette Example" || vignetteName == "") && vignetteCharacter)
{
vignetteName = "Blank";
}
if (vignetteCharacter && vignetteCharacter.stats.xmlName.Contains("RenazinSpy"))
{
if (Links.x.gameplay.IsDay())
{
vignetteName = "Vignette_Exterior_TreeGrassHill_B";
}
else
{
vignetteName = "Vignette_CaveA";
}
}
GameObject gameObject = this.vignettes[0];
for (int i = 0; i < this.vignettes.Count; i++)
{
if (this.vignettes[i].name == vignetteName)
{
gameObject = this.vignettes[i];
}
}
if (vignetteCharacter)
{
this.characterName = vignetteCharacter.name;
}
this.currentVignette = Object.Instantiate<GameObject>(gameObject, new Vector3(0f, 0f, 0f), Quaternion.identity, base.transform);
this.currentVignette.transform.localPosition = Vector3.zero;
this.currentVignette.SetActive(true);
this.trs = this.currentVignette.GetComponentsInChildren<Transform>();
float num = 0f;
foreach (Transform transform in this.trs)
{
if (transform.gameObject.name == "Point" || transform.gameObject.name.Contains("CharacterPosition"))
{
this.point = transform;
}
if (transform.gameObject.GetComponent<Camera>())
{
this.vignCamera = transform.gameObject.GetComponent<Camera>();
}
transform.gameObject.layer = 25;
MeshRenderer component = transform.gameObject.GetComponent<MeshRenderer>();
if (component)
{
this.mats = component.materials;
foreach (Material material in this.mats)
{
if (material.HasProperty("_InMenu"))
{
material.SetFloat("_InMenu", 1f);
}
else if (!material.shader.name.Contains("Unlit") && !material.shader.name.Contains("River"))
{
material.shader = this.litShader;
}
}
}
Light component2 = transform.gameObject.GetComponent<Light>();
if (component2)
{
component2.cullingMask = 33554432;
}
if (transform.gameObject.GetComponent<ParticleSystem>())
{
if (transform.GetComponent<ParticleSystemRenderer>().material.HasProperty("_Fog"))
{
transform.GetComponent<ParticleSystemRenderer>().material.SetFloat("_Fog", 0f);
}
if (transform.GetComponent<ParticleSystemRenderer>().material.HasProperty("_InMenu"))
{
transform.GetComponent<ParticleSystemRenderer>().material.SetFloat("_InMenu", 1f);
}
}
if (transform.gameObject.GetComponent<MagicaWindZone>())
{
transform.gameObject.SetActive(false);
}
}
this.cam.gameObject.transform.position = this.vignCamera.gameObject.transform.position;
this.cam.gameObject.transform.rotation = this.vignCamera.gameObject.transform.rotation;
this.cam.fieldOfView = this.vignCamera.fieldOfView;
this.cam.nearClipPlane = this.vignCamera.nearClipPlane;
this.cam.farClipPlane = this.vignCamera.farClipPlane;
this.vignCamera.enabled = false;
this.vignCamera.gameObject.SetActive(false);
Bokeh component3 = this.vignCamera.GetComponent<Bokeh>();
Obscurance component4 = this.vignCamera.GetComponent<Obscurance>();
if (!component3)
{
this.cameraBokeh.enabled = false;
}
else
{
this.cameraBokeh.enabled = false;
this.cameraBokeh.pointOfFocus = component3.pointOfFocus;
if (component3.pointOfFocus == null)
{
this.cameraBokeh.pointOfFocus = this.point;
}
this.cameraBokeh.focusDistance = component3.focusDistance;
this.cameraBokeh.fNumber = component3.fNumber;
this.cameraBokeh.useCameraFov = component3.useCameraFov;
this.cameraBokeh.focalLength = component3.focalLength * 0.65f;
}
if (!component4)
{
if (!vignetteCharacter)
{
this.cameraObscurance.enabled = false;
}
else
{
this.cameraObscurance.enabled = true;
this.cameraObscurance.intensity = 3f;
this.cameraObscurance.radius = 0.1f;
}
}
else
{
this.cameraObscurance.enabled = true;
this.cameraObscurance.intensity = component4.intensity;
this.cameraObscurance.radius = component4.radius;
}
if (vignetteName == "SemizenStatue_D5_WestRuins")
{
this.wiggle = this.cam.gameObject.AddComponent<Wiggle>();
}
else if (vignetteName.Contains("Semizen") && (vignetteName.Contains("C6") || vignetteName.Contains("C5") || vignetteName.Contains("Chora")))
{
this.doubleVision = this.cam.gameObject.AddComponent<DoubleVision>();
}
Character character = this.character;
this.character = vignetteCharacter;
if (this.body)
{
this.body.GatherRenderers(false);
}
if (this.currentModel != null)
{
if (this.currentModel.GetComponent<Animator>())
{
this.currentModel.GetComponent<Animator>().updateMode = AnimatorUpdateMode.Normal;
}
this.RecycleModel(character.name);
}
this.cam.enabled = true;
if (component3)
{
this.cameraBokeh.enabled = true;
}
this.useLookAt = true;
if (this.character)
{
string text = this.character.stats.model;
if (this.character.stats.xmlName == "LazureCaferaMerchant")
{
text = "Merchant_Cafera";
}
if (vignetteName.Contains("Vignette_RozafirBathsSitting"))
{
if (this.character.stats.race != "Yeti")
{
if (this.character.stats.sex < 0.5f)
{
text = "Undies_Maya_Volling_Female";
}
else
{
text = "Undies_Maya_Volling_Male";
}
}
else
{
text = "Player_LazureGuardsmanYeti";
}
}
this.currentModel = Links.x.archives.InstantiateBody(text, this.point);
this.crossfadeFX.StartCrossFade();
this.currentModel.SetActive(true);
this.body = this.currentModel.GetComponent<Body>();
this.body.Reset();
this.bodyCharacter = this.character;
this.body.model = text;
this.body.name = text;
string text2 = "_Volling_Dialogue_Basic";
bool flag = false;
this.lookAtObject.transform.position = this.cam.transform.position;
float num2 = -0.2f;
if (this.character.party && flag)
{
text2 = this.character.animator.runtimeAnimatorController.name;
}
else
{
num = -12f;
if (this.animController == "Left")
{
text2 = "_Volling_Dialogue_Basic";
num = 15f;
}
else if (this.animController == "Right")
{
text2 = "_Volling_Dialogue_Basic";
num = -35f;
}
if (this.character.stats.xmlName == "Pavura")
{
text2 = "_Volling_Dialogue_Pavura";
num = 0f;
num2 = 0f;
}
else if (this.character.stats.xmlName == "LazureGuardDayGateB")
{
text2 = "_Volling_Dialogue_Ferka";
num = 0f;
num2 = 0f;
}
else if (this.character.stats.xmlName == "LazureCaferaMerchant")
{
text2 = "_Volling_Dialogue_Cafera";
num = 0f;
num2 = 0f;
}
else if (this.character.stats.xmlName == "BanquetIsleFriend")
{
text2 = "_Volling_Dialogue_BanquetIsleFriend";
num = 0f;
num2 = 0f;
}
else if (this.character.stats.xmlName == "LazureForfeitsChild")
{
text2 = "_Volling_Dialogue_ForfeitsKid";
num = 0f;
num2 = 0f;
}
else if (this.character.stats.xmlName.Contains("Fairy"))
{
text2 = "_Fairy_Unarmed";
num = 0f;
num2 = 0f;
}
else if (this.character.stats.xmlName.Contains("Dryad"))
{
text2 = "_Volling_Dialogue_Dryad";
num = 0f;
}
else if (Links.x.dialogue.diaFile == "LazureCaves/MissingDryad")
{
text2 = "_Volling_Dialogue_DryadFlower";
num = 0f;
}
else if (vignetteName.Contains("Vignette_RozafirBathsSitting"))
{
text2 = "_Volling_Dialogue_Baths";
num = 0f;
num2 = 0f;
this.cam.depthTextureMode |= DepthTextureMode.DepthNormals;
}
else if (this.character.stats.xmlName.Contains("Boro") && this.character.stats.animal)
{
text2 = "_Boro_Unarmed";
num = 0f;
num2 = 0f;
}
}
AnimatorOverrideController overrideController = Links.x.archives.GetOverrideController(text2);
this.body.animationPrefix = this.character.animationPrefix;
if (!this.body.anim)
{
this.body.anim = this.body.gameObject.GetComponent<Animator>();
if (!this.body.anim)
{
Debug.Log("no animator");
}
}
this.body.inMenu = true;
this.body.isPortrait = false;
this.body.anim.runtimeAnimatorController = overrideController;
if (Time.timeScale < 0.5f)
{
this.body.anim.updateMode = AnimatorUpdateMode.UnscaledTime;
}
else
{
this.body.anim.updateMode = AnimatorUpdateMode.Normal;
}
this.body.anim.applyRootMotion = true;
this.body.gameObject.layer = 25;
this.body.SetGrounderState(false);
this.body.SetupHead(this.bodyCharacter.stats.headModel);
if (this.body.GetHead())
{
this.cameraBokeh.pointOfFocus = this.body.GetHead();
}
this.body.GatherRenderers(true);
this.body.SetupTextures(this.character.stats.race, this.character.stats.sex, this.character.stats.characterRow, this.character.stats.skinTexture, this.character.stats.hairTexture, false);
int invNum = this.character.GetInvNum(16);
int num3 = 0;
if (text2.Contains("DryadFlower"))
{
num3 = Links.x.library.GetInvRowFromName("DryadFlower")._ID;
this.useLookAt = false;
}
int invNum2 = this.character.GetInvNum(24);
if (invNum > 1 || invNum2 > 1 || num3 > 1)
{
this.SetupEquippedItems(this.body, invNum, invNum2, num3);
}
this.body.gameObject.layer = 25;
this.currentModel.transform.localPosition = new Vector3(0f, 0f, 0f);
if (vignetteCharacter.isBoro)
{
this.currentModel.transform.localPosition = new Vector3(0f, 2f, 0f);
}
if (vignetteCharacter.stats.race == "Yeti")
{
this.currentModel.transform.localPosition = new Vector3(0f, -0.45f, 0f);
}
else if (vignetteCharacter.stats.race == "Varuchov" || vignetteCharacter.stats.race == "Taratorith" || vignetteCharacter.stats.race == "Pasaaren" || vignetteCharacter.stats.race == "Ameythevian")
{
this.currentModel.transform.localPosition = new Vector3(0f, num2, 0f);
}
Vector3 eulerAngles = this.point.rotation.eulerAngles;
eulerAngles.y += num;
this.currentModel.transform.rotation = Quaternion.Euler(eulerAngles);
if (this.animController == "Left" || this.animController == "Right")
{
this.lookAtObject.transform.position = this.body.transform.position + this.body.transform.forward * 10f;
this.lookAtObject.transform.position = new Vector3(this.lookAtObject.transform.position.x, this.cam.transform.position.y, this.lookAtObject.transform.position.z);
}
this.LookAt();
this.SetFont(this.character.stats.race, false);
if (this.body.headAnim)
{
this.body.headAnim.FreshBlink();
}
if (!this.useLookAt)
{
this.body.lookAtController.EndLook();
}
}
if (this.newDialogue)
{
base.StartCoroutine(this.Bokeh(component3));
}
this.newDialogue = false;
}
// Token: 0x06000B04 RID: 2820 RVA: 0x000DBDC3 File Offset: 0x000D9FC3
public void LookAt()
{
if (this.useLookAt && this.body)
{
this.body.lookAtController.SetNewTarget(this.lookAtObject.transform, 0f, 0f, false);
}
}
// Token: 0x06000B05 RID: 2821 RVA: 0x000DBE00 File Offset: 0x000DA000
private IEnumerator Bokeh(bool enable)
{
this.cameraBokeh.enabled = false;
yield return new WaitForSeconds(0.0001f);
this.cameraBokeh.enabled = enable;
yield return new WaitForSeconds(0.1f);
this.LookAt();
yield break;
}
// Token: 0x06000B06 RID: 2822 RVA: 0x000DBE18 File Offset: 0x000DA018
public int AnimatorHash()
{
if (this.body && this.body.anim)
{
return this.body.anim.GetCurrentAnimatorStateInfo(0).shortNameHash;
}
return -1;
}
// Token: 0x06000B07 RID: 2823 RVA: 0x000DBE5F File Offset: 0x000DA05F
public void PlayAnimation(string animName, bool crossFade)
{
this.newLineAnimation = true;
if (this.body)
{
this.body.anim.Play(animName, -1, 0f);
}
if (crossFade)
{
this.crossfadeFX.StartCrossFade();
}
}
// Token: 0x06000B08 RID: 2824 RVA: 0x000DBE9C File Offset: 0x000DA09C
public void SetupEquippedItems(Body body, int id8, int id12, int id0)
{
body.CreateMenuItems(id8, 1, new Vector3(-1f, -1f, -1f), new Vector3(-1f, -1f, -1f), new Vector2(100f, 100f), 8, null);
if (id0 > 1)
{
body.CreateMenuItems(id0, 1, new Vector3(-1f, -1f, -1f), new Vector3(-1f, -1f, -1f), new Vector2(100f, 100f), 0, null);
}
body.CreateMenuItems(id12, 1, new Vector3(-1f, -1f, -1f), new Vector3(-1f, -1f, -1f), new Vector2(100f, 100f), 12, null);
}
// Token: 0x06000B09 RID: 2825 RVA: 0x000DBF84 File Offset: 0x000DA184
public void RecycleModel(string n)
{
Links.x.archives.RecycleBody(this.currentModel, this.body.model, n);
if (this.currentModel)
{
this.currentModel.SetActive(false);
}
this.currentModel = null;
this.body = null;
}
// Token: 0x06000B0A RID: 2826 RVA: 0x000DBFDC File Offset: 0x000DA1DC
public void SetFont(string race, bool excited)
{
if (excited)
{
this.textField1.font = this.fontAssetExcited;
this.textField2.font = this.fontAssetExcited;
this.textField3.font = this.fontAssetExcited;
return;
}
if (race == "Yeti")
{
this.textField1.font = this.fontAssetYeti;
this.textField2.font = this.fontAssetYeti;
this.textField3.font = this.fontAssetYeti;
return;
}
if (race == "Ameythevian")
{
this.textField1.font = this.fontAssetAmeythevian;
this.textField2.font = this.fontAssetAmeythevian;
this.textField3.font = this.fontAssetAmeythevian;
return;
}
if (race == "Varuchov")
{
this.textField1.font = this.fontAssetVaruchov;
this.textField2.font = this.fontAssetVaruchov;
this.textField3.font = this.fontAssetVaruchov;
return;
}
if (race == "Pasaaren")
{
this.textField1.font = this.fontAssetPasaaren;
this.textField2.font = this.fontAssetPasaaren;
this.textField3.font = this.fontAssetPasaaren;
return;
}
if (race == "Taratorith")
{
this.textField1.font = this.fontAssetTaratorith;
this.textField2.font = this.fontAssetTaratorith;
this.textField3.font = this.fontAssetTaratorith;
return;
}
this.textField1.font = this.fontAssetVaruchov;
this.textField2.font = this.fontAssetVaruchov;
this.textField3.font = this.fontAssetVaruchov;
}
// Token: 0x06000B0B RID: 2827 RVA: 0x000DC198 File Offset: 0x000DA398
public void End()
{
this.cam.enabled = false;
if (this.wiggle)
{
Object.Destroy(this.wiggle);
this.wiggle = null;
}
if (this.doubleVision)
{
Object.Destroy(this.doubleVision);
this.doubleVision = null;
}
if (this.body)
{
this.body.GatherRenderers(false);
}
if (this.currentModel != null)
{
this.body.lookAtController.EndLookFast(false);
if (this.currentModel.GetComponent<Animator>())
{
this.currentModel.GetComponent<Animator>().updateMode = AnimatorUpdateMode.Normal;
}
this.RecycleModel(this.characterName);
}
if (this.inCinematic != "")
{
this.EndCinematic(this.inCinematic);
}
this.inCinematic = "";
if (this.currentVignette)
{
Object.Destroy(this.currentVignette);
}
}
// Token: 0x06000B0C RID: 2828 RVA: 0x000DC298 File Offset: 0x000DA498
public void BanquetIsleCompanion()
{
this.body.faceRenderer.material.SetTexture("_MainTex", Links.x.cinematicLachoTextureSwap1);
this.fx1ID = 78;
this.fx1 = Links.x.cellar.GetPooledGameObject(this.fx1ID);
this.fxPrevLayer = this.fx1.layer;
this.fx1.transform.position = this.body.transform.position + new Vector3(0f, 1f, 0f);
this.fx1.SetActive(true);
this.fx1.layer = 25;
if (this.fx1.GetComponent<ParticleSystemRenderer>().material.HasProperty("_Fog"))
{
this.fx1.GetComponent<ParticleSystemRenderer>().material.SetFloat("_Fog", 1f);
}
if (this.fx1.GetComponent<ParticleSystemRenderer>().material.HasProperty("_InMenu"))
{
this.fx1.GetComponent<ParticleSystemRenderer>().material.SetFloat("_InMenu", 1f);
}
this.body.anim.Play("Distress");
MasterAudio.PlaySound3DAtVector3AndForget("BloodlessTurn", Links.x.main.transform.position, 1f, new float?(1f), 0f, "", null);
MasterAudio.PlaySound3DAtVector3AndForget("Choking", Links.x.main.transform.position, 1f, new float?(1f), 0.1f, "", null);
this.inCinematic = "BanquetIsleCompanion";
}
// Token: 0x06000B0D RID: 2829 RVA: 0x000DC468 File Offset: 0x000DA668
private void EndCinematic(string type)
{
if (type == "BanquetIsleCompanion" && this.fx1 != null)
{
this.fx1.layer = this.fxPrevLayer;
this.fx1.SetActive(false);
if (this.fx1.GetComponent<ParticleSystemRenderer>().material.HasProperty("_Fog"))
{
this.fx1.GetComponent<ParticleSystemRenderer>().material.SetFloat("_Fog", 0f);
}
if (this.fx1.GetComponent<ParticleSystemRenderer>().material.HasProperty("_InMenu"))
{
this.fx1.GetComponent<ParticleSystemRenderer>().material.SetFloat("_InMenu", 0f);
}
Links.x.cellar.ReturnPooledGameObject(this.fx1ID, this.fx1);
this.fx1 = null;
}
}
// Token: 0x04000FD2 RID: 4050
public List<GameObject> vignettes = new List<GameObject>();
// Token: 0x04000FD3 RID: 4051
public Camera cam;
// Token: 0x04000FD4 RID: 4052
public Character character;
// Token: 0x04000FD5 RID: 4053
private GameObject currentModel;
// Token: 0x04000FD6 RID: 4054
public Body body;
// Token: 0x04000FD7 RID: 4055
private Character bodyCharacter;
// Token: 0x04000FD8 RID: 4056
private Transform point;
// Token: 0x04000FD9 RID: 4057
private Camera vignCamera;
// Token: 0x04000FDA RID: 4058
public MenuCameraCrossFade crossfadeFX;
// Token: 0x04000FDB RID: 4059
private GameObject currentVignette;
// Token: 0x04000FDC RID: 4060
private Transform[] trs = new Transform[0];
// Token: 0x04000FDD RID: 4061
private GameObject fx1;
// Token: 0x04000FDE RID: 4062
private int fx1ID;
// Token: 0x04000FDF RID: 4063
private int fxPrevLayer;
// Token: 0x04000FE0 RID: 4064
private string inCinematic;
// Token: 0x04000FE1 RID: 4065
public TMP_FontAsset fontAssetVaruchov;
// Token: 0x04000FE2 RID: 4066
public TMP_FontAsset fontAssetPasaaren;
// Token: 0x04000FE3 RID: 4067
public TMP_FontAsset fontAssetAmeythevian;
// Token: 0x04000FE4 RID: 4068
public TMP_FontAsset fontAssetYeti;
// Token: 0x04000FE5 RID: 4069
public TMP_FontAsset fontAssetTaratorith;
// Token: 0x04000FE6 RID: 4070
public TMP_FontAsset fontAssetExcited;
// Token: 0x04000FE7 RID: 4071
public TextMeshPro textField1;
// Token: 0x04000FE8 RID: 4072
public TextMeshPro textField2;
// Token: 0x04000FE9 RID: 4073
public TextMeshPro textField3;
// Token: 0x04000FEA RID: 4074
private Material[] mats;
// Token: 0x04000FEB RID: 4075
public Shader litShader;
// Token: 0x04000FEC RID: 4076
public Bokeh cameraBokeh;
// Token: 0x04000FED RID: 4077
public Obscurance cameraObscurance;
// Token: 0x04000FEE RID: 4078
public RenderTexture noAA;
// Token: 0x04000FEF RID: 4079
public RenderTexture aa2;
// Token: 0x04000FF0 RID: 4080
public RenderTexture aa4;
// Token: 0x04000FF1 RID: 4081
public RenderTexture aa8;
// Token: 0x04000FF2 RID: 4082
public RawImage dialogueVignette;
// Token: 0x04000FF3 RID: 4083
private bool newDialogue;
// Token: 0x04000FF4 RID: 4084
private string characterName;
// Token: 0x04000FF5 RID: 4085
public bool newLineAnimation;
// Token: 0x04000FF6 RID: 4086
public string animController;
// Token: 0x04000FF7 RID: 4087
private GameObject lookAtObject;
// Token: 0x04000FF8 RID: 4088
private Wiggle wiggle;
// Token: 0x04000FF9 RID: 4089
private DoubleVision doubleVision;
// Token: 0x04000FFA RID: 4090
private bool useLookAt;
}