forked from aburch/simutrans
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpedestrian_desc.h
62 lines (50 loc) · 1.35 KB
/
pedestrian_desc.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
/*
* This file is part of the Simutrans project under the Artistic License.
* (see LICENSE.txt)
*/
#ifndef DESCRIPTOR_PEDESTRIAN_DESC_H
#define DESCRIPTOR_PEDESTRIAN_DESC_H
#include "obj_base_desc.h"
#include "image_array.h"
#include "image_list.h"
#include "../dataobj/ribi.h"
#include "../network/checksum.h"
/**
* Pedestrians.
*
* Child nodes:
* 0 Name
* 1 Copyright
* 2 Image-list or 2d
*/
class pedestrian_desc_t : public obj_desc_timelined_t {
friend class pedestrian_reader_t;
uint16 distribution_weight;
uint16 steps_per_frame;
uint16 offset;
public:
image_id get_image_id(ribi_t::dir dir, uint16 phase=0) const
{
image_t const* image = NULL;
if (steps_per_frame > 0) {
image = get_child<image_array_t>(2)->get_image(dir, phase);
}
else {
image = get_child<image_list_t>(2)->get_image(dir);
}
return image != NULL ? image->get_id() : IMG_EMPTY;
}
uint16 get_distribution_weight() const { return distribution_weight; }
uint16 get_steps_per_frame() const { return steps_per_frame; }
uint16 get_animation_count(ribi_t::dir dir) const
{
return steps_per_frame>0 ? get_child<image_array_t>(2)->get_list(dir)->get_count() : 1;
}
void calc_checksum(checksum_t *chk) const
{
chk->input(distribution_weight);
}
// images are offset steps away from boundary
uint16 get_offset() const { return offset; }
};
#endif