当前位置: 首页>>代码示例>>C#>>正文


C# Node.CloneProperties方法代码示例

本文整理汇总了C#中Behaviac.Design.Nodes.Node.CloneProperties方法的典型用法代码示例。如果您正苦于以下问题:C# Node.CloneProperties方法的具体用法?C# Node.CloneProperties怎么用?C# Node.CloneProperties使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Behaviac.Design.Nodes.Node的用法示例。


在下文中一共展示了Node.CloneProperties方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ResetByPrefab

        public bool ResetByPrefab(string prefabName, Node prefabNode) {
            bool reset = false;

            if (!this.HasOwnPrefabData && this.PrefabName == prefabName && this.PrefabNodeId == prefabNode.Id) {
                reset = true;

                int preId = this.Id;
                string prePrefabName = this.PrefabName;
                int prePrefabNodeId = this.PrefabNodeId;
                Comment preComment = (this.CommentObject != null) ? this.CommentObject.Clone() : null;

                prefabNode.CloneProperties(this);

                this.Id = preId;
                this.PrefabName = prePrefabName;
                this.PrefabNodeId = prePrefabNodeId;
                this.HasOwnPrefabData = false;
                this.CommentObject = preComment;

                // check the deleted children by the prefab node
                List<Node> deletedChildren = new List<Node>();
                foreach(Node child in this.Children) {
                    if (!child.HasOwnPrefabData && child.PrefabName == prefabName) {
                        bool bFound = false;
                        foreach(Node prefabChild in prefabNode.Children) {
                            if (child.PrefabNodeId == prefabChild.Id) {
                                bFound = true;
                                break;
                            }
                        }

                        if (!bFound) {
                            deletedChildren.Add(child);
                        }
                    }
                }

                foreach(Node child in deletedChildren) {
                    ((Node)child.Parent).RemoveChild(child.ParentConnector, child);
                }

                // check the added children by the prefab node
                List<Node> addedChildren = new List<Node>();
                List<int> indexes = new List<int>();

                for (int i = 0; i < prefabNode.Children.Count; ++i) {
                    Node prefabChild = (Node)prefabNode.Children[i];
                    bool bFound = false;
                    foreach(Node child in this.Children) {
                        if (!string.IsNullOrEmpty(prefabChild.PrefabName) && child.PrefabName == prefabChild.PrefabName && child.PrefabNodeId == prefabChild.PrefabNodeId ||
                            child.PrefabName == prefabName && child.PrefabNodeId == prefabChild.Id) {
                            bFound = true;
                            break;
                        }
                    }

                    if (!bFound) {
                        addedChildren.Add(prefabChild);
                        indexes.Add(i);
                    }
                }

                for (int i = 0; i < addedChildren.Count; ++i) {
                    Node child = addedChildren[i].CloneBranch();
                    child.SetPrefab(prefabName);

                    Node.Connector conn = addedChildren[i].ParentConnector;
                    Debug.Check(conn != null);
                    Node.Connector childconn = this.GetConnector(conn.Identifier);
                    Debug.Check(childconn != null);

                    if (indexes[i] < this.Children.Count)
                    { this.AddChild(childconn, child, indexes[i]); }

                    else
                    { this.AddChild(childconn, child); }

                    child.ResetId(true);
                }
            }

            if (!(this is ReferencedBehavior)) {
                foreach(Node child in this.Children) {
                    reset |= child.ResetByPrefab(prefabName, prefabNode);
                }
            }

            return reset;
        }
开发者ID:haolly,项目名称:behaviac,代码行数:89,代码来源:Node.cs


注:本文中的Behaviac.Design.Nodes.Node.CloneProperties方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。