public VoxelComponent ChangeType(VoxelObjectType _type) { return(Initialize(_type)); }
public VoxelComponent Initialize(VoxelObjectType _type = VoxelObjectType.GENERIC) { if (entity == Unity.Entities.Entity.Null) { CreateEntity(); this.GetComponent <EntityTracker>().SetReceivedEntity(entity); } foreach (Transform child in transform) { Destroy(child.gameObject); } type = _type; switch (type) { case VoxelObjectType.GENERIC: voxelObject = new VoxelObject(sizeX, sizeY, sizeZ, this); break; case VoxelObjectType.ASTEROID: voxelObject = new Asteroid(sizeX, sizeY, sizeZ, this); break; case VoxelObjectType.PLANETOID: voxelObject = new Planetoid(sizeX, sizeY, sizeZ, this); break; } voxelObject.isStatic = isStatic; voxelObject.setName(gameObject.name); if (seedFromName == false) { voxelObject.setRandomSeed(voxelObject.getGUID().GetHashCode()); } chunkObjects = new GameObject[sizeX, sizeY, sizeZ]; chunkComponents = new ChunkComponent[sizeX, sizeY, sizeZ]; pivotPoint = new Vector3(sizeX * Constants.CHUNK_SIZE, sizeY * Constants.CHUNK_SIZE, sizeZ * Constants.CHUNK_SIZE) * 0.5f; pivotPoint += (Vector3.one * 0.5f); pivotPoint *= -1; for (int x = 0; x < sizeX; x++) { for (int z = 0; z < sizeZ; z++) { for (int y = sizeY - 1; y >= 0; y--) { ChunkComponent chunkComponent = new ChunkComponent(); chunkComponent.transform = this.transform; chunkComponent.position = new Coord3D(x, y, z, voxelObject); chunkComponent.voxelComponent = this; chunkComponents[x, y, z] = chunkComponent; ChunkLoader.instance.Queue(chunkComponent); } } } reinitialize = false; initialized = true; return(this); }