forked from CleverRaven/Cataclysm-DDA
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbehavior_oracle.cpp
More file actions
51 lines (43 loc) · 2.16 KB
/
behavior_oracle.cpp
File metadata and controls
51 lines (43 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include "behavior_oracle.h"
#include <functional>
#include <string>
#include <unordered_map>
#include <utility>
#include "behavior.h"
#include "character_oracle.h"
#include "monster_oracle.h"
namespace behavior
{
status_t return_running( const oracle_t *, std::string_view )
{
return status_t::running;
}
// Just a little helper to make populating predicate_map slightly less gross.
static std::function < status_t( const oracle_t *, std::string_view ) >
make_function( status_t ( character_oracle_t::* fun )( std::string_view ) const )
{
return static_cast<status_t ( oracle_t::* )( std::string_view ) const>( fun );
}
static std::function < status_t( const oracle_t *, std::string_view ) >
make_function( status_t ( monster_oracle_t::* fun )( std::string_view ) const )
{
return static_cast<status_t ( oracle_t::* )( std::string_view ) const>( fun );
}
std::unordered_map<std::string, std::function<status_t( const oracle_t *, std::string_view ) >>
predicate_map = {{
{ "npc_needs_warmth_badly", make_function( &character_oracle_t::needs_warmth_badly ) },
{ "npc_needs_water_badly", make_function( &character_oracle_t::needs_water_badly ) },
{ "npc_needs_food_badly", make_function( &character_oracle_t::needs_food_badly ) },
{ "npc_can_wear_warmer_clothes", make_function( &character_oracle_t::can_wear_warmer_clothes ) },
{ "npc_can_make_fire", make_function( &character_oracle_t::can_make_fire ) },
{ "npc_can_take_shelter", make_function( &character_oracle_t::can_take_shelter ) },
{ "npc_has_water", make_function( &character_oracle_t::has_water ) },
{ "npc_has_food", make_function( &character_oracle_t::has_food ) },
{ "monster_not_hallucination", make_function( &monster_oracle_t::not_hallucination ) },
{ "monster_items_available", make_function( &monster_oracle_t::items_available ) },
{ "monster_split_possible", make_function( &monster_oracle_t::split_possible ) },
{ "monster_adjacent_plants", make_function( &monster_oracle_t::adjacent_plants ) },
{ "monster_special_available", make_function( &monster_oracle_t::special_available ) }
}
};
} // namespace behavior