Bladeren bron

Add events for node/component being cloned. These are sent by their owning scene after the cloning process (along with all attributes set) is complete.

Lasse Öörni 9 jaren geleden
bovenliggende
commit
e8559b316a
2 gewijzigde bestanden met toevoegingen van 38 en 0 verwijderingen
  1. 22 0
      Source/Urho3D/Scene/Node.cpp
  2. 16 0
      Source/Urho3D/Scene/SceneEvents.h

+ 22 - 0
Source/Urho3D/Scene/Node.cpp

@@ -970,6 +970,17 @@ Component* Node::CloneComponent(Component* component, CreateMode mode, unsigned
         cloneComponent->ApplyAttributes();
     }
 
+    {
+        using namespace ComponentCloned;
+
+        VariantMap& eventData = GetEventDataMap();
+        eventData[P_SCENE] = scene_;
+        eventData[P_COMPONENT] = component;
+        eventData[P_CLONECOMPONENT] = cloneComponent;
+
+        scene_->SendEvent(E_COMPONENTCLONED, eventData);
+    }
+
     return cloneComponent;
 }
 
@@ -2125,6 +2136,17 @@ Node* Node::CloneRecursive(Node* parent, SceneResolver& resolver, CreateMode mod
         node->CloneRecursive(cloneNode, resolver, mode);
     }
 
+    {
+        using namespace NodeCloned;
+
+        VariantMap& eventData = GetEventDataMap();
+        eventData[P_SCENE] = scene_;
+        eventData[P_NODE] = this;
+        eventData[P_CLONENODE] = cloneNode;
+
+        scene_->SendEvent(E_NODECLONED, eventData);
+    }
+
     return cloneNode;
 }
 

+ 16 - 0
Source/Urho3D/Scene/SceneEvents.h

@@ -186,6 +186,22 @@ URHO3D_EVENT(E_TEMPORARYCHANGED, TemporaryChanged)
     URHO3D_PARAM(P_SERIALIZABLE, Serializable);    // Serializable pointer
 }
 
+/// A node (and its children and components) has been cloned.
+URHO3D_EVENT(E_NODECLONED, NodeCloned)
+{
+    URHO3D_PARAM(P_SCENE, Scene);                  // Scene pointer
+    URHO3D_PARAM(P_NODE, Node);                    // Node pointer
+    URHO3D_PARAM(P_CLONENODE, CloneNode);          // Node pointer
+}
+
+/// A component has been cloned.
+URHO3D_EVENT(E_COMPONENTCLONED, ComponentCloned)
+{
+    URHO3D_PARAM(P_SCENE, Scene);                  // Scene pointer
+    URHO3D_PARAM(P_COMPONENT, Component);          // Component pointer
+    URHO3D_PARAM(P_CLONECOMPONENT, CloneComponent); // Component pointer
+}
+
 /// A network attribute update from the server has been intercepted.
 URHO3D_EVENT(E_INTERCEPTNETWORKUPDATE, InterceptNetworkUpdate)
 {