public new void UpdateArea(GraphUpdateObject o)
{
if (this.nodes == null || this.nodes.Length != this.width * this.depth * this.layerCount)
{
Debug.LogWarning("The Grid Graph is not scanned, cannot update area ");
return;
}
Bounds bounds = o.bounds;
Vector3 a;
Vector3 a2;
base.GetBoundsMinMax(bounds, this.inverseMatrix, out a, out a2);
int xmin = Mathf.RoundToInt(a.x - 0.5f);
int xmax = Mathf.RoundToInt(a2.x - 0.5f);
int ymin = Mathf.RoundToInt(a.z - 0.5f);
int ymax = Mathf.RoundToInt(a2.z - 0.5f);
IntRect intRect = new IntRect(xmin, ymin, xmax, ymax);
IntRect intRect2 = intRect;
IntRect b = new IntRect(0, 0, this.width - 1, this.depth - 1);
IntRect intRect3 = intRect;
bool flag = o.updatePhysics || o.modifyWalkability;
bool flag2 = o is LayerGridGraphUpdate && ((LayerGridGraphUpdate)o).recalculateNodes;
bool preserveExistingNodes = !(o is LayerGridGraphUpdate) || ((LayerGridGraphUpdate)o).preserveExistingNodes;
int num = (!o.updateErosion) ? 0 : this.erodeIterations;
if (o.trackChangedNodes && flag2)
{
Debug.LogError("Cannot track changed nodes when creating or deleting nodes.\nWill not update LayerGridGraph");
return;
}
if (o.updatePhysics && !o.modifyWalkability && this.collision.collisionCheck)
{
Vector3 a3 = new Vector3(this.collision.diameter, 0f, this.collision.diameter) * 0.5f;
a -= a3 * 1.02f;
a2 += a3 * 1.02f;
intRect3 = new IntRect(Mathf.RoundToInt(a.x - 0.5f), Mathf.RoundToInt(a.z - 0.5f), Mathf.RoundToInt(a2.x - 0.5f), Mathf.RoundToInt(a2.z - 0.5f));
intRect2 = IntRect.Union(intRect3, intRect2);
}
if (flag || num > 0)
{
intRect2 = intRect2.Expand(num + 1);
}
IntRect intRect4 = IntRect.Intersection(intRect2, b);
if (!flag2)
{
for (int i = intRect4.xmin; i <= intRect4.xmax; i++)
{
for (int j = intRect4.ymin; j <= intRect4.ymax; j++)
{
for (int k = 0; k < this.layerCount; k++)
{
o.WillUpdateNode(this.nodes[k * this.width * this.depth + j * this.width + i]);
}
}
}
}
if (o.updatePhysics && !o.modifyWalkability)
{
this.collision.Initialize(this.matrix, this.nodeSize);
intRect4 = IntRect.Intersection(intRect3, b);
bool flag3 = false;
for (int l = intRect4.xmin; l <= intRect4.xmax; l++)
{
for (int m = intRect4.ymin; m <= intRect4.ymax; m++)
{
flag3 |= this.RecalculateCell(l, m, preserveExistingNodes);
}
}
for (int n = intRect4.xmin; n <= intRect4.xmax; n++)
{
for (int num2 = intRect4.ymin; num2 <= intRect4.ymax; num2++)
{
for (int num3 = 0; num3 < this.layerCount; num3++)
{
int num4 = num3 * this.width * this.depth + num2 * this.width + n;
LevelGridNode levelGridNode = this.nodes[num4];
if (levelGridNode != null)
{
this.CalculateConnections(this.nodes, levelGridNode, n, num2, num3);
}
}
}
}
}
intRect4 = IntRect.Intersection(intRect, b);
for (int num5 = intRect4.xmin; num5 <= intRect4.xmax; num5++)
{
for (int num6 = intRect4.ymin; num6 <= intRect4.ymax; num6++)
{
for (int num7 = 0; num7 < this.layerCount; num7++)
{
int num8 = num7 * this.width * this.depth + num6 * this.width + num5;
LevelGridNode levelGridNode2 = this.nodes[num8];
if (levelGridNode2 != null)
{
if (flag)
{
levelGridNode2.Walkable = levelGridNode2.WalkableErosion;
if (o.bounds.Contains((Vector3)levelGridNode2.position))
{
o.Apply(levelGridNode2);
}
levelGridNode2.WalkableErosion = levelGridNode2.Walkable;
}
else if (o.bounds.Contains((Vector3)levelGridNode2.position))
{
o.Apply(levelGridNode2);
}
}
}
}
}
if (flag && num == 0)
{
intRect4 = IntRect.Intersection(intRect2, b);
for (int num9 = intRect4.xmin; num9 <= intRect4.xmax; num9++)
{
for (int num10 = intRect4.ymin; num10 <= intRect4.ymax; num10++)
{
for (int num11 = 0; num11 < this.layerCount; num11++)
{
int num12 = num11 * this.width * this.depth + num10 * this.width + num9;
LevelGridNode levelGridNode3 = this.nodes[num12];
if (levelGridNode3 != null)
{
this.CalculateConnections(this.nodes, levelGridNode3, num9, num10, num11);
}
}
}
}
}
else if (flag && num > 0)
{
IntRect a4 = IntRect.Union(intRect, intRect3).Expand(num);
IntRect a5 = a4.Expand(num);
a4 = IntRect.Intersection(a4, b);
a5 = IntRect.Intersection(a5, b);
for (int num13 = a5.xmin; num13 <= a5.xmax; num13++)
{
for (int num14 = a5.ymin; num14 <= a5.ymax; num14++)
{
for (int num15 = 0; num15 < this.layerCount; num15++)
{
int num16 = num15 * this.width * this.depth + num14 * this.width + num13;
LevelGridNode levelGridNode4 = this.nodes[num16];
if (levelGridNode4 != null)
{
bool walkable = levelGridNode4.Walkable;
levelGridNode4.Walkable = levelGridNode4.WalkableErosion;
if (!a4.Contains(num13, num14))
{
levelGridNode4.TmpWalkable = walkable;
}
}
}
}
}
for (int num17 = a5.xmin; num17 <= a5.xmax; num17++)
{
for (int num18 = a5.ymin; num18 <= a5.ymax; num18++)
{
for (int num19 = 0; num19 < this.layerCount; num19++)
{
int num20 = num19 * this.width * this.depth + num18 * this.width + num17;
LevelGridNode levelGridNode5 = this.nodes[num20];
if (levelGridNode5 != null)
{
this.CalculateConnections(this.nodes, levelGridNode5, num17, num18, num19);
}
}
}
}
this.ErodeWalkableArea(a5.xmin, a5.ymin, a5.xmax + 1, a5.ymax + 1);
for (int num21 = a5.xmin; num21 <= a5.xmax; num21++)
{
for (int num22 = a5.ymin; num22 <= a5.ymax; num22++)
{
if (!a4.Contains(num21, num22))
{
for (int num23 = 0; num23 < this.layerCount; num23++)
{
int num24 = num23 * this.width * this.depth + num22 * this.width + num21;
LevelGridNode levelGridNode6 = this.nodes[num24];
if (levelGridNode6 != null)
{
levelGridNode6.Walkable = levelGridNode6.TmpWalkable;
}
}
}
}
}
for (int num25 = a5.xmin; num25 <= a5.xmax; num25++)
{
for (int num26 = a5.ymin; num26 <= a5.ymax; num26++)
{
for (int num27 = 0; num27 < this.layerCount; num27++)
{
int num28 = num27 * this.width * this.depth + num26 * this.width + num25;
LevelGridNode levelGridNode7 = this.nodes[num28];
if (levelGridNode7 != null)
{
this.CalculateConnections(this.nodes, levelGridNode7, num25, num26, num27);
}
}
}
}
}
}