forked from cataclysmbnteam/Cataclysm-BN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scent_map.h
88 lines (70 loc) · 2.38 KB
/
scent_map.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
#pragma once
#ifndef CATA_SRC_SCENT_MAP_H
#define CATA_SRC_SCENT_MAP_H
#include <array>
#include <optional>
#include <set>
#include <string>
#include <vector>
#include "calendar.h"
#include "enums.h" // IWYU pragma: keep
#include "game_constants.h"
#include "point.h"
#include "type_id.h"
static constexpr int SCENT_MAP_Z_REACH = 1;
class game;
class map;
class JsonObject;
namespace catacurses
{
class window;
} // namespace catacurses
class scent_type
{
public:
static void load_scent_type( const JsonObject &jo, const std::string &src );
void load( const JsonObject &jo, const std::string & );
static const std::vector<scent_type> &get_all();
static void check_scent_consistency();
bool was_loaded = false;
scenttype_id id;
std::set<species_id> receptive_species;
static void reset();
};
class scent_map
{
protected:
template<typename T>
using scent_array = std::array<std::array<T, MAPSIZE_Y>, MAPSIZE_X>;
scent_array<int> grscent;
scenttype_id typescent;
std::optional<tripoint> player_last_position;
time_point player_last_moved = calendar::before_time_starts;
const game &gm;
public:
scent_map( const game &g ) : gm( g ) { }
void deserialize( const std::string &data, bool is_type = false );
std::string serialize( bool is_type = false ) const;
void draw( const catacurses::window &win, int div, const tripoint ¢er ) const;
void update( const tripoint ¢er, map &m );
void reset();
void decay();
void shift( point sm_shift );
/**
* Get the scent value at the given position.
* An invalid position is allows and will yield a 0 value.
* The coordinate system is the same as the @ref map (`g->m`) uses.
*/
/**@{*/
void set( const tripoint &p, int value, const scenttype_id &type = scenttype_id() );
int get( const tripoint &p ) const;
/**@}*/
void set_unsafe( const tripoint &p, int value, const scenttype_id &type = scenttype_id() );
int get_unsafe( const tripoint &p ) const;
scenttype_id get_type( const tripoint &p ) const;
bool inbounds( const tripoint &p ) const;
bool inbounds( point p ) const {
return inbounds( tripoint( p, 0 ) );
}
};
#endif // CATA_SRC_SCENT_MAP_H