本文整理汇总了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;
}