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

521 lines
15 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using Pathfinding;
using PixelCrushers.DialogueSystem;
using UnityEngine;
using UnityEngine.SceneManagement;
// Token: 0x02000038 RID: 56
public class MapExitActions : MonoBehaviour
{
// Token: 0x060007E6 RID: 2022 RVA: 0x000AEA6C File Offset: 0x000ACC6C
public void Setup()
{
this.box = base.gameObject.GetComponent<BoxCollider>();
this.box.isTrigger = false;
Transform[] componentsInChildren = base.gameObject.GetComponentsInChildren<Transform>(true);
this.lights.Clear();
for (int i = 0; i < componentsInChildren.Length; i++)
{
if (componentsInChildren[i].gameObject.GetComponent<Light>())
{
this.lights.Add(componentsInChildren[i].gameObject.GetComponent<Light>());
componentsInChildren[i].gameObject.GetComponent<Light>().enabled = false;
}
else
{
if (componentsInChildren[i] != base.transform && componentsInChildren[i].name.Contains("oint"))
{
this.spawnPoint = componentsInChildren[i];
}
if (componentsInChildren[i].gameObject.GetComponent<Door>())
{
this.door = componentsInChildren[i].gameObject.GetComponent<Door>();
}
}
}
if (this.lights.Count == 0 && this.spawnPoint)
{
GameObject gameObject = new GameObject("Door Light");
gameObject.transform.SetParent(base.gameObject.transform);
gameObject.transform.position = this.spawnPoint.position;
Light light = gameObject.AddComponent<Light>();
light.range = 7f;
light.enabled = false;
light.gameObject.SetActive(false);
this.lights.Add(light);
}
if (!this.spawnPoint && this.lights.Count > 0)
{
this.spawnPoint = this.lights[0].gameObject.transform;
}
this.sceneTo = this.mapExit.exitTo.ToString();
GameObject gameObject2 = GameObject.Find("Diorama");
this.mapChangeScene = SceneManager.GetSceneByName(gameObject2.GetComponent<Diorama>().sceneName);
this.sceneFrom = gameObject2.GetComponent<Diorama>().sceneName;
this.subExit = this.mapExit.subExit.ToString();
this.mapExit.doorPoint = this.spawnPoint.position;
if (Links.x)
{
this.Icon();
}
}
// Token: 0x060007E7 RID: 2023 RVA: 0x000AECA0 File Offset: 0x000ACEA0
private void Icon()
{
if (!this.icon)
{
if (!this.inBeta)
{
this.icon = Links.x.cellar.GetPooledGameObject(134);
this.icon.GetComponent<MapExitIcon>().mapExit = this;
this.icon.GetComponent<MapExitIcon>().beach = false;
this.icon.transform.position = this.NormalIconPosition();
this.icon.layer = 13;
this.box.enabled = true;
this.box.gameObject.layer = 8;
this.icon.transform.parent = base.transform.parent;
this.iconSprite = this.icon.GetComponent<SpriteRenderer>();
if (this.mapExit.exitTo == MapExit.exitToNames.Interiors || this.mapExit.exitTo == MapExit.exitToNames.Exterior)
{
this.iconSprite.sprite = Links.x.doorIconLocal;
}
else
{
this.iconSprite.sprite = Links.x.doorIconGlobal;
}
this.icon.SetActive(true);
this.iconSprite.material = Links.x.doorIconNormal;
return;
}
this.box.gameObject.layer = 8;
}
}
// Token: 0x060007E8 RID: 2024 RVA: 0x000AEDEB File Offset: 0x000ACFEB
public Vector3 GetIconPosition()
{
if (this.icon)
{
return this.icon.transform.position + new Vector3(0f, 0.9f, 0f);
}
return this.GetColliderCenter();
}
// Token: 0x060007E9 RID: 2025 RVA: 0x000AEE2A File Offset: 0x000AD02A
public void SetSprite(bool isLocked)
{
if (isLocked)
{
this.iconSprite.sprite = Links.x.doorIconLocked;
return;
}
this.iconSprite.sprite = Links.x.doorIconLocal;
}
// Token: 0x060007EA RID: 2026 RVA: 0x000AEE5C File Offset: 0x000AD05C
private void OnDestroy()
{
if (Links.x && Links.x.cellar && this.icon)
{
Links.x.cellar.ReturnPooledGameObject(134, this.icon);
}
}
// Token: 0x060007EB RID: 2027 RVA: 0x000AEEB0 File Offset: 0x000AD0B0
public void SetupNodeLink()
{
if (this.mapExit.exitTo == MapExit.exitToNames.Interiors || this.mapExit.exitTo == MapExit.exitToNames.Exterior)
{
bool flag = false;
if (this.mapExit.exitTo == MapExit.exitToNames.Interiors)
{
flag = true;
}
this.connectionExit = null;
if (flag)
{
this.connectionExit = Links.x.diorama.MatchMapExitInteriorExterior(flag, this.mapExit.interiorConnection, this.mapExit);
}
else
{
this.connectionExit = Links.x.diorama.MatchMapExitInteriorExterior(flag, this.mapExit.exteriorConnection, this.mapExit);
}
if (this.connectionExit && !this.connectionExit.GetComponent<MapExitActions>().nodeLink)
{
this.nodeLink = this.spawnPoint.gameObject.GetComponent<NodeLink>();
if (!this.nodeLink)
{
this.nodeLink = this.spawnPoint.gameObject.AddComponent<NodeLink>();
}
this.nodeLink.end = this.connectionExit.doorPoint;
this.nodeLink.SetLinks();
}
if (Links.x.main.node != null)
{
this.PartyInRoom(Links.x.main.node.Area);
}
}
}
// Token: 0x060007EC RID: 2028 RVA: 0x000AEFF1 File Offset: 0x000AD1F1
public void SetDoorPoint(Vector3 clickedPosition)
{
this.mapExit.doorPoint = clickedPosition;
if (this.lights.Count > 0)
{
this.lights[0].transform.position = clickedPosition;
}
}
// Token: 0x060007ED RID: 2029 RVA: 0x000AF024 File Offset: 0x000AD224
private void Start()
{
this.box = base.gameObject.GetComponent<BoxCollider>();
this.box.isTrigger = false;
if (this.lights.Count == 0)
{
this.Setup();
}
else
{
this.Icon();
}
for (int i = 0; i < this.lights.Count; i++)
{
this.lights[i].gameObject.SetActive(false);
}
this.sceneTo = this.mapExit.exitTo.ToString();
this.subExit = this.mapExit.subExit.ToString();
this.mapExit.doorPoint = this.spawnPoint.position;
if (!this.hoverMeshRenderer)
{
foreach (object obj in base.transform)
{
Transform transform = (Transform)obj;
if (transform.gameObject.GetComponent<MeshRenderer>() && !transform.gameObject.name.Contains("Blocker") && this.lights.Count == 0)
{
this.hoverMeshRenderer = transform.gameObject.GetComponent<MeshRenderer>();
this.hoverMeshRenderer.enabled = false;
GameObject gameObject = new GameObject("Door Light");
gameObject.transform.SetParent(base.gameObject.transform);
gameObject.transform.position = this.hoverMeshRenderer.gameObject.transform.position;
Light light = gameObject.AddComponent<Light>();
light.range = this.hoverMeshRenderer.bounds.size.x;
light.enabled = false;
light.gameObject.SetActive(false);
this.lights.Add(light);
}
}
}
}
// Token: 0x060007EE RID: 2030 RVA: 0x000AF224 File Offset: 0x000AD424
public Vector3 NormalIconPosition()
{
if (this.mapExit.exitTo == MapExit.exitToNames.Interiors || this.mapExit.exitTo == MapExit.exitToNames.Exterior)
{
return Vector3.Lerp(this.spawnPoint.transform.position + new Vector3(0f, 3f, 0f), this.box.transform.position, 0.5f);
}
return this.spawnPoint.position + new Vector3(0f, 1.5f, 0f);
}
// Token: 0x060007EF RID: 2031 RVA: 0x000AF2B8 File Offset: 0x000AD4B8
public void PartyInRoom(uint area)
{
if (this.mapExit.exitTo == MapExit.exitToNames.Interiors || this.mapExit.exitTo == MapExit.exitToNames.Exterior)
{
if (Links.x.worldCamera.orthographic)
{
this.icon.transform.position = this.NormalIconPosition();
return;
}
if (this.nodeLink != null && this.nodeLink.startNode != null && this.nodeLink.startNode.Area == area)
{
bool flag = false;
for (int i = 0; i < 10; i++)
{
if (!flag)
{
Vector3 position = this.icon.transform.position;
float num = 0.5f;
Vector3 right = Links.x.worldCamera.gameObject.transform.right;
Vector3 forward = Links.x.worldCamera.gameObject.transform.forward;
Vector3 vector = position + right * num - new Vector3(0f, 0.5f, 0f);
Vector3 vector2 = position + right * num * -1f - new Vector3(0f, 0.5f, 0f);
Vector3 vector3 = vector + new Vector3(0f, 1f, 0f);
Vector3 vector4 = vector2 + new Vector3(0f, 1f, 0f);
Camera worldCamera = Links.x.worldCamera;
int width = Screen.width;
int height = Screen.height;
Vector3 vector5 = worldCamera.WorldToScreenPoint(vector2);
Vector3 vector6 = worldCamera.WorldToScreenPoint(vector);
Vector3 vector7 = worldCamera.WorldToScreenPoint(vector3);
Vector3 vector8 = worldCamera.WorldToScreenPoint(vector4);
if ((vector5.x <= 0f && vector8.x <= 0f) || (vector6.x >= (float)width && vector7.x >= (float)width) || (vector5.y <= 0f && vector6.y <= 0f) || (vector7.y >= (float)height && vector8.y >= (float)height))
{
if (vector6.x <= 0f && vector7.x <= 0f)
{
this.icon.transform.position += right * 0.5f;
}
if (vector6.x >= (float)width && vector7.x >= (float)width)
{
this.icon.transform.position -= right * 0.5f;
}
if (vector5.y <= 0f && vector6.y <= 0f)
{
this.icon.transform.position += forward * 0.5f;
this.icon.transform.position = new Vector3(this.icon.transform.position.x, this.icon.transform.position.y + 0.5f, this.icon.transform.position.z);
}
if (vector8.y >= (float)height && vector7.y >= (float)height)
{
this.icon.transform.position -= forward * 0.5f;
this.icon.transform.position = new Vector3(this.icon.transform.position.x, this.icon.transform.position.y - 0.5f, this.icon.transform.position.z);
}
}
else
{
flag = true;
}
}
}
}
}
}
// Token: 0x060007F0 RID: 2032 RVA: 0x000AF6B0 File Offset: 0x000AD8B0
public Vector3 GetLightPoint()
{
if (this.lights.Count > 0)
{
return this.lights[0].gameObject.transform.position + new Vector3(0f, 1f, 0f);
}
return this.spawnPoint.position;
}
// Token: 0x060007F1 RID: 2033 RVA: 0x000AF70C File Offset: 0x000AD90C
public Vector3 GetColliderCenter()
{
this.bounds = this.box.bounds;
return this.bounds.center + new Vector3(0f, this.bounds.size.y / 2f, 0f);
}
// Token: 0x060007F2 RID: 2034 RVA: 0x000AF75F File Offset: 0x000AD95F
public void InRange()
{
}
// Token: 0x060007F3 RID: 2035 RVA: 0x000AF761 File Offset: 0x000AD961
public void OutOfRange()
{
}
// Token: 0x060007F4 RID: 2036 RVA: 0x000AF764 File Offset: 0x000AD964
public void Use()
{
bool flag = false;
if (!this.visited)
{
flag = true;
Transform parent = base.gameObject.transform.parent;
Transform transform = base.transform;
if (parent && parent.childCount > 1)
{
foreach (object obj in parent)
{
Transform transform2 = (Transform)obj;
if (transform2 != transform)
{
MapExitActions component = transform2.gameObject.GetComponent<MapExitActions>();
if (component && component.visited)
{
flag = false;
}
}
}
}
}
if (this.mapExit.locationText != "" && flag)
{
Links.x.dialogue.PlayLocationText(this.mapExit.locationText);
}
this.visited = true;
this.hovering = false;
}
// Token: 0x060007F5 RID: 2037 RVA: 0x000AF85C File Offset: 0x000ADA5C
public void GoThroughDoor()
{
if (Links.x.sceneMap.undergroundMap)
{
Links.x.sceneMap.undergroundMap.UsedDoor(this.mapExit);
return;
}
Links.x.gaia.SetSavedExit(Links.x.diorama.sceneName, this.mapExit.subExit.ToString());
}
// Token: 0x060007F6 RID: 2038 RVA: 0x000AF8D0 File Offset: 0x000ADAD0
public void Leave()
{
if (this.mapExit.questName != Creatures.Adventures.None)
{
string text = this.mapExit.questName.ToString();
QuestState questState = QuestLog.GetQuestState(text);
QuestState questState2 = Records.x.StringToQuestState(this.mapExit.ifIsQuestState.ToString());
QuestState questState3 = Records.x.StringToQuestState(this.mapExit.thenSetQuestTo.ToString());
Debug.Log(string.Concat(new string[]
{
"Setting map exit quest trigger: ",
text,
", current: ",
questState.ToString(),
", if is: ",
this.mapExit.ifIsQuestState.ToString(),
", change to: ",
this.mapExit.thenSetQuestTo.ToString()
}));
if (questState == questState2)
{
QuestLog.SetQuestState(text, questState3);
}
if (text.Contains("GobletGuildThieves"))
{
questState = QuestLog.GetQuestState("C6_GobletGuildThievesB");
if (questState == questState2)
{
QuestLog.SetQuestState("C6_GobletGuildThievesB", questState3);
}
questState = QuestLog.GetQuestState("C6_GobletGuildThievesC");
if (questState == questState2)
{
QuestLog.SetQuestState("C6_GobletGuildThievesC", questState3);
}
}
}
this.GoThroughDoor();
}
// Token: 0x060007F7 RID: 2039 RVA: 0x000AFA18 File Offset: 0x000ADC18
public void Hover(bool state)
{
this.hovering = state;
if (this.iconSprite)
{
if (state)
{
this.iconSprite.material = Links.x.doorIconHover;
}
else
{
this.iconSprite.material = Links.x.doorIconNormal;
}
}
if (state && this.doorActions && this.doorActions.door.locked)
{
return;
}
for (int i = 0; i < this.lights.Count; i++)
{
if (state)
{
Links.x.hoverObject = base.gameObject;
Shader.SetGlobalVector("_DoorLightPosition", this.lights[i].gameObject.transform.position);
Records.x.hoverLightColor = this.lights[i].color * (this.lights[i].intensity / 4f) * 4f;
Shader.SetGlobalFloat("_DoorLightRange", this.lights[i].range);
}
else if (this.corout == null && (Links.x.hoverObject == base.gameObject || Links.x.hoverObject == null))
{
Links.x.hoverObject = null;
}
}
}
// Token: 0x060007F8 RID: 2040 RVA: 0x000AFB81 File Offset: 0x000ADD81
public void Near(bool state)
{
this.near = state;
if (state && this.doorActions)
{
bool locked = this.doorActions.door.locked;
return;
}
}
// Token: 0x04000C4F RID: 3151
public MapExit mapExit;
// Token: 0x04000C50 RID: 3152
public List<Light> lights = new List<Light>();
// Token: 0x04000C51 RID: 3153
public Transform spawnPoint;
// Token: 0x04000C52 RID: 3154
public Scene mapChangeScene;
// Token: 0x04000C53 RID: 3155
public string sceneTo;
// Token: 0x04000C54 RID: 3156
public string sceneFrom;
// Token: 0x04000C55 RID: 3157
public string subExit;
// Token: 0x04000C56 RID: 3158
public Door door;
// Token: 0x04000C57 RID: 3159
public Door buddyDoor;
// Token: 0x04000C58 RID: 3160
public DoorActions doorActions;
// Token: 0x04000C59 RID: 3161
public DoorActions buddyDoorActions;
// Token: 0x04000C5A RID: 3162
public MeshRenderer hoverMeshRenderer;
// Token: 0x04000C5B RID: 3163
public NodeLink nodeLink;
// Token: 0x04000C5C RID: 3164
public GraphNode nearNode;
// Token: 0x04000C5D RID: 3165
public bool visited;
// Token: 0x04000C5E RID: 3166
private IEnumerator corout;
// Token: 0x04000C5F RID: 3167
private bool hovering;
// Token: 0x04000C60 RID: 3168
private bool near;
// Token: 0x04000C61 RID: 3169
public MapExit connectionExit;
// Token: 0x04000C62 RID: 3170
private GameObject bracket;
// Token: 0x04000C63 RID: 3171
private Bounds bounds;
// Token: 0x04000C64 RID: 3172
private BoxCollider box;
// Token: 0x04000C65 RID: 3173
private GameObject icon;
// Token: 0x04000C66 RID: 3174
public SpriteRenderer iconSprite;
// Token: 0x04000C67 RID: 3175
public bool inBeta;
}