private void HandleDefaultInputs(ChunkManager chunkManager) { if (_lastMouseState == null) { return; } const int leftClickIndex = 0; const int rightClickIndex = 1; if (!_currentKeyboardState.IsPressed(Key.Escape) && _lastKeyboardState.IsPressed(Key.Escape)) { IsPaused = !IsPaused; } if (!_currentKeyboardState.IsPressed(Key.F1) && _lastKeyboardState.IsPressed(Key.F1)) { Game.RenderSolid = !Game.RenderSolid; } if (!_currentKeyboardState.IsPressed(Key.F2) && _lastKeyboardState.IsPressed(Key.F2)) { Game.RenderWater = !Game.RenderWater; } if (!_currentKeyboardState.IsPressed(Key.F3) && _lastKeyboardState.IsPressed(Key.F3)) { Game.RenderSprites = !Game.RenderSprites; } if (!_currentKeyboardState.IsPressed(Key.F4) && _lastKeyboardState.IsPressed(Key.F4)) { Game.RenderBoxes = !Game.RenderBoxes; } if (!_currentKeyboardState.IsPressed(Key.F5) && _lastKeyboardState.IsPressed(Key.F5)) { Game.ShowChunkBoundingBoxes = !Game.ShowChunkBoundingBoxes; } if (!_currentKeyboardState.IsPressed(Key.F6) && _lastKeyboardState.IsPressed(Key.F6)) { Game.RenderSky = !Game.RenderSky; } if (!_currentKeyboardState.IsPressed(Key.F7) && _lastKeyboardState.IsPressed(Key.F7)) { Game.ShowPipelineVisualization = !Game.ShowPipelineVisualization; } if (!_currentKeyboardState.IsPressed(Key.F12) && _lastKeyboardState.IsPressed(Key.F12)) { Game.Debug = !Game.Debug; } var delta = _currentMouseState.Z / 120; if (delta != 0) { _voxelDefinitionIndexInHand += delta; if (_voxelDefinitionIndexInHand < 0) { _voxelDefinitionIndexInHand = VoxelDefinition.RegisteredDefinitions.Count - 1; } else { _voxelDefinitionIndexInHand %= VoxelDefinition.RegisteredDefinitions.Count; } VoxelInHand = VoxelDefinition.DefinitionByType[VoxelDefinition.RegisteredDefinitions[_voxelDefinitionIndexInHand]]; } if (DateTime.Now - _lastModification > BuildCooldown) { if (_currentMouseState.Buttons[leftClickIndex]) { if (CurrentCursor != null) { _lastModification = DateTime.Now; chunkManager.SetBlock(CurrentCursor.AbsoluteVoxelIndex, 0); } } if (_currentMouseState.Buttons[rightClickIndex]) { if (CurrentCursor != null) { chunkManager.TryGetVoxel(CurrentCursor.AbsoluteVoxelIndex, out var directTargetVoxel); var targetBlock = directTargetVoxel.GetDefinition().IsSprite ? CurrentCursor.AbsoluteVoxelIndex : CurrentCursor.AbsoluteVoxelIndex + CurrentCursor.Direction; var hasPositionConflict = false; var min = (WorldSettings.PlayerMin + Position).Round(); var max = (WorldSettings.PlayerMax + Position).Round(); for (var i = min.X; i <= max.X && !hasPositionConflict; i++) { for (var j = min.Y; j <= max.Y && !hasPositionConflict; j++) { for (var k = min.Z; k <= max.Z && !hasPositionConflict; k++) { hasPositionConflict = targetBlock == new Int3(i, j, k); } } } if (!hasPositionConflict) { _lastModification = DateTime.Now; chunkManager.SetBlock(targetBlock, VoxelInHand.Type); } } } } }