/// <summary>
        ///		Groups all the selected entitys together.
        /// </summary>
        private void Group()
        {
            // Create a new group node to place these nodes into.
            GroupNode groupSceneNode = new GroupNode("Group");
            Engine.Engine.GlobalInstance.Map.SceneGraph.RootNode.AddChild(groupSceneNode);

            // Add all scene nodes to this group node.
            foreach (EntityNode entity in _selectedEntityList)
            {
                if (entity.Parent != null) entity.Parent.RemoveChild(entity);
                groupSceneNode.AddChild(entity);
            }

            if (_sceneGraphWindow != null) _sceneGraphWindow.SyncronizeData();
            _mapChangedSinceSave = true;
        }
        /// <summary>
        ///		Loads the next node in the given binary reader and returns it.
        /// </summary>
        /// <param name="reader">Binary reader to read node from.</param>
        /// <param name="getProgress">If set to true this node is used to judge the current progress.</param>
        /// <returns>Scene node that was loaded from the binary reader.</returns>
        private SceneNode LoadNode(BinaryReader reader, bool getProgress)
        {
            // Read in the name of this node's class.
            string name = reader.ReadString();

            //HighPreformanceTimer timer = new HighPreformanceTimer();

            // Create a new instance of this entity and tell it to load itself.
            // (See if its a known object first as its quicker to get it without reflection)
            SceneNode node = null;
            if (name.ToLower().EndsWith("binaryphoenix.fusion.engine.entitys.entitynode"))
                node = new EntityNode();
            else if (name.ToLower().EndsWith("binaryphoenix.fusion.engine.entitys.scriptedentitynode"))
                node = new ScriptedEntityNode();
            else if (name.ToLower().EndsWith("binaryphoenix.fusion.engine.scenenode"))
                node = new SceneNode();
            else if (name.ToLower().EndsWith("binaryphoenix.fusion.engine.entitys.groupnode"))
                node = new GroupNode();
            else if (name.ToLower().EndsWith("binaryphoenix.fusion.engine.entitys.emitternode"))
                node = new EmitterNode();
            else if (name.ToLower().EndsWith("binaryphoenix.fusion.engine.entitys.tilemapsegmentnode"))
                node = new TilemapSegmentNode();
            else if (name.ToLower().EndsWith("binaryphoenix.fusion.engine.entitys.pathmarkernode"))
                node = new PathMarkerNode();
            else if (name.ToLower().EndsWith("binaryphoenix.fusion.engine.entitys.tilenode"))
                node = new TileNode();
            else
                node = (SceneNode)ReflectionMethods.CreateObject(name);

            //DebugLogger.WriteLog("Created scene graph node " + name + " in " + timer.DurationMillisecond + ".\n");
            //timer.Restart();

            // Load in this nodes details.
            node.UniqueID = (_uniqueIDTracker++);
            node.Load(reader);

            //DebugLogger.WriteLog("Loaded scene graph node " + name + " in " + timer.DurationMillisecond + ".\n");

            // Read in all the children of this node, and attach
            // them to this node.
            DebugLogger.IncreaseIndent();
            int childCount = reader.ReadInt32();
            for (int i = 0; i < childCount; i++)
            {
                SceneNode childNode = LoadNode(reader);
                node.AddChild(childNode);

                if (getProgress == true)
                    _loadingProgress = (int)(((float)(i + 1) / (float)childCount) * 100.0f);
            }
            DebugLogger.DecreaseIndent();

            return node;
        }
 public void CreateGroup(ScriptThread thread)
 {
     EntityNode node = new GroupNode();
     thread.SetReturnValue(new SceneNodeScriptObject(node));
 }