tiger_lib/vic3/data/
character_interactions.rs

1use crate::block::Block;
2use crate::context::ScopeContext;
3use crate::db::{Db, DbKind};
4use crate::everything::Everything;
5use crate::game::GameFlags;
6use crate::item::{Item, ItemLoader};
7use crate::scopes::Scopes;
8use crate::token::Token;
9use crate::tooltipped::Tooltipped;
10use crate::validate::validate_duration;
11use crate::validator::Validator;
12
13#[derive(Clone, Debug)]
14pub struct CharacterInteraction {}
15
16inventory::submit! {
17    ItemLoader::Normal(GameFlags::Vic3, Item::CharacterInteraction, CharacterInteraction::add)
18}
19
20impl CharacterInteraction {
21    pub fn add(db: &mut Db, key: Token, block: Block) {
22        db.add(Item::CharacterInteraction, key, block, Box::new(Self {}));
23    }
24}
25
26impl DbKind for CharacterInteraction {
27    fn validate(&self, key: &Token, block: &Block, data: &Everything) {
28        let mut vd = Validator::new(block, data);
29        let mut sc = ScopeContext::new(Scopes::Character, key);
30        sc.define_name("actor", Scopes::Country, key);
31
32        data.verify_exists(Item::Localization, key);
33
34        vd.field_item("icon", Item::File);
35        vd.field_item("clicksound", Item::Sound);
36
37        vd.field_trigger("potential", Tooltipped::No, &mut sc);
38        vd.field_trigger("possible", Tooltipped::Yes, &mut sc);
39        vd.field_effect("effect", Tooltipped::Yes, &mut sc);
40        vd.field_validated_block_sc("cooldown", &mut sc, validate_duration);
41
42        vd.field_bool("show_requirements");
43        vd.field_bool("show_confirmation_box");
44        vd.field_script_value("ai_chance", &mut sc);
45
46        // undocumented
47
48        vd.field_trigger_rooted("should_ai_evaluate", Tooltipped::No, Scopes::Country);
49        vd.field_bool("ai_considers_exiles");
50    }
51}