using System; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; // Token: 0x02000065 RID: 101 [ExecuteInEditMode] public class HannahAnimatorSimple : MonoBehaviour { // Token: 0x06000B57 RID: 2903 RVA: 0x000DD998 File Offset: 0x000DBB98 private void Awake() { if (this.randomStart) { this.delay = Random.Range(0f, 0.1f); this.startTime = Time.timeSinceLevelLoad; this.updateTime = Time.timeSinceLevelLoad + this.delay; if (this.realtime) { this.updateTime = Time.realtimeSinceStartup + this.delay; } if (this.animationType == HannahAnimatorSimple.type.sprite || this.animationType == HannahAnimatorSimple.type.image) { this.currentIndex = Random.Range(0, this.sprites.Count - 1); } if (this.animationType == HannahAnimatorSimple.type.singleMeshRenderer) { if (this.meshes.Count < 5) { this.currentIndex = Random.Range(0, this.meshes.Count - 1); } else { this.currentIndex = Random.Range(0, 5); } } if (this.animationType == HannahAnimatorSimple.type.multipleMeshRenderers) { if (this.meshRenderers.Count < 5) { this.currentIndex = Random.Range(0, this.meshRenderers.Count - 1); } else { this.currentIndex = Random.Range(0, 5); } } } if (this.animationType == HannahAnimatorSimple.type.multipleMeshRenderers) { foreach (MeshRenderer meshRenderer in this.meshRenderers) { if (meshRenderer) { meshRenderer.gameObject.SetActive(true); meshRenderer.enabled = false; } } foreach (MeshRenderer meshRenderer2 in this.meshRenderersAlternative) { if (meshRenderer2) { meshRenderer2.gameObject.SetActive(true); meshRenderer2.enabled = false; } } } this.SetupGroups(); } // Token: 0x06000B58 RID: 2904 RVA: 0x000DDB68 File Offset: 0x000DBD68 public void PlaySecondMeshAnimation() { this.currentIndex = 0; this.secondAnimation = true; foreach (MeshRenderer meshRenderer in this.meshRenderers) { if (meshRenderer) { meshRenderer.enabled = false; } } bool flag = false; foreach (MeshRenderer meshRenderer2 in this.meshRenderersAlternative) { if (meshRenderer2) { if (!flag) { meshRenderer2.enabled = true; flag = true; } else { meshRenderer2.enabled = false; } } } this.updateTime = Time.timeSinceLevelLoad; this.canPlay = true; } // Token: 0x06000B59 RID: 2905 RVA: 0x000DDC40 File Offset: 0x000DBE40 public bool HasSecondAnimation() { return this.meshRenderersAlternative.Count > 0; } // Token: 0x06000B5A RID: 2906 RVA: 0x000DDC53 File Offset: 0x000DBE53 public void PlayAgain() { this.currentIndex = 0; this.canPlay = true; } // Token: 0x06000B5B RID: 2907 RVA: 0x000DDC64 File Offset: 0x000DBE64 private void OnEnable() { if (this.meshRenderers.Count > 0) { for (int i = 0; i < this.meshRenderers.Count; i++) { if (this.meshRenderers[i]) { this.meshRenderers[i].enabled = false; } } } if (this.randomStart) { this.delay = Random.Range(0f, 0.1f); this.startTime = Time.timeSinceLevelLoad; this.updateTime = Time.timeSinceLevelLoad + this.delay; if (this.realtime) { this.updateTime = Time.realtimeSinceStartup + this.delay; } if (this.animationType == HannahAnimatorSimple.type.sprite || this.animationType == HannahAnimatorSimple.type.image) { this.currentIndex = Random.Range(0, this.sprites.Count - 1); } if (this.animationType == HannahAnimatorSimple.type.singleMeshRenderer) { if (this.meshes.Count < 5) { this.currentIndex = Random.Range(0, this.meshes.Count - 1); } else { this.currentIndex = Random.Range(0, 5); } } if (this.animationType == HannahAnimatorSimple.type.multipleMeshRenderers) { this.currentIndex = Random.Range(0, this.meshRenderers.Count - 1); } } this.SetupGroups(); this.canPlay = true; } // Token: 0x06000B5C RID: 2908 RVA: 0x000DDDAC File Offset: 0x000DBFAC private void OnDisable() { if (this.randomStart) { this.delay = Random.Range(0f, 0.5f); this.startTime = Time.timeSinceLevelLoad; if (this.animationType == HannahAnimatorSimple.type.sprite || this.animationType == HannahAnimatorSimple.type.image) { this.currentIndex = Random.Range(0, this.sprites.Count - 1); } if (this.animationType == HannahAnimatorSimple.type.singleMeshRenderer) { this.currentIndex = Random.Range(0, this.meshes.Count - 1); } if (this.animationType == HannahAnimatorSimple.type.multipleMeshRenderers) { this.currentIndex = Random.Range(0, this.meshRenderers.Count - 1); } } else { this.currentIndex = 0; } this.canPlay = true; this.secondAnimation = false; if (this.meshRenderers.Count > 0) { for (int i = 0; i < this.meshRenderers.Count; i++) { if (this.meshRenderers[i]) { this.meshRenderers[i].enabled = false; } } } } // Token: 0x06000B5D RID: 2909 RVA: 0x000DDEB4 File Offset: 0x000DC0B4 private void SetupGroups() { if (this.animationType == HannahAnimatorSimple.type.groups && this.currentIndexes.Count != this.singleRenderers.Count) { this.currentIndexes.Clear(); for (int i = 0; i < this.singleRenderers.Count; i++) { if (this.meshRenderers.Count < 5) { this.currentIndex = Random.Range(0, this.meshRenderers.Count - 1); } else { this.currentIndex = Random.Range(0, 5); } if (this.randomStart) { this.currentIndexes.Add(this.currentIndex); } else { this.currentIndexes.Add(0); } } } } // Token: 0x06000B5E RID: 2910 RVA: 0x000DDF64 File Offset: 0x000DC164 private void Update() { if (!this.canPlay) { return; } if (this.speed > 0f) { if (this.animationType == HannahAnimatorSimple.type.sprite && ((!this.realtime && Time.timeSinceLevelLoad > this.updateTime + this.updateInterval) || (this.realtime && Time.realtimeSinceStartup > this.updateTime + this.updateInterval))) { this.updateTime = Time.timeSinceLevelLoad; if (this.realtime) { this.updateTime = Time.realtimeSinceStartup; } this.currentIndex++; if (this.currentIndex > this.sprites.Count - 1) { if (!this.loop) { this.currentIndex = 0; this.canPlay = false; if (this.turnOffWhenDone) { base.gameObject.SetActive(false); base.gameObject.transform.SetParent(Links.x.cellar.tr); } return; } this.currentIndex = 0; } this.spriteRenderer.sprite = this.sprites[this.currentIndex]; if (this.randomRotationY || this.randomRotationY || this.randomRotationZ) { SpriteRenderer spriteRenderer = this.spriteRenderer; this.Rotate(spriteRenderer); } } if ((this.animationType == HannahAnimatorSimple.type.multipleMeshRenderers || this.animationType == HannahAnimatorSimple.type.singleMeshRenderer || this.animationType == HannahAnimatorSimple.type.groups) && ((!this.realtime && Time.timeSinceLevelLoad > this.updateTime + this.updateInterval) || (this.realtime && Time.realtimeSinceStartup > this.updateTime + this.updateInterval))) { this.updateTime = Time.timeSinceLevelLoad; if (this.realtime) { this.updateTime = Time.realtimeSinceStartup; } if (this.animationType != HannahAnimatorSimple.type.groups) { this.currentIndex++; if ((this.animationType == HannahAnimatorSimple.type.singleMeshRenderer && this.currentIndex >= this.meshes.Count - 1) || (!this.secondAnimation && this.animationType == HannahAnimatorSimple.type.multipleMeshRenderers && this.currentIndex >= this.meshRenderers.Count) || (this.secondAnimation && this.animationType == HannahAnimatorSimple.type.multipleMeshRenderers && this.currentIndex >= this.meshRenderersAlternative.Count)) { if (!this.loop) { this.currentIndex = 0; this.canPlay = false; if (this.turnOffWhenDone) { base.gameObject.SetActive(false); base.gameObject.transform.SetParent(Links.x.cellar.tr); } return; } this.currentIndex = 0; } } else { for (int i = 0; i < this.currentIndexes.Count; i++) { List list = this.currentIndexes; int num = i; int num2 = list[num]; list[num] = num2 + 1; if (this.currentIndexes[i] >= this.meshes.Count - 1) { if (!this.loop) { this.currentIndexes[i] = 0; this.canPlay = false; return; } this.currentIndexes[i] = 0; } } } if (this.animationType == HannahAnimatorSimple.type.multipleMeshRenderers) { if (!this.secondAnimation) { for (int j = 0; j < this.meshRenderers.Count; j++) { if (this.meshRenderers[j]) { if (j != this.currentIndex) { this.meshRenderers[j].enabled = false; } else { if (!this.meshRenderers[j].gameObject.activeSelf) { this.meshRenderers[j].gameObject.SetActive(true); } this.meshRenderers[j].enabled = true; } } } } else { for (int k = 0; k < this.meshRenderersAlternative.Count; k++) { if (this.meshRenderersAlternative[k]) { if (k != this.currentIndex) { this.meshRenderersAlternative[k].enabled = false; } else { if (!this.meshRenderersAlternative[k].gameObject.activeSelf) { this.meshRenderersAlternative[k].gameObject.SetActive(true); } this.meshRenderersAlternative[k].enabled = true; } } } } } else if (this.animationType == HannahAnimatorSimple.type.groups) { for (int l = 0; l < this.currentIndexes.Count; l++) { if (l < this.singleFilters.Count && l < this.singleRenderers.Count) { this.singleFilters[l].mesh = this.meshes[this.currentIndexes[l]]; if (!this.singleRenderers[l].enabled) { this.singleRenderer.enabled = true; } } } } else if (this.singleFilter) { this.singleFilter.mesh = this.meshes[this.currentIndex]; this.singleRenderer.enabled = true; } if (this.randomRotationY || this.randomRotationY || this.randomRotationZ) { if (this.animationType == HannahAnimatorSimple.type.groups) { for (int m = 0; m < this.currentIndexes.Count; m++) { if (m < this.singleFilters.Count && m < this.singleRenderers.Count && this.singleRenderers[m]) { this.Rotate(this.singleRenderers[m]); } } } else { MeshRenderer meshRenderer = this.singleRenderer; if (this.animationType == HannahAnimatorSimple.type.multipleMeshRenderers) { meshRenderer = this.meshRenderers[this.currentIndex]; } if (meshRenderer) { this.Rotate(meshRenderer); } } } else { int count = this.localRotations.Count; int count2 = this.meshRenderers.Count; } } if (this.animationType == HannahAnimatorSimple.type.image && ((!this.realtime && Time.timeSinceLevelLoad > this.updateTime + this.updateInterval) || (this.realtime && Time.realtimeSinceStartup > this.updateTime + this.updateInterval))) { this.updateTime = Time.timeSinceLevelLoad; if (this.realtime) { this.updateTime = Time.realtimeSinceStartup; } this.currentIndex++; if (this.currentIndex > this.sprites.Count - 1) { if (!this.loop) { this.currentIndex = 0; this.canPlay = false; return; } this.currentIndex = 0; } if (base.enabled) { this.imageRenderer.sprite = this.sprites[this.currentIndex]; } } if (this.animationType == HannahAnimatorSimple.type.multipleImages && ((!this.realtime && Time.timeSinceLevelLoad > this.updateTime + this.updateInterval) || (this.realtime && Time.realtimeSinceStartup > this.updateTime + this.updateInterval))) { this.updateTime = Time.timeSinceLevelLoad; if (this.realtime) { this.updateTime = Time.realtimeSinceStartup; } this.currentIndex++; if (this.currentIndex > this.multipleImages.Count - 1) { if (!this.loop) { this.currentIndex = 0; this.canPlay = false; return; } this.currentIndex = 0; } if (base.enabled) { for (int n = 0; n < this.multipleImages.Count; n++) { if (this.currentIndex == n) { this.multipleImages[n].enabled = true; } else { this.multipleImages[n].enabled = false; } } } } } } // Token: 0x06000B5F RID: 2911 RVA: 0x000DE728 File Offset: 0x000DC928 private void Rotate(SpriteRenderer m) { this.RotateAny(m.gameObject.transform); } // Token: 0x06000B60 RID: 2912 RVA: 0x000DE73B File Offset: 0x000DC93B private void Rotate(MeshRenderer m) { this.RotateAny(m.gameObject.transform); } // Token: 0x06000B61 RID: 2913 RVA: 0x000DE750 File Offset: 0x000DC950 private void RotateAny(Transform t) { Vector3 vector = new Vector3(0f, 0f, 0f); if (this.randomRotationY) { vector.y = Random.Range(0f, 360f); } if (this.randomRotationX) { vector.x = Random.Range(0f, 360f); } if (this.randomRotationZ) { vector.z = Random.Range(0f, 360f); } t.localRotation = Quaternion.Euler(vector); } // Token: 0x06000B62 RID: 2914 RVA: 0x000DE7DC File Offset: 0x000DC9DC public void UpdateMaterials(Material mat) { foreach (MeshRenderer meshRenderer in this.meshRenderers) { if (meshRenderer) { meshRenderer.sharedMaterial = mat; } } } // Token: 0x040010C0 RID: 4288 [Header("ANIMATION INFO")] private float updateTime; // Token: 0x040010C1 RID: 4289 public float speed = 1f; // Token: 0x040010C2 RID: 4290 public bool realtime; // Token: 0x040010C3 RID: 4291 public float updateInterval = 0.2f; // Token: 0x040010C4 RID: 4292 public HannahAnimatorSimple.type animationType; // Token: 0x040010C5 RID: 4293 public int currentIndex; // Token: 0x040010C6 RID: 4294 public bool randomStart; // Token: 0x040010C7 RID: 4295 public bool loop = true; // Token: 0x040010C8 RID: 4296 public bool turnOffWhenDone; // Token: 0x040010C9 RID: 4297 [Header("FOR MESH RENDERERS (on individual game objects)")] public List meshRenderers = new List(); // Token: 0x040010CA RID: 4298 public List meshRenderersAlternative = new List(); // Token: 0x040010CB RID: 4299 [Header("FOR MESHES (on one game object)")] public MeshRenderer singleRenderer; // Token: 0x040010CC RID: 4300 public MeshFilter singleFilter; // Token: 0x040010CD RID: 4301 [Header("FOR GROUPS (like candelabras)")] public List singleRenderers; // Token: 0x040010CE RID: 4302 public List singleFilters; // Token: 0x040010CF RID: 4303 private List currentIndexes = new List(); // Token: 0x040010D0 RID: 4304 [Header("MESHES TO FLIP BETWEEN")] public List meshes = new List(); // Token: 0x040010D1 RID: 4305 [Header("FOR ROTATIONS")] public List localRotations = new List(); // Token: 0x040010D2 RID: 4306 public bool randomRotationX; // Token: 0x040010D3 RID: 4307 public bool randomRotationY; // Token: 0x040010D4 RID: 4308 public bool randomRotationZ; // Token: 0x040010D5 RID: 4309 [Header("FOR SPRITES or UI IMAGES")] public SpriteRenderer spriteRenderer; // Token: 0x040010D6 RID: 4310 public Image imageRenderer; // Token: 0x040010D7 RID: 4311 public List multipleImages = new List(); // Token: 0x040010D8 RID: 4312 public List sprites = new List(); // Token: 0x040010D9 RID: 4313 private float t; // Token: 0x040010DA RID: 4314 private float start; // Token: 0x040010DB RID: 4315 private float target; // Token: 0x040010DC RID: 4316 private float delay; // Token: 0x040010DD RID: 4317 private float startTime; // Token: 0x040010DE RID: 4318 private bool canPlay; // Token: 0x040010DF RID: 4319 private bool secondAnimation; // Token: 0x020001CE RID: 462 public enum type { // Token: 0x04002E06 RID: 11782 sprite, // Token: 0x04002E07 RID: 11783 image, // Token: 0x04002E08 RID: 11784 singleMeshRenderer, // Token: 0x04002E09 RID: 11785 multipleMeshRenderers, // Token: 0x04002E0A RID: 11786 groups, // Token: 0x04002E0B RID: 11787 multipleImages } }