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

224 lines
6.0 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using DarkTonic.MasterAudio;
using UnityEngine;
// Token: 0x02000033 RID: 51
public class Gore : MonoBehaviour
{
// Token: 0x060007CF RID: 1999 RVA: 0x000AD748 File Offset: 0x000AB948
private void Start()
{
if (!this.skipRenderers)
{
this.meshRenderers = base.gameObject.GetComponentsInChildren<MeshRenderer>(true);
foreach (MeshRenderer meshRenderer in this.meshRenderers)
{
this.mat = meshRenderer.sharedMaterials;
foreach (Material material in this.mat)
{
if (material.shader != Links.x.characterGame && !material.shader.name.Contains("Single") && !Links.x.rallyStage.playing)
{
material.shader = Links.x.characterGame;
}
}
}
this.skinnedMeshRenderers = base.gameObject.GetComponentsInChildren<SkinnedMeshRenderer>(true);
foreach (SkinnedMeshRenderer skinnedMeshRenderer in this.skinnedMeshRenderers)
{
this.mat = skinnedMeshRenderer.sharedMaterials;
foreach (Material material2 in this.mat)
{
if (material2.shader != Links.x.characterGame && !material2.shader.name.Contains("Single") && !Links.x.rallyStage.playing)
{
material2.shader = Links.x.characterGame;
}
}
}
if (!this.addedListens)
{
Collider[] componentsInChildren = base.gameObject.GetComponentsInChildren<Collider>(true);
for (int i = 0; i < componentsInChildren.Length; i++)
{
componentsInChildren[i].gameObject.AddComponent<GoreListen>().gore = this;
}
this.addedListens = true;
}
if (!Links.x.rallyStage.playing)
{
this.skipRenderers = true;
}
}
if (this.breakOnStart)
{
if (this.rigidbodies.Length == 0)
{
this.Setup();
}
else
{
this.DoReset();
}
this.Break(base.gameObject.transform.position);
if (this.returnAfterTimer)
{
base.StartCoroutine(this.Wait());
}
}
}
// Token: 0x060007D0 RID: 2000 RVA: 0x000AD964 File Offset: 0x000ABB64
public void SetKinematic()
{
for (int i = 0; i < this.rigidbodies.Length; i++)
{
this.rigidbodies[i].isKinematic = true;
}
this.setKinematic = true;
}
// Token: 0x060007D1 RID: 2001 RVA: 0x000AD99C File Offset: 0x000ABB9C
public void Setup()
{
this.setKinematic = false;
this.rigidbodies = base.gameObject.GetComponentsInChildren<Rigidbody>(true);
for (int i = 0; i < this.rigidbodies.Length; i++)
{
this.positions.Add(this.rigidbodies[i].gameObject.transform.localPosition);
this.rotations.Add(this.rigidbodies[i].gameObject.transform.localRotation);
}
}
// Token: 0x060007D2 RID: 2002 RVA: 0x000ADA1C File Offset: 0x000ABC1C
public void DoReset()
{
this.setKinematic = false;
for (int i = 0; i < this.rigidbodies.Length; i++)
{
this.rigidbodies[i].isKinematic = true;
this.rigidbodies[i].gameObject.transform.localPosition = this.positions[i];
this.rigidbodies[i].gameObject.transform.localRotation = this.rotations[i];
}
}
// Token: 0x060007D3 RID: 2003 RVA: 0x000ADA98 File Offset: 0x000ABC98
public void Break(Vector3 position)
{
if (this.rigidbodies.Length == 0)
{
this.Setup();
}
base.gameObject.transform.position = position;
base.gameObject.SetActive(true);
this.DoReset();
for (int i = 0; i < this.rigidbodies.Length; i++)
{
this.rigidbodies[i].gameObject.SetActive(true);
this.rigidbodies[i].isKinematic = false;
this.rigidbodies[i].gameObject.layer = 20;
Vector3 vector = position;
vector.y += this.up;
Vector3 vector2 = position;
vector2.x += Random.Range(-3f, 3f);
vector2.z += Random.Range(-3f, 3f);
Quaternion quaternion = Quaternion.LookRotation(vector - vector2);
this.rigidbodies[i].AddForce(quaternion * Vector3.forward * this.force * 0.08f, ForceMode.Force);
}
if (this.playSound)
{
MasterAudio.PlaySound3DAtVector3AndForget("Interactives", base.gameObject.transform.position, 1f, new float?(1f), 0f, "Chest Break", null);
}
}
// Token: 0x060007D4 RID: 2004 RVA: 0x000ADBEF File Offset: 0x000ABDEF
private IEnumerator Wait()
{
float startSeconds = Links.x.gameplay.seconds;
yield return new WaitForSeconds(1f);
while (Links.x.gameplay.seconds < startSeconds + (float)this.timeToHoldFor)
{
for (int i = 0; i < this.rigidbodies.Length; i++)
{
if (this.rigidbodies[i].gameObject.activeSelf && this.rigidbodies[i].linearVelocity.sqrMagnitude < 0.2f)
{
this.rigidbodies[i].gameObject.SetActive(false);
}
}
yield return null;
}
Links.x.cellar.ReturnPooledGameObject(this.cellarID, base.gameObject);
base.gameObject.SetActive(false);
yield break;
}
// Token: 0x04000C25 RID: 3109
public List<Vector3> positions = new List<Vector3>();
// Token: 0x04000C26 RID: 3110
public List<Quaternion> rotations = new List<Quaternion>();
// Token: 0x04000C27 RID: 3111
public Rigidbody[] rigidbodies = new Rigidbody[0];
// Token: 0x04000C28 RID: 3112
private MeshRenderer[] meshRenderers;
// Token: 0x04000C29 RID: 3113
private SkinnedMeshRenderer[] skinnedMeshRenderers;
// Token: 0x04000C2A RID: 3114
public bool breakOnStart;
// Token: 0x04000C2B RID: 3115
private Material[] mat;
// Token: 0x04000C2C RID: 3116
private Vector3 originalScale = new Vector3(1f, 1f, 1f);
// Token: 0x04000C2D RID: 3117
public bool skipRenderers;
// Token: 0x04000C2E RID: 3118
public int cellarID;
// Token: 0x04000C2F RID: 3119
public bool returnAfterTimer;
// Token: 0x04000C30 RID: 3120
public int timeToHoldFor;
// Token: 0x04000C31 RID: 3121
public float force = 4000f;
// Token: 0x04000C32 RID: 3122
public float up = 2f;
// Token: 0x04000C33 RID: 3123
public bool playSound = true;
// Token: 0x04000C34 RID: 3124
public bool addBoneListeners;
// Token: 0x04000C35 RID: 3125
public Character character;
// Token: 0x04000C36 RID: 3126
private bool addedListens;
// Token: 0x04000C37 RID: 3127
public float startTime;
// Token: 0x04000C38 RID: 3128
public bool damageEveryone;
// Token: 0x04000C39 RID: 3129
public bool damageOthers = true;
// Token: 0x04000C3A RID: 3130
public bool damageNone;
// Token: 0x04000C3B RID: 3131
public bool setKinematic;
}