overlord_event_system/mechanics/
content_lookups.rs1use std::collections::HashMap;
6use std::sync::Arc;
7
8use essences::abilities::{AbilityId, AbilityRarityId};
9use essences::fighting::FightTemplateId;
10use essences::game::EntityTemplate;
11use essences::game::EntityTemplateId;
12use essences::items::{AttributeId, ItemRarityId};
13use uuid::Uuid;
14
15#[derive(Debug, Default, Clone)]
16pub struct ContentLookups {
17 pub item_rarity_q: HashMap<ItemRarityId, f64>,
19 pub ability_rarity_eff: HashMap<AbilityRarityId, f64>,
20 pub item_fixed_power: HashMap<Uuid, f64>,
21 pub item_id_by_mimic_code: HashMap<i64, Uuid>,
25
26 pub effects_by_code: HashMap<String, Arc<EffectTpl>>,
31 pub fight_template_is_dungeon: HashMap<FightTemplateId, bool>,
32 pub fight_template_is_bossfight: HashMap<FightTemplateId, bool>,
33 pub entity_template_is_boss: HashMap<EntityTemplateId, bool>,
34
35 pub attribute_by_code: HashMap<String, AttributeId>,
37 pub attribute_base_value: HashMap<AttributeId, f64>,
39
40 pub class_counter_role: HashMap<Uuid, i8>,
45
46 pub quest_by_code: HashMap<String, Uuid>,
49
50 pub ability_range: HashMap<AbilityId, i64>,
53 pub ability_target_type: HashMap<AbilityId, String>,
56}
57
58#[derive(Debug, Clone)]
59pub struct EffectTpl {
60 pub id: Uuid,
61 pub code: String,
62 pub max_duration_ticks: Option<i64>,
63}
64
65#[derive(Debug, Clone)]
67pub struct CachedEntityTemplate {
68 pub width: i64,
69 pub cast_time: i64,
70 pub is_boss: bool,
71}
72
73impl ContentLookups {
74 pub fn entity_template_cache(&self, tpl: &EntityTemplate) -> CachedEntityTemplate {
75 CachedEntityTemplate {
76 width: tpl.width as i64,
77 cast_time: tpl.cast_time as i64,
78 is_boss: self
79 .entity_template_is_boss
80 .get(&tpl.id)
81 .copied()
82 .unwrap_or(false),
83 }
84 }
85}