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

543 lines
15 KiB
C#

using System;
using System.Collections.Generic;
using DarkTonic.MasterAudio;
using UnityEngine;
// Token: 0x02000052 RID: 82
public class StatusRing : MonoBehaviour
{
// Token: 0x06000AC8 RID: 2760 RVA: 0x000D6238 File Offset: 0x000D4438
public void AddEffect(string type, Effects effect, bool addToList, int arrows)
{
this.allUseHead = true;
if (this.sprites.Count == 0)
{
if (!this.tr)
{
this.tr = base.transform;
}
this.updateTime = Time.timeSinceLevelLoad;
}
if (!this.spriteNames.Contains(type) || addToList)
{
Sprite effectImageMedium = Links.x.archives.GetEffectImageMedium(type);
if (effectImageMedium)
{
GameObject gameObject = new GameObject("Effect");
Transform transform = gameObject.transform;
transform.SetParent(base.gameObject.transform);
transform.localPosition = Vector3.zero;
transform.localScale = Vector3.one * this.normalScale;
if (Links.x.combat.inPocketAttack)
{
transform.localScale = Vector3.one * 1f;
}
gameObject.layer = 3;
SpriteRenderer spriteRenderer = gameObject.AddComponent<SpriteRenderer>();
spriteRenderer.sprite = effectImageMedium;
spriteRenderer.material = Links.x.spriteEffectMaterial;
if (type.Contains("Up") || type.Contains("Down"))
{
GameObject gameObject2 = new GameObject("Arrow");
gameObject2.layer = 3;
Transform transform2 = gameObject2.transform;
transform2.SetParent(transform);
transform2.localPosition = new Vector3(-0.55f, 0f, -0.05f);
transform2.localScale = Vector3.one * 0.62f;
spriteRenderer = gameObject2.AddComponent<SpriteRenderer>();
if (type.Contains("Up"))
{
if (arrows <= 1)
{
spriteRenderer.sprite = Links.x.archives.arrowUp1;
}
else if (arrows == 2)
{
spriteRenderer.sprite = Links.x.archives.arrowUp2;
}
else if (arrows == 3)
{
spriteRenderer.sprite = Links.x.archives.arrowUp3;
}
}
else if (arrows <= 1)
{
spriteRenderer.sprite = Links.x.archives.arrowDown1;
}
else if (arrows == 2)
{
spriteRenderer.sprite = Links.x.archives.arrowDown2;
}
else if (arrows == 3)
{
spriteRenderer.sprite = Links.x.archives.arrowDown3;
}
spriteRenderer.material = Links.x.spriteEffectMaterial;
}
int count = this.sprites.Count;
if (addToList)
{
this.sprites.Add(gameObject);
if (count == 0)
{
int num = Random.Range(0, 8);
this.angles.Add((float)num * 45f);
}
else
{
float num2 = 3f;
if (!this.allUseHead)
{
num2 = 2f;
}
if (count == 1)
{
this.angles.Add(this.angles[0] + 180f * num2);
}
if (count == 2)
{
this.angles.Add(this.angles[0] + 90f * num2);
}
if (count == 3)
{
this.angles.Add(this.angles[0] + -90f * num2);
}
if (count == 4)
{
this.angles.Add(this.angles[0] + 45f * num2);
}
if (count == 5)
{
this.angles.Add(this.angles[0] + 135f * num2);
}
if (count == 6)
{
this.angles.Add(this.angles[0] + -45f * num2);
}
if (count == 7)
{
this.angles.Add(this.angles[0] + -135f * num2);
}
if (count == 8)
{
this.angles.Add(this.angles[0] + 22.5f * num2);
}
if (count == 9)
{
this.angles.Add(this.angles[0] + 157.5f * num2);
}
if (count == 10)
{
this.angles.Add(this.angles[0] + 67.5f * num2);
}
if (count == 11)
{
this.angles.Add(this.angles[0] + 202.5f * num2);
}
if (count == 12)
{
this.angles.Add(this.angles[0] + -22.5f * num2);
}
if (count == 13)
{
this.angles.Add(this.angles[0] + -157.5f * num2);
}
if (count == 14)
{
this.angles.Add(this.angles[0] + -67.5f * num2);
}
if (count == 15)
{
this.angles.Add(this.angles[0] + -202.5f * num2);
}
if (count > 15)
{
this.angles.Add(Random.Range(0f, 360f));
}
}
this.effects.Add(effect);
this.fx.Add(null);
this.spriteNames.Add(type);
this.arrow.Add(arrows);
this.timeSinceAdded.Add(Time.timeSinceLevelLoad);
MasterAudio.PlaySound3DAtVector3AndForget("Paper", this.character.torsoPosition, 1f, new float?(1f), 0f, "", null);
}
else
{
count = this.savedIndex;
this.sprites[this.savedIndex] = gameObject;
this.angles[this.savedIndex] = this.savedAngle;
this.timeSinceAdded[this.savedIndex] = -1f;
}
int num3 = arrows;
for (int i = 0; i < this.spriteNames.Count; i++)
{
if (this.spriteNames[i] == type && i != count && this.arrow[i] > num3)
{
num3 += this.arrow[i];
}
}
if (num3 != arrows && this.sprites[count])
{
if (Records.x.editor)
{
string text = "Found better arrow amount ";
string text2 = " ";
Character character = this.character;
Debug.Log(text + type + text2 + ((character != null) ? character.ToString() : null));
}
if (type.Contains("Up") || type.Contains("Down"))
{
spriteRenderer = this.sprites[count].transform.GetChild(0).gameObject.GetComponent<SpriteRenderer>();
if (type.Contains("Up"))
{
if (arrows <= 1)
{
spriteRenderer.sprite = Links.x.archives.arrowUp1;
}
else if (arrows == 2)
{
spriteRenderer.sprite = Links.x.archives.arrowUp2;
}
else if (arrows == 3)
{
spriteRenderer.sprite = Links.x.archives.arrowUp3;
}
}
else if (arrows <= 1)
{
spriteRenderer.sprite = Links.x.archives.arrowDown1;
}
else if (arrows == 2)
{
spriteRenderer.sprite = Links.x.archives.arrowDown2;
}
else if (arrows == 3)
{
spriteRenderer.sprite = Links.x.archives.arrowDown3;
}
}
}
this.Rotate(count, type);
}
}
else if (addToList)
{
this.effects.Add(effect);
this.fx.Add(null);
this.spriteNames.Add(type);
this.sprites.Add(null);
this.angles.Add(0f);
this.timeSinceAdded.Add(0f);
this.arrow.Add(arrows);
}
base.gameObject.SetActive(true);
}
// Token: 0x06000AC9 RID: 2761 RVA: 0x000D6A00 File Offset: 0x000D4C00
public void RemoveEffect(string type, Effects effect)
{
this.removing = true;
int num = this.effects.IndexOf(effect);
Vector3 vector = Vector3.zero;
bool flag = false;
if (num > -1)
{
this.effects.RemoveAt(num);
GameObject gameObject = this.sprites[num];
if (gameObject)
{
flag = true;
vector = this.sprites[num].transform.position;
Object.Destroy(gameObject);
}
this.sprites.RemoveAt(num);
this.fx.RemoveAt(num);
this.spriteNames.RemoveAt(num);
this.savedAngle = this.angles[num];
this.angles.RemoveAt(num);
this.arrow.RemoveAt(num);
this.timeSinceAdded.RemoveAt(num);
}
int num2 = this.spriteNames.IndexOf(type);
if (num2 > -1 && flag)
{
this.AddEffect(type, this.effects[num2], false, this.arrow[num2]);
}
if (num2 == -1)
{
RectTransform hannahAnimator = Links.x.cellar.GetHannahAnimator(1);
hannahAnimator.gameObject.SetActive(true);
HannahAnimator component = hannahAnimator.gameObject.GetComponent<HannahAnimator>();
component.Play("Idle");
Vector3 vector2 = Links.x.worldCamera.WorldToScreenPoint(vector);
vector2.z = 0f;
vector2.x = vector2.x * (1920f / (float)Screen.width) - 960f;
vector2.y = vector2.y * (Links.x.canvasRT.sizeDelta.y / (float)Screen.height) - Links.x.canvasRT.sizeDelta.y / 2f;
hannahAnimator.localPosition = vector2;
if (type.Contains("Down"))
{
component.imageRenderer.color = new Color(0.83137256f, 0.23529412f, 0.1764706f, 1f);
}
else if (type.Contains("Up"))
{
component.imageRenderer.color = new Color(0.42352942f, 0.6901961f, 0.18039216f, 1f);
}
else
{
component.imageRenderer.color = new Color(0.74509805f, 0.41568628f, 0.23529412f, 1f);
}
}
if (this.sprites.Count == 0 && !this.character.party)
{
this.ending = 1;
}
this.removing = false;
}
// Token: 0x06000ACA RID: 2762 RVA: 0x000D6C80 File Offset: 0x000D4E80
public void End()
{
for (int i = 0; i < this.sprites.Count; i++)
{
if (this.sprites[i])
{
Object.Destroy(this.sprites[i].gameObject);
}
}
for (int j = base.transform.childCount - 1; j >= 0; j--)
{
if (base.transform.GetChild(j))
{
Object.Destroy(base.transform.GetChild(j).gameObject);
}
}
Object.Destroy(base.gameObject);
}
// Token: 0x06000ACB RID: 2763 RVA: 0x000D6D18 File Offset: 0x000D4F18
private void LateUpdate()
{
this.Rotate(-1, "");
}
// Token: 0x06000ACC RID: 2764 RVA: 0x000D6D28 File Offset: 0x000D4F28
private void Rotate(int index, string n)
{
if (this.sprites.Count > 0 && !this.removing && this.character)
{
bool flag = false;
if (this.character == Links.x.gameplay.gameCardCharacter && Links.x.gameCard.animator.enabled)
{
flag = true;
}
if (this.character.party && this.character.portrait && this.character.portrait.hovering)
{
flag = true;
}
float num = this.radius;
float num2 = this.speedBoost;
bool flag2 = this.allUseHead;
if (this.character.stats.flying)
{
flag2 = true;
}
if (this.character.body.IsHit() || this.character.downed || this.character.dead || this.character.stunned || this.character.sleeping || this.character.animID == 8 || flag2)
{
float num3 = 1f;
if (this.character.neck == this.character.body.tr)
{
this.tr.position = this.character.body.headBone.position + new Vector3(0f, num3, 0f);
}
else
{
this.tr.position = this.character.neck.position + new Vector3(0f, num3, 0f);
}
num = this.radius * 1.7f;
num2 = this.speedBoost * 1f;
}
else
{
this.tr.position = this.character.tr.position + new Vector3(0f, this.yAdd, 0f);
}
Vector3 eulerAngles = Quaternion.LookRotation(this.character.currentPosition - Links.x.worldCamera.gameObject.transform.position).eulerAngles;
eulerAngles.x = 0f;
eulerAngles.z = 0f;
this.tr.rotation = Quaternion.Euler(eulerAngles);
if (Time.timeSinceLevelLoad > this.updateTime + this.updateSpeed || index > -1)
{
this.updateTime = Time.timeSinceLevelLoad;
for (int i = 0; i < this.sprites.Count; i++)
{
if ((index == -1 || i == index) && this.sprites[i])
{
float num4 = this.angles[i];
num4 += this.moveSpeed * Time.deltaTime;
this.sprites[i].transform.localPosition = new Vector3(Mathf.Cos(num4 * num2), 0f, Mathf.Sin(num4 * num2)) / num;
if (Random.Range(0, 3) == 0)
{
this.sprites[i].transform.localRotation = Quaternion.Euler(new Vector3(Random.Range(-5f, 5f), Random.Range(-15f, 15f), Random.Range(-5f, 5f)));
}
this.angles[i] = num4;
if (this.fx[i] && this.fx[i].gameObject.activeSelf)
{
Vector3 vector = Links.x.worldCamera.WorldToScreenPoint(this.sprites[i].transform.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;
this.fx[i].localPosition = vector;
}
if (index > -1)
{
RectTransform hannahAnimator = Links.x.cellar.GetHannahAnimator(0);
this.fx[index] = hannahAnimator;
hannahAnimator.gameObject.SetActive(true);
HannahAnimator component = hannahAnimator.gameObject.GetComponent<HannahAnimator>();
component.Play("Idle");
if (n.Contains("Down"))
{
component.imageRenderer.color = new Color(0.83137256f, 0.23529412f, 0.1764706f, 1f);
}
else if (n.Contains("Up"))
{
component.imageRenderer.color = new Color(0.42352942f, 0.6901961f, 0.18039216f, 1f);
}
else
{
component.imageRenderer.color = new Color(0.74509805f, 0.41568628f, 0.23529412f, 1f);
}
Vector3 vector2 = Links.x.worldCamera.WorldToScreenPoint(this.sprites[i].transform.position);
vector2.z = 0f;
vector2.x = vector2.x * (1920f / (float)Screen.width) - 960f;
vector2.y = vector2.y * (Links.x.canvasRT.sizeDelta.y / (float)Screen.height) - Links.x.canvasRT.sizeDelta.y / 2f;
hannahAnimator.localPosition = vector2;
}
}
}
for (int j = 0; j < this.sprites.Count; j++)
{
if ((index == -1 || j == index) && this.sprites[j])
{
if (this.timeSinceAdded[j] > 0f)
{
if (Time.timeSinceLevelLoad > this.timeSinceAdded[j] + 2f)
{
float num5 = this.timeSinceAdded[j] + 3f - Time.timeSinceLevelLoad;
if (num5 < 0f)
{
this.sprites[j].transform.localScale = Vector3.one * this.smallScale;
this.timeSinceAdded[j] = 0f;
}
else
{
this.sprites[j].transform.localScale = Mathf.Lerp(this.normalScale, this.smallScale, 1f - num5) * Vector3.one;
}
}
}
else if (flag)
{
this.sprites[j].transform.localScale = Vector3.one * this.normalScale;
}
else
{
this.sprites[j].transform.localScale = Vector3.one * this.smallScale;
}
}
}
}
else
{
for (int k = 0; k < this.sprites.Count; k++)
{
if (this.fx[k] && this.sprites[k] && this.fx[k].gameObject.activeSelf)
{
Vector3 vector3 = Links.x.worldCamera.WorldToScreenPoint(this.sprites[k].transform.position);
vector3.z = 0f;
vector3.x = vector3.x * (1920f / (float)Screen.width) - 960f;
vector3.y = vector3.y * (Links.x.canvasRT.sizeDelta.y / (float)Screen.height) - Links.x.canvasRT.sizeDelta.y / 2f;
this.fx[k].localPosition = vector3;
}
}
}
}
if (this.ending > 0)
{
this.ending++;
if (this.ending > 10)
{
if (this.sprites.Count == 0)
{
this.End();
}
this.ending = 0;
}
}
}
// Token: 0x04000F55 RID: 3925
public Character character;
// Token: 0x04000F56 RID: 3926
public List<Effects> effects = new List<Effects>();
// Token: 0x04000F57 RID: 3927
public List<string> spriteNames = new List<string>();
// Token: 0x04000F58 RID: 3928
public List<GameObject> sprites = new List<GameObject>();
// Token: 0x04000F59 RID: 3929
public List<RectTransform> fx = new List<RectTransform>();
// Token: 0x04000F5A RID: 3930
public List<float> angles = new List<float>();
// Token: 0x04000F5B RID: 3931
public List<int> arrow = new List<int>();
// Token: 0x04000F5C RID: 3932
public List<float> timeSinceAdded = new List<float>();
// Token: 0x04000F5D RID: 3933
public float moveSpeed = 3f;
// Token: 0x04000F5E RID: 3934
public float radius = 1.2f;
// Token: 0x04000F5F RID: 3935
public float yAdd = 0.4f;
// Token: 0x04000F60 RID: 3936
private Transform tr;
// Token: 0x04000F61 RID: 3937
private float updateTime;
// Token: 0x04000F62 RID: 3938
public float updateSpeed = 0.07f;
// Token: 0x04000F63 RID: 3939
public float speedBoost = 2.5f;
// Token: 0x04000F64 RID: 3940
private bool removing;
// Token: 0x04000F65 RID: 3941
private float savedAngle;
// Token: 0x04000F66 RID: 3942
private int savedIndex;
// Token: 0x04000F67 RID: 3943
public bool allUseHead;
// Token: 0x04000F68 RID: 3944
private int ending;
// Token: 0x04000F69 RID: 3945
public float normalScale = 0.65f;
// Token: 0x04000F6A RID: 3946
public float smallScale = 0.45f;
}