summaryrefslogtreecommitdiff
path: root/Thronefall_1_57/Decompile/NGS.MeshFusionPro/DynamicCombinedObjectMatcher.cs
blob: cf76052547a7239acd79bb972142bbb59ef07f3a (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
namespace NGS.MeshFusionPro;

public class DynamicCombinedObjectMatcher : CombinedObjectMatcher<DynamicCombinedObject, DynamicCombineSource>
{
	private RendererSettings _settings;

	private int _vertexCount;

	private int _vertexLimit;

	public DynamicCombinedObjectMatcher(int vertexLimit)
	{
		_vertexLimit = vertexLimit;
	}

	public override void StartMatching(DynamicCombinedObject combinedObject)
	{
		_settings = combinedObject.RendererSettings;
		_vertexCount = combinedObject.VertexCount;
	}

	public override bool CanAddSource(DynamicCombineSource source)
	{
		if (!_settings.Equals(source.Base.RendererSettings))
		{
			return false;
		}
		if (_vertexCount + source.Base.CombineInfo.vertexCount > _vertexLimit)
		{
			return false;
		}
		return true;
	}

	public override void SourceAdded(DynamicCombineSource source)
	{
		_vertexCount += source.Base.CombineInfo.vertexCount;
	}
}