示例#1
0
        public override IEdgeAction RemoveEdge(DGEdge edge)
        {
            if (edge == null)
            {
                return(null);
            }
            int i = this.mEntryAnchor.Edges.IndexOf(edge);

            if (i >= 0)
            {
                return(new EdgeAction(false, i, edge, this.mEntryAnchor));
            }
            AnchorPoint ap;

            for (int k = this.mSliceCount - 1; k >= 0; k--)
            {
                ap = this.mSliceAnchors[k];
                i  = ap.Edges.IndexOf(edge);
                if (i >= 0)
                {
                    return(new SliceTargetAction(false, edge, k, i, this));
                }
            }
            return(null);
        }
示例#2
0
 public void AddRootDGEdges()
 {
     if (this.mRootNode == null)
     {
         DecisionGraph dg = this.mState.DecisionGraph;
         if (dg != null)
         {
             this.mRootNode = new DGRootNode(dg, this);
             this.mDGraph.InsertNode(0, this.mRootNode);
             this.mRootNode.SetParent(this);
         }
     }
     if (this.mRootNode != null)
     {
         DGNode        node;
         DGEdge        edge;
         List <DGEdge> edges = this.mRootNode.EntryAnchor.Edges;
         for (int i = this.mDGraph.NodeCount - 1; i > 0; i--)
         {
             node = this.mDGraph.NodeAt(i);
             if (node.EntryAnchor.Edges.Count == 0)
             {
                 edge = new DGEdge(this.mRootNode, node, true);
                 edges.Add(edge);
                 node.EntryAnchor.Edges.Add(edge);
                 this.mDGraph.AddEdge(edge);
                 edge.SetParent(this);
             }
         }
     }
 }
示例#3
0
 public override AnchorPoint GetAnchorFor(DGEdge edge)
 {
     if (this.mEntryAnchor.Edges.Contains(edge))
     {
         return(this.mEntryAnchor);
     }
     return(null);
 }
示例#4
0
 public virtual IEdgeAction AddEdge(DGEdge edge, AnchorPoint ap)
 {
     if (edge != null && ap != null)
     {
         return(new EdgeAction(true, ap.Edges.Count, edge, ap));
     }
     return(null);
 }
示例#5
0
 public SliceTargetAction(bool add, DGEdge edge,
                          int sliceIndex, int targetIndex, DGRandNode node)
 {
     this.bAdd         = add;
     this.mEdge        = edge;
     this.mSliceIndex  = sliceIndex;
     this.mTargetIndex = targetIndex;
     this.mNode        = node;
 }
示例#6
0
 public virtual IEdgeAction RemoveEdge(DGEdge edge)
 {
     if (edge != null)
     {
         AnchorPoint ap = this.GetAnchorFor(edge);
         if (ap != null)
         {
             int i = ap.Edges.IndexOf(edge);
             return(new EdgeAction(false, i, edge, ap));
         }
     }
     return(null);
 }
示例#7
0
        public override AnchorPoint GetAnchorFor(DGEdge edge)
        {
            if (this.mEntryAnchor.Edges.Contains(edge))
            {
                return(this.mEntryAnchor);
            }
            AnchorPoint ap;

            for (int i = this.mCaseCount - 1; i >= 0; i--)
            {
                ap = this.mCaseAnchors[i];
                if (ap.Edges.Contains(edge))
                {
                    return(ap);
                }
            }
            return(null);
        }
示例#8
0
 public override IEdgeAction AddEdge(DGEdge edge, AnchorPoint ap)
 {
     if (edge == null || ap == null)
     {
         return(null);
     }
     if (ap == this.mEntryAnchor)
     {
         return(new EdgeAction(true, ap.Edges.Count, edge, ap));
     }
     for (int k = this.mSliceCount - 1; k >= 0; k--)
     {
         if (this.mSliceAnchors[k] == ap)
         {
             return(new SliceTargetAction(
                        true, edge, k, ap.Edges.Count, this));
         }
     }
     return(null);
 }
示例#9
0
 public EdgeAction(bool add, int i, DGEdge edge, AnchorPoint ap)
 {
     if (edge == null)
     {
         throw new ArgumentNullException("edge");
     }
     if (ap == null)
     {
         throw new ArgumentNullException("ap");
     }
     if (i < 0)
     {
         throw new ArgumentOutOfRangeException("i");
     }
     if (add)
     {
         if (i > ap.Edges.Count)
         {
             throw new ArgumentOutOfRangeException("i");
         }
     }
     else
     {
         if (i >= ap.Edges.Count)
         {
             throw new ArgumentOutOfRangeException("i");
         }
         else if (ap.Edges[i] != edge)
         {
             throw new ArgumentException("ap.Edges[i] != edge");
         }
     }
     this.bAdd   = add;
     this.mIndex = i;
     this.mEdge  = edge;
     this.mAP    = ap;
 }
示例#10
0
 public abstract AnchorPoint GetAnchorFor(DGEdge edge);
示例#11
0
 public bool Equals(DGEdge other)
 {
     return(other != null &&
            other.mSrcNode.Equals(this.mSrcNode) &&
            other.mDstNode.Equals(this.mDstNode));
 }
示例#12
0
        private DGNode InitDGN(DGNode src, DecisionGraphNode dgn)
        {
            int    i;
            DGNode dst = null;

            for (i = this.mDGraph.NodeCount - 1; i >= 0; i--)
            {
                dst = this.mDGraph.NodeAt(i);
                if (dst.DGN == dgn)
                {
                    break;
                }
            }
            if (i < 0)
            {
                int                 j;
                DGEdge              edge;
                AnchorPoint         ap;
                DecisionGraphNode[] dgns;
                DGMulticastNode     dgmcn = null;
                switch (dgn.ChunkType)
                {
                case NextStateNode.ResourceType:
                    NextStateNode nsn = dgn as NextStateNode;
                    dst = new DGSnSnNode(nsn, this);
                    this.mDGraph.AddNode(dst);
                    dst.SetParent(this);
                    break;

                case RandomNode.ResourceType:
                    RandomNode rand = dgn as RandomNode;
                    DGRandNode dgrn = new DGRandNode(rand, this);
                    this.mDGraph.AddNode(dgrn);
                    dgrn.SetParent(this);
                    List <RandomNode.Slice> slices = rand.Slices;
                    if (slices.Count > 0)
                    {
                        for (i = 0; i < slices.Count; i++)
                        {
                            ap   = dgrn.GetSliceAnchor(i);
                            dgns = slices[i].Targets.ToArray();
                            for (j = 0; j < dgns.Length; j++)
                            {
                                dst  = this.InitDGN(dgrn, dgns[j]);
                                edge = new DGEdge(dgrn, dst, false);
                                ap.Edges.Add(edge);
                                dst.EntryAnchor.Edges.Add(edge);
                                this.mDGraph.AddEdge(edge);
                                edge.SetParent(this);
                            }
                        }
                    }
                    dst = dgrn;
                    break;

                case SelectOnDestinationNode.ResourceType:
                    SelectOnDestinationNode sodn
                        = dgn as SelectOnDestinationNode;
                    DGSoDnNode dgsodn
                        = new DGSoDnNode(sodn, this);
                    this.mDGraph.AddNode(dgsodn);
                    dgsodn.SetParent(this);
                    if (sodn.CaseCount > 0)
                    {
                        SelectOnDestinationNode.Case[] cases = sodn.Cases;
                        for (i = 0; i < cases.Length; i++)
                        {
                            ap   = dgsodn.GetCaseAnchorAt(i);
                            dgns = cases[i].Targets;
                            for (j = 0; j < dgns.Length; j++)
                            {
                                dst  = this.InitDGN(dgsodn, dgns[j]);
                                edge = new DGEdge(dgsodn, dst, false);
                                ap.Edges.Add(edge);
                                dst.EntryAnchor.Edges.Add(edge);
                                this.mDGraph.AddEdge(edge);
                                edge.SetParent(this);
                            }
                        }
                    }
                    dst = dgsodn;
                    break;

                case SelectOnParameterNode.ResourceType:
                    SelectOnParameterNode sopn
                        = dgn as SelectOnParameterNode;
                    DGSoPnNode dgsopn
                        = new DGSoPnNode(sopn, this);
                    this.mDGraph.AddNode(dgsopn);
                    dgsopn.SetParent(this);
                    if (sopn.CaseCount > 0)
                    {
                        SelectOnParameterNode.Case[] cases = sopn.Cases;
                        for (i = 0; i < cases.Length; i++)
                        {
                            ap   = dgsopn.GetCaseAnchorAt(i);
                            dgns = cases[i].Targets;
                            for (j = 0; j < dgns.Length; j++)
                            {
                                dst  = this.InitDGN(dgsopn, dgns[j]);
                                edge = new DGEdge(dgsopn, dst, false);
                                ap.Edges.Add(edge);
                                dst.EntryAnchor.Edges.Add(edge);
                                this.mDGraph.AddEdge(edge);
                                edge.SetParent(this);
                            }
                        }
                    }
                    dst = dgsopn;
                    break;

                case CreatePropNode.ResourceType:
                    CreatePropNode cpn   = dgn as CreatePropNode;
                    DGPropNode     dgcpn = new DGPropNode(cpn, this);
                    this.mDGraph.AddNode(dgcpn);
                    dgcpn.SetParent(this);
                    dgmcn = dgcpn;
                    break;

                case ActorOperationNode.ResourceType:
                    ActorOperationNode aon   = dgn as ActorOperationNode;
                    DGAcOpNode         dgaon = new DGAcOpNode(aon, this);
                    this.mDGraph.AddNode(dgaon);
                    dgaon.SetParent(this);
                    dgmcn = dgaon;
                    break;

                case StopAnimationNode.ResourceType:
                    StopAnimationNode san   = dgn as StopAnimationNode;
                    DGStopNode        dgsan = new DGStopNode(san, this);
                    this.mDGraph.AddNode(dgsan);
                    dgsan.SetParent(this);
                    dgmcn = dgsan;
                    break;

                case PlayAnimationNode.ResourceType:
                    PlayAnimationNode pan   = dgn as PlayAnimationNode;
                    DGPlayNode        dgpan = new DGPlayNode(pan, this);
                    this.mDGraph.AddNode(dgpan);
                    dgpan.SetParent(this);
                    dgmcn = dgpan;
                    break;
                }
                if (dgmcn != null)
                {
                    MulticastDecisionGraphNode mcn
                        = dgn as MulticastDecisionGraphNode;
                    if (mcn.TargetCount > 0)
                    {
                        ap   = dgmcn.TargetAnchor;
                        dgns = mcn.Targets;
                        for (i = 0; i < dgns.Length; i++)
                        {
                            dst  = this.InitDGN(dgmcn, dgns[i]);
                            edge = new DGEdge(dgmcn, dst, false);
                            ap.Edges.Add(edge);
                            dst.EntryAnchor.Edges.Add(edge);
                            this.mDGraph.AddEdge(edge);
                            edge.SetParent(this);
                        }
                    }
                    dst = dgmcn;
                }
            }
            return(dst);
        }