public override IEnumerable <Progress> ScanInternal()
{
if (this.nodeSize <= 0f)
{
yield break;
}
base.UpdateTransform();
if (this.width > 1024 || this.depth > 1024)
{
Debug.LogError("One of the grid's sides is longer than 1024 nodes");
yield break;
}
this.lastScannedWidth = this.width;
this.lastScannedDepth = this.depth;
this.SetUpOffsetsAndCosts();
LevelGridNode.SetGridGraph((int)this.graphIndex, this);
this.maxClimb = Mathf.Clamp(this.maxClimb, 0f, this.characterHeight);
LinkedLevelNode[] linkedCells = new LinkedLevelNode[this.width * this.depth];
this.collision = (this.collision ?? new GraphCollision());
this.collision.Initialize(base.transform, this.nodeSize);
int progressCounter = 0;
for (int z = 0; z < this.depth; z++)
{
if (progressCounter >= 1000)
{
progressCounter = 0;
yield return(new Progress(Mathf.Lerp(0.1f, 0.5f, (float)z / (float)this.depth), "Calculating positions"));
}
progressCounter += this.width;
for (int i = 0; i < this.width; i++)
{
linkedCells[z * this.width + i] = this.SampleCell(i, z);
}
}
this.layerCount = 0;
for (int j = 0; j < linkedCells.Length; j++)
{
int num = 0;
for (LinkedLevelNode linkedLevelNode = linkedCells[j]; linkedLevelNode != null; linkedLevelNode = linkedLevelNode.next)
{
num++;
}
this.layerCount = Math.Max(this.layerCount, num);
}
if (this.layerCount > 255)
{
Debug.LogError(string.Concat(new object[]
{
"Too many layers, a maximum of ",
255,
" (LevelGridNode.MaxLayerCount) layers are allowed (found ",
this.layerCount,
")"
}));
yield break;
}
this.nodes = new LevelGridNode[this.width * this.depth * this.layerCount];
for (int z2 = 0; z2 < this.depth; z2++)
{
if (progressCounter >= 1000)
{
progressCounter = 0;
yield return(new Progress(Mathf.Lerp(0.5f, 0.8f, (float)z2 / (float)this.depth), "Creating nodes"));
}
progressCounter += this.width;
for (int k = 0; k < this.width; k++)
{
this.RecalculateCell(k, z2, true, true);
}
}
for (int z3 = 0; z3 < this.depth; z3++)
{
if (progressCounter >= 1000)
{
progressCounter = 0;
yield return(new Progress(Mathf.Lerp(0.8f, 0.9f, (float)z3 / (float)this.depth), "Calculating connections"));
}
progressCounter += this.width;
for (int l = 0; l < this.width; l++)
{
this.CalculateConnections(l, z3);
}
}
yield return(new Progress(0.95f, "Calculating Erosion"));
for (int m = 0; m < this.nodes.Length; m++)
{
LevelGridNode levelGridNode = this.nodes[m];
if (levelGridNode != null)
{
if (!levelGridNode.HasAnyGridConnections())
{
levelGridNode.Walkable = false;
levelGridNode.WalkableErosion = levelGridNode.Walkable;
}
}
}
this.ErodeWalkableArea();
yield break;
}