summaryrefslogtreecommitdiff
path: root/Thronefall_1_57/Decompile/Ara/ElectricalArc.cs
blob: 14ff239cdb35c884c6b85c7c84d0b65f20268425 (plain)
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
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));
			}
		}
	}
}