private bool TryToAddTerrain(int tileX, int tileZ, Terrain terrain) { bool result = false; bool flag = terrain != null; if (flag) { Terrain terrain2 = this.GetTerrain(tileX, tileZ); bool flag2 = terrain2 != null; if (flag2) { bool flag3 = terrain2 != terrain; if (flag3) { this.m_errorCode |= TerrainUtility.TerrainMap.ErrorCode.Overlapping; } } else { this.AddTerrainInternal(tileX, tileZ, terrain); result = true; } } return(result); }
private void ValidateTerrain(int tileX, int tileZ) { Terrain terrain = this.GetTerrain(tileX, tileZ); bool flag = terrain != null; if (flag) { Terrain terrain2 = this.GetTerrain(tileX - 1, tileZ); Terrain terrain3 = this.GetTerrain(tileX + 1, tileZ); Terrain terrain4 = this.GetTerrain(tileX, tileZ + 1); Terrain terrain5 = this.GetTerrain(tileX, tileZ - 1); bool flag2 = terrain2; if (flag2) { bool flag3 = !Mathf.Approximately(terrain.transform.position.x, terrain2.transform.position.x + terrain2.terrainData.size.x) || !Mathf.Approximately(terrain.transform.position.z, terrain2.transform.position.z); if (flag3) { this.m_errorCode |= TerrainUtility.TerrainMap.ErrorCode.EdgeAlignmentMismatch; } } bool flag4 = terrain3; if (flag4) { bool flag5 = !Mathf.Approximately(terrain.transform.position.x + terrain.terrainData.size.x, terrain3.transform.position.x) || !Mathf.Approximately(terrain.transform.position.z, terrain3.transform.position.z); if (flag5) { this.m_errorCode |= TerrainUtility.TerrainMap.ErrorCode.EdgeAlignmentMismatch; } } bool flag6 = terrain4; if (flag6) { bool flag7 = !Mathf.Approximately(terrain.transform.position.x, terrain4.transform.position.x) || !Mathf.Approximately(terrain.transform.position.z + terrain.terrainData.size.z, terrain4.transform.position.z); if (flag7) { this.m_errorCode |= TerrainUtility.TerrainMap.ErrorCode.EdgeAlignmentMismatch; } } bool flag8 = terrain5; if (flag8) { bool flag9 = !Mathf.Approximately(terrain.transform.position.x, terrain5.transform.position.x) || !Mathf.Approximately(terrain.transform.position.z, terrain5.transform.position.z + terrain5.terrainData.size.z); if (flag9) { this.m_errorCode |= TerrainUtility.TerrainMap.ErrorCode.EdgeAlignmentMismatch; } } } }
private void AddTerrainInternal(int x, int z, Terrain terrain) { bool flag = this.m_terrainTiles.Count == 0; if (flag) { this.m_patchSize = terrain.terrainData.size; } else { bool flag2 = terrain.terrainData.size != this.m_patchSize; if (flag2) { this.m_errorCode |= TerrainUtility.TerrainMap.ErrorCode.SizeMismatch; } } this.m_terrainTiles.Add(new TerrainUtility.TerrainMap.TileCoord(x, z), terrain); }
public TerrainMap() { this.m_errorCode = TerrainUtility.TerrainMap.ErrorCode.OK; this.m_terrainTiles = new Dictionary <TerrainUtility.TerrainMap.TileCoord, Terrain>(); }