//For Chunk Selector public void SetSelectedChunk(Vector3 Position, Vector3 RayDirection) { CollisionResults Collision = ChunkSelectorQuad.CollideWith(Position, RayDirection); if (Collision == null) { return; } if (MasteryFile != null && Collision.GetClosest() != null) { float ChunkSize = MasteryFile.Settings.ChunkSize; SelectedChunkX = (int)Math.Floor(Collision.GetClosest().CollisionPoint.X / ChunkSize); SelectedChunkY = (int)Math.Floor(Collision.GetClosest().CollisionPoint.Y / ChunkSize); SelectedChunkX = SelectedChunkX >= 0 ? SelectedChunkX : 0; SelectedChunkY = SelectedChunkY >= 0 ? SelectedChunkY : 0; Vector3 ChunkPosition = new Vector3(SelectedChunkX * ChunkSize, SelectedChunkY * ChunkSize, 0); WorldFileGrid.SetPosition(Render.Graphics, ChunkPosition); ChunkSelectorQuad.SetPosition(ChunkPosition); //change CurrentWordFile CurrentWorldFile = null; if (MasteryFile.HasWorldFile(SelectedChunkX, SelectedChunkY)) { CurrentWorldFile = MasteryFile.GetWorldFile(SelectedChunkX, SelectedChunkY, 0); } } }
//Updates data for public void MoveToChunk(int PX, int PY) { //if contains Worldfile SelectedChunkX = PX >= 0 ? PX : 0; SelectedChunkY = PY >= 0 ? PY : 0; float ChunkSize = MasteryFile.Settings.ChunkSize; Vector3 ChunkPosition = new Vector3(SelectedChunkX * ChunkSize, SelectedChunkY * ChunkSize, 0); WorldFileGrid.SetPosition(Render.Graphics, ChunkPosition); ChunkSelectorQuad.SetPosition(ChunkPosition); //change CurrentWordFile CurrentWorldFile = null; if (MasteryFile.HasWorldFile(SelectedChunkX, SelectedChunkY)) { CurrentWorldFile = MasteryFile.GetWorldFile(SelectedChunkX, SelectedChunkY, 0); } }