From b73b28146cad3818ffa2324e9808da5c7d723add Mon Sep 17 00:00:00 2001 From: Pascal Serrarens Date: Thu, 5 Feb 2026 12:52:13 +0100 Subject: [PATCH] WIP: all array elements share the same receptor (value) --- Cluster.cs | 56 ++++---------------------------------- Editor/ClusterInspector.cs | 4 +-- Receptor.cs | 51 ++-------------------------------- 3 files changed, 10 insertions(+), 101 deletions(-) diff --git a/Cluster.cs b/Cluster.cs index 3d601db..82faa5d 100644 --- a/Cluster.cs +++ b/Cluster.cs @@ -76,65 +76,19 @@ public class Cluster : INucleus { // Find the synapse for the weight float weight = 1; - //NucleusArray clonedNucleusArray = null; foreach (Synapse synapse in receiver.synapses) { // Find the weight for this synapse - if (synapse.nucleus == receptor) + if (synapse.nucleus == receptor) { weight = synapse.weight; - - // if (synapse.nucleus is INucleus synapseNucleus) { - // if (synapseNucleus.array != null && synapseNucleus.array.nuclei.Length > 0) { - // Debug.Log("Clone: Nucleus array"); - // if (clonedNucleusArray == null) { - // // copy the array - // clonedNucleusArray = new NucleusArray(synapseNucleus.array.nuclei.Length, "array"); - // for (int arrayIx = 0; arrayIx < synapseNucleus.array.nuclei.Length; arrayIx++) { - // IReceptor arrayNucleus = synapseNucleus.array.nuclei[arrayIx]; - // int ix2 = GetNucleusIndex(nuclei, arrayNucleus); - // clonedNucleusArray.nuclei[arrayIx] = clonedNuclei[ix2]; - // } - // } - // synapseNucleus.array = clonedNucleusArray; - // } - // } + break; + } } clonedReceptor.AddReceiver(clonedReceiver, weight); - // Nucleus clonedNucleus = clonedReceptor as Nucleus; - // if (clonedNucleus is not null) { - // Synapse clonedSynapse = clonedNucleus.GetSynapse(clonedReceiver); - // if (clonedSynapse.nucleus is INucleus synapseNucleus) { - // if (synapseNucleus.array != null && synapseNucleus.array.nuclei.Length > 0) { - // Debug.Log("Clone: Nucleus array"); - // if (clonedNucleusArray == null) { - // // copy the array - // clonedNucleusArray = new NucleusArray(synapseNucleus.array.nuclei.Length, "array"); - // for (int arrayIx = 0; arrayIx < synapseNucleus.array.nuclei.Length; arrayIx++) { - // IReceptor arrayNucleus = synapseNucleus.array.nuclei[arrayIx]; - // int ix2 = GetNucleusIndex(nuclei, arrayNucleus); - // clonedNucleusArray.nuclei[arrayIx] = clonedNuclei[ix2]; - // } - // } - // synapseNucleus.array = clonedNucleusArray; - // } - // } - // } } - - // if (receptor is INucleus nucleus) { - // if (clonedSender is not INucleus clonedNucleus) { - // Debug.LogError("INucleus clone is not an INucleus!"); - // continue; - // } - // clonedNucleus.array = new NucleusArray(nucleus.array._nuclei.Length, "array"); - // for (int arrayIx = 0; arrayIx < nucleus.array._nuclei.Length; arrayIx++) { - // //foreach (INucleus arrayNucleus in nucleus.array.nuclei) { - // IReceptor arrayNucleus = nucleus.array._nuclei[arrayIx]; - // int ix = GetNucleusIndex(nuclei, arrayNucleus); - // clonedNucleus.array._nuclei[arrayIx] = clonedNuclei[ix]; - // } - // } } + + // Copy nucleus arrays for (int nucleusIx = 0; nucleusIx < nuclei.Length; nucleusIx++) { IReceptor prefabReceptor = nuclei[nucleusIx]; if (prefabReceptor is not INucleus prefabNucleus) diff --git a/Editor/ClusterInspector.cs b/Editor/ClusterInspector.cs index 0d84576..c805b8e 100644 --- a/Editor/ClusterInspector.cs +++ b/Editor/ClusterInspector.cs @@ -432,12 +432,12 @@ public class ClusterInspector : Editor { tooltip = new( $"{nucleus.name}" + $"\nsynapse count {n.synapses.Count}" + - $"\nValue: {nucleus.outputValue}"); + $"\nValue: {length(nucleus.outputValue)}"); } else { tooltip = new( $"{nucleus.name}" + - $"\nValue: {nucleus.outputValue}"); + $"\nValue: {length(nucleus.outputValue)}"); } Vector2 mousePosition = Event.current.mousePosition; diff --git a/Receptor.cs b/Receptor.cs index cf99794..ad6d526 100644 --- a/Receptor.cs +++ b/Receptor.cs @@ -25,12 +25,6 @@ public class Receptor : IReceptor { cluster.nuclei.Add(this); } - // public Receptor(ClusterPrefab cluster, INucleus nucleus) { - // this.cluster = cluster; - // if (cluster != null) - // cluster.nuclei.Add(this); - // this.AddReceiver(nucleus); - // } public Receptor(Cluster parent, string name, string nucleusName) { this.parent = parent ?? throw new ArgumentNullException(nameof(parent), "Parent cannot be null."); @@ -43,24 +37,6 @@ public class Receptor : IReceptor { } } - [Obsolete("This method is deprecated. Use Receptor() constructor instead.")] - public static Receptor CreateReceptor(Cluster cluster, string nucleusName) { - return new Receptor(cluster, "Receptor", nucleusName); - // if (cluster == null) - // return null; - - // Receptor receptor = new(cluster); - // foreach (INucleus nucleus in cluster.inputs) { - // if (nucleus != null && nucleus.name == nucleusName) { - // receptor.AddReceiver(nucleus); - // } - // } - // if (receptor._receivers.Count == 0) - // return null; - // else - // return receptor; - } - private ClusterPrefab cluster; private Cluster parent; @@ -68,20 +44,7 @@ public class Receptor : IReceptor { Receptor clone = new(parent); return clone; } - // public virtual IReceptor ShallowCloneTo(ClusterPrefab parent) { - // Receptor clone = new(parent); - // return clone; - // } - // public virtual IReceptor CloneTo(ClusterPrefab parent) { - // Receptor clone = new(parent); - - // foreach (INucleus receiver in this.receivers) { - // clone.AddReceiver(receiver); - // } - - // return clone; - // } public virtual IReceptor Clone() { Receptor clone = new(this.cluster); @@ -127,16 +90,8 @@ public class Receptor : IReceptor { private bool _isSleeping = false; public bool isSleeping => _isSleeping; - public Vector3 localPosition { - set { - this.stale = 0; - this._isSleeping = false; - this._outputValue = value; - - } - } - public float distanceResolution = 0.1f; - public float directionResolution = 5; + // public float distanceResolution = 0.1f; + // public float directionResolution = 5; private float3 _outputValue; public float3 outputValue { @@ -149,7 +104,7 @@ public class Receptor : IReceptor { } public virtual void ProcessStimulus(int thingId, Vector3 newLocalPositionVector, string thingName = null) { - this.localPosition = newLocalPositionVector; + this.outputValue = newLocalPositionVector; if (this._receivers == null) return;