forked from cataclysmbnteam/Cataclysm-BN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
activity_handlers.h
296 lines (267 loc) · 13.4 KB
/
activity_handlers.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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
#pragma once
#ifndef CATA_SRC_ACTIVITY_HANDLERS_H
#define CATA_SRC_ACTIVITY_HANDLERS_H
#include <functional>
#include <list>
#include <map>
#include <optional>
#include <string>
#include <unordered_set>
#include <vector>
#include "type_id.h"
class Character;
class inventory;
class item;
class player;
class player_activity;
struct tripoint;
// TODO (https://github.com/cataclysmbnteam/Cataclysm-BN/issues/1612):
// Remove that forward declaration after repair_activity_actor.
class vehicle;
std::vector<tripoint> get_sorted_tiles_by_distance( const tripoint &abspos,
const std::unordered_set<tripoint> &tiles );
std::vector<tripoint> route_adjacent( const player &p, const tripoint &dest );
enum requirement_check_result : int {
SKIP_LOCATION = 0,
CAN_DO_LOCATION,
RETURN_EARLY //another activity like a fetch activity has been started.
};
enum butcher_type : int {
BUTCHER, // quick butchery
BUTCHER_FULL, // full workshop butchery
F_DRESS, // field dressing a corpse
SKIN, // skinning a corpse
QUARTER, // quarter a corpse
DISMEMBER, // destroy a corpse
DISSECT // dissect a corpse for CBMs
};
enum class do_activity_reason : int {
CAN_DO_CONSTRUCTION, // Can do construction.
CAN_DO_FETCH, // Can do fetch - this is usually the default result for fetch task
CAN_DO_PREREQ, // for constructions - can't build the main construction, but can build the pre-req
CAN_DO_PREREQ_2, // Can do the second pre-req deep below the desired one.
NO_COMPONENTS, // can't do the activity there due to lack of components /tools
NO_COMPONENTS_PREREQ, // need components to build the pre-requisite for the actual desired construction
NO_COMPONENTS_PREREQ_2, // need components to the second pre-req deep.
DONT_HAVE_SKILL, // don't have the required skill
NO_ZONE, // There is no required zone anymore
ALREADY_DONE, // the activity is done already ( maybe by someone else )
UNKNOWN_ACTIVITY, // This is probably an error - got to the end of function with no previous reason
NEEDS_HARVESTING, // For farming - tile is harvestable now.
NEEDS_PLANTING, // For farming - tile can be planted
NEEDS_TILLING, // For farming - tile can be tilled
BLOCKING_TILE, // Something has made it's way onto the tile, so the activity cannot proceed
NEEDS_CHOPPING, // There is wood there to be chopped
NEEDS_TREE_CHOPPING, // There is a tree there that needs to be chopped
NEEDS_BIG_BUTCHERING, // There is at least one corpse there to butcher, and it's a big one
NEEDS_BUTCHERING, // THere is at least one corpse there to butcher, and there's no need for additional tools
ALREADY_WORKING, // somebody is already working there
NEEDS_VEH_DECONST, // There is a vehicle part there that we can deconstruct, given the right tools.
NEEDS_VEH_REPAIR, // There is a vehicle part there that can be repaired, given the right tools.
NEEDS_MINING, // This spot can be mined, if the right tool is present.
NEEDS_FISHING // This spot can be fished, if the right tool is present.
};
struct activity_reason_info {
//reason for success or fail
do_activity_reason reason;
//is it possible to do this
bool can_do;
//construction index
std::optional<construction_id> con_idx;
activity_reason_info( do_activity_reason reason_, bool can_do_,
const std::optional<construction_id> &con_idx_ = std::nullopt ) :
reason( reason_ ),
can_do( can_do_ ),
con_idx( con_idx_ )
{ }
static activity_reason_info ok( const do_activity_reason &reason_ ) {
return activity_reason_info( reason_, true );
}
static activity_reason_info build( const do_activity_reason &reason_, bool can_do_,
const construction_id &con_idx_ ) {
return activity_reason_info( reason_, can_do_, con_idx_ );
}
static activity_reason_info fail( const do_activity_reason &reason_ ) {
return activity_reason_info( reason_, false );
}
};
enum class butchery_possibility : int {
yes = 0,
need_confirmation,
never,
not_this
};
struct butchery_setup {
std::vector<std::string> problems;
std::vector<std::string> info;
butchery_possibility can_do;
int move_cost;
butcher_type type;
};
butchery_setup consider_butchery( const item &corpse_item, player &u, butcher_type action );
int butcher_time_to_cut( const Character &who, const inventory &inv, const item &corpse_item,
butcher_type action );
// activity_item_handling.cpp
void activity_on_turn_drop();
void activity_on_turn_move_loot( player_activity &act, player &p );
//return true if there is an activity that can be done potentially, return false if no work can be found.
bool generic_multi_activity_handler( player_activity &act, player &p, bool check_only = false );
void activity_on_turn_fetch( player_activity &, player *p );
void activity_on_turn_wear( player_activity &act, player &p );
bool find_auto_consume( player &p, bool food );
void try_fuel_fire( player_activity &act, player &p, bool starting_fire = false );
enum class item_drop_reason {
deliberate,
too_large,
too_heavy,
tumbling
};
void put_into_vehicle_or_drop( Character &c, item_drop_reason, const std::list<item> &items );
void put_into_vehicle_or_drop( Character &c, item_drop_reason, const std::list<item> &items,
const tripoint &where, bool force_ground = false );
void drop_on_map( Character &c, item_drop_reason reason, const std::list<item> &items,
const tripoint &where );
namespace activity_handlers
{
bool resume_for_multi_activities( player &p );
/** activity_do_turn functions: */
void burrow_do_turn( player_activity *act, player *p );
void craft_do_turn( player_activity *act, player *p );
void fill_liquid_do_turn( player_activity *act, player *p );
void pickaxe_do_turn( player_activity *act, player *p );
void drop_do_turn( player_activity *act, player *p );
void stash_do_turn( player_activity *act, player *p );
void pulp_do_turn( player_activity *act, player *p );
void game_do_turn( player_activity *act, player *p );
void generic_game_do_turn( player_activity *act, player *p );
void churn_do_turn( player_activity *act, player *p );
void start_fire_do_turn( player_activity *act, player *p );
void vibe_do_turn( player_activity *act, player *p );
void hand_crank_do_turn( player_activity *act, player *p );
void multiple_chop_planks_do_turn( player_activity *act, player *p );
void oxytorch_do_turn( player_activity *act, player *p );
void wear_do_turn( player_activity *act, player *p );
void eat_menu_do_turn( player_activity *act, player *p );
void consume_food_menu_do_turn( player_activity *act, player *p );
void consume_drink_menu_do_turn( player_activity *act, player *p );
void consume_meds_menu_do_turn( player_activity *act, player *p );
void move_items_do_turn( player_activity *act, player *p );
void multiple_farm_do_turn( player_activity *act, player *p );
void multiple_fish_do_turn( player_activity *act, player *p );
void multiple_construction_do_turn( player_activity *act, player *p );
void multiple_mine_do_turn( player_activity *act, player *p );
void multiple_butcher_do_turn( player_activity *act, player *p );
void vehicle_deconstruction_do_turn( player_activity *act, player *p );
void vehicle_repair_do_turn( player_activity *act, player *p );
void chop_trees_do_turn( player_activity *act, player *p );
void fetch_do_turn( player_activity *act, player *p );
void move_loot_do_turn( player_activity *act, player *p );
void travel_do_turn( player_activity *act, player *p );
void adv_inventory_do_turn( player_activity *act, player *p );
void armor_layers_do_turn( player_activity *act, player *p );
void atm_do_turn( player_activity *act, player *p );
void fish_do_turn( player_activity *act, player *p );
void cracking_do_turn( player_activity *act, player *p );
void repair_item_do_turn( player_activity *act, player *p );
void butcher_do_turn( player_activity *act, player *p );
void pry_nails_do_turn( player_activity *act, player *p );
void hacksaw_do_turn( player_activity *act, player *p );
void chop_tree_do_turn( player_activity *act, player *p );
void jackhammer_do_turn( player_activity *act, player *p );
void find_mount_do_turn( player_activity *act, player *p );
void tidy_up_do_turn( player_activity *act, player *p );
void build_do_turn( player_activity *act, player *p );
void fill_pit_do_turn( player_activity *act, player *p );
void fertilize_plot_do_turn( player_activity *act, player *p );
void try_sleep_do_turn( player_activity *act, player *p );
void operation_do_turn( player_activity *act, player *p );
void robot_control_do_turn( player_activity *act, player *p );
void tree_communion_do_turn( player_activity *act, player *p );
void spellcasting_do_turn( player_activity *act, player *p );
void study_spell_do_turn( player_activity *act, player *p );
void read_do_turn( player_activity *act, player *p );
void wait_stamina_do_turn( player_activity *act, player *p );
// defined in activity_handlers.cpp
extern const std::map< activity_id, std::function<void( player_activity *, player * )> >
do_turn_functions;
/** activity_finish functions: */
void burrow_finish( player_activity *act, player *p );
void butcher_finish( player_activity *act, player *p );
void firstaid_finish( player_activity *act, player *p );
void fish_finish( player_activity *act, player *p );
void forage_finish( player_activity *act, player *p );
void hotwire_finish( player_activity *act, player *p );
void longsalvage_finish( player_activity *act, player *p );
void pulp_finish( player_activity *act, player *p );
void make_zlave_finish( player_activity *act, player *p );
void pickaxe_finish( player_activity *act, player *p );
void reload_finish( player_activity *act, player *p );
void start_fire_finish( player_activity *act, player *p );
void train_finish( player_activity *act, player *p );
void milk_finish( player_activity *act, player *p );
void shear_finish( player_activity *act, player *p );
void vehicle_finish( player_activity *act, player *p );
void start_engines_finish( player_activity *act, player *p );
void churn_finish( player_activity *act, player *p );
void plant_seed_finish( player_activity *act, player *p );
void oxytorch_finish( player_activity *act, player *p );
void cracking_finish( player_activity *act, player *p );
void lockpicking_finish( player_activity *act, player *p );
void repair_item_finish( player_activity *act, player *p );
void mend_item_finish( player_activity *act, player *p );
void gunmod_add_finish( player_activity *act, player *p );
void toolmod_add_finish( player_activity *act, player *p );
void clear_rubble_finish( player_activity *act, player *p );
void meditate_finish( player_activity *act, player *p );
void read_finish( player_activity *act, player *p );
void wait_finish( player_activity *act, player *p );
void wait_weather_finish( player_activity *act, player *p );
void wait_npc_finish( player_activity *act, player *p );
void wait_stamina_finish( player_activity *act, player *p );
void socialize_finish( player_activity *act, player *p );
void try_sleep_finish( player_activity *act, player *p );
void operation_finish( player_activity *act, player *p );
void vibe_finish( player_activity *act, player *p );
void hand_crank_finish( player_activity *act, player *p );
void atm_finish( player_activity *act, player *p );
void eat_menu_finish( player_activity *act, player *p );
void washing_finish( player_activity *act, player *p );
void hacksaw_finish( player_activity *act, player *p );
void pry_nails_finish( player_activity *act, player *p );
void chop_tree_finish( player_activity *act, player *p );
void chop_logs_finish( player_activity *act, player *p );
void chop_planks_finish( player_activity *act, player *p );
void jackhammer_finish( player_activity *act, player *p );
void fill_pit_finish( player_activity *act, player *p );
void play_with_pet_finish( player_activity *act, player *p );
void shaving_finish( player_activity *act, player *p );
void haircut_finish( player_activity *act, player *p );
void unload_mag_finish( player_activity *act, player *p );
void robot_control_finish( player_activity *act, player *p );
void mind_splicer_finish( player_activity *act, player *p );
void spellcasting_finish( player_activity *act, player *p );
void study_spell_finish( player_activity *act, player *p );
void try_sleep_query( player_activity *act, player *p );
// defined in activity_handlers.cpp
extern const std::map< activity_id, std::function<void( player_activity *, player * )> >
finish_functions;
// HACK: This is a hack to provide fake items
// from vehicles or furniture until
// `repair_activity_actor` would be implemented.
//
// TODO (https://github.com/cataclysmbnteam/Cataclysm-BN/issues/1612):
// Remove that repair code after repair_activity_actor.
namespace repair_activity_hack
{
void patch_activity_for_vehicle_welder(
player_activity &activity,
const tripoint &veh_part_position,
const vehicle &veh,
int interact_part_idx
);
void patch_activity_for_furniture( player_activity &activity,
const tripoint &furniture_position,
const itype_id &itt );
} // namespace repair_activity_hack
} // namespace activity_handlers
#endif // CATA_SRC_ACTIVITY_HANDLERS_H