// Note: now this function is invoked to attack building public void AlterVoxelInChunk(int vx, int vy, int vz, VFVoxel voxel, bool writeType, bool writeVolume) { if (!AttackVoxel(vx, vy, vz, voxel.Volume)) { return; } //Instantiate effect int index = UnityEngine.Random.Range(1, 3); string path = "Prefab/Particle/FX_voxel_block_collapsing_0" + index; GameObject particleResources = Resources.Load(path) as GameObject; if (particleResources != null) { GameObject particle = GameObject.Instantiate(particleResources, new Vector3(vx, vy, vz), Quaternion.identity) as GameObject; GameObject.Destroy(particle, 2.5f); } int n = Voxels.DirtyChunkList.Count; for (int i = 0; i < n; i++) { SaveLoad.AddChunkToSaveList(Voxels.DirtyChunkList[i]); } }
// Note: now this function is invoked to mod/dig terrain public void AlterVoxelInBuild(int vx, int vy, int vz, VFVoxel voxel) { Voxels.SafeWrite(vx, vy, vz, voxel); int n = Voxels.DirtyChunkList.Count; for (int i = 0; i < n; i++) { SaveLoad.AddChunkToSaveList(Voxels.DirtyChunkList[i]); } }