Exemplo n.º 1
0
        public ProtogameEditorWorld(
            INode worldNode,
            IHierarchy hierarchy,
            ISkinLayout skinLayout,
            ISkinDelegator skinDelegator,
            IAssetManager assetManager,
            IMainMenuController mainMenuController,
            IEditorWindowFactory editorWindowFactory,
            IProjectManager projectManager,
            ILoadedGame loadedGame,
            IRecentProjects recentProjects,
            IThumbnailSampler thumbnailSampler,
            IExtensionManager extensionManager)
        {
            _skinLayout          = skinLayout;
            _skinDelegator       = skinDelegator;
            _assetManager        = assetManager;
            _mainMenuController  = mainMenuController;
            _editorWindowFactory = editorWindowFactory;
            _projectManager      = projectManager;
            _loadedGame          = loadedGame;
            _recentProjects      = recentProjects;
            _thumbnailSampler    = thumbnailSampler;
            _extensionManager    = extensionManager;

            SetupCanvas();

            var entity = new CanvasEntity(_skinLayout, _skinDelegator);

            entity.Canvas = _canvas;
            hierarchy.AddChildNode(worldNode, hierarchy.CreateNodeForObject(entity));
        }
Exemplo n.º 2
0
        public INode CreateEmptyNode(string name, INode parent = null)
        {
            var node = new DefaultNode
            {
                Parent = parent,
                Name   = DefaultNode.NormalizeName(name)
            };

            if (parent == null)
            {
                _hierarchy.AddRootNode(node);
            }
            else
            {
                _hierarchy.AddChildNode(parent, node);
            }
            return(node);
        }
Exemplo n.º 3
0
        public INode Batch(IGameContext gameContext, INode node, IBatchingOptions options)
        {
            BatchedControlEntity entity = null;

            if (options.BatchPhysics)
            {
                entity = BatchPhysics(gameContext, node, entity);
            }

            if (entity != null)
            {
                _consoleHandle.LogDebug("Attached batched control entity to parent of batch request.");

                _hierarchy.AddChildNode(node, entity.Node);
            }

            return(entity?.Node);
        }
Exemplo n.º 4
0
        protected void RegisterComponent(object component)
        {
            if (_node == null || _hierarchy == null)
            {
                // No hierarchy, always use private list.
                _nonHierarchyComponents.Add(component);

                UpdateCache();
                UpdateEnabledInterfacesCache();
            }
            else
            {
                // Check if the component is underneath this hierarchy, if node, add it.
                if (_node.Children.All(x => x.UntypedValue != component))
                {
                    // It is not underneath the hierarchy; add it.
                    var childNode = _hierarchy.Lookup(component) ?? _hierarchy.CreateNodeForObject(component);

                    _hierarchy.AddChildNode(_node, childNode);
                }
            }
        }
Exemplo n.º 5
0
        private void ProcessElementToPlan(IPlan parentPlan, IPlan rootPlan, XmlElement currentElement, List <IPlan> rootPlans, int depth, Func <IPlan, object, bool> filter)
        {
            switch (currentElement.LocalName)
            {
            case "gameObjectFolder":
            {
                foreach (var childElement in currentElement.ChildNodes.OfType <XmlElement>())
                {
                    ProcessElementToPlan(parentPlan, rootPlan, childElement, rootPlans, depth, filter);
                }
                break;
            }

            case "resource":
            {
                // This is used directly by the parent game object.
                break;
            }

            case "gameObject":
            {
                Type targetType = null;

                var xsiType = currentElement.GetAttribute("xsi:type");
                if (xsiType == "gameObjectGroupType")
                {
                    targetType = typeof(EntityGroup);
                }
                else if (xsiType == "locatorType")
                {
                    targetType = typeof(LocatorEntity);
                }
                else if (xsiType == "DirLight")
                {
                    targetType = typeof(DefaultDirectionalLightEntity);
                }
                else if (xsiType == "PointLight")
                {
                    targetType = typeof(DefaultPointLightEntity);
                }

                var qualifiedName = currentElement.GetAttribute("qualifiedName");
                if (!string.IsNullOrEmpty(qualifiedName))
                {
                    targetType = Type.GetType(qualifiedName);
                }

                if (targetType == null)
                {
                    break;
                }

                var queryType = typeof(IEditorQuery <>).MakeGenericType(targetType);

                var plan = _kernel.Plan(
                    targetType,
                    (INode)parentPlan,
                    null,
                    null,
                    (INode)rootPlan,
                    null,
                    null,
                    new Dictionary <Type, List <IMapping> >
                    {
                        {
                            queryType, new List <IMapping>
                            {
                                new DefaultMapping(
                                    null,
                                    ctx => ResolveEditorQueryForElement(ctx, queryType, targetType, currentElement),
                                    false,
                                    null,
                                    null,
                                    true,
                                    true,
                                    null)
                            }
                        }
                    });

                if (filter != null && !filter(plan, currentElement))
                {
                    // Discard this plan; it has been filtered out.
                    _kernel.Discard(plan);
                }
                else
                {
                    _hierarchy.AddChildNode(parentPlan, (INode)plan);

                    if (rootPlan == null)
                    {
                        rootPlan = (INode)plan;
                    }

                    if (depth == 0)
                    {
                        rootPlans.Add(plan);
                    }

                    foreach (var childElement in currentElement.ChildNodes.OfType <XmlElement>())
                    {
                        ProcessElementToPlan(plan, rootPlan, childElement, null, depth + 1, filter);
                    }

                    if (depth > 0)
                    {
                        parentPlan.PlannedCreatedNodes.InsertRange(0, plan.PlannedCreatedNodes);
                    }
                }

                break;
            }
            }
        }