CUGL 2.5
Cornell University Game Library
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
cugl::physics2::net::PhysSyncEvent Class Reference

#include <CUPhysSyncEvent.h>

Inheritance diagram for cugl::physics2::net::PhysSyncEvent:
cugl::physics2::net::NetEvent

Classes

class  Parameters
 

Public Member Functions

std::shared_ptr< NetEventnewEvent () override
 
const std::vector< Parameters > & getSyncList () const
 
void addObstacle (Uint64 id, const std::shared_ptr< physics2::Obstacle > &obs)
 
std::vector< std::byte > serialize () override
 
void deserialize (const std::vector< std::byte > &data) override
 
- Public Member Functions inherited from cugl::physics2::net::NetEvent
virtual std::shared_ptr< NetEventnewEvent ()
 
virtual std::vector< std::byte > serialize ()
 
virtual void deserialize (const std::vector< std::byte > &data)
 
Uint64 getEventTimeStamp () const
 
Uint64 getReceiveTimeStamp () const
 
const std::string getSourceId () const
 

Static Public Member Functions

static std::shared_ptr< PhysSyncEventalloc ()
 

Protected Attributes

std::vector< Parameters_syncList
 

Detailed Description

This class represents a message to synchronize obstacle positions.

This class should only be used internally by the networked physics library. It is not designed to synchronize customs state. For that, you should use GameStateEvent instead.

Member Function Documentation

◆ addObstacle()

void cugl::physics2::net::PhysSyncEvent::addObstacle ( Uint64  id,
const std::shared_ptr< physics2::Obstacle > &  obs 
)

Snapshots an obstacle's current position and velocity.

This snapshot is then added to the list for serialization.

Parameters
obsthe obstacle reference to add
idthe global id of the obstacle

◆ alloc()

static std::shared_ptr< PhysSyncEvent > cugl::physics2::net::PhysSyncEvent::alloc ( )
inlinestatic

Returns a newly allocated event of this type.

This is a static version of newEvent.

Returns
a newly allocated event of this type.

◆ deserialize()

void cugl::physics2::net::PhysSyncEvent::deserialize ( const std::vector< std::byte > &  data)
overridevirtual

Unpacks a byte vector into a list of snapshots.

These snapshots can then be used in physics synchronizations.

Parameters
datathe byte vector to deserialize

Reimplemented from cugl::physics2::net::NetEvent.

◆ getSyncList()

const std::vector< Parameters > & cugl::physics2::net::PhysSyncEvent::getSyncList ( ) const
inline

Returns a reference to the obstacle snapshots added so far.

Returns
a reference to the obstacle snapshots added so far.

◆ newEvent()

std::shared_ptr< NetEvent > cugl::physics2::net::PhysSyncEvent::newEvent ( )
inlineoverridevirtual

Returns a newly allocated event of this type.

This method is used by the NetEventController to create a new event with this type as a reference.

Note that this method is not static, unlike the alloc method present in most of CUGL. That is because we need this factory method to be polymorphic. All custom subclasses must implement this method.

Returns
a newly allocated event of this type.

Reimplemented from cugl::physics2::net::NetEvent.

◆ serialize()

std::vector< std::byte > cugl::physics2::net::PhysSyncEvent::serialize ( )
overridevirtual

Returns a byte vector serializing the current list of snapshots.

Returns
a byte vector serializing the current list of snapshots.

Reimplemented from cugl::physics2::net::NetEvent.

Member Data Documentation

◆ _syncList

std::vector<Parameters> cugl::physics2::net::PhysSyncEvent::_syncList
protected

The vector of added object snapshots.


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