using UnityEngine; using Unity.Mathematics; using static Unity.Mathematics.math; [System.Serializable] public class Receptor : Neuron, IReceptor { public Receptor(Cluster parent, string name) : base(parent, name) { this.array ??= new NucleusArray(this); if (this.name.IndexOf(":") < 0) this.name += ": 0"; } public Receptor(ClusterPrefab prefab, string name) : base(prefab, name) { this.array ??= new NucleusArray(this); } public string GetName() { return this.name; } public override Nucleus ShallowCloneTo(Cluster parent) { Receptor clone = new(parent, name); CloneFields(clone); return clone; } public override Nucleus Clone(ClusterPrefab prefab) { Receptor clone = new(prefab, name) { array = this.array }; CloneFields(clone); return clone; } [SerializeReference] private NucleusArray _array; public NucleusArray array { get { return _array; } set { _array = value; } } public override void UpdateStateIsolated() { this.outputValue = this.bias; //Debug.Log($"Receptor {this.name} outputvalue = {this.outputValue}"); } 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 virtual void ProcessStimulus(Vector3 inputValue, int thingId = 0, string thingName = null) { this.array ??= new NucleusArray(this.parent); this.array.ProcessStimulus(thingId, inputValue, thingName); } }