Elin Modding Docs Doc
Loading...
Searching...
No Matches
HS_ParticleEndSound.cs
1using System;
2using System.Collections;
3using System.Collections.Generic;
4using UnityEngine;
5
6// Token: 0x02000126 RID: 294
7public class HS_ParticleEndSound : MonoBehaviour
8{
9 // Token: 0x060007EB RID: 2027 RVA: 0x0003340C File Offset: 0x0003160C
10 private void Awake()
11 {
12 HS_ParticleEndSound.SharedInstance = this;
13 }
14
15 // Token: 0x060007EC RID: 2028 RVA: 0x00033414 File Offset: 0x00031614
16 private void Start()
17 {
18 this.poolDictionary = new Dictionary<string, Queue<GameObject>>();
19 foreach (HS_ParticleEndSound.Pool pool in this.pools)
20 {
22 GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(pool.prefab);
23 AudioSource component = gameObject.GetComponent<AudioSource>();
24 if (pool.tag == "AudioExplosion")
25 {
26 component.clip = this.audioExplosion[UnityEngine.Random.Range(0, this.audioExplosion.Length)];
27 component.volume = UnityEngine.Random.Range(this.explosionMinVolume, this.explosionMaxVolume);
28 component.pitch = UnityEngine.Random.Range(this.explosionPitchMin, this.explosionPitchMax);
29 }
30 else if (pool.tag == "AudioShot")
31 {
32 component.clip = this.audioShot[UnityEngine.Random.Range(0, this.audioExplosion.Length)];
33 component.volume = UnityEngine.Random.Range(this.shootMinVolume, this.shootMaxVolume);
34 component.pitch = UnityEngine.Random.Range(this.shootPitchMin, this.shootPitchMax);
35 }
36 gameObject.transform.parent = base.gameObject.transform;
37 gameObject.SetActive(false);
38 queue.Enqueue(gameObject);
39 this.poolDictionary.Add(pool.tag, queue);
40 }
41 }
42
43 // Token: 0x060007ED RID: 2029 RVA: 0x0003358C File Offset: 0x0003178C
44 public GameObject SpawnFromPool(string tag, Vector3 position)
45 {
46 if (!this.poolDictionary.ContainsKey(tag))
47 {
48 Debug.LogWarning("Pool with tag" + tag + " does not excist.");
49 return null;
50 }
51 GameObject gameObject = this.poolDictionary[tag].Dequeue();
52 gameObject.SetActive(true);
53 position.z = 0f;
54 gameObject.transform.position = position;
55 this.poolDictionary[tag].Enqueue(gameObject);
56 return gameObject;
57 }
58
59 // Token: 0x060007EE RID: 2030 RVA: 0x00033604 File Offset: 0x00031804
60 public void LateUpdate()
61 {
62 ParticleSystem.Particle[] array = new ParticleSystem.Particle[base.GetComponent<ParticleSystem>().particleCount];
63 int particles = base.GetComponent<ParticleSystem>().GetParticles(array);
64 for (int i = 0; i < particles; i++)
65 {
66 if (this.audioExplosion.Length != 0 && array[i].remainingLifetime < Time.deltaTime)
67 {
68 GameObject gameObject = HS_ParticleEndSound.SharedInstance.SpawnFromPool("AudioExplosion", array[i].position);
69 if (gameObject != null)
70 {
71 base.StartCoroutine(this.LateCall(gameObject));
72 }
73 }
74 if (this.audioShot.Length != 0 && array[i].remainingLifetime >= array[i].startLifetime - Time.deltaTime)
75 {
76 GameObject gameObject2 = HS_ParticleEndSound.SharedInstance.SpawnFromPool("AudioShot", array[i].position);
77 if (gameObject2 != null)
78 {
79 base.StartCoroutine(this.LateCall(gameObject2));
80 }
81 }
82 }
83 }
84
85 // Token: 0x060007EF RID: 2031 RVA: 0x000336EF File Offset: 0x000318EF
86 private IEnumerator LateCall(GameObject soundInstance)
87 {
88 yield return new WaitForSeconds(this.poolReturnTimer);
89 soundInstance.SetActive(false);
90 yield break;
91 }
92
93 // Token: 0x04000821 RID: 2081
94 public float poolReturnTimer = 1.5f;
95
96 // Token: 0x04000822 RID: 2082
97 public float explosionMinVolume = 0.3f;
98
99 // Token: 0x04000823 RID: 2083
100 public float explosionMaxVolume = 0.7f;
101
102 // Token: 0x04000824 RID: 2084
103 public float explosionPitchMin = 0.75f;
104
105 // Token: 0x04000825 RID: 2085
106 public float explosionPitchMax = 1.25f;
107
108 // Token: 0x04000826 RID: 2086
109 public float shootMinVolume = 0.05f;
110
111 // Token: 0x04000827 RID: 2087
112 public float shootMaxVolume = 0.1f;
113
114 // Token: 0x04000828 RID: 2088
115 public float shootPitchMin = 0.75f;
116
117 // Token: 0x04000829 RID: 2089
118 public float shootPitchMax = 1.25f;
119
120 // Token: 0x0400082A RID: 2090
121 public AudioClip[] audioExplosion;
122
123 // Token: 0x0400082B RID: 2091
124 public AudioClip[] audioShot;
125
126 // Token: 0x0400082C RID: 2092
127 public static HS_ParticleEndSound SharedInstance;
128
129 // Token: 0x0400082D RID: 2093
130 public List<HS_ParticleEndSound.Pool> pools;
131
132 // Token: 0x0400082E RID: 2094
133 public Dictionary<string, Queue<GameObject>> poolDictionary;
134
135 // Token: 0x02000852 RID: 2130
136 [Serializable]
137 public class Pool
138 {
139 // Token: 0x04002398 RID: 9112
140 public string tag;
141
142 // Token: 0x04002399 RID: 9113
143 public GameObject prefab;
144
145 // Token: 0x0400239A RID: 9114
146 public int size;
147 }
148}
Definition Queue.cs:5