private static GameObject CreateNode(Springy.Node springyNode, string label) { var nodeObject = (GameObject)Instantiate(_nodeResource); nodeObject.name = label; var node = nodeObject.GetComponent <Node>(); node.springyNode = springyNode; node.Label = label; return(nodeObject); }
public Edge CreateNewEdge(Node source, Node target, float length) { if (source.Id == target.Id) { throw new ArgumentException("Cannot link a node with itself"); } if (length < 0) { throw new ArgumentException("Cannot have negative length"); } Edge edge = new Edge(edges.Count, source, target, length); edges.Add(edge); return edge; }
public bool RemoveNode(Node node) { if (node == null) { throw new ArgumentException("Specified node cannot be null"); } DetachNode(node); return nodes.Remove(node); }
public bool DetachNode(Node node) { if (node == null) { throw new ArgumentException("Specified node cannot be null"); } // remove all edges connecting this node int num_removed = edges.RemoveAll(edge => (edge.Source == node || edge.Target == node)); return num_removed > 0; }
public Node CreateNewNode(float mass = 1) { if (mass < 0) { throw new ArgumentException("Cannot have negative mass"); } Node node = new Node(nodes.Count, mass); nodes.Add(node); return node; }