From 29b7f18cd835224e4eab310c9aac172efad77dcd Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 3 Jan 2022 15:24:38 -0500 Subject: [PATCH] Create Skills Component --- src/components.rs | 17 ++++++++++++++++- src/main.rs | 1 + src/saveload_system.rs | 2 ++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/components.rs b/src/components.rs index 9bf44de..38a1ac4 100644 --- a/src/components.rs +++ b/src/components.rs @@ -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, +} + // Serialization helper code. We need to implement ConvertSaveLoad for each type that contains an // Entity. diff --git a/src/main.rs b/src/main.rs index cc79b95..4dcdb38 100644 --- a/src/main.rs +++ b/src/main.rs @@ -543,6 +543,7 @@ fn main() -> ::rltk::BError { Vendor, Quips, Attributes, + Skills, ); gs.ecs.insert(SimpleMarkerAllocator::::new()); diff --git a/src/saveload_system.rs b/src/saveload_system.rs index 303b341..366f6ae 100644 --- a/src/saveload_system.rs +++ b/src/saveload_system.rs @@ -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, ); }