protected void CreateCells(EPartyType partyType) { foreach (GroundMesh ground in planetLink.allGroundMesh) { GameObject newGo = Instantiate(_cellPrefab, Vector3.zero, Quaternion.identity, planetLink.transform); _cellsObj.Add(newGo); Cell newCell = newGo.GetComponent <Cell>(); newCell.SetID(); newCell.Init(ground); Mesh finalMesh = newCell.gameObject.GetComponent <MeshFilter>().mesh; finalMesh.vertices = ground.smoothVertex; finalMesh.triangles = ground.smoothTriangles; finalMesh.normals = ground.smoothNormals; finalMesh.uv = ground.UVs; newCell.gameObject.GetComponent <MeshCollider>().sharedMesh = finalMesh; finalMesh.RecalculateBounds(); _cells.Add(newCell); } planetLink.GenerateNeighborLinks(planetLink.GetMinimalNeighborDistance(), _cells); if (partyType == EPartyType.SAVE) { int l = _cells.Count; Cell cCell; for (int i = 0; i < l; i++) { cCell = _cells[i]; Mesh finalMesh = cCell.gameObject.GetComponent <MeshFilter>().mesh; List <SaveCell> outCells; ArrayExtensions.ToList(PlanetSave.GameStateSave.SavedCells, out outCells); SaveCell sCell = outCells.Find(c => c.ID == cCell.ID); cCell.Init(sCell); cCell.SetPolution(sCell.poluted); if (sCell.poluted) { PolutionArea.CELLS_USED.Add(cCell); } cCell.SetDeforestation(sCell.deforested); if (sCell.deforested) { DeforestationArea.CELLS_USED.Add(cCell); } UpdateNbCell(cCell.State); finalMesh.vertices = cCell.GroundMesh.smoothVertex; finalMesh.triangles = cCell.GroundMesh.smoothTriangles; finalMesh.normals = cCell.GroundMesh.smoothNormals; finalMesh.uv = cCell.GroundMesh.UVs; cCell.gameObject.GetComponent <MeshCollider>().sharedMesh = finalMesh; finalMesh.RecalculateBounds(); } } else if (partyType == EPartyType.NEW) { if (PlanetSave.LoadCells(playingPlanetName)) { foreach (Cell cCell in _cells) { Mesh finalMesh = cCell.gameObject.GetComponent <MeshFilter>().mesh; SaveCell sCell = PlanetSave.BaseCells.Find(c => c.ID == cCell.ID); cCell.Init(sCell); UpdateNbCell(cCell.State); finalMesh.vertices = cCell.GroundMesh.smoothVertex; finalMesh.triangles = cCell.GroundMesh.smoothTriangles; finalMesh.normals = cCell.GroundMesh.smoothNormals; finalMesh.uv = cCell.GroundMesh.UVs; cCell.gameObject.GetComponent <MeshCollider>().sharedMesh = finalMesh; finalMesh.RecalculateBounds(); } } } }