forked from CleverRaven/Cataclysm-DDA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gun_mode.h
60 lines (48 loc) · 1.49 KB
/
gun_mode.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
#pragma once
#ifndef CATA_SRC_GUN_MODE_H
#define CATA_SRC_GUN_MODE_H
#include <set>
#include <string>
#include "translations.h"
class item;
class gun_mode
{
private:
translation name_;
public:
/** pointer to item providing this mode - base gun or attached gunmod */
item *target = nullptr;
/** burst size for is_gun() firearms, or melee range for is_melee() weapons */
int qty = 0;
/** flags change behavior of gun mode, e.g. MELEE for bayonets that make a reach attack instead of firing - these are **not** equivalent to item flags! */
std::set<std::string> flags;
gun_mode() = default;
gun_mode( const translation &n, item *target, int qty, const std::set<std::string> &flags ) :
name_( n ),
target( target ),
qty( qty ),
flags( flags ) {}
/** if true perform a melee attach as opposed to shooting */
bool melee() const {
return flags.count( "MELEE" );
}
explicit operator bool() const {
return target != nullptr;
}
item &operator*() {
return *target;
}
const item &operator*() const {
return *target;
}
item *operator->() {
return target;
}
const item *operator->() const {
return target;
}
std::string tname() const {
return name_.translated();
}
};
#endif // CATA_SRC_GUN_MODE_H