1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
|
using System;
using Photon.Pun;
using Sirenix.OdinInspector;
using Sonigon;
using UnityEngine;
public class Explosion : MonoBehaviour
{
[Header("Sounds")]
public SoundEvent soundDamage;
[Header("Settings")]
public float slow;
public float silence;
public bool fastSlow;
public float stun;
public float force = 2000f;
public float objectForceMultiplier = 1f;
public bool forceIgnoreMass;
public float damage = 25f;
public Color dmgColor = Color.black;
public float range = 2f;
public float flyingFor;
public bool auto = true;
public bool ignoreTeam;
public bool ignoreWalls;
public bool staticRangeMultiplier;
[FoldoutGroup("Scaling", 0)]
public bool scaleSlow = true;
[FoldoutGroup("Scaling", 0)]
public bool scaleSilence = true;
[FoldoutGroup("Scaling", 0)]
public bool scaleDmg = true;
[FoldoutGroup("Scaling", 0)]
public bool scaleRadius = true;
[FoldoutGroup("Scaling", 0)]
public bool scaleStun = true;
[FoldoutGroup("Scaling", 0)]
public bool scaleForce = true;
[FoldoutGroup("Immunity", 0)]
public float immunity;
private SpawnedAttack spawned;
public bool locallySimulated;
public Action<Damagable> DealDamageAction;
public Action<Damagable> DealHealAction;
public Action<Damagable, float> HitTargetAction;
private PhotonView view;
public Action<CharacterData, float> hitPlayerAction;
private void Start()
{
spawned = GetComponent<SpawnedAttack>();
view = GetComponent<PhotonView>();
if (auto)
{
Explode();
}
}
private void DoExplosionEffects(Collider2D hitCol, float rangeMultiplier, float distance)
{
float num = (scaleDmg ? base.transform.localScale.x : 1f);
float num2 = (scaleForce ? base.transform.localScale.x : 1f);
float num3 = (scaleSlow ? base.transform.localScale.x : 1f);
float num4 = (scaleSilence ? base.transform.localScale.x : 1f);
float num5 = (scaleStun ? ((1f + base.transform.localScale.x) * 0.5f) : 1f);
Damagable componentInParent = hitCol.gameObject.GetComponentInParent<Damagable>();
CharacterData characterData = null;
if ((bool)componentInParent)
{
characterData = hitCol.gameObject.GetComponentInParent<CharacterData>();
if ((immunity > 0f && (bool)characterData && characterData.GetComponent<PlayerImmunity>().IsImune(immunity, num * damage * rangeMultiplier, base.gameObject.name)) || (!ignoreWalls && (bool)characterData && !PlayerManager.instance.CanSeePlayer(base.transform.position, characterData.player).canSee))
{
return;
}
if (slow != 0f && (bool)componentInParent.GetComponent<CharacterStatModifiers>())
{
if (locallySimulated)
{
if (spawned.IsMine() && !characterData.block.IsBlocking())
{
characterData.stats.RPCA_AddSlow(slow * rangeMultiplier * num3, fastSlow);
}
}
else if (spawned.IsMine() && !characterData.block.IsBlocking())
{
characterData.view.RPC("RPCA_AddSlow", RpcTarget.All, slow * rangeMultiplier * num3, fastSlow);
}
}
if (silence != 0f && (bool)componentInParent.GetComponent<SilenceHandler>() && spawned.IsMine() && !characterData.block.IsBlocking())
{
characterData.view.RPC("RPCA_AddSilence", RpcTarget.All, silence * rangeMultiplier * num4);
}
if ((bool)spawned)
{
_ = spawned.spawner;
}
hitPlayerAction?.Invoke(characterData, rangeMultiplier);
if (damage < 0f)
{
if ((bool)characterData)
{
characterData.healthHandler.Heal(0f - damage);
}
if (DealHealAction != null)
{
DealHealAction(componentInParent);
}
}
else if (damage > 0f)
{
if (soundDamage != null && characterData != null)
{
SoundManager.Instance.Play(soundDamage, characterData.transform);
}
Vector2 vector = ((Vector2)hitCol.bounds.ClosestPoint(base.transform.position) - (Vector2)base.transform.position).normalized;
if (vector == Vector2.zero)
{
vector = Vector2.up;
}
if (spawned.IsMine())
{
componentInParent.CallTakeDamage(num * damage * rangeMultiplier * vector, base.transform.position, null, spawned.spawner);
}
if (DealDamageAction != null)
{
DealDamageAction(componentInParent);
}
}
}
if ((bool)characterData)
{
if (HitTargetAction != null)
{
HitTargetAction(componentInParent, distance);
}
if (force != 0f)
{
if (locallySimulated)
{
characterData.healthHandler.TakeForce(((Vector2)hitCol.bounds.ClosestPoint(base.transform.position) - (Vector2)base.transform.position).normalized * rangeMultiplier * force * num2, ForceMode2D.Impulse, forceIgnoreMass);
}
else if (spawned.IsMine())
{
characterData.healthHandler.CallTakeForce(((Vector2)hitCol.bounds.ClosestPoint(base.transform.position) - (Vector2)base.transform.position).normalized * rangeMultiplier * force * num2, ForceMode2D.Impulse, forceIgnoreMass, ignoreBlock: false, flyingFor * rangeMultiplier);
}
}
if (stun > 0f)
{
characterData.stunHandler.AddStun(stun * num5);
}
}
else if ((bool)hitCol.attachedRigidbody)
{
hitCol.attachedRigidbody.AddForce(((Vector2)hitCol.bounds.ClosestPoint(base.transform.position) - (Vector2)base.transform.position).normalized * rangeMultiplier * force * num2, ForceMode2D.Impulse);
}
}
public void Explode()
{
float num = (scaleRadius ? base.transform.localScale.x : 1f);
Collider2D[] array = Physics2D.OverlapCircleAll(base.transform.position, range * num);
for (int i = 0; i < array.Length; i++)
{
if (array[i].gameObject.layer != 19)
{
Damagable componentInParent = array[i].gameObject.GetComponentInParent<Damagable>();
float num2 = Vector2.Distance(base.transform.position, array[i].bounds.ClosestPoint(base.transform.position));
float value = 1f - num2 / (range * num);
if (staticRangeMultiplier)
{
value = 1f;
}
value = Mathf.Clamp(value, 0f, 1f);
NetworkPhysicsObject component = array[i].GetComponent<NetworkPhysicsObject>();
if ((bool)component && component.photonView.IsMine)
{
float num3 = (scaleForce ? base.transform.localScale.x : 1f);
component.BulletPush((Vector2)(component.transform.position - base.transform.position).normalized * objectForceMultiplier * 1f * value * force * num3, Vector2.zero, null);
}
if (((bool)componentInParent || (bool)array[i].attachedRigidbody) && (!ignoreTeam || !spawned || !(spawned.spawner.gameObject == array[i].transform.gameObject)))
{
DoExplosionEffects(array[i], value, num2);
}
}
}
}
}
|