using System.Collections.Generic; using UnityEngine; namespace NanoBrain.Unity { /// /// The Unity ScriptableObject to implement re-usable Cluster Prefabs /// [CreateAssetMenu(menuName = "Passer/Cluster")] public class ClusterPrefab : ScriptableObject { /// /// The cluster data /// public Cluster cluster; /// /// Retrieve a nucleus in this cluster /// /// The name of the nucleus /// The Nucleus with the given name or null if no such Nucleus could be found public Nucleus GetNucleus(string nucleusName) { return cluster.GetNucleus(nucleusName); } /// /// Call this function to ensure that there is at least one nucleus /// /// his is an invariant and should be ensured before the nucleus is used /// because output requires it. public void EnsureInitialization() { this.cluster.prefab = this; this.cluster.name = this.name; this.cluster.nuclei ??= new List(); if (this.cluster.nuclei.Count <= 0) new Neuron(this.cluster, "Output"); // Every cluster should have at least 1 neuron this.cluster.instanceCount = 1; } } }