summaryrefslogtreecommitdiff
path: root/Thronefall_1_57/Decompile/Ara/ElectricalArc.cs
diff options
context:
space:
mode:
authorchai <215380520@qq.com>2024-05-19 16:05:58 +0800
committerchai <215380520@qq.com>2024-05-19 16:05:58 +0800
commit8e13e7e2874adc8982e16d1d2ed2e28d7480b45f (patch)
tree63ef85c460288891f5a593d69afeca16cba050b3 /Thronefall_1_57/Decompile/Ara/ElectricalArc.cs
parentc5f145786f4c6d2fe4bea831dfc16e52228920a5 (diff)
+1.57
Diffstat (limited to 'Thronefall_1_57/Decompile/Ara/ElectricalArc.cs')
-rw-r--r--Thronefall_1_57/Decompile/Ara/ElectricalArc.cs57
1 files changed, 57 insertions, 0 deletions
diff --git a/Thronefall_1_57/Decompile/Ara/ElectricalArc.cs b/Thronefall_1_57/Decompile/Ara/ElectricalArc.cs
new file mode 100644
index 0000000..14ff239
--- /dev/null
+++ b/Thronefall_1_57/Decompile/Ara/ElectricalArc.cs
@@ -0,0 +1,57 @@
+using System;
+using UnityEngine;
+
+namespace Ara;
+
+[RequireComponent(typeof(AraTrail))]
+public class ElectricalArc : MonoBehaviour
+{
+ private AraTrail trail;
+
+ public Transform source;
+
+ public Transform target;
+
+ public int points = 20;
+
+ public float burstInterval = 0.5f;
+
+ public float burstRandom = 0.2f;
+
+ public float speedRandom = 2f;
+
+ public float positionRandom = 0.1f;
+
+ private float accum;
+
+ private void OnEnable()
+ {
+ trail = GetComponent<AraTrail>();
+ trail.emit = false;
+ }
+
+ private void Update()
+ {
+ accum += Time.deltaTime;
+ if (accum >= burstInterval)
+ {
+ ChangeArc();
+ accum = (0f - burstInterval) * UnityEngine.Random.value * burstRandom;
+ }
+ }
+
+ private void ChangeArc()
+ {
+ trail.points.Clear();
+ if (source != null && target != null)
+ {
+ for (int i = 0; i < points; i++)
+ {
+ float num = (float)i / (float)(points - 1);
+ float num2 = Mathf.Sin(num * MathF.PI);
+ Vector3 vector = Vector3.Lerp(source.position, target.position, num);
+ trail.points.Add(new AraTrail.Point(vector + UnityEngine.Random.onUnitSphere * positionRandom * num2, UnityEngine.Random.onUnitSphere * speedRandom * num2, Vector3.up, Vector3.forward, Color.white, 1f, 0f, burstInterval * 2f));
+ }
+ }
+ }
+}