summaryrefslogtreecommitdiff
path: root/RigidbodyHolder.cs
blob: 796f77ac77a8fe12289dddc776498e59f9904d73 (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
using System.Collections.Generic;
using UnityEngine;

public class RigidbodyHolder : MonoBehaviour
{
	private Rigidbody[] allRigs;

	private WeaponHandler weapons;

	private void Start()
	{
		allRigs = GetComponentsInChildren<Rigidbody>();
		weapons = GetComponent<WeaponHandler>();
	}

	private void Update()
	{
	}

	public Rigidbody[] GetAllRigs()
	{
		if (!weapons.leftGun && !weapons.rightGun)
		{
			return allRigs;
		}
		List<Rigidbody> list = new List<Rigidbody>();
		for (int i = 0; i < allRigs.Length; i++)
		{
			list.Add(allRigs[i]);
		}
		if ((bool)weapons)
		{
			if ((bool)weapons.leftGun)
			{
				list.Add(weapons.leftGun.rig);
			}
			if ((bool)weapons.rightGun)
			{
				list.Add(weapons.rightGun.rig);
			}
		}
		return list.ToArray();
	}
}