ant and mouth share the same brain
This commit is contained in:
parent
2cae7a6c41
commit
7bcd4a6cf1
@ -86,8 +86,12 @@ public class Cluster : Nucleus {
|
|||||||
int arrayIx = 0;
|
int arrayIx = 0;
|
||||||
foreach (Nucleus prefabArrayNucleus in prefabNucleus.array.nuclei) {
|
foreach (Nucleus prefabArrayNucleus in prefabNucleus.array.nuclei) {
|
||||||
int arrayNucleusIx = GetNucleusIndex(prefabNuclei, prefabArrayNucleus);
|
int arrayNucleusIx = GetNucleusIndex(prefabNuclei, prefabArrayNucleus);
|
||||||
|
if (arrayNucleusIx >= 0) {
|
||||||
Nucleus clonedArrayNucleus = clonedNuclei[arrayNucleusIx];
|
Nucleus clonedArrayNucleus = clonedNuclei[arrayNucleusIx];
|
||||||
clonedArray.nuclei[arrayIx] = clonedArrayNucleus;
|
clonedArray.nuclei[arrayIx] = clonedArrayNucleus;
|
||||||
|
} else {
|
||||||
|
Debug.LogError($" Could not find prefab nuclues {prefabNucleus.name} in the clones");
|
||||||
|
}
|
||||||
arrayIx++;
|
arrayIx++;
|
||||||
}
|
}
|
||||||
clonedNucleus.array = clonedArray;
|
clonedNucleus.array = clonedArray;
|
||||||
@ -138,9 +142,9 @@ public class Cluster : Nucleus {
|
|||||||
return sortedOrder;
|
return sortedOrder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Nucleus Clone() {
|
public override Nucleus Clone(ClusterPrefab prefab) {
|
||||||
//Neuron clone = new(this.cluster, this.name) {
|
//Neuron clone = new(this.cluster, this.name) {
|
||||||
Neuron clone = new(this.parent, this.name) {
|
Neuron clone = new(prefab, this.name) {
|
||||||
array = this.array,
|
array = this.array,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -550,7 +550,7 @@ public class ClusterInspector : Editor {
|
|||||||
EditorGUILayout.BeginHorizontal();
|
EditorGUILayout.BeginHorizontal();
|
||||||
EditorGUILayout.IntField("Array size", neuroid.array.nuclei.Count());
|
EditorGUILayout.IntField("Array size", neuroid.array.nuclei.Count());
|
||||||
if (GUILayout.Button("Add"))
|
if (GUILayout.Button("Add"))
|
||||||
neuroid.array.AddNucleus();
|
neuroid.array.AddNucleus(this.cluster);
|
||||||
if (GUILayout.Button("Del"))
|
if (GUILayout.Button("Del"))
|
||||||
neuroid.array.RemoveNucleus();
|
neuroid.array.RemoveNucleus();
|
||||||
EditorGUILayout.EndHorizontal();
|
EditorGUILayout.EndHorizontal();
|
||||||
|
|||||||
@ -139,8 +139,8 @@ public class Neuron : Nucleus {
|
|||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Nucleus Clone() {
|
public override Nucleus Clone(ClusterPrefab prefab) {
|
||||||
Neuron clone = new(this.cluster, this.name) {
|
Neuron clone = new(prefab, this.name) {
|
||||||
//Neuron clone = new(this.parent, this.name) {
|
//Neuron clone = new(this.parent, this.name) {
|
||||||
array = this.array,
|
array = this.array,
|
||||||
curve = this.curve,
|
curve = this.curve,
|
||||||
|
|||||||
@ -34,7 +34,7 @@ public abstract class Nucleus {
|
|||||||
public int stale = 1000;
|
public int stale = 1000;
|
||||||
|
|
||||||
public abstract Nucleus ShallowCloneTo(Cluster parent);
|
public abstract Nucleus ShallowCloneTo(Cluster parent);
|
||||||
public abstract Nucleus Clone();
|
public abstract Nucleus Clone(ClusterPrefab prefab);
|
||||||
|
|
||||||
#region Synapses
|
#region Synapses
|
||||||
|
|
||||||
|
|||||||
@ -28,7 +28,7 @@ public class NucleusArray {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void AddNucleus() {
|
public void AddNucleus(ClusterPrefab prefab) {
|
||||||
if (this._nuclei.Length == 0) {
|
if (this._nuclei.Length == 0) {
|
||||||
Debug.LogError("Empty perceptoid array, cannot add");
|
Debug.LogError("Empty perceptoid array, cannot add");
|
||||||
return;
|
return;
|
||||||
@ -39,7 +39,7 @@ public class NucleusArray {
|
|||||||
for (int i = 0; i < this._nuclei.Length; i++)
|
for (int i = 0; i < this._nuclei.Length; i++)
|
||||||
newArray[i] = this._nuclei[i];
|
newArray[i] = this._nuclei[i];
|
||||||
if (this._nuclei[0] is Nucleus nucleus)
|
if (this._nuclei[0] is Nucleus nucleus)
|
||||||
newArray[newLength - 1] = nucleus.Clone();
|
newArray[newLength - 1] = nucleus.Clone(prefab);
|
||||||
|
|
||||||
this._nuclei = newArray;
|
this._nuclei = newArray;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user