private void RemoveLink() { DialogTreeBranch parentBranch = m_project[(DialogTreeBranchIdentifier)Parent]; if (parentBranch == null) { Logging.Logger.Warn($"Unable to remove branch link as parent '{Parent}' couldn't be found"); return; } if (!parentBranch.RemoveChild(Child)) { Logging.Logger.Warn($"Failed to remove link between '{Parent}' and '{Child}'"); } else { m_script.ClearBranchListAfterParent(Parent); } }
public void RemoveChild() { NpcChatProject project = new NpcChatProject(); DialogTree tree = project.ProjectDialogs.CreateNewDialogTree(); DialogTreeBranch start = tree.GetStart(); start.Name = "Start"; DialogTreeBranch aBranch = tree.CreateNewBranch(); aBranch.Name = "aBranch"; Assert.IsTrue(aBranch.AddParent(start)); Assert.AreEqual(1, aBranch.Parents.Count); Assert.AreEqual(1, start.Children.Count); Assert.IsTrue(start.RemoveChild(aBranch)); Assert.AreEqual(0, aBranch.Parents.Count); Assert.AreEqual(0, start.Children.Count); }
public void RemoveChildCallback() { NpcChatProject project = new NpcChatProject(); DialogTree tree = project.ProjectDialogs.CreateNewDialogTree(); DialogTreeBranch start = tree.GetStart(); DialogTreeBranch aBranch = tree.CreateNewBranch(); Assert.IsTrue(start.AddChild(aBranch), "Cannot test removal if you can't add branches"); Assert.AreEqual(1, start.Children.Count); Assert.AreEqual(1, aBranch.Parents.Count); bool parentCallback = false, childCallback = false; aBranch.OnBranchParentRemoved += id => parentCallback = true; start.OnBranchChildRemoved += id => childCallback = true; Assert.IsTrue(start.RemoveChild(aBranch)); Assert.IsTrue(parentCallback, "Parent Added Callback failed"); Assert.IsTrue(childCallback, "Child Added Callback failed"); }
protected override void RelationshipDestroy(DialogTreeBranch parent, DialogTreeBranch child) { parent.RemoveChild(child); }