summaryrefslogtreecommitdiff
path: root/GameCode/ThereCanOnlyBeOne.cs
blob: 78dd68df3e162c877f9d143e3c031eeb81ed35b5 (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
using UnityEngine;
using UnityEngine.Events;

public class ThereCanOnlyBeOne : MonoBehaviour
{
	public UnityEvent PokeEvent;

	private void Start()
	{
		bool flag = false;
		ThereCanOnlyBeOne[] componentsInChildren = base.transform.root.GetComponentsInChildren<ThereCanOnlyBeOne>();
		for (int i = 0; i < componentsInChildren.Length; i++)
		{
			if (!(componentsInChildren[i] == this))
			{
				flag = true;
				componentsInChildren[i].Poke();
			}
		}
		if (flag)
		{
			Object.Destroy(base.gameObject);
		}
	}

	public void Poke()
	{
		PokeEvent.Invoke();
	}
}