summaryrefslogtreecommitdiff
path: root/Thronefall_v1.0/Decompile/SelfDestructWhenInRangeOf.cs
blob: 8ab0e294d626cc4df32e51c8b0c139e0cf24bed4 (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
using UnityEngine;

public class SelfDestructWhenInRangeOf : MonoBehaviour
{
	[SerializeField]
	private TargetPriority selfDestructIfInRangeOf;

	[SerializeField]
	private float checkInterval = 0.5f;

	private float timeTillNextCheck;

	private Hp hp;

	private void Start()
	{
		hp = GetComponent<Hp>();
		timeTillNextCheck = checkInterval;
	}

	private void Update()
	{
		timeTillNextCheck -= Time.deltaTime;
		if (timeTillNextCheck <= 0f)
		{
			timeTillNextCheck = checkInterval;
			if (selfDestructIfInRangeOf.FindClosestTaggedObject(base.transform.position) != null && (bool)hp)
			{
				hp.TakeDamage(1E+09f);
			}
		}
	}
}