beatitude identification
This commit is contained in:
parent
113d26cf41
commit
f55f4504db
7 changed files with 59 additions and 6 deletions
|
|
@ -454,6 +454,9 @@ pub struct Hidden {}
|
|||
#[derive(Component, Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct SingleActivation {}
|
||||
|
||||
#[derive(Component, Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct IdentifiedBeatitude {}
|
||||
|
||||
#[derive(Component, Clone, ConvertSaveload)]
|
||||
pub struct ParticleLifetime {
|
||||
pub lifetime_ms: f32,
|
||||
|
|
|
|||
|
|
@ -338,7 +338,7 @@ fn get_starting_inventory(class: Class, rng: &mut RandomNumberGenerator) -> (Vec
|
|||
Class::Rogue => {
|
||||
starting_food = "1d2+2";
|
||||
equipped = vec!["equip_rapier".to_string(), "equip_body_weakleather".to_string()];
|
||||
carried = vec!["equip_dagger".to_string(), "equip_dagger".to_string(), "scroll_fireball".to_string()];
|
||||
carried = vec!["equip_dagger".to_string(), "equip_dagger".to_string()];
|
||||
}
|
||||
Class::Wizard => {
|
||||
starting_food = "1d2+1";
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
use crate::{
|
||||
gamelog,
|
||||
gui::{item_colour, obfuscate_name},
|
||||
Beatitude, EquipmentChanged, Equippable, Equipped, IdentifiedItem, InBackpack, MagicItem, MasterDungeonMap, Name,
|
||||
ObfuscatedName, WantsToUseItem, BUC,
|
||||
Beatitude, EquipmentChanged, Equippable, Equipped, IdentifiedBeatitude, IdentifiedItem, InBackpack, MagicItem,
|
||||
MasterDungeonMap, Name, ObfuscatedName, WantsToUseItem, BUC,
|
||||
};
|
||||
use specs::prelude::*;
|
||||
|
||||
|
|
@ -23,6 +23,7 @@ impl<'a> System<'a> for ItemEquipSystem {
|
|||
ReadStorage<'a, MagicItem>,
|
||||
ReadStorage<'a, ObfuscatedName>,
|
||||
ReadStorage<'a, Beatitude>,
|
||||
WriteStorage<'a, IdentifiedBeatitude>,
|
||||
ReadExpect<'a, MasterDungeonMap>,
|
||||
);
|
||||
|
||||
|
|
@ -41,6 +42,7 @@ impl<'a> System<'a> for ItemEquipSystem {
|
|||
magic_items,
|
||||
obfuscated_names,
|
||||
beatitudes,
|
||||
mut identified_beatitude,
|
||||
dm,
|
||||
) = data;
|
||||
let mut remove: Vec<Entity> = Vec::new();
|
||||
|
|
@ -74,6 +76,9 @@ impl<'a> System<'a> for ItemEquipSystem {
|
|||
)
|
||||
.colour(rltk::WHITE)
|
||||
.append("!");
|
||||
identified_beatitude
|
||||
.insert(item_entity, IdentifiedBeatitude {})
|
||||
.expect("Unable to push");
|
||||
}
|
||||
}
|
||||
to_unequip.push(item_entity);
|
||||
|
|
@ -129,6 +134,9 @@ impl<'a> System<'a> for ItemEquipSystem {
|
|||
IdentifiedItem { name: names.get(wants_to_use_item.item).unwrap().name.clone() },
|
||||
)
|
||||
.expect("Unable to insert IdentifiedItem");
|
||||
identified_beatitude
|
||||
.insert(wants_to_use_item.item, IdentifiedBeatitude {})
|
||||
.expect("Unable to push");
|
||||
}
|
||||
remove.push(target);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{Beatitude, IdentifiedItem, Item, MasterDungeonMap, Name, ObfuscatedName, Player};
|
||||
use crate::{Beatitude, IdentifiedBeatitude, IdentifiedItem, Item, MasterDungeonMap, Name, ObfuscatedName, Player};
|
||||
use specs::prelude::*;
|
||||
|
||||
pub struct ItemIdentificationSystem {}
|
||||
|
|
@ -9,6 +9,7 @@ impl<'a> System<'a> for ItemIdentificationSystem {
|
|||
ReadStorage<'a, Player>,
|
||||
WriteStorage<'a, IdentifiedItem>,
|
||||
WriteStorage<'a, Beatitude>,
|
||||
WriteStorage<'a, IdentifiedBeatitude>,
|
||||
WriteExpect<'a, MasterDungeonMap>,
|
||||
ReadStorage<'a, Item>,
|
||||
ReadStorage<'a, Name>,
|
||||
|
|
@ -17,7 +18,17 @@ impl<'a> System<'a> for ItemIdentificationSystem {
|
|||
);
|
||||
|
||||
fn run(&mut self, data: Self::SystemData) {
|
||||
let (player, mut identified, mut beatitudes, mut dm, items, names, mut obfuscated_names, entities) = data;
|
||||
let (
|
||||
player,
|
||||
mut identified,
|
||||
mut beatitudes,
|
||||
mut identified_beatitudes,
|
||||
mut dm,
|
||||
items,
|
||||
names,
|
||||
mut obfuscated_names,
|
||||
entities,
|
||||
) = data;
|
||||
for (_p, id) in (&player, &identified).join() {
|
||||
let tag = crate::raws::get_id_from_name(id.name.clone());
|
||||
if !dm.identified_items.contains(&id.name) && crate::raws::is_tag_magic(&tag) {
|
||||
|
|
@ -29,7 +40,13 @@ impl<'a> System<'a> for ItemIdentificationSystem {
|
|||
}
|
||||
}
|
||||
}
|
||||
for (e, _id) in (&entities, &identified_beatitudes).join() {
|
||||
if let Some(beatitude) = beatitudes.get_mut(e) {
|
||||
beatitude.known = true;
|
||||
}
|
||||
}
|
||||
// Clean up
|
||||
identified.clear();
|
||||
identified_beatitudes.clear();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -599,6 +599,7 @@ fn main() -> rltk::BError {
|
|||
gs.ecs.register::<Item>();
|
||||
gs.ecs.register::<Beatitude>();
|
||||
gs.ecs.register::<IdentifiedItem>();
|
||||
gs.ecs.register::<IdentifiedBeatitude>();
|
||||
gs.ecs.register::<MagicItem>();
|
||||
gs.ecs.register::<GrantsXP>();
|
||||
gs.ecs.register::<LootTable>();
|
||||
|
|
|
|||
|
|
@ -235,8 +235,30 @@ pub fn spawn_named_item(
|
|||
let potion_names = dm.potion_map.clone();
|
||||
let wand_names = dm.wand_map.clone();
|
||||
let identified_items = dm.identified_items.clone();
|
||||
// --- WE GET ALL THE VALUES FROM THE ECS WE NEED HERE, BEFORE ---
|
||||
// --- WE CREATE THE EB, TO AVOID BORROW CHECKER COMPLAINTS ---
|
||||
let roll = ecs.write_resource::<RandomNumberGenerator>().roll_dice(1, 6);
|
||||
let player_entity = ecs.fetch::<Entity>();
|
||||
let known_beatitude = match pos {
|
||||
SpawnType::Equipped { by } => {
|
||||
if by == *player_entity {
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
SpawnType::Carried { by } => {
|
||||
if by == *player_entity {
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
_ => false,
|
||||
};
|
||||
std::mem::drop(player_entity);
|
||||
std::mem::drop(dm);
|
||||
// -- DROP EVERYTHING THAT INVOLVES THE ECS BEFORE THIS POINT ---
|
||||
let mut eb = ecs.create_entity().marked::<SimpleMarker<SerializeMe>>();
|
||||
|
||||
eb = eb.with(Name { name: item_template.name.name.clone(), plural: item_template.name.plural.clone() });
|
||||
|
|
@ -256,7 +278,7 @@ pub fn spawn_named_item(
|
|||
_ => BUC::Uncursed,
|
||||
}
|
||||
};
|
||||
eb = eb.with(Beatitude { buc, known: true });
|
||||
eb = eb.with(Beatitude { buc, known: known_beatitude });
|
||||
|
||||
if let Some(flags) = &item_template.flags {
|
||||
apply_flags!(flags, eb);
|
||||
|
|
|
|||
|
|
@ -76,6 +76,7 @@ pub fn save_game(ecs: &mut World) {
|
|||
HasClass,
|
||||
Hidden,
|
||||
HungerClock,
|
||||
IdentifiedBeatitude,
|
||||
IdentifiedItem,
|
||||
InBackpack,
|
||||
InflictsDamage,
|
||||
|
|
@ -199,6 +200,7 @@ pub fn load_game(ecs: &mut World) {
|
|||
HasClass,
|
||||
Hidden,
|
||||
HungerClock,
|
||||
IdentifiedBeatitude,
|
||||
IdentifiedItem,
|
||||
InBackpack,
|
||||
InflictsDamage,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue