/// <summary> /// /// </summary> /// <param name="atLoadTime">If true this fixup is happening when the level is being loaded. If false then it's happening during brain editing.</param> /// <param name="incomingLanguageVersion">If atLoadTime is true, this is the version of the language for the level being loaded.</param> public void Fixup(bool atLoadTime, int incomingLanguageVersion) { haveThingUpdateSensors = false; sensorCount = 0; maxReflexIndentation = 0; Stack <Reflex> parentStack = new Stack <Reflex>(); for (int indexReflex = 0; indexReflex < reflexes.Count; indexReflex++) { Reflex reflex = reflexes[indexReflex] as Reflex; reflex.Task = this; maxReflexIndentation = Math.Max(maxReflexIndentation, reflex.Indentation); while (parentStack.Count > reflex.Indentation) { parentStack.Pop(); } Reflex currParent = null; if (parentStack.Count > 0) { currParent = parentStack.Peek(); } reflex.Parent = currParent; reflex.Fixup(atLoadTime, incomingLanguageVersion); parentStack.Push(reflex); Sensor sensor = reflex.Sensor; if (sensor != null) { sensorCount += 1; haveThingUpdateSensors |= sensor.WantThingUpdate; } } Reset(); } // end of FixUp()