Esempio n. 1
0
 public void AddEdge(int from, int to)
 {
     rootComponent.Edges.Add(new Pair <int>(from, to));
     if (InsideTransaction)
     {
         return;
     }
     GlobalGraph        = new StoryGraph(rootComponent.Node, GetEdges(), false);
     RootLayoutInstance = layouts.Values.Single().ArrangeAndDecorate(GlobalGraph);
     editSceneComponent.OnEdgeAdded(new Pair <int>(from, to), GlobalGraph);
     GraphChanged?.Invoke();
 }
Esempio n. 2
0
        private void OnStoryNodeAdded(ISceneNode parent, ISceneNode newNode)
        {
            var layoutRoot = SearchLayoutRoot(newNode);

            if (layoutRoot == newNode)
            {
                throw new NotImplementedException();
                //var layoutType = newNode.GetAspect<IStoryAspect>().StartLayoutType;
                //var layout = layoutsByType[layoutType];
                //layouts[newNode] = layout;
                //var sg = new StoryGraph(newNode, );
                //layout.ArrangeAndDecorate();
            }

            GlobalGraph = new StoryGraph(rootComponent.Node, GetEdges(), false);
            editSceneComponent.OnStoryNodeAdded(parent, newNode, GlobalGraph);
            RootLayoutInstance = layouts[rootComponent.Node].ArrangeAndDecorate(GlobalGraph);
            GraphChanged?.Invoke();
        }
Esempio n. 3
0
        private void OnStoryNodeRemoved(ISceneNode parent, ISceneNode removedNode)
        {
            var layoutRoot = SearchLayoutRoot(removedNode);

            if (layoutRoot == removedNode)
            {
                throw new NotImplementedException();
                //var layoutType = newNode.GetAspect<IStoryAspect>().StartLayoutType;
                //var layout = layoutsByType[layoutType];
                //layouts[newNode] = layout;
                //var sg = new StoryGraph(newNode, );
                //layout.ArrangeAndDecorate();
            }
            var removedIds = removedNode.GetComponent <IStoryComponent>().EnumerateStoryAspectsDeep(false).Select(x => x.Node.Id).ToArray();

            rootComponent.Edges.RemoveWhere(x => removedIds.Contains(x.First) || removedIds.Contains(x.Second));
            GlobalGraph = new StoryGraph(rootComponent.Node, GetEdges(), false);
            editSceneComponent.OnStoryNodeRemoved(parent, removedNode, GlobalGraph);
            RootLayoutInstance = layouts[rootComponent.Node].ArrangeAndDecorate(GlobalGraph);
            GraphChanged?.Invoke();
        }
Esempio n. 4
0
        private void OnWorldRootChanged(ISceneNode newRoot)
        {
            rootComponent = newRoot.SearchComponent <StoryServiceRootComponent>();
            if (rootComponent == null)
            {
                rootComponent = AmFactory.Create <StoryServiceRootComponent>();
                newRoot.Components.Add(rootComponent);
            }

            var rootNode = newRoot;

            rootComponent = rootNode.SearchComponent <StoryServiceRootComponent>();
            if (rootComponent == null)
            {
                rootComponent = AmFactory.Create <StoryServiceRootComponent>();
                rootNode.Components.Add(rootComponent);
            }

            GlobalGraph = new StoryGraph(rootNode, GetEdges(), false);

            layouts.Clear();
            var aStory = rootNode.SearchComponent <IStoryComponent>();

            if (aStory?.StartLayoutType == null)
            {
                throw new InvalidOperationException("Root SceneNode is expected to have a StoryAspect and be a LayoutRoot.");
            }
            var layout = layoutsByType[aStory.StartLayoutType];

            layouts.Add(rootNode, layout);
            // todo: sub-layouts
            editSceneComponent.OnWorldRootChanged(newRoot, GlobalGraph);
            var rootSg = new StoryGraph(newRoot, (IReadOnlyList <Pair <int> >)rootComponent.Edges, true);

            RootLayoutInstance = layout.ArrangeAndDecorate(rootSg);
            GraphChanged?.Invoke();
        }