summaryrefslogtreecommitdiff
path: root/Thronefall_1_0/Thronefall/NGS.MeshFusionPro/UniversalObjectsCombiner.cs
diff options
context:
space:
mode:
authorchai <215380520@qq.com>2024-05-19 16:05:01 +0800
committerchai <215380520@qq.com>2024-05-19 16:05:01 +0800
commitc5f145786f4c6d2fe4bea831dfc16e52228920a5 (patch)
treea6ead7ea8266c767d58ed0f816dcd7a1dd75bd65 /Thronefall_1_0/Thronefall/NGS.MeshFusionPro/UniversalObjectsCombiner.cs
parent48b64e573a1709dc923cb9162b55be0246b3ff63 (diff)
* move
Diffstat (limited to 'Thronefall_1_0/Thronefall/NGS.MeshFusionPro/UniversalObjectsCombiner.cs')
-rw-r--r--Thronefall_1_0/Thronefall/NGS.MeshFusionPro/UniversalObjectsCombiner.cs102
1 files changed, 102 insertions, 0 deletions
diff --git a/Thronefall_1_0/Thronefall/NGS.MeshFusionPro/UniversalObjectsCombiner.cs b/Thronefall_1_0/Thronefall/NGS.MeshFusionPro/UniversalObjectsCombiner.cs
new file mode 100644
index 0000000..ae5189f
--- /dev/null
+++ b/Thronefall_1_0/Thronefall/NGS.MeshFusionPro/UniversalObjectsCombiner.cs
@@ -0,0 +1,102 @@
+using System;
+using System.Collections.Generic;
+
+namespace NGS.MeshFusionPro;
+
+public class UniversalObjectsCombiner
+{
+ private StaticObjectsCombiner _staticCombiner;
+
+ private DynamicObjectsCombiner _dynamicCombiner;
+
+ private LODGroupsCombiner _lodCombiner;
+
+ public event Action<CombinedObject> onStaticCombinedObjectCreated;
+
+ public event Action<DynamicCombinedObject> onDynamicCombinedObjectCreated;
+
+ public event Action<CombinedLODGroup> onCombinedLODGroupCreated;
+
+ public UniversalObjectsCombiner(ICombinedMeshFactory factory, int vertexLimit)
+ {
+ _staticCombiner = new StaticObjectsCombiner(factory, vertexLimit);
+ _dynamicCombiner = new DynamicObjectsCombiner(factory, vertexLimit);
+ _lodCombiner = new LODGroupsCombiner(factory, vertexLimit);
+ _staticCombiner.onCombinedObjectCreated += delegate(CombinedObject r)
+ {
+ this.onStaticCombinedObjectCreated?.Invoke(r);
+ };
+ _dynamicCombiner.onCombinedObjectCreated += delegate(DynamicCombinedObject r)
+ {
+ this.onDynamicCombinedObjectCreated?.Invoke(r);
+ };
+ _lodCombiner.onCombinedObjectCreated += delegate(CombinedLODGroup r)
+ {
+ this.onCombinedLODGroupCreated?.Invoke(r);
+ };
+ }
+
+ public void AddSource(ICombineSource source)
+ {
+ if (source is CombineSource source2)
+ {
+ _staticCombiner.AddSource(source2);
+ return;
+ }
+ if (source is DynamicCombineSource source3)
+ {
+ _dynamicCombiner.AddSource(source3);
+ return;
+ }
+ if (source is LODGroupCombineSource source4)
+ {
+ _lodCombiner.AddSource(source4);
+ return;
+ }
+ throw new NotImplementedException("Unknown Combine Source");
+ }
+
+ public void AddSources(IEnumerable<ICombineSource> sources)
+ {
+ foreach (ICombineSource source in sources)
+ {
+ AddSource(source);
+ }
+ }
+
+ public void RemoveSource(ICombineSource source)
+ {
+ if (source is CombineSource source2)
+ {
+ _staticCombiner.RemoveSource(source2);
+ return;
+ }
+ if (source is DynamicCombineSource source3)
+ {
+ _dynamicCombiner.RemoveSource(source3);
+ return;
+ }
+ if (source is LODGroupCombineSource source4)
+ {
+ _lodCombiner.RemoveSource(source4);
+ return;
+ }
+ throw new NotImplementedException("Unknown Combine Source");
+ }
+
+ public void Combine()
+ {
+ if (_staticCombiner.ContainSources)
+ {
+ _staticCombiner.Combine();
+ }
+ if (_dynamicCombiner.ContainSources)
+ {
+ _dynamicCombiner.Combine();
+ }
+ if (_lodCombiner.ContainSources)
+ {
+ _lodCombiner.Combine();
+ }
+ }
+}