From 62107a20d88b35fc1f1c0f79657076e741ff5a6f Mon Sep 17 00:00:00 2001 From: Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> Date: Mon, 17 Apr 2023 19:51:02 +0200 Subject: [PATCH] delete --- src/app.rs | 34 ++++----- src/bitmanip.rs | 20 ----- src/cmdline.rs | 31 +------- src/command.rs | 13 +--- src/debug.rs | 20 ++--- src/game.rs | 39 ++++------ src/graphics.rs | 26 ++----- src/input.rs | 22 +++--- src/inventory.rs | 58 +++----------- src/main.rs | 14 +--- src/math.rs | 58 ++++++-------- src/player.rs | 19 ++--- src/res.rs | 12 +-- src/stringfmt.rs | 2 +- src/texture_atlas.rs | 23 ++---- src/tiles.rs | 5 ++ src/tiles/tiledb_edit_ui.rs | 38 +--------- src/world.rs | 125 ++++++------------------------- src/world/reg_chunk_existence.rs | 16 +--- src/world/serialization.rs | 10 --- src/worldgen.rs | 12 +-- 21 files changed, 138 insertions(+), 459 deletions(-) diff --git a/src/app.rs b/src/app.rs index 896f660..ca30538 100644 --- a/src/app.rs +++ b/src/app.rs @@ -22,28 +22,27 @@ use crate::{ res::Res, tiles::TileId, CliArgs, }; /// Application level state (includes game and ui state, etc.) -pub struct App { - pub rw: RenderWindow, - pub should_quit: bool, - pub game: GameState, - pub res: Res, - pub sf_egui: SfEgui, - pub input: Input, - pub debug: DebugState, +pub(crate) struct App { + pub(crate) rw: RenderWindow, + pub(crate) should_quit: bool, + pub(crate) game: GameState, + pub(crate) res: Res, + pub(crate) sf_egui: SfEgui, + pub(crate) input: Input, + pub(crate) debug: DebugState, /// Integer scale for rendering the game - pub scale: u8, + pub(crate) scale: u8, /// RenderTexture for rendering the game at its native resolution - pub rt: RenderTexture, + pub(crate) rt: RenderTexture, /// Light map overlay, blended together with the non-lighted version of the scene - pub light_map: RenderTexture, - pub project_dirs: ProjectDirs, - pub cmdvec: CmdVec, + pub(crate) light_map: RenderTexture, + pub(crate) cmdvec: CmdVec, } impl App { - pub fn new(args: CliArgs) -> anyhow::Result { + pub(crate) fn new(args: CliArgs) -> anyhow::Result { loop {} } - pub fn do_game_loop(&mut self) { + pub(crate) fn do_game_loop(&mut self) { while !self.should_quit { self.do_event_handling(); self.do_update(); @@ -122,11 +121,6 @@ impl App { loop {} } } -/// Tile collision entity for doing physics -struct TileColEn { - col: s2dc::Entity, - platform: bool, -} fn viewport_center_offset(rw_size: Vector2u, rt_size: Vector2u, scale: u8) -> ScreenVec { loop {} } diff --git a/src/bitmanip.rs b/src/bitmanip.rs index 49e7098..a9fa62f 100644 --- a/src/bitmanip.rs +++ b/src/bitmanip.rs @@ -1,22 +1,2 @@ use std::ops::{BitAndAssign, BitOrAssign}; use num_traits::PrimInt; -pub fn nth_bit_set(number: N, n: usize) -> bool { - loop {} -} -pub fn set_nth_bit( - number: &mut N, - n: usize, - set: bool, -) { - loop {} -} -#[test] -#[allow(clippy::bool_assert_comparison)] -fn test_nth_bit_set() { - loop {} -} -#[test] -#[allow(clippy::bool_assert_comparison)] -fn test_set_nth_bit() { - loop {} -} diff --git a/src/cmdline.rs b/src/cmdline.rs index 08c9c7b..a414cbc 100644 --- a/src/cmdline.rs +++ b/src/cmdline.rs @@ -1,7 +1,7 @@ use clap::Parser; use crate::{command::Cmd, math::WorldPos}; #[derive(Parser)] -pub enum CmdLine { +pub(crate) enum CmdLine { Quit, Freecam, Clear, @@ -10,31 +10,6 @@ pub enum CmdLine { Give(Give), } #[derive(Parser)] -pub struct Tp { - x: u32, - y: u32, - /// Relative to current position - #[arg(short, long)] - rel: bool, -} -impl Tp { - fn to_world_pos(&self) -> WorldPos { - loop {} - } -} +pub(crate) struct Tp {} #[derive(Parser)] -pub struct Give { - name: String, -} -pub enum Dispatch { - Cmd(Cmd), - ClearConsole, -} -impl CmdLine { - pub fn parse_cmdline(cmdline: &str) -> anyhow::Result { - loop {} - } - pub(crate) fn dispatch(self) -> Dispatch { - loop {} - } -} +pub(crate) struct Give {} diff --git a/src/command.rs b/src/command.rs index 569eafd..8c91a23 100644 --- a/src/command.rs +++ b/src/command.rs @@ -1,16 +1,11 @@ use crate::math::WorldPos; - /// A command that can change application or game state -pub enum Cmd { +pub(crate) enum Cmd { /// Quit the application QuitApp, ToggleFreecam, - TeleportPlayer { - pos: WorldPos, - relative: bool, - }, + TeleportPlayer {}, TeleportPlayerSpawn, - GiveItemByName(String), + GiveItemByName(), } - -pub type CmdVec = Vec; +pub(crate) type CmdVec = Vec; diff --git a/src/debug.rs b/src/debug.rs index 3cc5023..5323b07 100644 --- a/src/debug.rs +++ b/src/debug.rs @@ -9,20 +9,16 @@ use crate::{ tiles::tiledb_edit_ui::TileDbEdit, }; #[derive(Default, Debug, Inspect)] -pub struct DebugState { - pub panel: bool, - pub freecam: bool, - pub tiledb_edit: TileDbEdit, - pub show_atlas: bool, - pub console: Console, +pub(crate) struct DebugState { + pub(crate) panel: bool, + pub(crate) freecam: bool, + pub(crate) tiledb_edit: TileDbEdit, + pub(crate) show_atlas: bool, + pub(crate) console: Console, } #[derive(Default, Debug, Inspect)] -pub struct Console { - pub show: bool, - pub cmdline: String, - pub log: String, - pub just_opened: bool, - pub history: Vec, +pub(crate) struct Console { + pub(crate) show: bool, } fn debug_panel_ui( mut debug: &mut DebugState, diff --git a/src/game.rs b/src/game.rs index 16a145f..8ec8e75 100644 --- a/src/game.rs +++ b/src/game.rs @@ -18,43 +18,32 @@ use crate::{ }; #[derive(Derivative, Inspect)] #[derivative(Debug)] -pub struct GameState { - pub camera_offset: WorldPos, - pub world: World, - pub gravity: f32, - pub current_biome: Biome, - pub prev_biome: Biome, - #[derivative(Debug = "ignore")] - #[opaque] - pub worldgen: Worldgen, - pub ambient_light: u8, - pub light_sources: Vec, - pub tile_db: TileDb, - pub inventory: Inventory, - pub itemdb: ItemDb, - pub selected_inv_slot: usize, - pub spawn_point: WorldPos, -} -#[derive(Debug, Inspect)] -pub struct LightSource { - pub pos: ScreenVec, +pub(crate) struct GameState { + pub(crate) camera_offset: WorldPos, + pub(crate) world: World, + pub(crate) tile_db: TileDb, } #[derive(PartialEq, Eq, Clone, Copy, Debug, Inspect)] -pub enum Biome { +pub(crate) enum Biome { Surface, Underground, } impl GameState { - pub fn update(&mut self, input: &Input) { + pub(crate) fn update(&mut self, input: &Input) { loop {} } pub(crate) fn draw_world(&mut self, rt: &mut RenderTexture, res: &mut Res) { loop {} } - pub fn draw_entities(&mut self, rt: &mut RenderTexture) { + pub(crate) fn draw_entities(&mut self, rt: &mut RenderTexture) { loop {} } - pub fn draw_ui(&mut self, rt: &mut RenderTexture, res: &Res, ui_dims: Vector2f) { + pub(crate) fn draw_ui( + &mut self, + rt: &mut RenderTexture, + res: &Res, + ui_dims: Vector2f, + ) { loop {} } pub(crate) fn light_pass(&mut self, lightmap: &mut RenderTexture, res: &Res) { @@ -64,7 +53,7 @@ impl GameState { loop {} } } -pub fn for_each_tile_on_screen( +pub(crate) fn for_each_tile_on_screen( camera_offset: WorldPos, rt_size: Vector2u, mut f: impl FnMut(TilePos, ScreenVec), diff --git a/src/graphics.rs b/src/graphics.rs index da4c300..f05c4a9 100644 --- a/src/graphics.rs +++ b/src/graphics.rs @@ -5,29 +5,15 @@ use sfml::{ }; use sfml_xt::graphics::RenderWindowExt; use crate::math::FPS_TARGET; -pub struct ScreenRes { - pub w: u16, - pub h: u16, -} -impl ScreenRes { - fn to_sf(&self) -> VideoMode { - loop {} - } +pub(crate) struct ScreenRes { + pub(crate) w: u16, + pub(crate) h: u16, } #[derive(Default, Clone, Copy, Debug, Inspect, Serialize, Deserialize)] pub struct ScreenVec { - pub x: ScreenSc, - pub y: ScreenSc, + pub(crate) x: ScreenSc, + pub(crate) y: ScreenSc, } /// Screen position/offset scalar /// We assume this game won't be played above 32767*32767 resolution -pub type ScreenSc = i16; -impl ScreenVec { - pub fn to_sf_vec(self) -> Vector2f { - loop {} - } -} -const DEFAULT_RES: ScreenRes = ScreenRes { w: 960, h: 540 }; -pub fn make_window() -> RenderWindow { - loop {} -} +pub(crate) type ScreenSc = i16; diff --git a/src/input.rs b/src/input.rs index 14856a0..eeb27dc 100644 --- a/src/input.rs +++ b/src/input.rs @@ -2,26 +2,24 @@ use fnv::FnvHashSet; use sfml::window::{mouse, Event, Key}; use crate::graphics::ScreenVec; #[derive(Default, Debug)] -pub struct Input { - down: FnvHashSet, - pressed: FnvHashSet, - pub lmb_down: bool, - pub rmb_down: bool, - pub mouse_down_loc: ScreenVec, - pub mid_pressed: bool, -} +pub(crate) struct Input {} impl Input { - pub fn update_from_event(&mut self, ev: &Event, egui_kbd: bool, egui_ptr: bool) { + pub(crate) fn update_from_event( + &mut self, + ev: &Event, + egui_kbd: bool, + egui_ptr: bool, + ) { loop {} } /// Pressed event should be cleared every frame - pub fn clear_pressed(&mut self) { + pub(crate) fn clear_pressed(&mut self) { loop {} } - pub fn down(&self, key: Key) -> bool { + pub(crate) fn down(&self, key: Key) -> bool { loop {} } - pub fn pressed(&self, key: Key) -> bool { + pub(crate) fn pressed(&self, key: Key) -> bool { loop {} } } diff --git a/src/inventory.rs b/src/inventory.rs index c62cf5b..07cbe09 100644 --- a/src/inventory.rs +++ b/src/inventory.rs @@ -1,62 +1,24 @@ use egui_inspect::derive::Inspect; use crate::{math::IntRect, tiles::{BgTileId, FgTileId, MidTileId}}; /// We won't have more than 65535 different items -pub type ItemId = u16; -/// We won't have more than 65535 item quantity in a single slot -pub type ItemQty = u16; +pub(crate) type ItemId = u16; /// Inventory slot #[derive(Debug, Inspect)] -pub struct Slot { - pub id: ItemId, - pub qty: ItemQty, -} +pub(crate) struct Slot {} #[derive(Debug, Inspect)] -pub struct Inventory { - pub slots: Vec, -} -impl Inventory { - /// A new inventory filled with some debug items - pub(crate) fn new_debug() -> Inventory { - loop {} - } -} -#[derive(Debug, Inspect)] -pub struct ItemDef { - pub name: String, - pub graphic_name: String, - pub tex_rect: IntRect, - #[opaque] - pub use_action: UseAction, - pub consumable: bool, -} +pub(crate) struct Inventory {} #[derive(Debug, Inspect, PartialEq)] -pub enum TileLayer { +pub(crate) enum TileLayer { Bg, Mid, Fg, } #[derive(Debug)] -pub enum UseAction { - PlaceBgTile { id: BgTileId }, - PlaceMidTile { id: MidTileId }, - PlaceFgTile { id: FgTileId }, - RemoveTile { layer: TileLayer }, +pub(crate) enum UseAction { + PlaceBgTile {}, + PlaceMidTile {}, + PlaceFgTile {}, + RemoveTile {}, } #[derive(Debug, Inspect)] -pub struct ItemDb { - pub db: Vec, -} -impl Default for ItemDb { - fn default() -> Self { - loop {} - } -} -pub mod items { - use super::ItemId; - pub const DIRT_BLOCK: ItemId = 0; - pub const TORCH: ItemId = 1; - pub const PLATFORM: ItemId = 2; - pub const WOOD_PICK: ItemId = 3; - pub const PANZERIUM: ItemId = 4; - pub const STONE_WALL: ItemId = 5; -} +pub(crate) struct ItemDb {} diff --git a/src/main.rs b/src/main.rs index c9f45fa..6b1c5a3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,4 @@ mod app; -mod bitmanip; mod cmdline; mod command; mod debug; @@ -15,16 +14,10 @@ mod texture_atlas; mod tiles; mod world; mod worldgen; - use app::App; use clap::Parser; - #[derive(Parser)] -pub struct CliArgs { - #[arg(default_value = "TestWorld")] - world_name: String, -} - +pub(crate) struct CliArgs {} fn try_main() -> anyhow::Result<()> { gamedebug_core::set_enabled(true); let cli_args = CliArgs::parse(); @@ -32,11 +25,8 @@ fn try_main() -> anyhow::Result<()> { app.do_game_loop(); Ok(()) } - fn main() { - env_logger::builder() - .filter_level(log::LevelFilter::Info) - .init(); + env_logger::builder().filter_level(log::LevelFilter::Info).init(); if let Err(e) = try_main() { rfd::MessageDialog::new() .set_title("Fatal error") diff --git a/src/math.rs b/src/math.rs index 68e4f05..605f454 100644 --- a/src/math.rs +++ b/src/math.rs @@ -3,37 +3,34 @@ use egui_inspect::derive::Inspect; use num_traits::{Num, Signed}; use serde::{Deserialize, Serialize}; use crate::world::{TPosSc, TilePos}; -pub type WPosSc = u32; +pub(crate) type WPosSc = u32; #[derive(Clone, Copy, Debug, Inspect)] -pub struct WorldPos { - pub x: WPosSc, - pub y: WPosSc, +pub(crate) struct WorldPos { + pub(crate) x: WPosSc, + pub(crate) y: WPosSc, } /// Tile size in pixels -pub const TILE_SIZE: u8 = 32; +pub(crate) const TILE_SIZE: u8 = 32; /// Pixels per meter. -pub const PX_PER_M: f32 = TILE_SIZE as f32 * 2.; +pub(crate) const PX_PER_M: f32 = TILE_SIZE as f32 * 2.; /// Meters per pixel -pub const M_PER_PX: f32 = 1. / PX_PER_M; -pub const FPS_TARGET: u8 = 60; -pub fn px_per_frame_to_m_per_s(px_per_frame: f32) -> f32 { - loop {} -} -pub fn px_per_frame_to_km_h(px_per_frame: f32) -> f32 { +pub(crate) const M_PER_PX: f32 = 1. / PX_PER_M; +pub(crate) const FPS_TARGET: u8 = 60; +pub(crate) fn px_per_frame_to_km_h(px_per_frame: f32) -> f32 { loop {} } /// World extent in tiles. Roughly 50km*50km. -pub const WORLD_EXTENT: TPosSc = 100_000; +pub(crate) const WORLD_EXTENT: TPosSc = 100_000; impl WorldPos { - pub fn tile_pos(&self) -> TilePos { + pub(crate) fn tile_pos(&self) -> TilePos { loop {} } /// Horizontal center of the world - pub const CENTER: WPosSc = (WORLD_EXTENT / 2) * TILE_SIZE as WPosSc; + pub(crate) const CENTER: WPosSc = (WORLD_EXTENT / 2) * TILE_SIZE as WPosSc; /// Vertical surface level. /// You can build 10 km high. - pub const SURFACE: WPosSc = 20_000 * TILE_SIZE as WPosSc; - pub const SURFACE_CENTER: Self = Self { + pub(crate) const SURFACE: WPosSc = 20_000 * TILE_SIZE as WPosSc; + pub(crate) const SURFACE_CENTER: Self = Self { x: Self::CENTER, y: Self::SURFACE, }; @@ -41,33 +38,20 @@ impl WorldPos { loop {} } } -pub fn wp_to_tp(wp: WPosSc) -> TPosSc { +pub(crate) fn wp_to_tp(wp: WPosSc) -> TPosSc { loop {} } -pub fn center_offset + Copy + Signed>(xw: N, yw: N) -> N { +pub(crate) fn center_offset + Copy + Signed>(xw: N, yw: N) -> N { loop {} } /// A smooth triangle-wave like transform of the input value, oscillating between 0 and the ceiling. -pub fn smoothwave + PartialOrd + Copy>(input: T, max: T) -> T { +pub(crate) fn smoothwave + PartialOrd + Copy>(input: T, max: T) -> T { loop {} } #[derive(Serialize, Deserialize, Debug, Inspect, Default, Clone, Copy)] pub struct IntRect { - pub x: i32, - pub y: i32, - pub w: i32, - pub h: i32, -} -impl IntRect { - pub(crate) fn to_sf(self) -> sfml::graphics::Rect { - loop {} - } -} -#[test] -fn test_smooth_wave() { - loop {} -} -#[test] -fn test_wp_to_tp() { - loop {} + pub(crate) x: i32, + pub(crate) y: i32, + pub(crate) w: i32, + pub(crate) h: i32, } diff --git a/src/player.rs b/src/player.rs index 3d6ccf0..6742ca8 100644 --- a/src/player.rs +++ b/src/player.rs @@ -7,30 +7,27 @@ use crate::{ world::{TPosSc, TilePos}, }; #[derive(Debug, Inspect, Serialize, Deserialize)] -pub struct Player { +pub(crate) struct Player { #[inspect_with(inspect_mobile_entity)] - pub col_en: MobileEntity, - pub vspeed: f32, - pub hspeed: f32, - pub jumps_left: u8, - /// true if the player wants to jump down from a platform - pub down_intent: bool, + pub(crate) col_en: MobileEntity, + pub(crate) vspeed: f32, + pub(crate) hspeed: f32, } fn inspect_mobile_entity(en: &mut MobileEntity, ui: &mut egui::Ui, _id_src: u64) { loop {} } impl Player { - pub fn new_at(pos: WorldPos) -> Self { + pub(crate) fn new_at(pos: WorldPos) -> Self { loop {} } #[allow(dead_code)] - pub fn center_tp(&self) -> TilePos { + pub(crate) fn center_tp(&self) -> TilePos { loop {} } - pub fn can_jump(&self) -> bool { + pub(crate) fn can_jump(&self) -> bool { loop {} } - pub fn feet_y(&self) -> i32 { + pub(crate) fn feet_y(&self) -> i32 { loop {} } pub(crate) fn save(&self, path: &Path) { diff --git a/src/res.rs b/src/res.rs index 4fb8439..df982cc 100644 --- a/src/res.rs +++ b/src/res.rs @@ -1,13 +1,7 @@ use sfml::audio::Music; use crate::texture_atlas::AtlasBundle; #[derive(Debug)] -pub struct Res { - pub atlas: AtlasBundle, - pub surf_music: Music<'static>, - pub und_music: Music<'static>, -} -impl Res { - pub fn load() -> anyhow::Result { - loop {} - } +pub(crate) struct Res { + pub(crate) atlas: AtlasBundle, + pub(crate) surf_music: Music<'static>, } diff --git a/src/stringfmt.rs b/src/stringfmt.rs index 897d837..a1c1c32 100644 --- a/src/stringfmt.rs +++ b/src/stringfmt.rs @@ -1,6 +1,6 @@ use std::fmt; use crate::math::M_PER_PX; -pub struct LengthDisp(pub f32); +pub(crate) struct LengthDisp(pub f32); impl fmt::Display for LengthDisp { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { loop {} diff --git a/src/texture_atlas.rs b/src/texture_atlas.rs index e1e6580..8bf66a9 100644 --- a/src/texture_atlas.rs +++ b/src/texture_atlas.rs @@ -2,27 +2,14 @@ use std::{collections::HashMap, path::Path}; use crate::math::IntRect; use sfml::{graphics::Texture, SfBox}; use texture_packer::{texture::Texture as _, TexturePacker, TexturePackerConfig}; -pub type RectMap = HashMap; +pub(crate) type RectMap = HashMap; #[derive(Debug)] -pub struct AtlasBundle { - pub tex: SfBox, - pub rects: RectMap, +pub(crate) struct AtlasBundle { + pub(crate) tex: SfBox, + pub(crate) rects: RectMap, } impl AtlasBundle { - pub fn new() -> anyhow::Result { + pub(crate) fn new() -> anyhow::Result { loop {} } } -fn make_pix_buf(packer: &TexturePacker) -> Vec { - loop {} -} -fn path_img_key(path: &Path) -> String { - loop {} -} -#[test] -fn test_path_img_key() { - loop {} -} -fn walk_graphics(mut f: impl FnMut(&Path)) { - loop {} -} diff --git a/src/tiles.rs b/src/tiles.rs index 4b6288e..5e62b95 100644 --- a/src/tiles.rs +++ b/src/tiles.rs @@ -52,6 +52,7 @@ impl Bg { h: 0, }, layer: (), + blend_graphic: String::new(), } } } @@ -76,6 +77,7 @@ impl Mid { h: 32, }), }, + blend_graphic: String::new(), } } } @@ -92,6 +94,7 @@ impl Fg { h: 0, }, layer: (), + blend_graphic: String::new(), } } } @@ -145,6 +148,7 @@ where pub graphic_name: String, pub tex_rect: IntRect, pub layer: Layer::SpecificDef, + pub blend_graphic: String, } #[derive(Debug, Inspect, Default, Serialize, Deserialize)] @@ -179,6 +183,7 @@ where graphic_name: Default::default(), tex_rect: Default::default(), layer: Layer::SpecificDef::default(), + blend_graphic: String::new(), } } } diff --git a/src/tiles/tiledb_edit_ui.rs b/src/tiles/tiledb_edit_ui.rs index d1b2368..f48acd9 100644 --- a/src/tiles/tiledb_edit_ui.rs +++ b/src/tiles/tiledb_edit_ui.rs @@ -5,46 +5,10 @@ use crate::{ math::TILE_SIZE, }; #[derive(Debug, Default, Inspect)] -pub struct TileDbEdit { - open: bool, - #[opaque] - layer: Layer, -} +pub(crate) struct TileDbEdit {} impl TileDbEdit { pub(crate) fn ui(&mut self, ctx: &egui::Context, tile_db: &mut TileDb) { loop {} } } -#[derive(Debug, PartialEq, Eq)] -enum Layer { - Bg, - Fg, - Mid, -} -impl Default for Layer { - fn default() -> Self { - loop {} - } -} use super::{Bg, Fg, Mid, TileDb, TileDef, TileLayer, DEFAULT_TILE_BB}; -trait SpecialUi { - fn special_ui(&mut self, ui: &mut egui::Ui); -} -impl SpecialUi for TileDef { - fn special_ui(&mut self, ui: &mut egui::Ui) { - loop {} - } -} -impl SpecialUi for TileDef { - fn special_ui(&mut self, _ui: &mut egui::Ui) {} -} -impl SpecialUi for TileDef { - fn special_ui(&mut self, _ui: &mut egui::Ui) {} -} -fn db_ui(db: &mut Vec>, ui: &mut egui::Ui) -where - ::SpecificDef: Debug + Default + Inspect, - TileDef: SpecialUi, -{ - loop {} -} diff --git a/src/world.rs b/src/world.rs index 1d35fbc..996f5d7 100644 --- a/src/world.rs +++ b/src/world.rs @@ -9,51 +9,33 @@ use crate::{ world::reg_chunk_existence::ExistenceBitset, worldgen::Worldgen, }; use self::serialization::save_chunk; -pub type ChkPosSc = u16; #[derive(Hash, PartialEq, Eq, Debug, Clone, Copy, Inspect)] -pub struct ChunkPos { - pub x: ChkPosSc, - pub y: ChkPosSc, -} -impl ChunkPos { - /// Returns the region this chunk position belongs to - pub fn region(&self) -> (u8, u8) { - loop {} - } - /// Returns the local position in the region (0-7) - pub fn local(&self) -> (u8, u8) { - loop {} - } -} +pub(crate) struct ChunkPos {} #[derive(Debug, Inspect)] -pub struct World { - /// The currently loaded chunks - chunks: FnvHashMap, - /// This is the number of ticks since the world has started. - /// In other words, the age of the world. - pub ticks: u64, - pub player: Player, - pub name: String, - #[opaque] - pub path: PathBuf, +pub(crate) struct World { + pub(crate) player: Player, } impl World { - pub fn new(spawn_point: WorldPos, name: &str, path: PathBuf) -> Self { + pub(crate) fn new(spawn_point: WorldPos, name: &str, path: PathBuf) -> Self { loop {} } /// Get mutable access to the tile at `pos`. /// /// Loads or generates the containing chunk if necessary. - pub fn tile_at_mut(&mut self, pos: TilePos, worldgen: &Worldgen) -> &mut Tile { + pub(crate) fn tile_at_mut( + &mut self, + pos: TilePos, + worldgen: &Worldgen, + ) -> &mut Tile { loop {} } - pub fn save(&self) { + pub(crate) fn save(&self) { loop {} } - pub fn save_meta(&self) { + pub(crate) fn save_meta(&self) { loop {} } - pub fn save_chunks(&self) { + pub(crate) fn save_chunks(&self) { loop {} } } @@ -71,89 +53,24 @@ fn format_reg_file_name((x, y): (u8, u8)) -> String { } const CHUNK_BYTES: usize = CHUNK_N_TILES * TILE_BYTES; const TILE_BYTES: usize = 3 * 2; -#[derive(Serialize, Deserialize)] -struct WorldMetaSave { - name: String, - ticks: u64, -} #[derive(Debug, Clone, Copy)] -pub struct TilePos { - pub x: TPosSc, - pub y: TPosSc, -} +pub(crate) struct TilePos {} #[derive(Debug, PartialEq, Eq, Clone, Copy)] -pub struct ChunkLocalTilePos { - pub x: ChkLocalTPosSc, - pub y: ChkLocalTPosSc, -} +pub(crate) struct ChunkLocalTilePos {} /// Chunk-local tile position scalar. Supports up to 256 tiles per chunk. type ChkLocalTPosSc = u8; -impl TilePos { - pub fn to_chunk_and_local(self) -> (ChunkPos, ChunkLocalTilePos) { - loop {} - } - pub(crate) fn to_chunk(self) -> ChunkPos { - loop {} - } -} -fn chk_pos(tile: TPosSc) -> ChkPosSc { - loop {} -} -#[test] -fn test_chk_pos() { - loop {} -} -fn chunk_local(global: TPosSc) -> ChkLocalTPosSc { - loop {} -} -#[test] -fn test_chunk_local() { - loop {} -} -#[test] -fn test_to_chunk_and_local() { - loop {} -} -pub type TPosSc = u32; -pub const CHUNK_EXTENT: u16 = 128; +pub(crate) type TPosSc = u32; +pub(crate) const CHUNK_EXTENT: u16 = 128; const CHUNK_N_TILES: usize = CHUNK_EXTENT as usize * CHUNK_EXTENT as usize; type ChunkTiles = [Tile; CHUNK_N_TILES]; fn default_chunk_tiles() -> ChunkTiles { loop {} } #[derive(Debug, Inspect)] -pub struct Chunk { - tiles: ChunkTiles, -} -impl Chunk { - pub fn gen(pos: ChunkPos, worldgen: &Worldgen) -> Self { - loop {} - } - pub fn load_or_gen(chk: ChunkPos, worldgen: &Worldgen, world_path: &Path) -> Chunk { - loop {} - } - fn at_mut(&mut self, local: ChunkLocalTilePos) -> &mut Tile { - loop {} - } -} -fn chunk_exists(reg_path: &Path, pos: ChunkPos) -> bool { - loop {} -} +pub(crate) struct Chunk {} #[derive(Clone, Copy, Debug, Inspect)] -pub struct Tile { - /// Background wall behind entities - pub bg: BgTileId, - /// The solid wall on the same level as entities - pub mid: MidTileId, - /// A layer on top of the mid wall. Usually ores or decorative pieces. - pub fg: FgTileId, -} -pub const REGION_CHUNK_EXTENT: u8 = 8; -pub const REGION_N_CHUNKS: u8 = REGION_CHUNK_EXTENT * REGION_CHUNK_EXTENT; +pub(crate) struct Tile {} +pub(crate) const REGION_CHUNK_EXTENT: u8 = 8; +pub(crate) const REGION_N_CHUNKS: u8 = REGION_CHUNK_EXTENT * REGION_CHUNK_EXTENT; /// This is the uncompressed byte length of a region -pub const REGION_BYTES: usize = REGION_N_CHUNKS as usize * CHUNK_BYTES; -#[allow(clippy::assertions_on_constants)] -const _: () = assert!( - REGION_N_CHUNKS <= 64, - "A region file uses an existence bitset that's a 64 bit integer" -); +pub(crate) const REGION_BYTES: usize = REGION_N_CHUNKS as usize * CHUNK_BYTES; diff --git a/src/world/reg_chunk_existence.rs b/src/world/reg_chunk_existence.rs index 14e5c52..818af4f 100644 --- a/src/world/reg_chunk_existence.rs +++ b/src/world/reg_chunk_existence.rs @@ -1,17 +1,3 @@ use std::{fs::File, io::Read, path::Path}; #[derive(Clone, Copy)] -pub struct ExistenceBitset(pub u64); -impl ExistenceBitset { - pub const EMPTY: Self = Self(0); - pub fn read_from_file(f: &mut File) -> ExistenceBitset { - loop {} - } - pub fn read_from_fs(path: &Path) -> ExistenceBitset { - loop {} - } -} -impl std::fmt::Debug for ExistenceBitset { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - loop {} - } -} +pub(crate) struct ExistenceBitset(pub u64); diff --git a/src/world/serialization.rs b/src/world/serialization.rs index 84b3117..2f6daf5 100644 --- a/src/world/serialization.rs +++ b/src/world/serialization.rs @@ -10,13 +10,3 @@ use super::{default_chunk_tiles, loc_byte_idx_xy, Chunk, ChunkPos}; pub(super) fn save_chunk(pos: &ChunkPos, chk: &Chunk, world_dir: &Path) { loop {} } -const COMP_LEVEL: i32 = 9; -impl Chunk { - pub fn load_from_region(data: &[u8], x: u8, y: u8) -> Self { - loop {} - } -} -#[test] -fn test_chunk_seri() { - loop {} -} diff --git a/src/worldgen.rs b/src/worldgen.rs index 42b0d05..1573e58 100644 --- a/src/worldgen.rs +++ b/src/worldgen.rs @@ -10,14 +10,4 @@ use crate::{ tiles::{BgTileId, FgTileId, MidTileId, TileId}, world::{ChunkPos, Tile as Tl, CHUNK_EXTENT}, }; -pub struct Worldgen { - world: World, -} -impl Worldgen { - pub fn from_seed(seed: i64) -> Self { - loop {} - } - pub fn chunk_noise(&self, pos: ChunkPos) -> Vec> { - loop {} - } -} +pub(crate) struct Worldgen {}