-
Notifications
You must be signed in to change notification settings - Fork 290
/
Copy pathactive_tile_data.h
65 lines (51 loc) · 1.7 KB
/
active_tile_data.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
#pragma once
#ifndef CATA_SRC_ACTIVE_TILE_DATA_H
#define CATA_SRC_ACTIVE_TILE_DATA_H
#include <string>
#include "calendar.h"
#include "coordinates.h"
class JsonObject;
class JsonOut;
struct tripoint;
class distribution_grid;
class active_tile_data
{
public:
static active_tile_data *create( const std::string &id );
private:
time_point last_updated;
protected:
/**
* @param to the time to update to
* @param p absolute map coordinates (@ref map::getabs) of the tile being updated
* @param grid distribution grid being updated, containing the tile being updated
*/
virtual void update_internal( time_point to, const tripoint_abs_ms &p,
distribution_grid &grid ) = 0;
public:
void update( time_point to, const tripoint_abs_ms &p, distribution_grid &grid ) {
update_internal( to, p, grid );
last_updated = to;
}
time_point get_last_updated() {
return last_updated;
}
void set_last_updated( time_point t ) {
last_updated = t;
}
void serialize( JsonOut &jsout ) const;
void deserialize( JsonIn &jsin );
virtual ~active_tile_data();
virtual active_tile_data *clone() const = 0;
virtual const std::string &get_type() const = 0;
virtual void store( JsonOut &jsout ) const = 0;
virtual void load( JsonObject &jo ) = 0;
};
// TODO: Better place for this
namespace active_tiles
{
// TODO: Don't return a raw pointer
template <typename T = active_tile_data>
T * furn_at( const tripoint_abs_ms &pos );
} // namespace active_tiles
#endif // CATA_SRC_ACTIVE_TILE_DATA_H