-
Notifications
You must be signed in to change notification settings - Fork 1
/
CosmicLightningMerge.cs
71 lines (65 loc) · 3.13 KB
/
CosmicLightningMerge.cs
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using ThunderRoad;
namespace CosmicSpell {
class CosmicLightningMerge : SpellMergeData {
public float radius = 10.0f;
EffectData imbueRagdollEffect;
public override void Load(Mana mana) {
base.Load(mana);
imbueRagdollEffect = Catalog.GetData<EffectData>("ImbueLightningRagdoll");
}
public override void Merge(bool active) {
base.Merge(active);
if (active) {
} else {
if (currentCharge == 1) {
DisarmEveryoneLmao();
}
}
}
public override void Update() {
base.Update();
if (currentCharge > 0) {
chargeEffect?.SetSource(mana.mergePoint);
}
}
public void DisarmEveryoneLmao() {
SpellCastData lightningData = Player.currentCreature.mana.casterLeft.spellInstance is SpellCastLightning
? Player.currentCreature.mana.casterLeft.spellInstance
: Player.currentCreature.mana.casterRight.spellInstance;
if (lightningData is SpellCastLightning cast) {
// modified from ThunderRoad source code for Gravity crystal slam
List<Creature> pushedCreatures = new List<Creature>();
foreach (Collider collider in Physics.OverlapSphere(Player.currentCreature.mana.mergePoint.position, radius)
.Where(c =>
c.attachedRigidbody
&& c.attachedRigidbody
&& !c.attachedRigidbody.isKinematic)) {
if (collider.attachedRigidbody.gameObject.layer == GameManager.GetLayer(LayerName.NPC) || collider.attachedRigidbody.gameObject.layer == GameManager.GetLayer(LayerName.Ragdoll)) {
RagdollPart component = collider.attachedRigidbody.gameObject.GetComponent<RagdollPart>();
if (component.ragdoll.creature == Player.currentCreature)
continue;
if (component && !pushedCreatures.Contains(component.ragdoll.creature)) {
// do it again, just in case lmao
pushedCreatures.Add(component.ragdoll.creature);
component.ragdoll.creature.handLeft.TryRelease();
component.ragdoll.creature.handRight.TryRelease();
ActionShock action = component.ragdoll.creature.brain.GetAction<ActionShock>();
if (action != null) {
action.Refresh(0.5f, cast.boltShockDuration);
} else {
ActionShock actionShock = new ActionShock(0.5f, cast.boltShockDuration, imbueRagdollEffect);
component.ragdoll.creature.brain.TryAction(actionShock, true);
}
}
}
}
}
}
}
}