using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
/// Base class for all node graphs
[Serializable]
public abstract class NodeGraph : ScriptableObject {
/// All nodes in the graph.
/// See:
[SerializeField] public List nodes = new List();
public T AddNode() where T : Node {
return AddNode(typeof(T)) as T;
}
public virtual Node AddNode(Type type) {
Node node = (Node)Activator.CreateInstance(type);
nodes.Add(node);
node.graph = this;
return node;
}
/// Safely remove a node and all its connections
///
public void RemoveNode(Node node) {
node.ClearConnections();
nodes.Remove(node);
}
/// Remove all nodes and connections from the graph
public void Clear() {
nodes.Clear();
}
}