summaryrefslogtreecommitdiff
path: root/Thronefall_1_57/Decompile/NGS.MeshFusionPro/CombinedLODGroupPart.cs
blob: 95c9c003c6352139a9f38d70b625006b7e711cd2 (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
using System.Collections.Generic;
using UnityEngine;

namespace NGS.MeshFusionPro;

public class CombinedLODGroupPart : ICombinedObjectPart<CombinedLODGroup>, ICombinedObjectPart
{
	private List<CombinedObjectPart> _baseParts;

	private Bounds _localBounds;

	ICombinedObject ICombinedObjectPart.Root => Root;

	public CombinedLODGroup Root { get; private set; }

	public Bounds LocalBounds => _localBounds;

	public Bounds Bounds
	{
		get
		{
			Bounds localBounds = _localBounds;
			localBounds.center += Root.transform.position;
			return localBounds;
		}
	}

	public CombinedLODGroupPart(CombinedLODGroup root, List<CombinedObjectPart> baseParts)
	{
		Root = root;
		_baseParts = baseParts;
		CalculateLocalBounds();
	}

	public void Destroy()
	{
		Root.Destroy(this, _baseParts);
	}

	private void CalculateLocalBounds()
	{
		_localBounds = _baseParts[0].Bounds;
		for (int i = 1; i < _baseParts.Count; i++)
		{
			_localBounds.Encapsulate(_baseParts[i].Bounds);
		}
		_localBounds.center -= Root.transform.position;
	}
}