Wrath of Zeus
Made by Torchlight Games for CSE 125 SP24
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes
Trap Class Referenceabstract

#include <trap.hpp>

Inheritance diagram for Trap:
Object ArrowTrap FakeWall FireballTrap FloorSpike Lava SpikeTrap TeleporterTrap

Public Member Functions

 Trap (ObjectType type, bool movable, glm::vec3 corner, Collider collider, ModelType model, glm::vec3 dimensions=glm::vec3(1.0f))
 
virtual bool shouldTrigger (ServerGameState &state)=0
 
virtual void trigger (ServerGameState &state)
 
virtual bool shouldReset (ServerGameState &state)=0
 
virtual void reset (ServerGameState &state)
 
SharedObject toShared () override
 Generates a SharedObject representation of this object. More...
 
void setIsDMTrap (bool is_dm_trap)
 
void setIsDMTrapHover (bool is_dm_trap_hover)
 
void setExpiration (std::chrono::time_point< std::chrono::system_clock > expiration)
 
bool getIsDMTrap ()
 
std::chrono::time_point< std::chrono::system_clock > getExpiration ()
 
- Public Member Functions inherited from Object
 Object (ObjectType type, Physics physics, ModelType modelType)
 
virtual ~Object ()
 
void setModel (ModelType type)
 Sets this Object's model and initializes its dimensions to the given model's default dimensions. More...
 
virtual SharedObject toShared ()
 Generates a SharedObject representation of this object. More...
 
virtual void doCollision (Object *other, ServerGameState &state)
 Code to run when this object collides with another. More...
 
std::string to_string (unsigned int tab_offset)
 
std::string to_string ()
 

Protected Attributes

bool is_dm_trap
 
std::chrono::time_point< std::chrono::system_clock > expiration
 
SharedTrapInfo info
 

Additional Inherited Members

- Data Fields inherited from Object
EntityID globalID {}
 Unique object ID (used to index into the ServerGameState::objects vector) More...
 
SpecificID typeID {}
 Type-specific Object ID (used to index into the type-specific objects vector in ServerGameState) More...
 
MovableID movableID {}
 Movable ID (used to index into the movable objects vector in ServerGameState) More...
 
ObjectType type
 Identifies this object's type (derived class) More...
 
Physics physics
 Object's Physics-related properties. More...
 
ModelType modelType
 Object's render model type (specifies this Object's render model to the client) More...
 
AnimState animState
 Object's animation state and current action. For non-animated objects, this defaults as AnimState::IdleAnim. More...
 
bool is_sprinting
 used to determine if the player is sprinting for animation purposes More...
 
std::vector< glm::ivec2 > gridCellPositions
 Vector of (x, y) positions of GridCells currently occupied by this object. More...
 
float distance_moved
 Distance moved, for use in deciding when to play footsteps IMPORTANT: reset every time a footstep sound is performed for objects that play foosteps. More...
 
- Static Public Attributes inherited from Object
static std::unordered_map< ModelType, glm::vec3 > models
 Maps from ModelType to a model's dimensions as read from the model files. (At present, these values are hard-coded in object.cpp) More...
 

Constructor & Destructor Documentation

◆ Trap()

Trap::Trap ( ObjectType  type,
bool  movable,
glm::vec3  corner,
Collider  collider,
ModelType  model,
glm::vec3  dimensions = glm::vec3(1.0f) 
)
Parameters
typeWhat type of trap this is
movableWhether or not the trap should be initialized being affected by gravity/velocity
cornerCorner position of the trap
collidercollider type for the trap
modelWhat model should be used to render the trap
dimensionsDimensions to use for the trap, if it won't be overridden by the model info

Member Function Documentation

◆ getExpiration()

std::chrono::time_point< std::chrono::system_clock > Trap::getExpiration ( )

Gets the expiration time of this trap

Returns
the expiration time of this trap

◆ getIsDMTrap()

bool Trap::getIsDMTrap ( )

Gets if this trap is a DM trap or not

Returns
True if the trap is a DM trap and false otherwise

◆ reset()

void Trap::reset ( ServerGameState state)
virtual

Logic to reset the trap

At the highest level, this version just sets the triggered flag to false. Derivations of this should do additional resetting logic, and potentially call this Base class version as well to reset the common logic for all traps (currently just the triggered variable)

Parameters
stateGameState in case the trap needs to use the state for that

Reimplemented in ArrowTrap, FireballTrap, SpikeTrap, and TeleporterTrap.

◆ setExpiration()

void Trap::setExpiration ( std::chrono::time_point< std::chrono::system_clock >  expiration)

Set the expiration of this trap

Parameters
expirationtime

◆ setIsDMTrap()

void Trap::setIsDMTrap ( bool  is_dm_trap)

Set the is_dm_trap field

Parameters
booleanfor if this trap is a DM trap or not

◆ setIsDMTrapHover()

void Trap::setIsDMTrapHover ( bool  is_dm_trap_hover)

Set the SharedTrapInfo info dm_hover field

Parameters
booleanfor if this trap is a a DM hover or not

◆ shouldReset()

virtual bool Trap::shouldReset ( ServerGameState state)
pure virtual

Resets the trap

Parameters
stateGameState, in case you need that to determine if the trap should reset
Returns
True if the trap should reset, false otherwise

Implemented in ArrowTrap, FakeWall, FireballTrap, FloorSpike, Lava, SpikeTrap, and TeleporterTrap.

◆ shouldTrigger()

virtual bool Trap::shouldTrigger ( ServerGameState state)
pure virtual

Determines if the trap should be triggered

Parameters
stateGameState, in case you need that to determine if the trap should trigger
Returns
True if the trap should trigger, false otherwise

Implemented in ArrowTrap, FakeWall, FireballTrap, FloorSpike, Lava, SpikeTrap, and TeleporterTrap.

◆ toShared()

SharedObject Trap::toShared ( )
overridevirtual

Generates a SharedObject representation of this object.

Returns
A SharedObject representation of this object.

Reimplemented from Object.

◆ trigger()

void Trap::trigger ( ServerGameState state)
virtual

Activates the trap

At the highest level, this just sets the triggered variable to true. Subclass versions of this will also probably want to call this function to set the triggered variable, in addition to any other common flags we add in later.

Parameters
stateState in case triggering the trap needs to affect the gamestate

Reimplemented in ArrowTrap, FireballTrap, SpikeTrap, and TeleporterTrap.

Field Documentation

◆ expiration

std::chrono::time_point<std::chrono::system_clock> Trap::expiration
protected

the expiration time of this trap

◆ info

SharedTrapInfo Trap::info
protected

◆ is_dm_trap

bool Trap::is_dm_trap
protected

is this trap a DM trap?


The documentation for this class was generated from the following files: