using UnityEngine; using Unity.Mathematics; using static Unity.Mathematics.math; [System.Serializable] public class Receptor : Neuron { public Receptor(Cluster parent, string name) : base(parent, name) { } public Receptor(ClusterPrefab prefab, string name) : base(prefab, name) { } public override Nucleus ShallowCloneTo(Cluster parent) { Receptor clone = new(parent, name); CloneFields(clone); clone.array = this.array; return clone; } public override Nucleus Clone(ClusterPrefab prefab) { Receptor clone = new(prefab, name); CloneFields(clone); clone.array = this.array; // Adding receivers will also add synapses to the receivers foreach (Nucleus receiver in this.receivers) clone.AddReceiver(receiver); return clone; } [SerializeReference] private NucleusArray _array; public NucleusArray array { get { return _array; } set { _array = value; } } public override void UpdateStateIsolated() { this.outputValue = this.bias; } public override void UpdateNuclei() { this.stale++; if (this.stale > staleValueForSleep && lengthsq(this.bias) > 0) { this.bias = new float3(0, 0, 0); this.parent.UpdateFromNucleus(this); } } public override void ProcessStimulus(Vector3 inputValue, int thingId = 0, string thingName = null) { this.array.ProcessStimulus(thingId, inputValue, thingName); } }