Browse Source

Merge pull request #1349 from LumaDigital/MB_ReparentNoComponentUpdate

Fixes CSComponents on reparented nodes not being re-added to the scene for updates
JoshEngebretson 9 years ago
parent
commit
38e7f8e8ad
1 changed files with 17 additions and 9 deletions
  1. 17 9
      Script/AtomicNET/AtomicNET/Scene/Scene.cs

+ 17 - 9
Script/AtomicNET/AtomicNET/Scene/Scene.cs

@@ -14,7 +14,16 @@ namespace AtomicEngine
             {
             {
                 //Log.Info($"Node ADDED: {e.Node.Name}");
                 //Log.Info($"Node ADDED: {e.Node.Name}");
 
 
-                // TODO: How to handle adding components on existing node?
+                // The NodeAdded event is generated when adding a node as a child
+
+                e.Node.GetComponents<CSComponent>(componentVector);
+
+                for (uint i = 0; i < componentVector.Size; i++)
+                {
+                    AddCSComponent(componentVector[i]);
+                }
+
+                componentVector.Clear();
 
 
             });
             });
 
 
@@ -292,17 +301,16 @@ namespace AtomicEngine
 
 
             cslist.Add(csc);
             cslist.Add(csc);
 
 
-            if (cscomponentStart.Contains(csc))
+            if (!csc.started)
             {
             {
-                throw new InvalidOperationException("Scene.HandleComponentAdded CSComponent already added to start list");
-            }
+                if (cscomponentStart.Contains(csc))
+                {
+                    throw new InvalidOperationException("Scene.HandleComponentAdded CSComponent already added to start list");
+                }
 
 
-            if (csc.started)
-            {
-                throw new InvalidOperationException("Scene.HandleComponentAdded CSComponent already started");
-            }
 
 
-            cscomponentStart.Add(csc);
+                cscomponentStart.Add(csc);
+            }
 
 
         }
         }