private Node GetOrCreateNode(NodeType type, agx.Uuid uuid, bool isRoot, Action onCreate) { if (m_nodeCache.ContainsKey(uuid)) { return(m_nodeCache[uuid]); } onCreate(); return(CreateNode(type, uuid, isRoot)); }
private Node CreateNode(NodeType type, agx.Uuid uuid, bool isRoot) { Node node = new Node() { Type = type, Uuid = uuid }; if (isRoot) { if (type == NodeType.Constraint) { m_constraintRoot.AddChild(node); } else if (type == NodeType.Material) { m_materialRoot.AddChild(node); } else if (type == NodeType.ContactMaterial) { m_contactMaterialRoot.AddChild(node); } else if (type == NodeType.Wire) { m_wireRoot.AddChild(node); } else if (type == NodeType.Cable) { m_cableRoot.AddChild(node); } else if (m_roots.FindIndex(n => n.Uuid == uuid) >= 0) { Debug.LogError("Node already present as root."); } else { m_roots.Add(node); } } m_nodeCache.Add(uuid, node); return(node); }