nanoMMO 0.97.8
Building an MMO: The Engineering Series
Loading...
Searching...
No Matches
figures.h
Go to the documentation of this file.
1#ifndef NANOMMO_CONTENT_FIGURES_H_
2#define NANOMMO_CONTENT_FIGURES_H_
3
4#include <cstdint>
5#include <optional>
6#include <string_view>
7#include <vector>
8
9#include "absl/status/status.h"
10#include "absl/status/statusor.h"
11#include "content/figures.pb.h"
12#include "google/protobuf/repeated_ptr_field.h"
13
14namespace nanommo {
15
16/// What's wrong with a part, if anything: no shape, no bone to move with, a
17/// limb with no end or no thickness, or a ball with no size.
18absl::Status CheckPart(const figures::Part& part);
19
20/// The figures in text format, or what's wrong with them: a field
21/// figures.proto doesn't have, or a part of the body or of a way to wear the
22/// hair that's wrong.
23absl::StatusOr<figures::Figures> ParseFigures(std::string_view text);
24
25/// What a player looks like under what they wear, from the figures' lists,
26/// as they chose it or as their id picks it, so that every client draws them
27/// the same.
28struct Features {
29 /// As 0xRRGGBBAA: white, when there are none to pick from.
30 uint32_t skin = 0xFFFFFFFF;
31 uint32_t hair_color = 0xFFFFFFFF;
32 /// Which way they wear their hair, from the figures' hairs, or -1 when
33 /// there are none.
34 int hair = -1;
35 /// Which of the rig's builds, wrapped round to what there is, or none for
36 /// the one the figure's id picks.
37 std::optional<uint32_t> build;
38 /// Which of the players' colours their clothes are dyed in, wrapped round
39 /// to what there is, or none for the one the figure's id picks.
40 std::optional<uint32_t> shirt;
41};
42Features FeaturesOf(const figures::Figures& figures, uint32_t id);
43
44/// The parts, each mirrored one followed by its twin on the right, on the
45/// right's bones, with its offsets the other way across.
46std::vector<figures::Part> Unfold(
47 const google::protobuf::RepeatedPtrField<figures::Part>& parts);
48
49} // namespace nanommo
50
51#endif // NANOMMO_CONTENT_FIGURES_H_
Definition chat.cc:9
absl::Status CheckPart(const figures::Part &part)
Definition figures.cc:24
absl::StatusOr< figures::Figures > ParseFigures(std::string_view text)
Definition figures.cc:50
std::vector< figures::Part > Unfold(const google::protobuf::RepeatedPtrField< figures::Part > &parts)
Definition figures.cc:96
Features FeaturesOf(const figures::Figures &figures, uint32_t id)
Definition figures.cc:74
std::optional< uint32_t > shirt
Definition figures.h:40
uint32_t hair_color
Definition figures.h:31
std::optional< uint32_t > build
Definition figures.h:37
uint32_t skin
As 0xRRGGBBAA: white, when there are none to pick from.
Definition figures.h:30