Create Skills Component

This commit is contained in:
Timothy Warren 2022-01-03 15:24:38 -05:00
parent 5a4d8bc234
commit 29b7f18cd8
3 changed files with 19 additions and 1 deletions

View File

@ -1,4 +1,5 @@
use crate::gamesystem::attr_bonus;
use std::collections::HashMap;
use ::rltk::{Point, RGB};
use ::serde::{Deserialize, Serialize};
use ::specs::error::NoError;
@ -6,6 +7,8 @@ use ::specs::prelude::*;
use ::specs::saveload::{ConvertSaveload, Marker};
use ::specs_derive::*;
use crate::gamesystem::attr_bonus;
#[derive(Component, ConvertSaveload, Default, Copy, Clone)]
pub struct Position {
pub x: i32,
@ -274,6 +277,18 @@ pub struct Attributes {
pub intelligence: Attribute,
}
#[derive(Debug, Serialize, Deserialize, Clone, Eq, PartialEq, Hash)]
pub enum Skill {
Melee,
Defense,
Magic,
}
#[derive(Component, Debug, Serialize, Deserialize, Clone)]
pub struct Skills {
pub skills: HashMap<Skill, i32>,
}
// Serialization helper code. We need to implement ConvertSaveLoad for each type that contains an
// Entity.

View File

@ -543,6 +543,7 @@ fn main() -> ::rltk::BError {
Vendor,
Quips,
Attributes,
Skills,
);
gs.ecs.insert(SimpleMarkerAllocator::<SerializeMe>::new());

View File

@ -93,6 +93,7 @@ pub fn save_game(ecs: &mut World) {
Vendor,
Quips,
Attributes,
Skills,
);
}
@ -188,6 +189,7 @@ pub fn load_game(ecs: &mut World) {
Vendor,
Quips,
Attributes,
Skills,
);
}