removes deprecated SufferDamage component
This commit is contained in:
parent
945242bc42
commit
51f8ee66e6
7 changed files with 20 additions and 39 deletions
|
|
@ -197,22 +197,6 @@ pub struct GrantsXP {
|
|||
pub amount: i32,
|
||||
}
|
||||
|
||||
#[derive(Component, Debug, ConvertSaveload, Clone)]
|
||||
pub struct SufferDamage {
|
||||
pub amount: Vec<(i32, bool)>,
|
||||
}
|
||||
|
||||
impl SufferDamage {
|
||||
pub fn new_damage(store: &mut WriteStorage<SufferDamage>, victim: Entity, amount: i32, from_player: bool) {
|
||||
if let Some(suffering) = store.get_mut(victim) {
|
||||
suffering.amount.push((amount, from_player));
|
||||
} else {
|
||||
let dmg = SufferDamage { amount: vec![(amount, from_player)] };
|
||||
store.insert(victim, dmg).expect("Unable to insert damage.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Component, Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct Item {
|
||||
pub weight: f32, // in lbs
|
||||
|
|
|
|||
|
|
@ -1,8 +1,4 @@
|
|||
use super::{
|
||||
gamelog, Attributes, Equipped, GrantsXP, InBackpack, Item, LootTable, Map, Name, ParticleBuilder, Player, Pools,
|
||||
Position, RunState, SufferDamage,
|
||||
};
|
||||
use crate::gamesystem::{hp_per_level, mana_per_level};
|
||||
use super::{gamelog, Equipped, InBackpack, Item, LootTable, Name, Player, Pools, Position, RunState};
|
||||
use rltk::prelude::*;
|
||||
use specs::prelude::*;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +1,17 @@
|
|||
use super::{gamelog, HungerClock, HungerState, SufferDamage, LOG_TICKS};
|
||||
use super::{
|
||||
effects::{add_effect, EffectType, Targets},
|
||||
gamelog, HungerClock, HungerState, LOG_TICKS,
|
||||
};
|
||||
use specs::prelude::*;
|
||||
|
||||
pub struct HungerSystem {}
|
||||
|
||||
impl<'a> System<'a> for HungerSystem {
|
||||
#[allow(clippy::type_complexity)]
|
||||
type SystemData =
|
||||
(Entities<'a>, WriteStorage<'a, HungerClock>, ReadExpect<'a, Entity>, WriteStorage<'a, SufferDamage>);
|
||||
type SystemData = (Entities<'a>, WriteStorage<'a, HungerClock>, ReadExpect<'a, Entity>);
|
||||
|
||||
fn run(&mut self, data: Self::SystemData) {
|
||||
let (entities, mut hunger_clock, player_entity, mut inflict_damage) = data;
|
||||
let (entities, mut hunger_clock, player_entity) = data;
|
||||
|
||||
for (entity, mut clock) in (&entities, &mut hunger_clock).join() {
|
||||
if LOG_TICKS && entity == *player_entity {
|
||||
|
|
@ -32,14 +34,14 @@ impl<'a> System<'a> for HungerSystem {
|
|||
clock.state = HungerState::Hungry;
|
||||
clock.duration = 400;
|
||||
if entity == *player_entity {
|
||||
gamelog::Logger::new().colour(rltk::RED).append("You feel hungry.").log();
|
||||
gamelog::Logger::new().colour(rltk::BROWN1).append("You feel hungry.").log();
|
||||
}
|
||||
}
|
||||
HungerState::Hungry => {
|
||||
clock.state = HungerState::Weak;
|
||||
clock.duration = 200;
|
||||
if entity == *player_entity {
|
||||
gamelog::Logger::new().colour(rltk::RED).append("You feel weak with hunger.").log();
|
||||
gamelog::Logger::new().colour(rltk::ORANGE).append("You feel weak with hunger.").log();
|
||||
}
|
||||
}
|
||||
HungerState::Weak => {
|
||||
|
|
@ -50,7 +52,7 @@ impl<'a> System<'a> for HungerSystem {
|
|||
}
|
||||
}
|
||||
HungerState::Fainting => {
|
||||
SufferDamage::new_damage(&mut inflict_damage, entity, 1, false);
|
||||
add_effect(None, EffectType::Damage { amount: 1 }, Targets::Entity { target: entity });
|
||||
if entity == *player_entity {
|
||||
gamelog::Logger::new().colour(rltk::RED).append("You can't go on without food...").log();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ use super::{
|
|||
gamelog, Confusion, Consumable, Cursed, Destructible, Digger, EquipmentChanged, Equippable, Equipped, HungerClock,
|
||||
HungerState, IdentifiedItem, InBackpack, InflictsDamage, MagicItem, MagicMapper, Map, MasterDungeonMap, Name,
|
||||
ObfuscatedName, ParticleBuilder, Point, Pools, Position, ProvidesHealing, ProvidesNutrition, RandomNumberGenerator,
|
||||
RunState, SufferDamage, TileType, Viewshed, Wand, WantsToDropItem, WantsToPickupItem, WantsToRemoveItem,
|
||||
WantsToUseItem, AOE, DEFAULT_PARTICLE_LIFETIME, LONG_PARTICLE_LIFETIME,
|
||||
RunState, TileType, Viewshed, Wand, WantsToDropItem, WantsToPickupItem, WantsToRemoveItem, WantsToUseItem, AOE,
|
||||
DEFAULT_PARTICLE_LIFETIME, LONG_PARTICLE_LIFETIME,
|
||||
};
|
||||
|
||||
mod collection_system;
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ mod spawner;
|
|||
mod visibility_system;
|
||||
use visibility_system::VisibilitySystem;
|
||||
mod damage_system;
|
||||
use damage_system::*;
|
||||
mod hunger_system;
|
||||
mod melee_combat_system;
|
||||
mod trigger_system;
|
||||
|
|
@ -546,7 +545,6 @@ fn main() -> rltk::BError {
|
|||
gs.ecs.register::<Skills>();
|
||||
gs.ecs.register::<HungerClock>();
|
||||
gs.ecs.register::<WantsToMelee>();
|
||||
gs.ecs.register::<SufferDamage>();
|
||||
gs.ecs.register::<Item>();
|
||||
gs.ecs.register::<IdentifiedItem>();
|
||||
gs.ecs.register::<MagicItem>();
|
||||
|
|
|
|||
|
|
@ -1,7 +1,11 @@
|
|||
use super::{
|
||||
gamelog, gui::obfuscate_name_ecs, raws::Reaction, Attributes, BlocksTile, BlocksVisibility, Door, EntityMoved,
|
||||
Faction, Hidden, HungerClock, HungerState, Item, Map, Name, ParticleBuilder, Player, Pools, Position, Renderable,
|
||||
RunState, State, SufferDamage, Telepath, TileType, Viewshed, WantsToMelee, WantsToPickupItem,
|
||||
effects::{add_effect, EffectType, Targets},
|
||||
gamelog,
|
||||
gui::obfuscate_name_ecs,
|
||||
raws::Reaction,
|
||||
Attributes, BlocksTile, BlocksVisibility, Door, EntityMoved, Faction, Hidden, HungerClock, HungerState, Item, Map,
|
||||
Name, ParticleBuilder, Player, Pools, Position, Renderable, RunState, State, Telepath, TileType, Viewshed,
|
||||
WantsToMelee, WantsToPickupItem,
|
||||
};
|
||||
use rltk::{Point, RandomNumberGenerator, Rltk, VirtualKeyCode};
|
||||
use specs::prelude::*;
|
||||
|
|
@ -193,8 +197,7 @@ pub fn kick(i: i32, j: i32, ecs: &mut World) -> RunState {
|
|||
|
||||
if !crate::spatial::has_tile_content(destination_idx) {
|
||||
if rng.roll_dice(1, 20) == 20 {
|
||||
let mut suffer_damage = ecs.write_storage::<SufferDamage>();
|
||||
SufferDamage::new_damage(&mut suffer_damage, entity, 1, false);
|
||||
add_effect(None, EffectType::Damage { amount: 1 }, Targets::Entity { target: entity });
|
||||
gamelog::Logger::new().append("Ouch! You kick the open air, and pull something.").log();
|
||||
break;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -101,7 +101,6 @@ pub fn save_game(ecs: &mut World) {
|
|||
Renderable,
|
||||
SingleActivation,
|
||||
Skills,
|
||||
SufferDamage,
|
||||
TakingTurn,
|
||||
Telepath,
|
||||
Viewshed,
|
||||
|
|
@ -219,7 +218,6 @@ pub fn load_game(ecs: &mut World) {
|
|||
Renderable,
|
||||
SingleActivation,
|
||||
Skills,
|
||||
SufferDamage,
|
||||
TakingTurn,
|
||||
Telepath,
|
||||
Viewshed,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue