Add a few more components

This commit is contained in:
Timothy Warren 2022-01-25 13:45:44 -05:00
parent bd7fa27794
commit 1fb4bf293f
4 changed files with 29 additions and 3 deletions

View File

@ -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,
}

View File

@ -92,6 +92,7 @@ fn init_state() -> State {
Confusion,
Consumable,
CursedItem,
DamageOverTime,
Door,
DMSerializationHelper,
Duration,
@ -136,6 +137,7 @@ fn init_state() -> State {
SimpleMarker<SerializeMe>,
SingleActivation,
Skills,
Slow,
SpawnParticleBurst,
SpawnParticleLine,
SpellTemplate,

View File

@ -293,6 +293,11 @@ macro_rules! apply_effects {
mana_amount: effect.1.parse::<i32>().unwrap(),
})
}
"teach_spell" => {
$eb = $eb.with(TeachesSpell {
spell: effect.1.to_string(),
})
}
"ranged" => {
$eb = $eb.with(Ranged {
range: effect.1.parse::<i32>().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::<f32>().unwrap(),
})
}
"damage_over_time" => {
$eb = $eb.with(DamageOverTime {
damage: effect.1.parse::<i32>().unwrap(),
})
}
_ => {

View File

@ -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,