Update docs

This commit is contained in:
Timothy Warren 2022-02-01 15:41:08 -05:00
parent 83cab40c13
commit dedbb0927c
11 changed files with 19 additions and 3 deletions

View File

@ -25,7 +25,9 @@ pub struct Position {
impl From<(i32, i32)> for Position {
fn from(f: (i32, i32)) -> Self {
Position { x: f.0, y: f.1 }
let (x, y) = f;
Position { x, y }
}
}

View File

@ -1,3 +1,4 @@
//! The effects system
mod damage;
mod hunger;
mod movement;

View File

@ -1,3 +1,4 @@
//! Miscellaneous common functions
use crate::{Skill, Skills};
pub fn attr_bonus(value: i32) -> i32 {

View File

@ -1,3 +1,4 @@
//! Interface-building output
mod enums;
mod menu;
mod tooltip;

View File

@ -1,3 +1,4 @@
//! Procedurally generated map builders
mod area_ending_point;
mod area_starting_points;
mod bsp_dungeon;

View File

@ -1,3 +1,4 @@
//! Player-related functionality
use std::cmp::{max, min};
use rltk::{DistanceAlg, Point, RandomNumberGenerator, Rltk, VirtualKeyCode};

View File

@ -1,3 +1,4 @@
//! Weighted random generation of entities
use ::rltk::RandomNumberGenerator;
use crate::raws::{spawn_type_by_name, RawMaster, SpawnTableType};

View File

@ -1,3 +1,4 @@
//! Generates entities based on spec files
mod faction_structs;
mod item_structs;
mod loot_structs;

View File

@ -1,3 +1,4 @@
//! Serializes / Deserializes game data for saving and loading
use std::fs::{self, File};
use std::path::Path;
@ -29,6 +30,7 @@ macro_rules! serialize_individually {
#[cfg(target_arch = "wasm32")]
pub fn save_game(_ecs: &mut World) {}
/// Saves the game data to a file
#[cfg(not(target_arch = "wasm32"))]
pub fn save_game(ecs: &mut World) {
// Create helper
@ -152,6 +154,7 @@ pub fn save_game(ecs: &mut World) {
.expect("Failed to clean up savehelper2 component");
}
/// Does the save game exist?
pub fn does_save_exist() -> bool {
Path::new("./savegame.json").exists()
}
@ -171,6 +174,7 @@ macro_rules! deserialize_individually {
};
}
/// Loads the game data from a file
pub fn load_game(ecs: &mut World) {
{
// Delete everything
@ -319,6 +323,7 @@ pub fn load_game(ecs: &mut World) {
.expect("Unable to delete helper2 entity");
}
/// Deletes the save file, if it exists
pub fn delete_save() {
if Path::new("./savegame.json").exists() {
std::fs::remove_file("./savegame.json").expect("Failed to delete save file.");

View File

@ -1,3 +1,4 @@
//! Spawns things
use std::collections::HashMap;
use ::rltk::{Point, RandomNumberGenerator};

View File

@ -1,4 +1,4 @@
//!
//! Game state
use ::rltk::{GameState, Point, Rltk};
use ::specs::prelude::*;
@ -59,6 +59,7 @@ pub enum RunState {
ShowIdentify,
}
/// The main wrapper around the game's state
pub struct State {
pub ecs: World,
mapgen_next_state: Option<RunState>,