RakNet  4.0
Public Member Functions | List of all members
RakNet::TM_TeamMember Class Reference

A member of one or more teams. More...

#include <TeamManager.h>

Public Member Functions

bool RequestTeam (TeamSelection teamSelection)
 Request to join any team, a specific team, or to leave all teams.
 
bool RequestTeamSwitch (TM_Team *teamToJoin, TM_Team *teamToLeave)
 Similar to RequestTeam with TeamSelection::SpecificTeam(), but leave a team simultaneously when the desired team is joinable.
 
TeamSelection GetRequestedTeam (void) const
 Returns the first requested team in the list of requested teams, if you have a requested team at all.
 
void GetRequestedSpecificTeams (DataStructures::List< TM_Team * > &requestedTeams) const
 Returns pending calls to RequestTeam() when using TeamSelection::JOIN_SPECIFIC_TEAM.
 
bool HasRequestedTeam (TM_Team *team) const
 Returns if the specified team is in the list of pending requested teams.
 
unsigned int GetRequestedTeamIndex (TM_Team *team) const
 Returns the index of team in the requested teams list.
 
unsigned int GetRequestedTeamCount (void) const
 
bool CancelTeamRequest (TM_Team *specificTeamToCancel)
 Cancels a request to join a specific team.
 
bool LeaveTeam (TM_Team *team, NoTeamId _noTeamSubcategory)
 Leave a team.
 
bool LeaveAllTeams (NoTeamId noTeamSubcategory)
 Leave all teams Leaves all teams you are on, and sets noTeamSubcategory.
 
TM_TeamGetCurrentTeam (void) const
 
unsigned int GetCurrentTeamCount (void) const
 
TM_TeamGetCurrentTeamByIndex (unsigned int index)
 
void GetCurrentTeams (DataStructures::List< TM_Team * > &_teams) const
 
void GetLastTeams (DataStructures::List< TM_Team * > &_teams) const
 
bool IsOnTeam (TM_Team *team) const
 
NetworkID GetNetworkID (void) const
 
TM_WorldGetTM_World (void) const
 
void SerializeConstruction (BitStream *constructionBitstream)
 Serializes the current state of this object.
 
bool DeserializeConstruction (TeamManager *teamManager, BitStream *constructionBitstream)
 Deserializes the current state of this object.
 
void SetOwner (void *o)
 
void * GetOwner (void) const
 
NoTeamId GetNoTeamId (void) const
 
unsigned int GetWorldIndex (void) const
 Return world->GetTeamMemberIndex(this)
 

Detailed Description

A member of one or more teams.

Contains data and operations on data to manage which team your game's team members are on. Best used as a composite member of your "User" or "Player" class(es). When using with ReplicaManager3, call TM_TeamMember::ReferenceTeamMember() in Replica3::DeserializeConstruction() and TM_TeamMember::DeserializeConstruction() in Replica3::PostDeserializeConstruction() There is otherwise no need to manually serialize the class, as operations are networked internally.

Member Function Documentation

bool RakNet::TM_TeamMember::CancelTeamRequest ( TM_Team specificTeamToCancel)

Cancels a request to join a specific team.

Useful if you got ID_TEAM_BALANCER_REQUESTED_TEAM_FULL or ID_TEAM_BALANCER_REQUESTED_TEAM_LOCKED and changed your mind about joining the team.

Note
This is not guaranteed to work due to latency. To clarify, If the host switches your team at the same time you call CancelRequestTeam() you may still get ID_TEAM_BALANCER_TEAM_ASSIGNED for the team you tried to cancel.
Parameters
[in]specificTeamToCancelWhich team to no longer join. Use 0 for all.
Returns
false On invalid or unnecessary operation. Otherwise returns true
bool RakNet::TM_TeamMember::DeserializeConstruction ( TeamManager teamManager,
BitStream constructionBitstream 
)

Deserializes the current state of this object.

See SerializeConstruction for more details()

Note
DeserializeConstruction also calls ReferenceTeamMember on the passed teamManager instance, there is no need to do so yourself
Parameters
[in]teamManagerTeamManager instance
[in]constructionBitstreamThis object serialized to a BitStream
TM_Team* RakNet::TM_TeamMember::GetCurrentTeam ( void  ) const
Returns
Get the first team we are on, or 0 if we are not on a team.
TM_Team* RakNet::TM_TeamMember::GetCurrentTeamByIndex ( unsigned int  index)
Returns
Returns one of the teams in the current team list, up to GetCurrentTeamCount()
unsigned int RakNet::TM_TeamMember::GetCurrentTeamCount ( void  ) const
Returns
How many teams we are on
void RakNet::TM_TeamMember::GetCurrentTeams ( DataStructures::List< TM_Team * > &  _teams) const
Parameters
[out]Getall teams we are on, as a list
void RakNet::TM_TeamMember::GetLastTeams ( DataStructures::List< TM_Team * > &  _teams) const

For each team member, when you get ID_TEAM_BALANCER_TEAM_ASSIGNED for that member, the team list is saved. Use this function to get that list, for example to determine which teams we just left or joined

Parameters
[out]_teamsThe previous list of teams we were on
NetworkID RakNet::TM_TeamMember::GetNetworkID ( void  ) const
Returns
The teamMemberID parameter passed to TM_World::ReferenceTeamMember()
NoTeamId RakNet::TM_TeamMember::GetNoTeamId ( void  ) const
Returns
If not on a team, returns the current NoTeamId value
void* RakNet::TM_TeamMember::GetOwner ( void  ) const
Returns
Whatever was passed to SetOwner()
void RakNet::TM_TeamMember::GetRequestedSpecificTeams ( DataStructures::List< TM_Team * > &  requestedTeams) const

Returns pending calls to RequestTeam() when using TeamSelection::JOIN_SPECIFIC_TEAM.

Parameters
[out]Allpending requested teams
TeamSelection RakNet::TM_TeamMember::GetRequestedTeam ( void  ) const

Returns the first requested team in the list of requested teams, if you have a requested team at all.

Returns
TeamSelection::SpecificTeam(), TeamSelection::NoTeam(), or TeamSelection::AnyAvailable()
unsigned int RakNet::TM_TeamMember::GetRequestedTeamCount ( void  ) const
Returns
The number of teams that would be returned by a call to GetRequestedSpecificTeams()
unsigned int RakNet::TM_TeamMember::GetRequestedTeamIndex ( TM_Team team) const

Returns the index of team in the requested teams list.

Parameters
[in]Theteam we are checking
Returns
-1 if we did not requested to join this team. Otherwise the index.
TM_World* RakNet::TM_TeamMember::GetTM_World ( void  ) const
Returns
The TM_World instance that was used when calling TM_World::ReferenceTeamMember()
bool RakNet::TM_TeamMember::HasRequestedTeam ( TM_Team team) const

Returns if the specified team is in the list of pending requested teams.

Parameters
[in]Theteam we are checking
Returns
Did we request to join this specific team?
bool RakNet::TM_TeamMember::IsOnTeam ( TM_Team team) const
Parameters
[in]Theteam we are checking
Returns
Are we on this team?
bool RakNet::TM_TeamMember::LeaveAllTeams ( NoTeamId  noTeamSubcategory)

Leave all teams Leaves all teams you are on, and sets noTeamSubcategory.

Note
This is the same as and just calls RequestTeam(TeamSelection::NoTeam(noTeamSubcategory));
Returns
false On invalid or unnecessary operation. Otherwise returns true
bool RakNet::TM_TeamMember::LeaveTeam ( TM_Team team,
NoTeamId  _noTeamSubcategory 
)

Leave a team.

Leaves a team that you are on. Always succeeds provided you are on that team Generates ID_TEAM_BALANCER_TEAM_ASSIGNED on all systems on success. If you leave the last team you are on, noTeamSubcategory is set as well.

Parameters
[in]teamWhich team to leave
[in]_noTeamSubcategoryIf the team member has been removed from all teams, which subcategory of NoTeamId to set them to
Returns
false On invalid or unnecessary operation. Otherwise returns true
bool RakNet::TM_TeamMember::RequestTeam ( TeamSelection  teamSelection)

Request to join any team, a specific team, or to leave all teams.

Function will return false on invalid operations, such as joining a team you are already on. Will also fail with TeamSelection::JOIN_ANY_AVAILABLE_TEAM if you are currently on a team. On success, every system will get ID_TEAM_BALANCER_TEAM_ASSIGNED. Use TeamManager::DecomposeTeamAssigned() to get details of which team member the message refers to. On failure, all systems will get ID_TEAM_BALANCER_REQUESTED_TEAM_FULL or ID_TEAM_BALANCER_REQUESTED_TEAM_LOCKED. Use TeamManager::DecomposeTeamFull() and TeamManager::DecomposeTeamLocked() to get details of which team member the message refers to.

Note
Joining a specific team with this function may result in being on more than one team at once, even if you call the function while locally only on one team. If your game depends on only being on one team at a team, use RequestTeamSwitch() instead with the parameter teamToLeave set to 0
Parameters
[in]TeamSelection::AnyAvailable(),TeamSelection::SpecificTeam(),orTeamSelection::NoTeam()
Returns
false On invalid or unnecessary operation. Otherwise returns true
bool RakNet::TM_TeamMember::RequestTeamSwitch ( TM_Team teamToJoin,
TM_Team teamToLeave 
)

Similar to RequestTeam with TeamSelection::SpecificTeam(), but leave a team simultaneously when the desired team is joinable.

Parameters
[in]teamToJoinWhich team to join
[in]teamToLeaveIf 0, means leave all current teams. Otherwise, leave the specified team.
Returns
false On invalid or unnecessary operation. Otherwise returns true
void RakNet::TM_TeamMember::SerializeConstruction ( BitStream constructionBitstream)

Serializes the current state of this object.

To replicate a TM_TeamMember on another system, first instantiate the object using your own code, or a system such as ReplicaManager3. Next, call SerializeConstruction() from whichever system owns the team member Last, call DeserializeConstruction() on the newly created TM_TeamMember

Note
You must instantiate and deserialize all TM_Team instances that the team member refers to before calling DesrializeConstruction(). ReplicaManager3::PostSerializeConstruction() and ReplicaManager3::PostDeserializeConstruction() will ensure this.
Parameters
[out]constructionBitstreamThis object serialized to a BitStream
void RakNet::TM_TeamMember::SetOwner ( void *  o)
Parameters
[in]oStores a void* for your own use. If using composition, this is useful to store a pointer to the containing object.

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