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

151 lines
3.9 KiB
C#

using System;
using System.Collections;
using Pathfinding;
using UnityEngine;
// Token: 0x02000055 RID: 85
public class TimedBreakable : MonoBehaviour
{
// Token: 0x06000AF9 RID: 2809 RVA: 0x000DAC80 File Offset: 0x000D8E80
private void Update()
{
if (this.breakable.destroyed && !this.falling)
{
if (!this.destroying)
{
this.destroying = true;
bool kicked = this.breakable.kicked;
base.StartCoroutine(this.DestroyWait(kicked));
return;
}
}
else if (!this.finishing && this.startSeconds > 0f && !this.falling && Links.x.gameplay.seconds > this.startSeconds + this.gameSecondsBeforeBreak && base.gameObject.name.Contains("Egg"))
{
this.finishing = true;
this.breakable.ClickToBreak(null, true, false);
this.breakable.HoverOut();
base.StartCoroutine(this.Egg());
}
}
// Token: 0x06000AFA RID: 2810 RVA: 0x000DAD4E File Offset: 0x000D8F4E
public void Fall()
{
this.falling = true;
base.StartCoroutine(this.Falling());
}
// Token: 0x06000AFB RID: 2811 RVA: 0x000DAD64 File Offset: 0x000D8F64
private IEnumerator Falling()
{
float timeToLerp = 0.5f;
float percentage = 0f;
float startTime = Time.time;
Transform tr = base.gameObject.transform;
Vector3 startPoint = tr.position;
while (percentage < 1f)
{
percentage = (Time.time - startTime) / timeToLerp;
tr.position = Vector3.Lerp(startPoint, (Vector3)this.node.position, percentage);
tr.localScale = Vector3.Lerp(Vector3.one * 0.25f, Vector3.one, percentage);
yield return null;
}
this.falling = false;
this.startSeconds = Links.x.gameplay.seconds;
yield break;
}
// Token: 0x06000AFC RID: 2812 RVA: 0x000DAD73 File Offset: 0x000D8F73
private IEnumerator Egg()
{
this.animator.Play("HatchOpen");
float timeToLerp = 0.5f;
float percentage = 0f;
float startTime = Time.time;
while (percentage < 1f)
{
percentage = (Time.time - startTime) / timeToLerp;
yield return null;
}
while (Records.x.paused || Records.x.removeControls)
{
yield return null;
}
Quaternion quaternion = Quaternion.Euler(new Vector3(0f, Random.Range(-360f, 360f), 0f));
this.node.Walkable = true;
bool flag = true;
if (this.source.npc)
{
flag = false;
}
CreatureActions creatureActions = Links.x.gaia.CreateCreature(base.gameObject.transform.position, quaternion, "ShroomerFlyer", flag, 0f, 1);
Character summon = creatureActions.GetFirstCharacter();
summon.FirstPosition(this.node);
summon.downed = true;
summon.PlayAnimation("HitDown", 0f);
yield return new WaitForSeconds(0.5f);
summon.downed = false;
summon.PlayAnimation("GetUp", 0f);
Links.x.cellar.RemoveCombatBreakable(this);
Object.Destroy(base.gameObject);
yield break;
}
// Token: 0x06000AFD RID: 2813 RVA: 0x000DAD82 File Offset: 0x000D8F82
private IEnumerator DestroyWait(bool kicked)
{
if (kicked)
{
yield return new WaitForSeconds(0.5f);
}
this.animator.Play("BreakOpen");
Links.x.cellar.RemoveCombatBreakable(this);
float timeToLerp = 1.15f;
float percentage = 0f;
float startTime = Time.time;
while (percentage < 1f)
{
percentage = (Time.time - startTime) / timeToLerp;
yield return null;
}
Object.Destroy(base.gameObject);
yield break;
}
// Token: 0x06000AFE RID: 2814 RVA: 0x000DAD98 File Offset: 0x000D8F98
private void OnDisable()
{
if (Links.x && Links.x.cellar)
{
Links.x.cellar.RemoveCombatBreakable(this);
}
}
// Token: 0x04000FC9 RID: 4041
public float gameSecondsBeforeBreak;
// Token: 0x04000FCA RID: 4042
private float startSeconds;
// Token: 0x04000FCB RID: 4043
public BreakableActions breakable;
// Token: 0x04000FCC RID: 4044
public Animator animator;
// Token: 0x04000FCD RID: 4045
private bool destroying;
// Token: 0x04000FCE RID: 4046
private bool finishing;
// Token: 0x04000FCF RID: 4047
public GraphNode node;
// Token: 0x04000FD0 RID: 4048
private bool falling;
// Token: 0x04000FD1 RID: 4049
public Character source;
}