nanoMMO 0.97.8
Building an MMO: The Engineering Series
Loading...
Searching...
No Matches
telegraphs.h
Go to the documentation of this file.
1#ifndef NANOMMO_CLIENT_TELEGRAPHS_H_
2#define NANOMMO_CLIENT_TELEGRAPHS_H_
3
4#include <cstdint>
5#include <map>
6
7#include "content/monsters.h"
8#include "protocol/nanommo.pb.h"
9#include "terrain/lands.h"
10
11namespace nanommo {
12
13/// A monster's skill on its way: its shape, where the monster stood and the
14/// way it faced as it started, and how long until it lands, in seconds.
15struct Telegraph {
16 monsters::Skill skill;
18 float yaw = 0.0f;
19 float left = 0.0f;
20
21 /// How far its shape has filled, from 0 as it shows to 1 as it lands.
22 float Filled() const;
23};
24
25/// The monsters' skills on their way, from the worlds the server sends, with
26/// the skills of each kind of monster from the content.
28 public:
29 /// A world can come this late, in seconds, and say that a skill has more
30 /// left than we've counted down to. One that says more is the next skill.
31 static constexpr float kLate = 0.25f;
32
33 explicit Telegraphs(const MonsterTable& monsters) : kinds_(monsters.kinds) {}
34
35 /// Follows the newest world, the seconds since the last frame on. A skill
36 /// that's new shows where its monster stands, the way it faces, and stays
37 /// there however the monster moves. Between worlds, each counts down by
38 /// itself. One goes once it's landed, or its monster dies or goes.
39 void Update(const protocol::World& world, float seconds);
40
41 /// By the monster's id.
42 const std::map<uint32_t, Telegraph>& shown() const { return shown_; }
43
44 private:
45 std::map<uint32_t, monsters::Kind> kinds_;
46 std::map<uint32_t, Telegraph> shown_;
47};
48
49} // namespace nanommo
50
51#endif // NANOMMO_CLIENT_TELEGRAPHS_H_
Telegraphs(const MonsterTable &monsters)
Definition telegraphs.h:33
static constexpr float kLate
Definition telegraphs.h:31
void Update(const protocol::World &world, float seconds)
Definition telegraphs.cc:15
const std::map< uint32_t, Telegraph > & shown() const
By the monster's id.
Definition telegraphs.h:42
Definition chat.cc:9
The kinds of monster, by id, and where they spawn.
Definition monsters.h:17
In metres from the middle of a land.
Definition lands.h:13
monsters::Skill skill
Definition telegraphs.h:16
float Filled() const
How far its shape has filled, from 0 as it shows to 1 as it lands.
Definition telegraphs.cc:10