Update docs
This commit is contained in:
parent
83cab40c13
commit
dedbb0927c
@ -25,7 +25,9 @@ pub struct Position {
|
|||||||
|
|
||||||
impl From<(i32, i32)> for Position {
|
impl From<(i32, i32)> for Position {
|
||||||
fn from(f: (i32, i32)) -> Self {
|
fn from(f: (i32, i32)) -> Self {
|
||||||
Position { x: f.0, y: f.1 }
|
let (x, y) = f;
|
||||||
|
|
||||||
|
Position { x, y }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
//! The effects system
|
||||||
mod damage;
|
mod damage;
|
||||||
mod hunger;
|
mod hunger;
|
||||||
mod movement;
|
mod movement;
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
//! Miscellaneous common functions
|
||||||
use crate::{Skill, Skills};
|
use crate::{Skill, Skills};
|
||||||
|
|
||||||
pub fn attr_bonus(value: i32) -> i32 {
|
pub fn attr_bonus(value: i32) -> i32 {
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
//! Interface-building output
|
||||||
mod enums;
|
mod enums;
|
||||||
mod menu;
|
mod menu;
|
||||||
mod tooltip;
|
mod tooltip;
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
//! Procedurally generated map builders
|
||||||
mod area_ending_point;
|
mod area_ending_point;
|
||||||
mod area_starting_points;
|
mod area_starting_points;
|
||||||
mod bsp_dungeon;
|
mod bsp_dungeon;
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
//! Player-related functionality
|
||||||
use std::cmp::{max, min};
|
use std::cmp::{max, min};
|
||||||
|
|
||||||
use rltk::{DistanceAlg, Point, RandomNumberGenerator, Rltk, VirtualKeyCode};
|
use rltk::{DistanceAlg, Point, RandomNumberGenerator, Rltk, VirtualKeyCode};
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
//! Weighted random generation of entities
|
||||||
use ::rltk::RandomNumberGenerator;
|
use ::rltk::RandomNumberGenerator;
|
||||||
|
|
||||||
use crate::raws::{spawn_type_by_name, RawMaster, SpawnTableType};
|
use crate::raws::{spawn_type_by_name, RawMaster, SpawnTableType};
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
//! Generates entities based on spec files
|
||||||
mod faction_structs;
|
mod faction_structs;
|
||||||
mod item_structs;
|
mod item_structs;
|
||||||
mod loot_structs;
|
mod loot_structs;
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
//! Serializes / Deserializes game data for saving and loading
|
||||||
use std::fs::{self, File};
|
use std::fs::{self, File};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
@ -29,6 +30,7 @@ macro_rules! serialize_individually {
|
|||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_arch = "wasm32")]
|
||||||
pub fn save_game(_ecs: &mut World) {}
|
pub fn save_game(_ecs: &mut World) {}
|
||||||
|
|
||||||
|
/// Saves the game data to a file
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
pub fn save_game(ecs: &mut World) {
|
pub fn save_game(ecs: &mut World) {
|
||||||
// Create helper
|
// Create helper
|
||||||
@ -152,6 +154,7 @@ pub fn save_game(ecs: &mut World) {
|
|||||||
.expect("Failed to clean up savehelper2 component");
|
.expect("Failed to clean up savehelper2 component");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Does the save game exist?
|
||||||
pub fn does_save_exist() -> bool {
|
pub fn does_save_exist() -> bool {
|
||||||
Path::new("./savegame.json").exists()
|
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) {
|
pub fn load_game(ecs: &mut World) {
|
||||||
{
|
{
|
||||||
// Delete everything
|
// Delete everything
|
||||||
@ -319,6 +323,7 @@ pub fn load_game(ecs: &mut World) {
|
|||||||
.expect("Unable to delete helper2 entity");
|
.expect("Unable to delete helper2 entity");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Deletes the save file, if it exists
|
||||||
pub fn delete_save() {
|
pub fn delete_save() {
|
||||||
if Path::new("./savegame.json").exists() {
|
if Path::new("./savegame.json").exists() {
|
||||||
std::fs::remove_file("./savegame.json").expect("Failed to delete save file.");
|
std::fs::remove_file("./savegame.json").expect("Failed to delete save file.");
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
//! Spawns things
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use ::rltk::{Point, RandomNumberGenerator};
|
use ::rltk::{Point, RandomNumberGenerator};
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
//!
|
//! Game state
|
||||||
use ::rltk::{GameState, Point, Rltk};
|
use ::rltk::{GameState, Point, Rltk};
|
||||||
use ::specs::prelude::*;
|
use ::specs::prelude::*;
|
||||||
|
|
||||||
@ -59,6 +59,7 @@ pub enum RunState {
|
|||||||
ShowIdentify,
|
ShowIdentify,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The main wrapper around the game's state
|
||||||
pub struct State {
|
pub struct State {
|
||||||
pub ecs: World,
|
pub ecs: World,
|
||||||
mapgen_next_state: Option<RunState>,
|
mapgen_next_state: Option<RunState>,
|
||||||
|
Loading…
Reference in New Issue
Block a user