Elin Modding Docs Doc
Loading...
Searching...
No Matches
Effect.cs
1using System;
2using System.Collections.Generic;
3using DG.Tweening;
4using DG.Tweening.Core;
5using DG.Tweening.Plugins.Options;
6using UnityEngine;
7
8// Token: 0x0200011D RID: 285
9public class Effect : SceneObject
10{
11 // Token: 0x060007B0 RID: 1968 RVA: 0x00031BB9 File Offset: 0x0002FDB9
12 public static Effect Get(Effect original)
13 {
14 return UnityEngine.Object.Instantiate<Effect>(original);
15 }
16
17 // Token: 0x060007B1 RID: 1969 RVA: 0x00031BC1 File Offset: 0x0002FDC1
18 public static Effect Get(string id)
19 {
20 return Effect.manager.effects.Get(id);
21 }
22
23 // Token: 0x060007B2 RID: 1970 RVA: 0x00031BD3 File Offset: 0x0002FDD3
24 public static T Get<T>(string id) where T : Effect
25 {
26 return Effect.manager.effects.Get(id) as T;
27 }
28
29 // Token: 0x170001C4 RID: 452
30 // (get) Token: 0x060007B3 RID: 1971 RVA: 0x00031BEF File Offset: 0x0002FDEF
31 public static EffectManager manager
32 {
33 get
34 {
35 return EffectManager.Instance;
36 }
37 }
38
39 // Token: 0x060007B4 RID: 1972 RVA: 0x00031BF8 File Offset: 0x0002FDF8
40 public void Play(float delay, Point from, float fixY = 0f, Point to = null, Sprite sprite = null)
41 {
42 Point _from = from.Copy();
43 Point _to = ((to != null) ? to.Copy() : null) ?? null;
44 TweenUtil.Tween(delay, delegate()
45 {
46 this.Play(_from, fixY, _to, sprite);
47 }, null);
48 }
49
50 // Token: 0x060007B5 RID: 1973 RVA: 0x00031C5A File Offset: 0x0002FE5A
51 public unsafe Effect Play(Point from, float fixY = 0f, Point to = null, Sprite sprite = null)
52 {
53 return this._Play(from, *from.Position(), fixY, to, sprite);
54 }
55
56 // Token: 0x060007B6 RID: 1974 RVA: 0x00031C74 File Offset: 0x0002FE74
57 public unsafe Effect _Play(Point from, Vector3 fromV, float fixY = 0f, Point to = null, Sprite sprite = null)
58 {
59 if (!EMono.core.IsGameStarted)
60 {
61 this.Kill();
62 return null;
63 }
64 if (sprite)
65 {
66 this.sr.sprite = sprite;
67 }
68 if (this.setColor)
69 {
70 float num = 0.07f * (float)from.cell.light + EMono.core.screen.tileMap._baseBrightness;
71 num += ((from.cell.HasRoof || from.cell.isShadowed) ? -0.2f : 0f);
72 if (this.sr)
73 {
74 this.sr.material.SetVector("_Color", new Vector4(num, num, num, 1f));
75 }
76 }
77 fromV += this.posFix;
78 fromV.y += fixY;
79 if (to == null)
80 {
81 fromV += this.randomRange.Random();
82 }
83 this.fromV = fromV;
84 this.destPos = (to ?? from);
85 base.transform.position = fromV;
86 if (this.randomFlip)
87 {
88 this.sr.flipX = (EMono.rnd(2) == 0);
89 }
90 if (to != null)
91 {
92 float num2 = Mathf.Min(this.speed * (float)from.Distance(to), this.duration);
93 this.destV = *to.Position() + this.posFix + this.randomRange.Random();
94 if (this.rotate)
95 {
96 base.transform.rotation = from.GetRotation(to);
97 }
98 this.moveTween = base.transform.DOMove(this.destV, num2, false).SetEase(Ease.Linear).SetDelay(this.startDelay);
99 }
100 this.Activate();
101 this.OnPlay();
102 this.OnUpdate();
103 return this;
104 }
105
106 // Token: 0x060007B7 RID: 1975 RVA: 0x00031E4C File Offset: 0x0003004C
107 public Effect Play(Vector3 v)
108 {
109 if (!EMono.core.IsGameStarted)
110 {
111 this.Kill();
112 return null;
113 }
114 this.fromV = v;
115 base.transform.position = this.fromV + this.posFix;
116 this.Activate();
117 this.OnPlay();
118 this.OnUpdate();
119 return this;
120 }
121
122 // Token: 0x060007B8 RID: 1976 RVA: 0x00031EA4 File Offset: 0x000300A4
123 protected void Activate()
124 {
125 if (this.sprites.Length != 0 && this.type != Effect.Type.Firework)
126 {
127 this.sr.enabled = false;
128 }
129 Effect.manager.Add(this);
130 this.killTimer = TweenUtil.Tween(this.startDelay + this.duration + 0.01f + (float)this.sprites.Length * 0.01f, null, new Action(this.Kill));
131 }
132
133 // Token: 0x060007B9 RID: 1977 RVA: 0x00031F18 File Offset: 0x00030118
134 public Effect Flip(bool x = false, bool y = false)
135 {
136 if (this.sr)
137 {
138 this.sr.flipX = (this.sr.flipX ? (!x) : x);
139 this.sr.flipY = (this.sr.flipY ? (!y) : y);
140 }
141 return this;
142 }
143
144 // Token: 0x060007BA RID: 1978 RVA: 0x00031F71 File Offset: 0x00030171
145 public Effect SetStartDelay(float a)
146 {
147 this.startDelay = a;
148 return this;
149 }
150
151 // Token: 0x060007BB RID: 1979 RVA: 0x00031F7B File Offset: 0x0003017B
152 public virtual void OnPlay()
153 {
154 }
155
156 // Token: 0x060007BC RID: 1980 RVA: 0x00031F80 File Offset: 0x00030180
157 public virtual void OnUpdate()
158 {
159 if (!base.gameObject.activeSelf)
160 {
161 base.gameObject.SetActive(true);
162 }
163 this.timer += (this.randomSpeed ? UnityEngine.Random.Range(Time.deltaTime, Time.deltaTime * 1.5f) : Time.deltaTime);
164 if (this.startDelay != 0f)
165 {
166 if (this.timer < this.startDelay)
167 {
168 return;
169 }
170 this.timer = (this.startDelay = 0f);
171 }
172 if (this.sprites.Length != 0 && this.type != Effect.Type.Firework && this.timer > this.duration / (float)this.sprites.Length)
173 {
174 this.timer = 0f;
175 this.spriteIndex++;
176 if (this.spriteIndex >= this.sprites.Length)
177 {
178 this.Kill();
179 return;
180 }
181 this.sr.enabled = true;
182 this.sr.sprite = this.sprites[this.spriteIndex];
183 }
184 }
185
186 // Token: 0x060007BD RID: 1981 RVA: 0x00032088 File Offset: 0x00030288
187 public void Kill()
188 {
189 TweenUtil.KillTween(ref this.killTimer, false);
190 TweenUtil.KillTween(ref this.moveTween, false);
191 this.killed = true;
192 Effect.manager.Remove(this);
193 if (this.pool && Effect.manager.effects.usePool)
194 {
195 PoolManager.DespawnOrDestroy(base.transform);
196 return;
197 }
198 if (base.gameObject)
199 {
200 UnityEngine.Object.Destroy(base.gameObject);
201 }
202 }
203
204 // Token: 0x060007BE RID: 1982 RVA: 0x000320FE File Offset: 0x000302FE
205 public void OnDisable()
206 {
207 if (base.transform.parent && !this.test)
208 {
209 this.Kill();
210 }
211 }
212
213 // Token: 0x060007BF RID: 1983 RVA: 0x00032120 File Offset: 0x00030320
214 public void OnDestroy()
215 {
216 if (this.materialsToDestroy != null)
217 {
218 foreach (Material obj in this.materialsToDestroy)
219 {
220 UnityEngine.Object.Destroy(obj);
221 }
222 }
223 }
224
225 // Token: 0x060007C0 RID: 1984 RVA: 0x00032178 File Offset: 0x00030378
226 public Effect Emit(int num)
227 {
228 ParticleSystem[] array = this.systems;
229 for (int i = 0; i < array.Length; i++)
230 {
231 array[i].Emit(num);
232 }
233 return this;
234 }
235
236 // Token: 0x060007C1 RID: 1985 RVA: 0x000321A4 File Offset: 0x000303A4
237 public Effect SetParticleColor(Color c)
238 {
239 ParticleSystem[] array = this.systems;
240 for (int i = 0; i < array.Length; i++)
241 {
242 array[i].main.startColor = c;
243 }
244 return this;
245 }
246
247 // Token: 0x060007C2 RID: 1986 RVA: 0x000321E0 File Offset: 0x000303E0
248 public Effect SetParticleColor(Color color, bool changeMaterial = false, string idCol = "_Color")
249 {
250 if (changeMaterial)
251 {
252 this.materialsToDestroy = new List<Material>();
253 }
254 foreach (ParticleSystem particleSystem in this.systems)
255 {
256 if (changeMaterial)
257 {
258 Material material = particleSystem.GetComponent<ParticleSystemRenderer>().material;
259 this.materialsToDestroy.Add(material);
260 material.SetColor(idCol, color);
261 }
262 else
263 {
264 particleSystem.main.startColor = color;
265 }
266 }
267 return this;
268 }
269
270 // Token: 0x060007C3 RID: 1987 RVA: 0x0003224F File Offset: 0x0003044F
271 public Effect SetScale(float a)
272 {
273 base.transform.localScale *= a;
274 return this;
275 }
276
277 // Token: 0x040007B3 RID: 1971
278 public Effect.Type type;
279
280 // Token: 0x040007B4 RID: 1972
281 public float duration = 1f;
282
283 // Token: 0x040007B5 RID: 1973
284 public float speed;
285
286 // Token: 0x040007B6 RID: 1974
287 public float startDelay;
288
289 // Token: 0x040007B7 RID: 1975
290 public bool lookAtTarget;
291
292 // Token: 0x040007B8 RID: 1976
293 public bool rotate;
294
295 // Token: 0x040007B9 RID: 1977
296 public bool pool;
297
298 // Token: 0x040007BA RID: 1978
299 public SpriteRenderer sr;
300
301 // Token: 0x040007BB RID: 1979
302 public ParticleSystem[] systems;
303
304 // Token: 0x040007BC RID: 1980
305 public Vector3[] dirs;
306
307 // Token: 0x040007BD RID: 1981
308 public Ease ease;
309
310 // Token: 0x040007BE RID: 1982
311 public Vector3 posFix;
312
313 // Token: 0x040007BF RID: 1983
314 public Vector3 randomRange;
315
316 // Token: 0x040007C0 RID: 1984
317 public Tween moveTween;
318
319 // Token: 0x040007C1 RID: 1985
320 public Sprite[] sprites;
321
322 // Token: 0x040007C2 RID: 1986
323 public bool randomFlip;
324
325 // Token: 0x040007C3 RID: 1987
326 public bool randomSpeed;
327
328 // Token: 0x040007C4 RID: 1988
329 public bool test;
330
331 // Token: 0x040007C5 RID: 1989
332 public bool setColor = true;
333
334 // Token: 0x040007C6 RID: 1990
335 public Action onComplete;
336
337 // Token: 0x040007C7 RID: 1991
338 [NonSerialized]
339 public int spriteIndex;
340
341 // Token: 0x040007C8 RID: 1992
342 [NonSerialized]
343 public float timer;
344
345 // Token: 0x040007C9 RID: 1993
346 [NonSerialized]
347 public Vector3 fromV;
348
349 // Token: 0x040007CA RID: 1994
350 [NonSerialized]
351 public Vector3 destV;
352
353 // Token: 0x040007CB RID: 1995
354 [NonSerialized]
355 public bool pooled;
356
357 // Token: 0x040007CC RID: 1996
358 [NonSerialized]
359 public Transform poolParent;
360
361 // Token: 0x040007CD RID: 1997
362 [NonSerialized]
363 public List<Material> materialsToDestroy;
364
365 // Token: 0x040007CE RID: 1998
366 [NonSerialized]
367 public Point destPos;
368
369 // Token: 0x040007CF RID: 1999
370 protected bool killed;
371
372 // Token: 0x040007D0 RID: 2000
373 [NonSerialized]
374 public Tween killTimer;
375
376 // Token: 0x0200084C RID: 2124
377 public enum Type
378 {
379 // Token: 0x0400238D RID: 9101
380 Default,
381 // Token: 0x0400238E RID: 9102
382 Firework
383 }
384}
Definition EMono.cs:6
Definition Point.cs:11