summaryrefslogtreecommitdiff
path: root/Thronefall_v1.57/Thronefall/NGS.MeshFusionPro/DynamicCombineSource.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Thronefall_v1.57/Thronefall/NGS.MeshFusionPro/DynamicCombineSource.cs')
-rw-r--r--Thronefall_v1.57/Thronefall/NGS.MeshFusionPro/DynamicCombineSource.cs70
1 files changed, 70 insertions, 0 deletions
diff --git a/Thronefall_v1.57/Thronefall/NGS.MeshFusionPro/DynamicCombineSource.cs b/Thronefall_v1.57/Thronefall/NGS.MeshFusionPro/DynamicCombineSource.cs
new file mode 100644
index 0000000..dcbf244
--- /dev/null
+++ b/Thronefall_v1.57/Thronefall/NGS.MeshFusionPro/DynamicCombineSource.cs
@@ -0,0 +1,70 @@
+using System;
+using UnityEngine;
+
+namespace NGS.MeshFusionPro;
+
+public class DynamicCombineSource : ICombineSource<DynamicCombinedObject, DynamicCombinedObjectPart>, ICombineSource
+{
+ private CombineSource _base;
+
+ public CombineSource Base => _base;
+
+ public Vector3 Position => _base.Position;
+
+ public Bounds Bounds => _base.Bounds;
+
+ public event Action<ICombinedObject, ICombinedObjectPart> onCombined;
+
+ public event Action<ICombinedObject, string> onCombineError;
+
+ public event Action<ICombinedObject> onCombineFailed;
+
+ public event Action<DynamicCombinedObject, DynamicCombinedObjectPart> onCombinedTyped;
+
+ public event Action<DynamicCombinedObject, string> onCombineErrorTyped;
+
+ public event Action<DynamicCombinedObject> onCombineFailedTyped;
+
+ public DynamicCombineSource(GameObject go, int submeshIndex = 0)
+ {
+ _base = new CombineSource(go, submeshIndex);
+ }
+
+ public DynamicCombineSource(Mesh mesh, MeshRenderer renderer, int submeshIndex = 0)
+ {
+ _base = new CombineSource(mesh, renderer, submeshIndex);
+ }
+
+ public DynamicCombineSource(MeshCombineInfo info, RendererSettings settings)
+ {
+ _base = new CombineSource(info, settings);
+ }
+
+ public DynamicCombineSource(MeshCombineInfo info, RendererSettings settings, Bounds bounds)
+ {
+ _base = new CombineSource(info, settings, bounds);
+ }
+
+ public void Combined(DynamicCombinedObject root, DynamicCombinedObjectPart part)
+ {
+ this.onCombined?.Invoke(root, part);
+ this.onCombinedTyped?.Invoke(root, part);
+ }
+
+ public void CombineError(DynamicCombinedObject root, string errorMessage)
+ {
+ if (this.onCombineError == null && this.onCombineErrorTyped == null)
+ {
+ Debug.Log("Error during combine " + root.name + ", reason :" + errorMessage);
+ return;
+ }
+ this.onCombineError?.Invoke(root, errorMessage);
+ this.onCombineErrorTyped?.Invoke(root, errorMessage);
+ }
+
+ public void CombineFailed(DynamicCombinedObject root)
+ {
+ this.onCombineFailed?.Invoke(root);
+ this.onCombineFailedTyped?.Invoke(root);
+ }
+}