forked from cataclysmbnteam/Cataclysm-BN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bionics.h
219 lines (185 loc) · 7.34 KB
/
bionics.h
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
#pragma once
#ifndef CATA_SRC_BIONICS_H
#define CATA_SRC_BIONICS_H
#include <cstddef>
#include <map>
#include <optional>
#include <set>
#include <string>
#include <utility>
#include <vector>
#include "bodypart.h"
#include "calendar.h"
#include "flat_set.h"
#include "translations.h"
#include "type_id.h"
#include "units.h"
class JsonIn;
class JsonObject;
class JsonOut;
class Character;
class player;
enum class character_stat : char;
struct bionic_data {
bionic_data();
~bionic_data();
bionic_id id;
translation name;
translation description;
/** Power cost on activation */
units::energy power_activate = 0_kJ;
/** Power cost on deactivation */
units::energy power_deactivate = 0_kJ;
/** Power cost over time, does nothing without a non-zero charge_time */
units::energy power_over_time = 0_kJ;
/** Power cost when the bionic's special effect is triggered */
units::energy power_trigger = 0_kJ;
/** Kcal cost when the bionic's special effect is triggered */
int kcal_trigger = 0;
/** How often a bionic draws or produces power while active in turns */
int charge_time = 0;
/** Power bank size **/
units::energy capacity = 0_kJ;
/** Is true if a bionic is an active instead of a passive bionic */
bool activated = false;
/**
* If true, this bionic is included with another.
*/
bool included = false;
/**Factor modifiying weight capacity*/
float weight_capacity_modifier = 1.0f;
/**Bonus to weight capacity*/
units::mass weight_capacity_bonus = 0_gram;
/**Map of stats and their corresponding bonuses passively granted by a bionic*/
std::map<character_stat, int> stat_bonus;
/**This bionic draws power through a cable*/
bool is_remote_fueled = false;
/**Fuel types that can be used by this bionic*/
std::vector<itype_id> fuel_opts;
/**How much fuel this bionic can hold*/
int fuel_capacity = 0;
/**Fraction of fuel energy converted to bionic power*/
float fuel_efficiency = 0.0f;
/**Multiplies the amount of fuel when loading into the bionic storage*/
int fuel_multiplier = 1;
/**Fraction of fuel energy passively converted to bionic power*/
float passive_fuel_efficiency = 0.0f;
/**Fraction of coverage diminishing fuel_efficiency*/
std::optional<float> coverage_power_gen_penalty;
/**If true this bionic emits heat when producing power*/
bool exothermic_power_gen = false;
/**Type of field emitted by this bionic when it produces energy*/
emit_id power_gen_emission = emit_id::NULL_ID();
/**Amount of environemental protection offered by this bionic*/
std::map<bodypart_str_id, int> env_protec;
/**Amount of bash protection offered by this bionic*/
std::map<bodypart_str_id, int> bash_protec;
/**Amount of cut protection offered by this bionic*/
std::map<bodypart_str_id, int> cut_protec;
/**Amount of bullet protection offered by this bionic*/
std::map<bodypart_str_id, int> bullet_protec;
/**
* Body part slots used to install this bionic, mapped to the amount of space required.
*/
std::map<bodypart_str_id, int> occupied_bodyparts;
/**
* Body part encumbered by this bionic, mapped to the amount of encumbrance caused.
*/
std::map<bodypart_str_id, int> encumbrance;
/**
* Fake item created for crafting with this bionic available.
* Also the item used for gun bionics.
*/
itype_id fake_item;
/**
* Mutations/trait that are removed upon installing this CBM.
* E.g. enhanced optic bionic may cancel HYPEROPIC trait.
*/
std::vector<trait_id> canceled_mutations;
/** bionic enchantments */
std::vector<enchantment_id> enchantments;
/**
* The spells you learn when you install this bionic, and what level you learn them at.
*/
std::map<spell_id, int> learned_spells;
/**
* Additional bionics that are installed automatically when this
* bionic is installed. This can be used to install several bionics
* from one CBM item, which is useful as each of those can be
* activated independently.
*/
std::vector<bionic_id> included_bionics;
/**
* Id of another bionic which this bionic can upgrade.
*/
bionic_id upgraded_bionic = bionic_id::NULL_ID();
/**
* Upgrades available for this bionic (opposite to @ref upgraded_bionic).
*/
std::set<bionic_id> available_upgrades;
std::set<flag_str_id> flags;
bool has_flag( const flag_str_id &flag ) const;
itype_id itype() const;
bool is_included( const bionic_id &id ) const;
static void load_bionic( const JsonObject &jo, const std::string &src );
static void check_consistency();
static void finalize_all();
static void reset();
bool was_loaded = false;
void load( const JsonObject &obj, std::string );
void check() const;
void finalize() const;
};
struct bionic {
bionic_id id;
int charge_timer = 0;
char invlet = 'a';
bool powered = false;
/* Ammunition actually loaded in this bionic gun in deactivated state */
itype_id ammo_loaded = itype_id::NULL_ID();
/* Ammount of ammo actually held inside by this bionic gun in deactivated state */
unsigned int ammo_count = 0;
/* An amount of time during which this bionic has been rendered inoperative. */
time_duration incapacitated_time;
/* The amount of energy the Bionic has stored for it's function. [Currently only used for ADS]*/
units::energy energy_stored = 0_kJ;
bionic()
: id( "bio_batteries" ), incapacitated_time( 0_turns ) {
}
bionic( bionic_id pid, char pinvlet )
: id( pid ), invlet( pinvlet ), incapacitated_time( 0_turns ) { }
const bionic_data &info() const {
return *id;
}
void set_flag( const std::string &flag );
void remove_flag( const std::string &flag );
bool has_flag( const std::string &flag ) const;
int get_quality( const quality_id &quality ) const;
bool is_this_fuel_powered( const itype_id &this_fuel ) const;
void toggle_safe_fuel_mod();
void toggle_auto_start_mod();
void set_auto_start_thresh( float val );
float get_auto_start_thresh() const;
bool is_auto_start_on() const;
bool is_auto_start_keep_full() const;
void serialize( JsonOut &json ) const;
void deserialize( JsonIn &jsin );
private:
// generic bionic specific flags
cata::flat_set<std::string> bionic_tags;
float auto_start_threshold = -1.0;
};
// A simpler wrapper to allow forward declarations of it. std::vector can not
// be forward declared without a *definition* of bionic, but this wrapper can.
class bionic_collection : public std::vector<bionic>
{
};
/**List of bodyparts occupied by a bionic*/
std::vector<bodypart_id> get_occupied_bodyparts( const bionic_id &bid );
char get_free_invlet( bionic_collection &bionics );
std::string list_occupied_bps( const bionic_id &bio_id, const std::string &intro,
bool each_bp_on_new_line = true );
int bionic_manip_cos( float adjusted_skill, int bionic_difficulty );
std::vector<bionic_id> bionics_cancelling_trait( const std::vector<bionic_id> &bios,
const trait_id &tid );
#endif // CATA_SRC_BIONICS_H