forked from CleverRaven/Cataclysm-DDA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsubbodypart.cpp
99 lines (81 loc) · 2.21 KB
/
subbodypart.cpp
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#include "subbodypart.h"
#include <cstdlib>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include "debug.h"
#include "enum_conversions.h"
#include "generic_factory.h"
#include "json.h"
#include "type_id.h"
namespace
{
generic_factory<sub_body_part_type> sub_body_part_factory( "sub body part" );
} // namespace
/**@relates string_id*/
template<>
bool string_id<sub_body_part_type>::is_valid() const
{
return sub_body_part_factory.is_valid( *this );
}
/** @relates int_id */
template<>
bool int_id<sub_body_part_type>::is_valid() const
{
return sub_body_part_factory.is_valid( *this );
}
/**@relates string_id*/
template<>
const sub_body_part_type &string_id<sub_body_part_type>::obj() const
{
return sub_body_part_factory.obj( *this );
}
/** @relates int_id */
template<>
const sub_body_part_type &int_id<sub_body_part_type>::obj() const
{
return sub_body_part_factory.obj( *this );
}
/** @relates int_id */
template<>
const sub_bodypart_str_id &int_id<sub_body_part_type>::id() const
{
return sub_body_part_factory.convert( *this );
}
/**@relates string_id*/
template<>
sub_bodypart_id string_id<sub_body_part_type>::id() const
{
return sub_body_part_factory.convert( *this, sub_bodypart_id( 0 ) );
}
/** @relates int_id */
template<>
int_id<sub_body_part_type>::int_id( const string_id<sub_body_part_type> &id ) : _id( id.id() ) {}
void sub_body_part_type::load_bp( const JsonObject &jo, const std::string &src )
{
sub_body_part_factory.load( jo, src );
}
void sub_body_part_type::load( const JsonObject &jo, const std::string & )
{
mandatory( jo, was_loaded, "id", id );
mandatory( jo, was_loaded, "name", name );
mandatory( jo, was_loaded, "parent", parent );
optional( jo, was_loaded, "secondary", secondary );
optional( jo, was_loaded, "max_coverage", max_coverage );
optional( jo, was_loaded, "side", part_side );
optional( jo, was_loaded, "name_multiple", name_multiple );
optional( jo, was_loaded, "opposite", opposite );
}
void sub_body_part_type::reset()
{
sub_body_part_factory.reset();
}
void sub_body_part_type::finalize_all()
{
sub_body_part_factory.finalize();
}
void sub_body_part_type::finalize()
{
}