From 1fb4bf293fa52733b478347de33d91713175e638 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Tue, 25 Jan 2022 13:45:44 -0500 Subject: [PATCH] Add a few more components --- src/components.rs | 10 ++++++++++ src/main.rs | 2 ++ src/raws/rawmaster.rs | 16 +++++++++++++--- src/saveload_system.rs | 4 ++++ 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/components.rs b/src/components.rs index 97ee2ad..000624c 100644 --- a/src/components.rs +++ b/src/components.rs @@ -433,3 +433,13 @@ pub struct ProvidesMana { pub struct TeachesSpell { pub spell: String, } + +#[derive(Component, Debug, Serialize, Deserialize, Clone)] +pub struct Slow { + pub initiative_penalty: f32, +} + +#[derive(Component, Debug, Serialize, Deserialize, Clone)] +pub struct DamageOverTime { + pub damage: i32, +} diff --git a/src/main.rs b/src/main.rs index 2cac31e..c335adb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -92,6 +92,7 @@ fn init_state() -> State { Confusion, Consumable, CursedItem, + DamageOverTime, Door, DMSerializationHelper, Duration, @@ -136,6 +137,7 @@ fn init_state() -> State { SimpleMarker, SingleActivation, Skills, + Slow, SpawnParticleBurst, SpawnParticleLine, SpellTemplate, diff --git a/src/raws/rawmaster.rs b/src/raws/rawmaster.rs index d9d159c..b28ce91 100644 --- a/src/raws/rawmaster.rs +++ b/src/raws/rawmaster.rs @@ -293,6 +293,11 @@ macro_rules! apply_effects { mana_amount: effect.1.parse::().unwrap(), }) } + "teach_spell" => { + $eb = $eb.with(TeachesSpell { + spell: effect.1.to_string(), + }) + } "ranged" => { $eb = $eb.with(Ranged { range: effect.1.parse::().unwrap(), @@ -322,9 +327,14 @@ macro_rules! apply_effects { "particle" => $eb = $eb.with(parse_particle(&effect.1)), "remove_curse" => $eb = $eb.with(ProvidesRemoveCurse {}), "identify" => $eb = $eb.with(ProvidesIdentification {}), - "teach_spell" => { - $eb = $eb.with(TeachesSpell { - spell: effect.1.to_string(), + "slow" => { + $eb = $eb.with(Slow { + initiative_penalty: effect.1.parse::().unwrap(), + }) + } + "damage_over_time" => { + $eb = $eb.with(DamageOverTime { + damage: effect.1.parse::().unwrap(), }) } _ => { diff --git a/src/saveload_system.rs b/src/saveload_system.rs index 257d210..f526d45 100644 --- a/src/saveload_system.rs +++ b/src/saveload_system.rs @@ -71,6 +71,7 @@ pub fn save_game(ecs: &mut World) { Confusion, Consumable, CursedItem, + DamageOverTime, Door, DMSerializationHelper, Duration, @@ -114,6 +115,7 @@ pub fn save_game(ecs: &mut World) { SerializationHelper, SingleActivation, Skills, + Slow, SpawnParticleBurst, SpawnParticleLine, SpellTemplate, @@ -199,6 +201,7 @@ pub fn load_game(ecs: &mut World) { Confusion, Consumable, CursedItem, + DamageOverTime, Door, DMSerializationHelper, Duration, @@ -241,6 +244,7 @@ pub fn load_game(ecs: &mut World) { Renderable, SerializationHelper, SingleActivation, + Slow, Skills, SpawnParticleBurst, SpawnParticleLine,