Esempio n. 1
0
 public DGNode(DecisionGraphNode dgn, StateNode state)
     : base(state.Scene)
 {
     this.bInEditMode  = false;
     this.bVisible     = true;
     this.mDGN         = dgn;
     this.mState       = state;
     this.mScene       = state.Scene;
     this.mEntryAnchor = new AnchorPoint(this, -1, 0);
 }
Esempio n. 2
0
 public void AddDecisionMaker(DecisionGraphNode node)
 {
     if (!this.mDecisionMakers.Contains(node))
     {
         /*int index = this.mEntryPoints.IndexOf(node);
         if (index >= 0)
         {
             this.mEntryPoints.RemoveAt(index);
         }/* */
         this.mDecisionMakers.Add(node);
     }
 }
Esempio n. 3
0
 public void Remove(DecisionGraphNode node)
 {
     //if (node.mDecisionGraph == this)
     {
         int index = this.mDecisionMakers.IndexOf(node);
         if (index >= 0)
         {
             this.mDecisionMakers.RemoveAt(index);
         }
         index = this.mEntryPoints.IndexOf(node);
         if (index >= 0)
         {
             this.mEntryPoints.RemoveAt(index);
         }
         //node.mDecisionGraph = null;
     }
 }
Esempio n. 4
0
 private void SlurpDGNodes(DecisionGraphNode node)
 {
     this.mDGNodes.Add(node);
     int i, j;
     State state;
     DecisionGraphNode target;
     DecisionGraphNode[] targets;
     if (node is NextStateNode)
     {
         NextStateNode nsn = node as NextStateNode;
         state = nsn.NextState;
         if (state != null)
         {
             i = this.mStates.IndexOf(state);
             if (i < 0)
             {
                 i = this.mExtraStates.IndexOf(state);
                 if (i < 0)
                 {
                     this.mExtraStates.Add(state);
                 }
             }
         }
     }
     else if (node is RandomNode)
     {
         RandomNode rand = node as RandomNode;
         List<RandomNode.Slice> slices = rand.Slices;
         if (slices.Count > 0)
         {
             for (i = slices.Count - 1; i >= 0; i--)
             {
                 targets = slices[i].Targets.ToArray();
                 for (j = 0; j < targets.Length; j++)
                 {
                     target = targets[j];
                     if (target != null &&
                         !this.mDGNodes.Contains(target))
                     {
                         this.SlurpDGNodes(target);
                     }
                 }
             }
         }
     }
     else if (node is SelectOnDestinationNode)
     {
         SelectOnDestinationNode sodn = node as SelectOnDestinationNode;
         if (sodn.CaseCount > 0)
         {
             SelectOnDestinationNode.Case[] cases = sodn.Cases;
             for (i = 0; i < cases.Length; i++)
             {
                 targets = cases[i].Targets;
                 for (j = 0; j < targets.Length; j++)
                 {
                     target = targets[j];
                     if (target != null &&
                         !this.mDGNodes.Contains(target))
                     {
                         this.SlurpDGNodes(target);
                     }
                 }
                 state = cases[i].Value;
                 if (state != null)
                 {
                     j = this.mStates.IndexOf(state);
                     if (j < 0)
                     {
                         j = this.mExtraStates.IndexOf(state);
                         if (j < 0)
                         {
                             this.mExtraStates.Add(state);
                         }
                     }
                 }
             }
         }
     }
     else if (node is SelectOnParameterNode)
     {
         SelectOnParameterNode sopn = node as SelectOnParameterNode;
         if (sopn.CaseCount > 0)
         {
             SelectOnParameterNode.Case[] cases = sopn.Cases;
             for (i = 0; i < cases.Length; i++)
             {
                 targets = cases[i].Targets;
                 for (j = 0; j < targets.Length; j++)
                 {
                     target = targets[j];
                     if (target != null &&
                         !this.mDGNodes.Contains(target))
                     {
                         this.SlurpDGNodes(target);
                     }
                 }
             }
         }
         ParamDefinition param = sopn.Parameter;
         if (param != null)
         {
             i = this.mParamDefinitions.IndexOf(param);
             if (i < 0)
             {
                 i = this.mExtraParams.IndexOf(param);
                 if (i < 0)
                 {
                     this.mExtraParams.Add(param);
                 }
             }
         }
     }
     else if (node is MulticastDecisionGraphNode)
     {
         MulticastDecisionGraphNode mcdgn
             = node as MulticastDecisionGraphNode;
         if (mcdgn.TargetCount > 0)
         {
             targets = mcdgn.Targets;
             for (i = 0; i < targets.Length; i++)
             {
                 target = targets[i];
                 if (target != null &&
                     !this.mDGNodes.Contains(target))
                 {
                     this.SlurpDGNodes(target);
                 }
             }
         }
         if (node is CreatePropNode)
         {
             CreatePropNode cpn = node as CreatePropNode;
             ActorDefinition propActor = cpn.PropActor;
             if (propActor != null)
             {
                 i = this.mActorDefinitions.IndexOf(propActor);
                 if (i < 0)
                 {
                     i = this.mExtraActors.IndexOf(propActor);
                     if (i < 0)
                     {
                         this.mExtraActors.Add(propActor);
                     }
                 }
             }
             ParamDefinition propParam = cpn.PropParam;
             if (propParam != null)
             {
                 i = this.mParamDefinitions.IndexOf(propParam);
                 if (i < 0)
                 {
                     i = this.mExtraParams.IndexOf(propParam);
                     if (i < 0)
                     {
                         this.mExtraParams.Add(propParam);
                     }
                 }
             }
         }
         else if (node is ActorOperationNode)
         {
             ActorOperationNode aon = node as ActorOperationNode;
             ActorDefinition aTarget = aon.Actor;
             if (aTarget != null)
             {
                 i = this.mActorDefinitions.IndexOf(aTarget);
                 if (i < 0)
                 {
                     i = this.mExtraActors.IndexOf(aTarget);
                     if (i < 0)
                     {
                         this.mExtraActors.Add(aTarget);
                     }
                 }
             }
         }
         else if (node is AnimationNode)
         {
             AnimationNode an = node as AnimationNode;
             ActorDefinition ad = an.Actor;
             if (ad != null)
             {
                 i = this.mActorDefinitions.IndexOf(ad);
                 if (i < 0)
                 {
                     i = this.mExtraActors.IndexOf(ad);
                     if (i < 0)
                     {
                         this.mExtraActors.Add(ad);
                     }
                 }
             }
             if (node is PlayAnimationNode)
             {
                 PlayAnimationNode pan = node as PlayAnimationNode;
                 SlotSetupBuilder ssb = pan.SlotSetup;
                 if (ssb.ActorSuffixCount > 0)
                 {
                     ParamDefinition pd;
                     SlotSetupBuilder.ActorSuffix[] suffixes
                         = ssb.ActorSuffixArray;
                     for (i = 0; i < suffixes.Length; i++)
                     {
                         ad = suffixes[i].Actor;
                         if (ad != null)
                         {
                             j = this.mActorDefinitions.IndexOf(ad);
                             if (j < 0)
                             {
                                 j = this.mExtraActors.IndexOf(ad);
                                 if (j < 0)
                                 {
                                     this.mExtraActors.Add(ad);
                                 }
                             }
                         }
                         pd = suffixes[i].Param;
                         if (pd != null)
                         {
                             j = this.mParamDefinitions.IndexOf(pd);
                             if (j < 0)
                             {
                                 j = this.mExtraParams.IndexOf(pd);
                                 if (j < 0)
                                 {
                                     this.mExtraParams.Add(pd);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Esempio n. 5
0
 /// <summary>
 /// Recursively finds all of the unique resource keys referenced by
 /// the given <paramref name="node"/> (if it is a 
 /// <see cref="CreatePropNode"/> or <see cref="PlayAnimationNode"/>)
 /// and by all of the <see cref="DecisionGraphNode"/> instances it 
 /// references, and adds them to the given resource key list.
 /// </summary>
 /// <param name="node">The decision graph node to recursively search
 /// for external resource key references.</param>
 /// <param name="rks">The list of all unique resource keys referenced
 /// by the given <paramref name="node"/> and every 
 /// <see cref="DecisionGraphNode"/> instance it references.</param>
 private void SlurpDGNodeRKs(DecisionGraphNode node, List<RK> rks)
 {
     this.mDGNodes.Add(node);
     int i, j;
     State state;
     DecisionGraphNode target;
     DecisionGraphNode[] targets;
     if (node is NextStateNode)
     {
         NextStateNode nsn = node as NextStateNode;
         state = nsn.NextState;
         if (state != null)
         {
             i = this.mStates.IndexOf(state);
             if (i < 0)
             {
                 i = this.mExtraStates.IndexOf(state);
                 if (i < 0)
                 {
                     this.mExtraStates.Add(state);
                 }
             }
         }
     }
     else if (node is RandomNode)
     {
         RandomNode rand = node as RandomNode;
         List<RandomNode.Slice> slices = rand.Slices;
         if (slices.Count > 0)
         {
             for (i = slices.Count - 1; i >= 0; i--)
             {
                 targets = slices[i].Targets.ToArray();
                 for (j = 0; j < targets.Length; j++)
                 {
                     target = targets[j];
                     if (target != null &&
                         !this.mDGNodes.Contains(target))
                     {
                         this.SlurpDGNodeRKs(target, rks);
                     }
                 }
             }
         }
     }
     else if (node is SelectOnDestinationNode)
     {
         SelectOnDestinationNode sodn = node as SelectOnDestinationNode;
         if (sodn.CaseCount > 0)
         {
             SelectOnDestinationNode.Case[] cases = sodn.Cases;
             for (i = 0; i < cases.Length; i++)
             {
                 targets = cases[i].Targets;
                 for (j = 0; j < targets.Length; j++)
                 {
                     target = targets[j];
                     if (target != null &&
                         !this.mDGNodes.Contains(target))
                     {
                         this.SlurpDGNodeRKs(target, rks);
                     }
                 }
                 state = cases[i].Value;
                 if (state != null)
                 {
                     j = this.mStates.IndexOf(state);
                     if (j < 0)
                     {
                         j = this.mExtraStates.IndexOf(state);
                         if (j < 0)
                         {
                             this.mExtraStates.Add(state);
                         }
                     }
                 }
             }
         }
     }
     else if (node is SelectOnParameterNode)
     {
         SelectOnParameterNode sopn = node as SelectOnParameterNode;
         if (sopn.CaseCount > 0)
         {
             SelectOnParameterNode.Case[] cases = sopn.Cases;
             for (i = 0; i < cases.Length; i++)
             {
                 targets = cases[i].Targets;
                 for (j = 0; j < targets.Length; j++)
                 {
                     target = targets[j];
                     if (target != null &&
                         !this.mDGNodes.Contains(target))
                     {
                         this.SlurpDGNodeRKs(target, rks);
                     }
                 }
             }
         }
     }
     else if (node is MulticastDecisionGraphNode)
     {
         MulticastDecisionGraphNode mcdgn
             = node as MulticastDecisionGraphNode;
         if (mcdgn.TargetCount > 0)
         {
             targets = mcdgn.Targets;
             for (i = 0; i < targets.Length; i++)
             {
                 target = targets[i];
                 if (target != null &&
                     !this.mDGNodes.Contains(target))
                 {
                     this.SlurpDGNodeRKs(target, rks);
                 }
             }
         }
         if (node is CreatePropNode)
         {
             CreatePropNode cpn = node as CreatePropNode;
             RK propKey = cpn.PropKey;
             if (!rks.Contains(propKey))
             {
                 rks.Add(propKey);
             }
         }
         else if (node is PlayAnimationNode)
         {
             PlayAnimationNode lan = node as PlayAnimationNode;
             RK key = lan.ClipKey;
             if (!rks.Contains(key))
             {
                 rks.Add(key);
             }
             key = lan.AdditiveClipKey;
             if (!rks.Contains(key))
             {
                 rks.Add(key);
             }
             key = lan.TrackMaskKey;
             if (!rks.Contains(key))
             {
                 rks.Add(key);
             }
         }
     }
 }
Esempio n. 6
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);
        }