Wrath of Zeus
Made by Torchlight Games for CSE 125 SP24
Loading...
Searching...
No Matches
object.hpp
Go to the documentation of this file.
1#pragma once
2
10
11// From sharedobject.hpp
12class SharedObject;
13
14// From sharedobject.hpp
15struct SharedPhysics;
16
17class ServerGameState; // forward declaration to use ptr as parameter
18
23struct Physics {
39 glm::vec3 corner, glm::vec3 facing,
40 glm::vec3 dimensions = glm::vec3(1.0f)):
41 shared{.corner=corner, .facing=facing, .dimensions=dimensions},
42 movable(movable), feels_gravity(true), velocity(glm::vec3(0.0f)), velocityMultiplier(glm::vec3(1.0f)), \
43 currTickVelocity(glm::vec3(0.0f)), nauseous(1.0f), collider(collider)
44 {}
45
51
56 bool movable;
57
58
64
68 glm::vec3 velocity;
69
74
79
83 float nauseous;
84
89
90 /* Debugger Methods */
91 std::string to_string(unsigned int tab_offset);
92 std::string to_string() { return this->to_string(0); }
93};
94
95class Object {
96public:
102
108
114
119
124
130
137
142
147 std::vector<glm::ivec2> gridCellPositions;
148
154
161 virtual ~Object();
162
169 void setModel(ModelType type);
170
175 static std::unordered_map<ModelType, glm::vec3> models;
176
181 virtual SharedObject toShared();
182
189 virtual void doCollision(Object* other, ServerGameState& state) {};
190
191
192 /* Debugger Methods */
193
194 std::string to_string(unsigned int tab_offset);
195 std::string to_string() { return this->to_string(0); }
196};
197
198enum class Direction {
199 LEFT,
200 UP,
201 DOWN,
202 RIGHT
203};
204
205glm::vec3 directionToFacing(const Direction& direction);
Definition: object.hpp:95
ObjectType type
Identifies this object's type (derived class)
Definition: object.hpp:118
std::string to_string()
Definition: object.hpp:195
static std::unordered_map< ModelType, glm::vec3 > models
Maps from ModelType to a model's dimensions as read from the model files. (At present,...
Definition: object.hpp:175
bool is_sprinting
used to determine if the player is sprinting for animation purposes
Definition: object.hpp:141
virtual SharedObject toShared()
Generates a SharedObject representation of this object.
Definition: object.cpp:67
virtual void doCollision(Object *other, ServerGameState &state)
Code to run when this object collides with another.
Definition: object.hpp:189
AnimState animState
Object's animation state and current action. For non-animated objects, this defaults as AnimState::Id...
Definition: object.hpp:136
void setModel(ModelType type)
Sets this Object's model and initializes its dimensions to the given model's default dimensions.
Definition: object.cpp:22
EntityID globalID
Unique object ID (used to index into the ServerGameState::objects vector)
Definition: object.hpp:101
float distance_moved
Distance moved, for use in deciding when to play footsteps IMPORTANT: reset every time a footstep sou...
Definition: object.hpp:153
std::vector< glm::ivec2 > gridCellPositions
Vector of (x, y) positions of GridCells currently occupied by this object.
Definition: object.hpp:147
ModelType modelType
Object's render model type (specifies this Object's render model to the client)
Definition: object.hpp:129
virtual ~Object()
Definition: object.cpp:20
Physics physics
Object's Physics-related properties.
Definition: object.hpp:123
SpecificID typeID
Type-specific Object ID (used to index into the type-specific objects vector in ServerGameState)
Definition: object.hpp:107
MovableID movableID
Movable ID (used to index into the movable objects vector in ServerGameState)
Definition: object.hpp:113
The ServerGameState class contains all abstract game state data and logic for a single game state ins...
Definition: servergamestate.hpp:43
Representation of the Object class used by ServerGameState, containing exactly the subset of Object d...
Definition: sharedobject.hpp:302
Collider
Enumeration to identify collider shape.
Definition: collider.hpp:10
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glad.h:1531
Direction
Definition: object.hpp:198
glm::vec3 directionToFacing(const Direction &direction)
Definition: object.cpp:119
ModelType
Enumeration of every render model in the game.
Definition: sharedmodel.hpp:6
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
AnimState
Definition: sharedobject.hpp:261
Physics struct that contains all movement / collision related data for a particular object.
Definition: object.hpp:23
SharedPhysics shared
Shared physics properties (needed by both the server and the client)
Definition: object.hpp:50
float nauseous
Factor for potion of nausea.
Definition: object.hpp:83
glm::vec3 velocityMultiplier
3-D vector that denotes this object's velocity multiplier.
Definition: object.hpp:73
std::string to_string()
Definition: object.hpp:92
glm::vec3 currTickVelocity
Tick velocity for knockbacks.
Definition: object.hpp:78
glm::vec3 velocity
3-D vector that denotes this object's current velocity.
Definition: object.hpp:68
Collider collider
This object's collider type.
Definition: object.hpp:88
Physics(bool movable, Collider collider, glm::vec3 corner, glm::vec3 facing, glm::vec3 dimensions=glm::vec3(1.0f))
constructor for Physics
Definition: object.hpp:38
bool movable
true if the object that contains this Physics struct can move and false otherwise
Definition: object.hpp:56
bool feels_gravity
true if the object that contains this Physics struct feels gravity and false otherwise
Definition: object.hpp:63
Definition: sharedobject.hpp:179
uint32_t MovableID
Object ID within an movable SmartVector (used by ServerGameState's ObjectManager)
Definition: typedefs.hpp:22
uint32_t EntityID
Global Object ID (when the server or client references an object with a particular EntityID,...
Definition: typedefs.hpp:9
uint32_t SpecificID
Object ID within an object type-specific SmartVector (used by ServerGameState's ObjectManager)
Definition: typedefs.hpp:16