Wrath of Zeus
Made by Torchlight Games for CSE 125 SP24
Loading...
Searching...
No Matches
sharedobject.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <optional>
4#include <algorithm>
5#include <glm/glm.hpp>
6
13#include <chrono>
14
19enum class ObjectType {
20 Object, // Generic object type (base class)
22 Potion,
23 Player,
24 Enemy,
31 Lava,
35 Spell,
36 Slime,
38 Python,
39 Item,
40 Exit,
41 Orb,
42 Weapon,
44 Mirror
45};
46
53
56 health(0,0,0), speed(0,0,0) {}
59
62
63 DEF_SERIALIZE(Archive& ar, const unsigned int version) {
64 ar & health & speed;
65 }
66};
67
69public:
70 SharedStatuses() = default;
71
76 void addStatus(Status st, size_t len);
77
83 std::vector<std::string> getStatusStrings() const;
84
88 void tickStatus();
89
94 size_t getStatusLength(Status st) const;
95
96 DEF_SERIALIZE(Archive& ar, const unsigned int version) {
97 ar & map;
98 }
99
100private:
101 std::unordered_map<Status, size_t> map;
102};
103
104
105using UsedItemsMap = std::unordered_map<SpecificID, std::pair<ModelType, double>>;
106
108 // need to share itemtype data...
111 std::vector<ModelType> inventory; // For GUI model
112 std::vector<int> usesRemaining; // For GUI text description
113 UsedItemsMap usedItems; // For GUI effect duration
114
118 bool hasOrb;
119
120 DEF_SERIALIZE(Archive& ar, const unsigned int version) {
122 }
123};
124
126 // need to share itemtype data...
129 std::vector<ModelType> inventory;
130 std::unordered_map<CellType, std::time_t> trapsInCooldown;
131 std::unordered_map<CellType, int> trapsCooldown;
133
134 DEF_SERIALIZE(Archive& ar, const unsigned int version) {
136 }
137};
138
140 bool held; // for rendering
141 bool used; // for rendering
143
144 DEF_SERIALIZE(Archive& ar, const unsigned int version) {
146 }
147};
148
152
153 DEF_SERIALIZE(Archive& ar, const unsigned int version) {
154 ar& attacked& lightning;
155 }
156};
157
158enum class SurfaceType {
159 Wall,
160 Floor,
161 Ceiling,
162 Pillar,
163};
164
171
173
174 DEF_SERIALIZE(Archive& ar, const unsigned int version) {
176 }
177};
178
184 glm::vec3 corner;
185
189 glm::vec3 facing;
190
197 glm::vec3 dimensions;
198
203 glm::vec3 getCenterPosition() const;
204
205 DEF_SERIALIZE(Archive& ar, const unsigned int version) {
206 ar& corner& facing & dimensions;
207 }
208};
209
213
214 DEF_SERIALIZE(Archive& ar, const unsigned int version) {
215 ar & triggered & dm_hover;
216 }
217};
218
221 time_t respawn_time; // unix timestamp in ms when the player will be respawned
222 bool render; // for invis potion
223 bool used_mirror_to_reflect_lightning; // To tell the player that they successfully reflected lightning
224
225 DEF_SERIALIZE(Archive& ar, const unsigned int version) {
227 }
228};
229
232 // lighting properties of that the light source
233 // emits
234 glm::vec3 ambient_color;
235 glm::vec3 diffuse_color;
236 glm::vec3 specular_color; // shiny effects
237 // these two affect the dropoff of the light intensity
238 // as distance increases
241
242 bool is_cut = false;
243
244 DEF_SERIALIZE(Archive& ar, const int version) {
247 }
248};
249
254 bool open;
255
256 DEF_SERIALIZE(Archive& ar, const unsigned int version) {
257 ar & open;
258 }
259};
260
261enum class AnimState {
262 IdleAnim,
263 WalkAnim,
265 JumpAnim,
266 LandAnim,
270};
271
280
282
283 DEF_SERIALIZE(Archive& ar, const unsigned int version) {
285 }
286};
287
288
290
291 float angle;
292
293 DEF_SERIALIZE(Archive& ar, const unsigned int version) {
294 ar& angle;
295 }
296};
297
303public:
309
310 boost::optional<SharedStats> stats;
311 boost::optional<SharedItemInfo> iteminfo;
312 boost::optional<SharedSolidSurface> solidSurface;
313 boost::optional<SharedTrapInfo> trapInfo;
314 boost::optional<SharedPlayerInfo> playerInfo;
315 boost::optional<SharedInventory> inventoryInfo;
316 boost::optional<SharedTrapInventory> trapInventoryInfo;
317 boost::optional<SharedPointLightInfo> pointLightInfo;
318 boost::optional<SharedStatuses> statuses;
319 boost::optional<SharedExit> exit;
320 boost::optional<SharedWeaponInfo> weaponInfo;
321 boost::optional<SharedDMInfo> DMInfo;
322 boost::optional<SharedCompass> compass;
323
324 SharedObject() {} // cppcheck-suppress uninitMemberVar
326
327 DEF_SERIALIZE(Archive& ar, const unsigned int version) {
328 ar & globalID & type & physics & modelType & animState & stats &
332 }
333private:
334};
Definition: mirror.hpp:6
Representation of the Object class used by ServerGameState, containing exactly the subset of Object d...
Definition: sharedobject.hpp:302
ModelType modelType
Definition: sharedobject.hpp:307
EntityID globalID
Definition: sharedobject.hpp:304
boost::optional< SharedTrapInventory > trapInventoryInfo
Definition: sharedobject.hpp:316
AnimState animState
Definition: sharedobject.hpp:308
boost::optional< SharedTrapInfo > trapInfo
Definition: sharedobject.hpp:313
~SharedObject()
Definition: sharedobject.hpp:325
boost::optional< SharedWeaponInfo > weaponInfo
Definition: sharedobject.hpp:320
boost::optional< SharedPlayerInfo > playerInfo
Definition: sharedobject.hpp:314
DEF_SERIALIZE(Archive &ar, const unsigned int version)
Definition: sharedobject.hpp:327
boost::optional< SharedStatuses > statuses
Definition: sharedobject.hpp:318
boost::optional< SharedStats > stats
Definition: sharedobject.hpp:310
boost::optional< SharedExit > exit
Definition: sharedobject.hpp:319
boost::optional< SharedCompass > compass
Definition: sharedobject.hpp:322
boost::optional< SharedItemInfo > iteminfo
Definition: sharedobject.hpp:311
boost::optional< SharedPointLightInfo > pointLightInfo
Definition: sharedobject.hpp:317
boost::optional< SharedSolidSurface > solidSurface
Definition: sharedobject.hpp:312
SharedObject()
Definition: sharedobject.hpp:324
boost::optional< SharedInventory > inventoryInfo
Definition: sharedobject.hpp:315
SharedPhysics physics
Definition: sharedobject.hpp:306
ObjectType type
Definition: sharedobject.hpp:305
boost::optional< SharedDMInfo > DMInfo
Definition: sharedobject.hpp:321
Definition: stat.hpp:7
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glad.h:1531
ModelType
Enumeration of every render model in the game.
Definition: sharedmodel.hpp:6
SurfaceType
Definition: sharedobject.hpp:158
ObjectType
An enum for the type of an object; the fields here should match all class names in the inheritance tr...
Definition: sharedobject.hpp:19
std::unordered_map< SpecificID, std::pair< ModelType, double > > UsedItemsMap
Definition: sharedobject.hpp:105
std::string objectTypeString(ObjectType type)
Returns a string representation of the ObjectType enum.
Definition: sharedobject.cpp:5
AnimState
Definition: sharedobject.hpp:261
Status
Definition: status.hpp:5
Definition: sharedobject.hpp:289
DEF_SERIALIZE(Archive &ar, const unsigned int version)
Definition: sharedobject.hpp:293
float angle
Definition: sharedobject.hpp:291
Definition: sharedobject.hpp:272
DEF_SERIALIZE(Archive &ar, const unsigned int version)
Definition: sharedobject.hpp:283
int mana_remaining
Definition: sharedobject.hpp:281
bool paralyzed
The Dungeon Master can become paralyzed if a player used a Mirror object to reflect a lightning bolt ...
Definition: sharedobject.hpp:279
Definition: sharedobject.hpp:250
bool open
Whether the given exit is open or closed.
Definition: sharedobject.hpp:254
DEF_SERIALIZE(Archive &ar, const unsigned int version)
Definition: sharedobject.hpp:256
Definition: sharedobject.hpp:107
bool hasOrb
Denotes whether this player is carrying the Orb in their inventory.
Definition: sharedobject.hpp:118
int inventory_size
Definition: sharedobject.hpp:110
std::vector< int > usesRemaining
Definition: sharedobject.hpp:112
DEF_SERIALIZE(Archive &ar, const unsigned int version)
Definition: sharedobject.hpp:120
std::vector< ModelType > inventory
Definition: sharedobject.hpp:111
UsedItemsMap usedItems
Definition: sharedobject.hpp:113
int selected
Definition: sharedobject.hpp:109
Definition: sharedobject.hpp:139
bool used
Definition: sharedobject.hpp:141
double remaining_time
Definition: sharedobject.hpp:142
DEF_SERIALIZE(Archive &ar, const unsigned int version)
Definition: sharedobject.hpp:144
bool held
Definition: sharedobject.hpp:140
Definition: sharedobject.hpp:179
glm::vec3 facing
3-D vector that denotes this object's facing direction.
Definition: sharedobject.hpp:189
glm::vec3 getCenterPosition() const
Calculates and returns the center position of this object.
Definition: sharedobject.cpp:58
glm::vec3 corner
3-D vector that denotes this object's bottom left corner (min x and z coordinates).
Definition: sharedobject.hpp:184
DEF_SERIALIZE(Archive &ar, const unsigned int version)
Definition: sharedobject.hpp:205
glm::vec3 dimensions
3-D vector that defines a rectangular prism which outlines the object that contains this SharedPhysic...
Definition: sharedobject.hpp:197
Definition: sharedobject.hpp:219
bool used_mirror_to_reflect_lightning
Definition: sharedobject.hpp:223
bool is_alive
Definition: sharedobject.hpp:220
bool render
Definition: sharedobject.hpp:222
time_t respawn_time
Definition: sharedobject.hpp:221
DEF_SERIALIZE(Archive &ar, const unsigned int version)
Definition: sharedobject.hpp:225
Definition: sharedobject.hpp:230
DEF_SERIALIZE(Archive &ar, const int version)
Definition: sharedobject.hpp:244
glm::vec3 specular_color
Definition: sharedobject.hpp:236
float attenuation_quadratic
Definition: sharedobject.hpp:240
float intensity
Definition: sharedobject.hpp:231
float attenuation_linear
Definition: sharedobject.hpp:239
glm::vec3 ambient_color
Definition: sharedobject.hpp:234
glm::vec3 diffuse_color
Definition: sharedobject.hpp:235
bool is_cut
Definition: sharedobject.hpp:242
Definition: sharedobject.hpp:165
bool is_internal
Definition: sharedobject.hpp:172
DEF_SERIALIZE(Archive &ar, const unsigned int version)
Definition: sharedobject.hpp:174
SurfaceType surfaceType
Type of solid surface, e.g. wall, floor, ceiling, etc.(relevant for rendering)
Definition: sharedobject.hpp:170
Definition: sharedobject.hpp:54
DEF_SERIALIZE(Archive &ar, const unsigned int version)
Definition: sharedobject.hpp:63
Stat< int > health
Definition: sharedobject.hpp:60
SharedStats()
Definition: sharedobject.hpp:55
Stat< int > speed
Definition: sharedobject.hpp:61
SharedStats(Stat< int > &&health, Stat< int > &&speed)
Definition: sharedobject.hpp:57
Definition: sharedobject.hpp:68
std::vector< std::string > getStatusStrings() const
Definition: sharedobject.cpp:78
SharedStatuses()=default
void tickStatus()
Definition: sharedobject.cpp:70
size_t getStatusLength(Status st) const
Definition: sharedobject.cpp:91
DEF_SERIALIZE(Archive &ar, const unsigned int version)
Definition: sharedobject.hpp:96
void addStatus(Status st, size_t len)
Definition: sharedobject.cpp:62
Definition: sharedobject.hpp:210
bool dm_hover
Definition: sharedobject.hpp:212
DEF_SERIALIZE(Archive &ar, const unsigned int version)
Definition: sharedobject.hpp:214
bool triggered
Definition: sharedobject.hpp:211
Definition: sharedobject.hpp:125
DEF_SERIALIZE(Archive &ar, const unsigned int version)
Definition: sharedobject.hpp:134
int trapsPlaced
Definition: sharedobject.hpp:132
std::vector< ModelType > inventory
Definition: sharedobject.hpp:129
int inventory_size
Definition: sharedobject.hpp:128
std::unordered_map< CellType, int > trapsCooldown
Definition: sharedobject.hpp:131
int selected
Definition: sharedobject.hpp:127
std::unordered_map< CellType, std::time_t > trapsInCooldown
Definition: sharedobject.hpp:130
Definition: sharedobject.hpp:149
bool attacked
Definition: sharedobject.hpp:150
DEF_SERIALIZE(Archive &ar, const unsigned int version)
Definition: sharedobject.hpp:153
bool lightning
Definition: sharedobject.hpp:151
uint32_t EntityID
Global Object ID (when the server or client references an object with a particular EntityID,...
Definition: typedefs.hpp:9