nanoMMO 0.97.8
Building an MMO: The Engineering Series
Loading...
Searching...
No Matches
film.h
Go to the documentation of this file.
1#ifndef NANOMMO_TOOLS_CINEMA_FILM_H_
2#define NANOMMO_TOOLS_CINEMA_FILM_H_
3
4#include <raylib.h>
5
6#include <string>
7#include <vector>
8
9#include "absl/status/statusor.h"
10#include "content/content.h"
11#include "protocol/nanommo.pb.h"
12#include "terrain/terrain.h"
13#include "tools/cinema/film.pb.h"
14
15namespace nanommo::cinema {
16
17/// The shots in a text file, as the content files are written.
18absl::StatusOr<Film> ReadFilm(const std::string& path);
19
20/// The land a shot is in, by its place in kLands.
21int LandOf(const Shot& shot);
22
23/// The land's terrain, as the server builds it for the first world.
24Terrain TerrainOf(int land);
25
26/// How fast the game runs at that second of the shot.
27float SpeedAt(const Shot& shot, float seconds);
28
29/// The game's clock, which runs as fast as the shot's pace says against the
30/// film's.
31class Clock {
32 public:
33 explicit Clock(const Shot& shot) : shot_(shot), game_(shot.from()) {}
34
35 /// Moves the film on by the seconds, and gives how far the game moved.
36 float Advance(float seconds);
37
38 float film() const { return film_; }
39 float game() const { return game_; }
40
41 private:
42 const Shot& shot_;
43 float film_ = 0.0f;
44 float game_ = 0.0f;
45};
46
47/// The point in the land, with its height worked out from the ground or the
48/// sea.
49Vector3 Place(const Point& point, const Terrain& terrain);
50
51/// Where the camera is at that second of the shot, and what it looks at: the
52/// tall camera's, for a tall picture.
53Camera3D CameraAt(const Shot& shot, float seconds, bool tall,
54 const Terrain& terrain);
55
56/// A shot's world, played out on the game's clock. Players go where their
57/// legs take them and use their skills when the shot says. Monsters stand,
58/// walk their legs, or charge the player they're set on and swing at them in
59/// reach, and the skills' hits land on them as the server's would: knocked
60/// back by a push, falling at their last hit.
61class Stage {
62 public:
63 Stage(const Shot& shot, const Content& content);
64
65 /// Plays the world on to that moment, which can't be before the last, and
66 /// gives it as the server would send it.
67 protocol::World At(float game);
68
69 private:
70 struct Foe {
71 Monster spec;
72 Vector2 at;
73 float yaw = 0.0f;
74 uint32_t hits = 1;
75 bool fallen = false;
76 protocol::Motion motion = protocol::MOTION_IDLE;
77 /// While it's knocked back: from where, to where, and since when.
78 Vector2 pushed_from{};
79 Vector2 pushed_to{};
80 float pushed_at = -1.0f;
81 };
82
83 /// What a cast does, from its skill, or its weapon's swing for a skill
84 /// that swings it.
85 struct Blow {
86 float lasts = 0.0f;
87 float lands = 0.0f;
88 float reach = 0.0f;
89 bool all = false;
90 float push = 0.0f;
91 float arc = 0.0f;
92 };
93 Blow BlowOf(const Player& player, const Cast& cast) const;
94
95 /// Where the player is at that moment of the game.
96 Vector2 PlayerAt(int player, float game) const;
97
98 void Step(float from, float to);
99 void Land(int player, const Cast& cast, float game);
100
101 const Shot& shot_;
102 const Content& content_;
103 std::vector<Foe> foes_;
104 float now_ = 0.0f;
105};
106
107} // namespace nanommo::cinema
108
109#endif // NANOMMO_TOOLS_CINEMA_FILM_H_
float Advance(float seconds)
Moves the film on by the seconds, and gives how far the game moved.
Definition film.cc:199
float game() const
Definition film.h:39
float film() const
Definition film.h:38
Clock(const Shot &shot)
Definition film.h:33
Stage(const Shot &shot, const Content &content)
Definition film.cc:271
protocol::World At(float game)
Definition film.cc:481
Camera3D CameraAt(const Shot &shot, float seconds, bool tall, const Terrain &terrain)
Definition film.cc:253
Vector3 Place(const Point &point, const Terrain &terrain)
Definition film.cc:212
float SpeedAt(const Shot &shot, float seconds)
How fast the game runs at that second of the shot.
Definition film.cc:180
int LandOf(const Shot &shot)
The land a shot is in, by its place in kLands.
Definition film.cc:174
Terrain TerrainOf(int land)
The land's terrain, as the server builds it for the first world.
Definition film.cc:176
absl::StatusOr< Film > ReadFilm(const std::string &path)
The shots in a text file, as the content files are written.
Definition film.cc:143