Elin Modding Docs Doc
Loading...
Searching...
No Matches
RigidExplode.cs
1using System;
2using UnityEngine;
3
4// Token: 0x02000519 RID: 1305
6{
7 // Token: 0x0600230E RID: 8974 RVA: 0x000C5555 File Offset: 0x000C3755
8 private void Start()
9 {
10 this.interval = UnityEngine.Random.Range(this.intervalMin, this.intervalMax);
11 }
12
13 // Token: 0x0600230F RID: 8975 RVA: 0x000C5570 File Offset: 0x000C3770
14 public void Explode()
15 {
16 Vector2 position = this.rb.position;
17 if (this.particle)
18 {
19 ParticleSystem p = UnityEngine.Object.Instantiate<ParticleSystem>(this.particle);
20 p.transform.position = position;
21 TweenUtil.Delay(5f, delegate
22 {
23 if (p && p.gameObject)
24 {
25 UnityEngine.Object.DestroyImmediate(p.gameObject);
26 }
27 });
28 }
29 foreach (RaycastHit2D raycastHit2D in Physics2D.CircleCastAll(position, this.radius, Vector3.forward))
30 {
31 Rigidbody2D component = raycastHit2D.collider.GetComponent<Rigidbody2D>();
32 if (component)
33 {
34 Vector2 a = component.position - position;
35 component.AddForce(a * this.force * (1f + component.mass * this.massPower), ForceMode2D.Impulse);
36 }
37 }
38 if (!this.sound.IsEmpty())
39 {
40 EMono.Sound.Play(this.sound, this.rb.position, 1f);
41 }
42 }
43
44 // Token: 0x06002310 RID: 8976 RVA: 0x000C5690 File Offset: 0x000C3890
45 public override void OnFixedUpdate()
46 {
47 this.time += RigidUpdate.delta;
48 if (this.time > this.interval)
49 {
50 if (this.chance >= UnityEngine.Random.Range(0f, 1f))
51 {
52 this.Explode();
53 if (this.destroy)
54 {
55 this.active = false;
56 CollectibleActor component = base.gameObject.GetComponent<CollectibleActor>();
57 if (component)
58 {
59 component.Deactivate();
60 return;
61 }
62 base.gameObject.SetActive(false);
63 return;
64 }
65 }
66 if (this.repeat)
67 {
68 this.time = 0f;
69 return;
70 }
71 this.active = false;
72 }
73 }
74
75 // Token: 0x04001285 RID: 4741
76 public ParticleSystem particle;
77
78 // Token: 0x04001286 RID: 4742
79 public float force = 20f;
80
81 // Token: 0x04001287 RID: 4743
82 public float radius = 2.5f;
83
84 // Token: 0x04001288 RID: 4744
85 public float intervalMin = 5f;
86
87 // Token: 0x04001289 RID: 4745
88 public float intervalMax = 30f;
89
90 // Token: 0x0400128A RID: 4746
91 public float massPower = 0.1f;
92
93 // Token: 0x0400128B RID: 4747
94 public float chance = 0.8f;
95
96 // Token: 0x0400128C RID: 4748
97 public bool repeat;
98
99 // Token: 0x0400128D RID: 4749
100 public bool destroy = true;
101
102 // Token: 0x0400128E RID: 4750
103 public string sound = "explode";
104
105 // Token: 0x0400128F RID: 4751
106 private float time;
107
108 // Token: 0x04001290 RID: 4752
109 private float interval = 1f;
110}
Definition EMono.cs:6