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

1534 lines
38 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using DarkTonic.MasterAudio;
using Pathfinding;
using PixelCrushers.DialogueSystem;
using UnityEngine;
// Token: 0x02000028 RID: 40
public class DoorActions : MonoBehaviour
{
// Token: 0x06000676 RID: 1654 RVA: 0x00086584 File Offset: 0x00084784
private void Awake()
{
this.saveName = base.gameObject.name;
this.GetObjects();
if (this.mainCollider)
{
this.mainCollider.enabled = true;
this.SetDoorLayer();
}
if (base.gameObject.name.Contains("saloon"))
{
this.openDistance = 36f;
}
}
// Token: 0x06000677 RID: 1655 RVA: 0x000865EC File Offset: 0x000847EC
public void NewGameSetup()
{
RaycastHit raycastHit;
if (Physics.Raycast(this.tr.position + new Vector3(0f, 5f, 0f), Vector3.up * -1f, out raycastHit, 10f, 4194321))
{
this.floorHit = raycastHit.point;
}
else
{
this.floorHit = this.tr.position;
}
this.SetupExits();
this.currentHealth = this.door.health;
if (this.door.connectedExit)
{
this.swings = false;
}
else
{
this.swings = true;
}
if (!this.mainCollider)
{
this.GetObjects();
if (Records.x.editor && this.door.lockable)
{
Debug.Log(((this != null) ? this.ToString() : null) + " missing main collider");
}
}
if (this.mainCollider)
{
this.mainCollider.enabled = true;
}
if (this.door.locked)
{
if (this.swings)
{
this.SetDoorLayer();
this.UpdateAstar();
}
}
else if (this.swings)
{
this.SetDoorLayer();
this.UpdateAstar();
}
if (this.lockCollider && !this.destroyed)
{
this.door.lockable = true;
if (this.door.lockable)
{
this.lockCollider.enabled = true;
}
this.lockColliderPosition = this.lockCollider.bounds.center;
}
this.GetMapExit();
if (this.center == Vector3.zero)
{
this.center = this.tr.position;
}
if (this.lockColliderPosition == Vector3.zero)
{
this.lockColliderPosition = this.center;
}
base.gameObject.layer = 21;
}
// Token: 0x06000678 RID: 1656 RVA: 0x000867D8 File Offset: 0x000849D8
private void SetDoorLayer()
{
if (!this.mainCollider)
{
return;
}
if (!this.swings)
{
if (this.mainCollider.gameObject.layer != 13)
{
this.mainCollider.gameObject.layer = 9;
}
return;
}
if (this.door.locked && this.door.lockable)
{
this.mainCollider.gameObject.layer = 9;
return;
}
this.mainCollider.gameObject.layer = 17;
}
// Token: 0x06000679 RID: 1657 RVA: 0x00086864 File Offset: 0x00084A64
public void SetLayers(int x)
{
if (x == 6)
{
if (this.layers == null)
{
this.layers = new List<int>();
for (int i = 0; i < this.renderers.Length; i++)
{
if (this.renderers[i])
{
this.layers.Add(this.renderers[i].gameObject.layer);
if (this.renderers[i].gameObject.layer != 29)
{
this.renderers[i].gameObject.layer = 6;
}
}
else
{
this.layers.Add(0);
}
}
return;
}
}
else
{
for (int j = 0; j < this.renderers.Length; j++)
{
if (this.renderers[j])
{
this.renderers[j].gameObject.layer = this.layers[j];
}
}
}
}
// Token: 0x0600067A RID: 1658 RVA: 0x00086948 File Offset: 0x00084B48
public void SetLockNodeLink()
{
if (this.swings)
{
return;
}
if (!this.mapExitActions)
{
this.GetMapExit();
}
if (this.mapExitActions)
{
this.mapExitActions.SetSprite(this.door.locked);
if (this.door.locked)
{
if (this.mapExitActions.nodeLink)
{
this.mapExitActions.nodeLink.RemoveLinks();
}
if (this.mapExitActionsBuddy)
{
this.mapExitActionsBuddy.SetSprite(this.door.locked);
if (this.mapExitActionsBuddy.nodeLink)
{
this.mapExitActionsBuddy.nodeLink.RemoveLinks();
return;
}
}
}
else
{
if (this.mapExitActions.nodeLink)
{
this.mapExitActions.nodeLink.SetLinks();
}
if (this.mapExitActionsBuddy)
{
this.mapExitActionsBuddy.SetSprite(this.door.locked);
if (this.mapExitActionsBuddy.nodeLink)
{
this.mapExitActionsBuddy.nodeLink.SetLinks();
}
}
}
}
}
// Token: 0x0600067B RID: 1659 RVA: 0x00086A78 File Offset: 0x00084C78
public void LoadGameSetup(int x, bool isLocked)
{
RaycastHit raycastHit;
if (Physics.Raycast(this.center + new Vector3(0f, 1f, 0f), Vector3.up * -1f, out raycastHit, 4194321f))
{
this.floorHit = raycastHit.point;
}
else
{
this.floorHit = this.tr.position;
}
this.SetupExits();
this.currentHealth = x;
this.door.locked = isLocked;
if (this.door.connectedExit)
{
this.swings = false;
}
else
{
this.swings = true;
}
if (x > 0)
{
this.destroyed = false;
}
if (!isLocked)
{
this.ClickToOpen(null, true);
}
if (x < 0)
{
this.door.locked = false;
this.ClickToBreak(null, true);
this.destroyed = true;
}
else if (this.door.lockable)
{
if (this.door.locked)
{
if (this.mainCollider)
{
this.mainCollider.enabled = true;
this.SetDoorLayer();
}
if (this.swings)
{
this.UpdateAstar();
}
}
else if (this.swings)
{
this.mainCollider.enabled = true;
this.SetDoorLayer();
this.UpdateAstar();
}
}
else if (this.swings)
{
this.mainCollider.enabled = true;
this.SetDoorLayer();
this.UpdateAstar();
}
if (this.lockCollider && !this.destroyed)
{
this.door.lockable = true;
if (this.door.lockable)
{
this.lockCollider.enabled = true;
}
this.lockColliderPosition = this.lockCollider.bounds.center;
}
if (this.lockColliderPosition == Vector3.zero)
{
this.lockColliderPosition = this.center;
}
this.GetMapExit();
this.SetLockNodeLink();
}
// Token: 0x0600067C RID: 1660 RVA: 0x00086C60 File Offset: 0x00084E60
private void GetMapExit()
{
if (!this.swings)
{
this.mapExitActions = this.tr.parent.gameObject.GetComponent<MapExitActions>();
this.mapExitActions.doorActions = this;
this.mapExitActions.buddyDoor = Links.x.diorama.GetBuddyDoor(this.mapExitActions.mapExit);
if (this.mapExitActions.buddyDoor)
{
this.mapExitActionsBuddy = this.mapExitActions.buddyDoor.connectedExit.gameObject.GetComponent<MapExitActions>();
this.mapExitActions.buddyDoorActions = this.mapExitActions.buddyDoor.gameObject.GetComponent<DoorActions>();
this.mapExitActionsBuddy.SetSprite(this.door.locked);
}
this.mapExitActions.SetSprite(this.door.locked);
}
}
// Token: 0x0600067D RID: 1661 RVA: 0x00086D44 File Offset: 0x00084F44
public void GetObjects()
{
if (!this.mainCollider)
{
this.tr = base.transform;
this.center = this.floorHit;
this.renderers = base.gameObject.GetComponentsInChildren<MeshRenderer>(false);
this.lockCollider = base.gameObject.GetComponent<BoxCollider>();
if (this.lockCollider)
{
this.lockCollider.gameObject.layer = 21;
}
foreach (object obj in this.tr)
{
Transform transform = (Transform)obj;
GameObject gameObject = transform.gameObject;
string name = gameObject.name;
if (name == "Animation")
{
this.anim = gameObject;
using (IEnumerator enumerator2 = transform.GetEnumerator())
{
while (enumerator2.MoveNext())
{
object obj2 = enumerator2.Current;
Transform transform2 = (Transform)obj2;
if (transform2 != transform)
{
this.animationObjects.Add(transform2.gameObject);
}
}
continue;
}
}
if (name.Contains("FOW"))
{
this.fow = transform.gameObject;
}
else if (name.Contains("lock") || name.Contains("Lock"))
{
transform.gameObject.layer = 21;
}
else if (name.Contains("wall") || name.Contains("Wall"))
{
this.mainCollider = gameObject.GetComponent<BoxCollider>();
}
else
{
this.meshes = gameObject;
}
}
}
}
// Token: 0x0600067E RID: 1662 RVA: 0x00086F1C File Offset: 0x0008511C
public void SetupExits()
{
if (!this.mainCollider && this.door.connectedExit)
{
this.mainCollider = this.door.connectedExit.gameObject.GetComponent<BoxCollider>();
}
if (!this.point)
{
this.point = new GameObject("Point");
}
this.point.transform.SetParent(this.tr);
if (this.mainCollider)
{
this.center = this.mainCollider.bounds.center;
this.center.y = this.floorHit.y;
this.point.transform.position = this.center;
}
else
{
this.point.transform.position = this.floorHit;
this.center = this.floorHit;
}
if (this.lockCollider)
{
this.lockColliderPosition = this.lockCollider.bounds.center;
}
}
// Token: 0x0600067F RID: 1663 RVA: 0x00087032 File Offset: 0x00085232
public void PlayDoorOpen()
{
if (this.coroutine == null && this.swings)
{
this.coroutine = this.PlayingDoorOpen();
if (this.node == null)
{
this.GetNode();
}
base.StartCoroutine(this.coroutine);
}
}
// Token: 0x06000680 RID: 1664 RVA: 0x0008706C File Offset: 0x0008526C
private IEnumerator PlayingDoorOpen()
{
this.HoverOut();
int totalAnimObjects = this.animationObjects.Count;
int num;
for (int i = 0; i < totalAnimObjects; i = num + 1)
{
if (this.current >= 0 && this.current < totalAnimObjects)
{
for (int j = 0; j < totalAnimObjects; j++)
{
if (j == this.current)
{
this.animationObjects[j].SetActive(true);
}
else
{
this.animationObjects[j].SetActive(false);
}
}
this.current++;
yield return new WaitForSeconds(0.07f);
}
num = i;
}
this.open = true;
this.mainCollider.enabled = false;
if (this.fow)
{
this.fow.SetActive(false);
}
this.UpdateFOW();
while (this.CharacterOnDoorCollider() || Records.x.removeControls)
{
if (this.animationObjects[totalAnimObjects - 1].activeSelf)
{
this.mainCollider.enabled = false;
}
yield return null;
}
if (this.fow)
{
this.fow.SetActive(true);
}
this.mainCollider.enabled = true;
this.UpdateFOW();
this.current = totalAnimObjects - 1;
bool canClose = true;
for (int i = 0; i < totalAnimObjects; i = num + 1)
{
if (this.current >= 0 && this.current < totalAnimObjects)
{
for (int k = 0; k < totalAnimObjects; k++)
{
if (k == this.current)
{
this.animationObjects[k].SetActive(true);
}
else
{
this.animationObjects[k].SetActive(false);
}
}
this.current--;
yield return new WaitForSeconds(0.03f);
if (this.CharacterOnDoorCollider())
{
this.coroutine = null;
this.PlayDoorOpen();
canClose = false;
}
}
num = i;
}
if (this.door.lockable && !this.destroyed && this.lockCollider)
{
this.lockCollider.enabled = true;
}
if (canClose)
{
this.current = 0;
this.coroutine = null;
this.open = false;
}
yield break;
}
// Token: 0x06000681 RID: 1665 RVA: 0x0008707C File Offset: 0x0008527C
private void UpdateFOW()
{
if (this.node.GraphIndex == 0U)
{
Links.x.fogOfWar.UpdateGrid(this.center, 4f);
return;
}
Links.x.fogOfWarInterior.UpdateGrid(this.center, 4f);
}
// Token: 0x06000682 RID: 1666 RVA: 0x000870CC File Offset: 0x000852CC
private void SetDoorShutVisual()
{
int count = this.animationObjects.Count;
for (int i = 0; i < count; i++)
{
for (int j = 0; j < count; j++)
{
if (j == 0)
{
this.animationObjects[j].SetActive(true);
}
else
{
this.animationObjects[j].SetActive(false);
}
}
}
this.mainCollider.enabled = true;
if (this.coroutine != null)
{
this.StopDoorOpen();
}
}
// Token: 0x06000683 RID: 1667 RVA: 0x00087140 File Offset: 0x00085340
private void StopDoorOpen()
{
base.StopCoroutine(this.coroutine);
this.coroutine = null;
if (this.door.lockable && !this.destroyed && this.lockCollider)
{
this.lockCollider.enabled = true;
}
this.open = false;
this.current = 0;
}
// Token: 0x06000684 RID: 1668 RVA: 0x0008719C File Offset: 0x0008539C
public bool CharacterOnDoorCollider()
{
return this.characters.Count > 0;
}
// Token: 0x06000685 RID: 1669 RVA: 0x000871B0 File Offset: 0x000853B0
public void AddRemoveCharacterOnCollider(Character character, bool state)
{
int num = this.characters.IndexOf(character);
if (state && num == -1 && this.openRoutine == null)
{
this.characters.Add(character);
}
if (!state && num > -1)
{
this.characters.RemoveAt(num);
}
if (this.coroutine == null && this.characters.Count > 0 && state && !this.door.locked)
{
base.enabled = true;
this.PlayDoorOpen();
}
}
// Token: 0x06000686 RID: 1670 RVA: 0x00087230 File Offset: 0x00085430
public void HoverIn(bool isMainHover)
{
if (!this.destroyed)
{
bool flag = this.open;
}
if (isMainHover)
{
Links.x.hoverObject = base.gameObject;
Shader.SetGlobalVector("_DoorLightPosition", this.bounds.center + Links.x.rtsCamera.gameObject.transform.forward * -2f);
Records.x.hoverLightColor = Color.white * 0.25f;
Shader.SetGlobalFloat("_DoorLightRange", 2f);
if (Records.x.pocketPause && !Links.x.gameplay.attackingCharacter.CanAttack())
{
bool rallyWheelOpen = Links.x.pocketWheel.rallyWheelOpen;
}
}
if (this.lockCollider)
{
this.bounds = this.lockCollider.bounds;
}
this.bounds.Expand(0.25f);
int num = 0;
if (Records.x.pocketPause)
{
num = 2;
}
if (this.door.owner)
{
Character firstCharacter = this.door.owner.GetComponent<CreatureActions>().GetFirstCharacter();
if (firstCharacter && !firstCharacter.stunned && !firstCharacter.dead)
{
num = 1;
}
}
if (!this.bracket)
{
this.bracket = Links.x.cellar.GetBracket(num, this.bounds);
return;
}
Links.x.cellar.SetBracketMaterial(num, this.bracket);
}
// Token: 0x06000687 RID: 1671 RVA: 0x000873C0 File Offset: 0x000855C0
public void HoverOut()
{
if (Links.x.hoverObject == base.gameObject)
{
Links.x.hoverObject = null;
}
if (this.multiHover)
{
this.multiHover = false;
Links.x.combat.MultiHitCharacters(false);
Links.x.combat.MultiHitObjects(false, base.gameObject.transform.position, null, null, this);
Links.x.gameplay.CheckIfAnythingShouldRedoMultiTargetHover();
}
if (this.bracket)
{
Links.x.cellar.ReturnPooledGameObject(61, this.bracket);
this.bracket = null;
}
}
// Token: 0x06000688 RID: 1672 RVA: 0x0008746C File Offset: 0x0008566C
public void CombatSheen(int num)
{
if (this.destroyed && num == 3)
{
return;
}
bool flag = false;
if (num == 3)
{
flag = true;
}
this.combatTargetID = num;
for (int i = 0; i < this.renderers.Length; i++)
{
if (this.renderers[i].gameObject.layer != 29 && this.renderers[i].gameObject.layer == 21)
{
this.mats = this.renderers[i].materials;
foreach (Material material in this.mats)
{
this.sheen = 0f;
if (flag)
{
this.sheen = 1f;
}
material.SetFloat("_InCombatBubble", this.sheen);
}
}
}
}
// Token: 0x06000689 RID: 1673 RVA: 0x00087530 File Offset: 0x00085730
public void AlertOwner(bool madeNoise, Character character)
{
if (this.door.owner)
{
Character firstCharacter = this.door.owner.GetComponent<CreatureActions>().GetFirstCharacter();
if (firstCharacter)
{
bool flag = false;
if (!firstCharacter.stunned && !firstCharacter.dead && (!firstCharacter.sleeping || madeNoise) && (firstCharacter.tr.position - character.tr.position).sqrMagnitude < firstCharacter.stats.SightRadius(false, false, false) * firstCharacter.stats.SightRadius(false, false, false) && !character.body.sneaking && !Physics.Linecast(firstCharacter.raycastPosition, character.raycastPosition, Links.x.sightBlockers))
{
if (firstCharacter.sleeping)
{
firstCharacter.WakeUp();
}
if (!Links.x.main.InSporeForest() && !Links.x.sensory.ProofState(firstCharacter))
{
Records.x.AddBribeBadge(firstCharacter, "Seen", false, character);
}
Links.x.sensory.AddPlayerFromDamage(firstCharacter, Links.x.main);
flag = true;
}
if (!flag)
{
Character character2 = null;
int num = Links.x.combat.NPCCount(true);
int num3;
int num2 = Links.x.sensory.NonHostileAttacked(null, base.gameObject.transform.position, character, false, madeNoise, out character2, out num3);
Debug.Log("Alert owner non-hostile seen count " + num2.ToString() + " made noise " + madeNoise.ToString());
int num4 = Links.x.combat.NPCCount(true);
if (num2 == 0 && num4 == 0 && num3 == 0)
{
if (!this.door.locked)
{
character.StartQuip("None the wiser");
return;
}
character.StartQuip("At least I was not seen");
return;
}
else if (character2 && num == 0 && !character2.party && !character2.stats.animal && !Links.x.main.InSporeForest() && !Links.x.sensory.ProofState(firstCharacter))
{
Records.x.AddBribeBadge(character2, "Seen", false, character);
}
}
}
}
}
// Token: 0x0600068A RID: 1674 RVA: 0x00087770 File Offset: 0x00085970
public void CheckQuestState()
{
if (this.door.triggersQuest)
{
string questName = this.door.questName;
if (questName == "D6_Dolki")
{
for (int i = 0; i < 6; i++)
{
bool flag = false;
string text = questName;
if (i == 0)
{
text += "A";
}
if (i == 1)
{
text += "B";
}
if (i == 2)
{
text += "C";
}
if (i == 3)
{
text += "D";
}
if (i == 4)
{
text += "E";
}
if (i == 5)
{
text += "F";
}
QuestState questState = QuestLog.GetQuestState(text);
if ((questState == QuestState.Active || questState == QuestState.Unassigned) && this.door.locked)
{
QuestLog.SetQuestState(text, QuestState.Unassigned);
}
if ((questState == QuestState.Active || questState == QuestState.Unassigned) && !this.door.locked)
{
QuestLog.SetQuestState(text, QuestState.Active);
flag = true;
}
if (flag)
{
float num = 0f;
float num2 = Links.x.gameplay.gameHours;
if (num2 < 17f)
{
num = 17f - num2;
}
if (num2 == 22f)
{
num = 19f;
}
if (num2 >= 23f)
{
num = 20f;
}
Records.x.AddQuestToTimer(text, num, "active", "activePart2", false);
Debug.Log(string.Concat(new string[]
{
"Setting dolki quest: ",
text,
" ",
num.ToString(),
" ",
num2.ToString()
}));
}
}
}
}
}
// Token: 0x0600068B RID: 1675 RVA: 0x0008790E File Offset: 0x00085B0E
public void Damage(Character party)
{
this.AlertOwner(true, party);
}
// Token: 0x0600068C RID: 1676 RVA: 0x00087918 File Offset: 0x00085B18
public void Remake(bool locked)
{
this.destroyed = false;
base.enabled = true;
if (this.swings)
{
this.mainCollider.enabled = true;
}
this.lockCollider.enabled = true;
this.door.locked = locked;
if (this.mapExitActions)
{
this.mapExitActions.SetSprite(this.door.locked);
if (this.mapExitActions.buddyDoor)
{
this.mapExitActions.buddyDoor.locked = this.door.locked;
this.mapExitActions.buddyDoorActions.Remake(locked);
this.mapExitActionsBuddy.SetSprite(this.door.locked);
}
}
this.SetLockNodeLink();
if (this.anim)
{
this.anim.SetActive(true);
}
this.currentHealth = this.door.health;
if (this.currentHealth < 0)
{
this.currentHealth = 100;
}
if (this.fow)
{
this.fow.SetActive(true);
}
this.UpdateAstar();
}
// Token: 0x0600068D RID: 1677 RVA: 0x00087A38 File Offset: 0x00085C38
public void Bend()
{
if (this.currentHealth < this.door.health && !this.destroyed && this.currentHealth > 0)
{
if (this.timeSinceHeal == 0f)
{
this.timeSinceHeal = Links.x.gameplay.seconds;
}
if (Links.x.gameplay.seconds > this.timeSinceHeal + 100f || this.timeSinceHeal == 0f)
{
this.timeSinceHeal = Links.x.gameplay.seconds;
float num = (float)this.door.health / 5f;
this.currentHealth += Mathf.RoundToInt(num);
Vector3 position = this.mainCollider.gameObject.transform.position;
Vector3 vector = Links.x.worldCamera.WorldToScreenPoint(position);
vector.z = 0f;
vector.x = vector.x * (1920f / (float)Screen.width) - 960f;
vector.y = vector.y * (Links.x.canvasRT.sizeDelta.y / (float)Screen.height) - Links.x.canvasRT.sizeDelta.y / 2f;
Links.x.repairFX.localPosition = vector;
Links.x.repairFX.gameObject.SetActive(true);
Links.x.repairFX.gameObject.GetComponent<HannahAnimator>().Play("Idle");
string text = "Repair 1";
if (Random.Range(0, 2) == 0)
{
text = "Repair 2";
}
if (Random.Range(0, 3) == 0)
{
text = "Repair 3";
}
MasterAudio.PlaySound3DAtVector3AndForget("Interactives", base.gameObject.transform.position, Random.Range(0.7f, 0.9f), new float?(1f), 0f, text, null);
if (this.currentHealth == this.door.health)
{
this.timeSinceHeal = 0f;
}
}
}
}
// Token: 0x0600068E RID: 1678 RVA: 0x00087C5C File Offset: 0x00085E5C
public void SetSprites()
{
if (this.mapExitActions)
{
this.mapExitActions.SetSprite(this.door.locked);
if (this.mapExitActions.buddyDoor)
{
this.mapExitActionsBuddy.SetSprite(this.door.locked);
}
}
}
// Token: 0x0600068F RID: 1679 RVA: 0x00087CB4 File Offset: 0x00085EB4
public void ClickToBreak(Character party, bool fromSave)
{
if (!this.destroyed)
{
this.destroyed = true;
base.enabled = true;
base.StartCoroutine(this.Breaking(party, fromSave));
}
}
// Token: 0x06000690 RID: 1680 RVA: 0x00087CDB File Offset: 0x00085EDB
private IEnumerator Breaking(Character party, bool fromSave)
{
if (this.openRoutine != null)
{
base.StopCoroutine(this.openRoutine);
this.openRoutine = null;
}
if (this.coroutine != null)
{
this.StopDoorOpen();
}
if (!fromSave && party)
{
Links.x.sensory.LookAtObject(base.transform, 15f, false, party, 4f, 0.5f, null, 0);
this.HoverOut();
}
if (!fromSave)
{
Links.x.sensory.AddNoise(party.gameObject, party.node, "Break", party);
this.AlertOwner(true, party);
}
if (!fromSave)
{
while (Links.x.combat.rallyTarget)
{
yield return null;
}
}
if (this.swings)
{
this.mainCollider.enabled = false;
}
this.lockCollider.enabled = false;
if (this.fow)
{
this.fow.SetActive(false);
}
this.UpdateAstar();
this.door.locked = false;
if (this.mapExitActions)
{
this.mapExitActions.SetSprite(this.door.locked);
if (this.mapExitActions.buddyDoor && !fromSave)
{
this.mapExitActions.buddyDoor.locked = this.door.locked;
this.mapExitActions.buddyDoorActions.ClickToBreak(party, fromSave);
this.mapExitActionsBuddy.SetSprite(this.door.locked);
}
}
this.SetLockNodeLink();
if (this.anim)
{
this.anim.SetActive(false);
}
if (!fromSave)
{
GameObject pooledGameObject = Links.x.cellar.GetPooledGameObject(133);
pooledGameObject.GetComponent<Gore>().Break(this.tr.position);
pooledGameObject.transform.position = this.tr.position;
MasterAudio.PlaySound3DAtVector3AndForget("Interactives", base.gameObject.transform.position, 1f, new float?(1f), 0f, "Chest Break", null);
this.CombatSheen(0);
this.HoverOut();
}
this.currentHealth = -1;
if (this.interactiveCharacterObject)
{
Object.Destroy(this.interactiveCharacterObject);
}
if (Records.x.pocketPause && party.mainSelected)
{
Links.x.gameplay.PocketPause(false);
}
this.destroyed = true;
this.CheckQuestState();
yield return new WaitForSeconds(0.25f);
this.HoverOut();
base.enabled = false;
Links.x.hudControl.AddRemoveInteraction(false, null, null, null, null, this, null, null);
Links.x.combat.AddRemoveInteraction(false, null, null, null, this);
yield break;
}
// Token: 0x06000691 RID: 1681 RVA: 0x00087CF8 File Offset: 0x00085EF8
public void ClickToOpen(Character party, bool fromSave)
{
if (this.openRoutine == null && !this.destroyed && this.door.lockable)
{
base.enabled = true;
this.openRoutine = this.Opening(party, fromSave);
base.StartCoroutine(this.openRoutine);
}
}
// Token: 0x06000692 RID: 1682 RVA: 0x00087D44 File Offset: 0x00085F44
public bool HasKey(Character party)
{
Links.x.SetFormationOrder();
bool flag = false;
string text = this.door.keyItem.ToString();
if (this.partyList == null)
{
this.formationList = Links.x.formationOrder;
this.partyList.Clear();
this.partyList.Add(party);
for (int i = 0; i < this.formationList.Count; i++)
{
if (this.formationList[i] != party)
{
this.partyList.Add(this.formationList[i]);
}
}
}
if (text != "")
{
int invRowID = Links.x.library.GetInvRowID(text);
for (int j = 0; j < this.partyList.Count; j++)
{
if (!flag && this.partyList[j] && this.partyList[j].HasItem(invRowID) > -1)
{
flag = true;
break;
}
}
if (party.HasItem(invRowID) > -1)
{
flag = true;
}
}
return flag;
}
// Token: 0x06000693 RID: 1683 RVA: 0x00087E5A File Offset: 0x0008605A
private IEnumerator Opening(Character party, bool fromSave)
{
if (!fromSave && party)
{
while (party.moving)
{
yield return null;
}
party.SetRotation(Quaternion.LookRotation(this.center - party.tr.position), false, true);
party.PlayAnimation("Use", 0f);
Links.x.sensory.LookAtObject(base.transform, 15f, false, party, 4f, 0.5f, null, 0);
}
bool locked = this.door.locked;
if (!fromSave && party)
{
Links.x.SetFormationOrder();
this.formationList = Links.x.formationOrder;
this.partyList.Clear();
this.partyList.Add(party);
for (int i = 0; i < this.formationList.Count; i++)
{
if (this.formationList[i] != party)
{
this.partyList.Add(this.formationList[i]);
}
}
StringFast stringFast = new StringFast(64);
bool flag = this.HasKey(party);
if (flag)
{
stringFast.Clear();
stringFast.Append(Links.x.gameFeed.GetPartyColorText(party));
stringFast.Append(party.stats.GetName());
stringFast.Append("</color>");
if (locked)
{
this.door.locked = false;
stringFast.Append(" unlocked door with a key");
}
else
{
this.door.locked = true;
stringFast.Append(" locked door with a key");
}
if (this.mapExitActions)
{
this.mapExitActions.SetSprite(this.door.locked);
if (this.mapExitActions.buddyDoor)
{
this.mapExitActions.buddyDoor.locked = this.door.locked;
this.mapExitActionsBuddy.SetSprite(this.door.locked);
}
}
this.SetLockNodeLink();
Links.x.gameFeed.AddFeed(stringFast.ToString());
this.AlertOwner(false, party);
this.CheckQuestState();
MasterAudio.PlaySound3DAtVector3AndForget("Interactives", base.gameObject.transform.position, 1f, new float?(1f), 0f, "Key", null);
this.UpdateAstar();
if (this.door.locked)
{
this.mainCollider.enabled = true;
}
else if (this.swings)
{
this.SetDoorLayer();
if (!this.door.locked)
{
if (this.coroutine != null)
{
this.StopDoorOpen();
}
if (this.characters.Count > 0)
{
this.PlayDoorOpen();
}
}
else
{
this.SetDoorShutVisual();
}
}
}
if (!flag)
{
float num = party.stats.Lockpicking(false);
string text = party.stats.LockpickingCalculation(false);
string text2 = party.stats.LockDifficultyString((float)this.door.lockDifficulty);
bool flag2 = false;
if (num + 1f >= (float)this.door.lockDifficulty && Random.Range(0, 5) == 0)
{
flag2 = true;
}
if (num >= (float)this.door.lockDifficulty || flag2)
{
stringFast.Clear();
stringFast.Append(Links.x.gameFeed.GetPartyColorText(party));
stringFast.Append(party.stats.GetName());
stringFast.Append("</color>");
if (locked)
{
this.door.locked = false;
stringFast.Append(" unlocked door with Lockpicking skill");
}
else
{
this.door.locked = true;
stringFast.Append(" locked door with Lockpicking skill");
}
if (this.mapExitActions)
{
this.mapExitActions.SetSprite(this.door.locked);
if (this.mapExitActions.buddyDoor)
{
this.mapExitActions.buddyDoor.locked = this.door.locked;
this.mapExitActionsBuddy.SetSprite(this.door.locked);
}
}
this.SetLockNodeLink();
if (Records.x.showRulesetInfo)
{
stringFast.Append(" <color #857C6C>... ");
stringFast.Append(text);
stringFast.Append(" vs. ");
stringFast.Append(text2);
stringFast.Append("</color>");
}
Links.x.gameFeed.AddFeed(stringFast.ToString());
MasterAudio.PlaySound3DAtVector3AndForget("Interactives", base.gameObject.transform.position, 1f, new float?(1f), 0f, "Lockpick", null);
yield return new WaitForSeconds(0.3f);
MasterAudio.PlaySound3DAtVector3AndForget("Skills", base.gameObject.transform.position, 1f, new float?(1f), 0f, "GenericBuff", null);
MasterAudio.PlaySoundAndForget("Feedback", 0.6f, new float?(1f), 0f, "Song Learned", null);
GameObject go = Links.x.cellar.GetPooledGameObject(10);
go.transform.position = party.body.headBone.position + new Vector3(0f, 1.5f, 0f);
go.SetActive(true);
if (this.swings)
{
this.UpdateAstar();
this.SetDoorLayer();
if (!this.door.locked)
{
if (this.coroutine != null)
{
this.StopDoorOpen();
}
if (this.characters.Count > 0)
{
this.PlayDoorOpen();
}
}
else
{
this.SetDoorShutVisual();
}
}
string text3 = "Unlocked";
if (this.door.locked)
{
text3 = "Locked";
}
Animator animatedText = Links.x.cellar.GetAnimatedText("", text3, false);
animatedText.gameObject.transform.position = this.lockCollider.bounds.center + new Vector3(0f, Random.Range(1.5f, 1.8f), 0f);
animatedText.gameObject.SetActive(true);
party.stats.AddSkillProgress(20, (float)this.door.lockDifficulty * 2f, null);
Links.x.itemPickupFX.gameObject.SetActive(true);
Links.x.itemPickupFX.gameObject.GetComponent<HannahAnimator>().Play("Idle");
Vector3 position = this.tr.position;
if (this.lockCollider)
{
position = this.lockCollider.bounds.center;
}
else
{
position = this.mainCollider.bounds.center;
}
Vector3 vector = Links.x.worldCamera.WorldToScreenPoint(position);
vector.z = 0f;
vector.x = vector.x * (1920f / (float)Screen.width) - 960f;
vector.y = vector.y * (Links.x.canvasRT.sizeDelta.y / (float)Screen.height) - Links.x.canvasRT.sizeDelta.y / 2f;
Links.x.itemPickupFX.localPosition = vector;
this.CheckQuestState();
yield return new WaitForSeconds(1f);
Links.x.cellar.ReturnPooledGameObject(10, go);
this.AlertOwner(false, party);
go = null;
}
else
{
stringFast.Clear();
stringFast.Append(Links.x.gameFeed.GetPartyColorText(party));
stringFast.Append(party.stats.GetName());
stringFast.Append("</color>");
stringFast.Append(" failed to lockpick");
if (Records.x.showRulesetInfo)
{
stringFast.Append(" <color #857C6C>... ");
stringFast.Append(text);
stringFast.Append(" vs. ");
stringFast.Append(text2);
stringFast.Append("</color>");
}
Links.x.gameFeed.AddFeed(stringFast.ToString());
GameObject pooledGameObject = Links.x.cellar.GetPooledGameObject(58);
if (pooledGameObject && party)
{
pooledGameObject.transform.position = party.body.headBone.position + new Vector3(0f, 1f, 0f);
pooledGameObject.SetActive(true);
}
if (party)
{
this.AlertOwner(false, party);
}
MasterAudio.PlaySound3DAtVector3AndForget("Skills", base.gameObject.transform.position, Random.Range(0.4f, 0.5f), new float?(1f), 0f, "Fail", null);
float num2 = (float)this.door.lockDifficulty - num;
if (num2 <= 1f)
{
party.StartQuip("Nearly got it");
}
else if (num2 > 1f && num2 < 3f)
{
party.StartQuip("With a little more skill...");
}
else if (num2 >= 3f)
{
if (this.door.lockDifficulty > 900)
{
party.StartQuip("Too hard for anyone...");
}
else
{
party.StartQuip("Too hard for me...");
}
}
}
}
}
else if (fromSave)
{
if (this.door.lockable)
{
if (this.door.locked)
{
this.mainCollider.enabled = true;
if (this.swings)
{
this.SetDoorLayer();
}
}
else
{
this.mainCollider.enabled = true;
if (this.swings)
{
this.SetDoorLayer();
}
}
}
else
{
if (this.mainCollider)
{
this.mainCollider.enabled = true;
}
if (this.swings)
{
this.SetDoorLayer();
}
}
this.UpdateAstar();
}
this.openRoutine = null;
yield break;
}
// Token: 0x06000694 RID: 1684 RVA: 0x00087E78 File Offset: 0x00086078
public GraphNode GetNode()
{
this.SetNodeConstraint();
if (this.mainCollider)
{
this.center = this.mainCollider.bounds.center;
this.center.y = this.floorHit.y;
if (this.point)
{
this.point.transform.position = this.center;
}
}
else
{
if (this.point)
{
this.point.transform.position = this.floorHit;
}
this.center = this.floorHit;
}
this.node = AstarPath.active.GetNearest(this.center, this.nodeConstraint).node;
this.SetCenter();
return this.node;
}
// Token: 0x06000695 RID: 1685 RVA: 0x00087F48 File Offset: 0x00086148
public void SetCenter()
{
this.center = this.floorHit;
if (this.node != null)
{
Vector3 vector = (Vector3)this.node.position;
this.center.y = vector.y;
}
if (this.point)
{
this.point.transform.position = this.center;
}
}
// Token: 0x06000696 RID: 1686 RVA: 0x00087FB0 File Offset: 0x000861B0
public void UpdateAstar()
{
if (this.node == null)
{
this.GetNode();
}
if (this.door.connectedExit)
{
return;
}
if (!this.updatingPath)
{
this.updatingPath = true;
base.enabled = true;
base.StartCoroutine(this.UpdatePath(false));
}
}
// Token: 0x06000697 RID: 1687 RVA: 0x00088003 File Offset: 0x00086203
private IEnumerator UpdatePath(bool destroying)
{
yield return new WaitForSecondsRealtime(0.1f);
if (!Links.x.gaia.sceneLoaded)
{
yield return new WaitForSecondsRealtime(Random.Range(0.2f, 0.5f));
}
while (!Links.x.gaia.pathfindingReady)
{
yield return null;
}
if (!Physics.Raycast(this.center + new Vector3(0f, 100f, 0f), Vector3.up * -1f, 400f, 1073741824))
{
Links.x.fogOfWar.UpdateGrid(this.center, 4f);
}
else
{
Links.x.fogOfWarInterior.UpdateGrid(this.center, 4f);
}
if (this.node == null)
{
this.GetNode();
}
AstarPath.active.UpdateGraphs(new Bounds(this.center + new Vector3(0f, -1f, 0f), new Vector3(6f, 40f, 6f)));
this.updatingPath = false;
yield break;
}
// Token: 0x06000698 RID: 1688 RVA: 0x00088014 File Offset: 0x00086214
public void SetNodeConstraint()
{
this.nodeConstraint.constrainWalkability = true;
this.nodeConstraint.walkable = false;
this.nodeConstraint.constrainTags = false;
this.nodeConstraint.passID = 0;
this.nodeConstraint.passID2 = 0;
this.nodeConstraint.checkConnections = 0;
this.nodeConstraint.constrainPenalty = 0;
this.nodeConstraint.constrainToArea = -1;
this.nodeConstraint.checkCircleID = 0;
}
// Token: 0x0400092E RID: 2350
public Door door;
// Token: 0x0400092F RID: 2351
public MapExitActions mapExitActions;
// Token: 0x04000930 RID: 2352
public MapExitActions mapExitActionsBuddy;
// Token: 0x04000931 RID: 2353
public bool swings;
// Token: 0x04000932 RID: 2354
public GraphNode node;
// Token: 0x04000933 RID: 2355
public int currentHealth;
// Token: 0x04000934 RID: 2356
public string itemA;
// Token: 0x04000935 RID: 2357
public string itemB;
// Token: 0x04000936 RID: 2358
public string itemC;
// Token: 0x04000937 RID: 2359
public string itemD;
// Token: 0x04000938 RID: 2360
public MeshRenderer[] renderers = new MeshRenderer[0];
// Token: 0x04000939 RID: 2361
private GameObject anim;
// Token: 0x0400093A RID: 2362
private GameObject meshes;
// Token: 0x0400093B RID: 2363
private GameObject fow;
// Token: 0x0400093C RID: 2364
public bool destroyed;
// Token: 0x0400093D RID: 2365
private bool updatingPath;
// Token: 0x0400093E RID: 2366
public BoxCollider mainCollider;
// Token: 0x0400093F RID: 2367
public BoxCollider lockCollider;
// Token: 0x04000940 RID: 2368
private NNConstraint nodeConstraint = new NNConstraint();
// Token: 0x04000941 RID: 2369
public Character interactiveCharacterObject;
// Token: 0x04000942 RID: 2370
private Transform tr;
// Token: 0x04000943 RID: 2371
private IEnumerator openRoutine;
// Token: 0x04000944 RID: 2372
private IEnumerator coroutine;
// Token: 0x04000945 RID: 2373
public bool open;
// Token: 0x04000946 RID: 2374
private List<GameObject> animationObjects = new List<GameObject>();
// Token: 0x04000947 RID: 2375
public Vector3 center;
// Token: 0x04000948 RID: 2376
public GameObject point;
// Token: 0x04000949 RID: 2377
private int current;
// Token: 0x0400094A RID: 2378
public List<Character> characters = new List<Character>();
// Token: 0x0400094B RID: 2379
public string saveName;
// Token: 0x0400094C RID: 2380
private List<Character> formationList;
// Token: 0x0400094D RID: 2381
private List<Character> partyList = new List<Character>();
// Token: 0x0400094E RID: 2382
private Vector3 floorHit;
// Token: 0x0400094F RID: 2383
public Vector3 lockColliderPosition;
// Token: 0x04000950 RID: 2384
private Material[] mats;
// Token: 0x04000951 RID: 2385
public GameObject bracket;
// Token: 0x04000952 RID: 2386
private Bounds bounds;
// Token: 0x04000953 RID: 2387
private bool multiHover;
// Token: 0x04000954 RID: 2388
private List<int> layers;
// Token: 0x04000955 RID: 2389
public int combatTargetID;
// Token: 0x04000956 RID: 2390
public float sheen;
// Token: 0x04000957 RID: 2391
private float timeSinceHeal;
// Token: 0x04000958 RID: 2392
public float openDistance = 9f;
}