RakNet
4.0
|
Stores a list of teams which may be enforcing a balanced number of members. More...
#include <TeamManager.h>
Public Member Functions | |
TeamManager * | GetTeamManager (void) const |
void | AddParticipant (RakNetGUID rakNetGUID) |
Add a new system to send team and team member updates to. | |
void | RemoveParticipant (RakNetGUID rakNetGUID) |
Remove a system that was previously added with AddParticipant() | |
void | SetAutoManageConnections (bool autoAdd) |
If true, all new connections are added to this world using AddParticipant() | |
void | GetParticipantList (DataStructures::List< RakNetGUID > &participantList) |
void | ReferenceTeam (TM_Team *team, NetworkID networkId, bool applyBalancing) |
Register a TM_Team object with this system. | |
void | DereferenceTeam (TM_Team *team, NoTeamId noTeamSubcategory) |
Unregisters the associated TM_Team object with this system. Call when a TM_Team instance is no longer needed. | |
unsigned int | GetTeamCount (void) const |
TM_Team * | GetTeamByIndex (unsigned int index) const |
TM_Team * | GetTeamByNetworkID (NetworkID teamId) |
unsigned int | GetTeamIndex (const TM_Team *team) const |
Inverse of GetTeamByIndex() | |
void | ReferenceTeamMember (TM_TeamMember *teamMember, NetworkID networkId) |
Register a TM_TeamMember object with this system. | |
void | DereferenceTeamMember (TM_TeamMember *teamMember) |
Unregisters the associated TM_TeamMember object with this system. Call when a TM_TeamMember instance is no longer needed. | |
unsigned int | GetTeamMemberCount (void) const |
TM_TeamMember * | GetTeamMemberByIndex (unsigned int index) const |
NetworkID | GetTeamMemberIDByIndex (unsigned int index) const |
TM_TeamMember * | GetTeamMemberByNetworkID (NetworkID teamMemberId) |
unsigned int | GetTeamMemberIndex (const TM_TeamMember *teamMember) const |
Inverse of GetTeamMemberByIndex() | |
bool | SetBalanceTeams (bool balanceTeams, NoTeamId noTeamSubcategory) |
Force or stop forcing teams to be balanced. | |
bool | GetBalanceTeams (void) const |
void | SetHost (RakNetGUID _hostGuid) |
Set the host that will perform balancing calculations and send notifications. | |
RakNetGUID | GetHost (void) const |
WorldId | GetWorldId (void) const |
void | Clear (void) |
Clear all memory and reset everything. | |
Stores a list of teams which may be enforcing a balanced number of members.
Each TM_World instance is independent of other TM_World world instances. This enables you to host multiple games on a single computer. Not currently supported to have the same TM_Team or TM_TeamMember in more than one world at a time, but easily added on request.
void RakNet::TM_World::AddParticipant | ( | RakNetGUID | rakNetGUID | ) |
Add a new system to send team and team member updates to.
[in] | rakNetGUID | GUID of the system you are adding. See Packet::rakNetGUID or RakPeerInterface::GetGUIDFromSystemAddress() |
void RakNet::TM_World::Clear | ( | void | ) |
Clear all memory and reset everything.
It is up to the user to deallocate pointers passed to ReferenceTeamMember() or ReferenceTeam(), if so desired.
void RakNet::TM_World::DereferenceTeamMember | ( | TM_TeamMember * | teamMember | ) |
Unregisters the associated TM_TeamMember object with this system. Call when a TM_TeamMember instance is no longer needed.
bool RakNet::TM_World::GetBalanceTeams | ( | void | ) | const |
RakNetGUID RakNet::TM_World::GetHost | ( | void | ) | const |
void RakNet::TM_World::GetParticipantList | ( | DataStructures::List< RakNetGUID > & | participantList | ) |
Get the participants added with AddParticipant()
[out] | participantList | Participants added with AddParticipant(); |
TM_Team* RakNet::TM_World::GetTeamByIndex | ( | unsigned int | index | ) | const |
[in] | index | A value between 0 and GetTeamCount() |
TM_Team* RakNet::TM_World::GetTeamByNetworkID | ( | NetworkID | teamId | ) |
[in] | teamId | Value passed to ReferenceTeam() |
unsigned int RakNet::TM_World::GetTeamCount | ( | void | ) | const |
unsigned int RakNet::TM_World::GetTeamIndex | ( | const TM_Team * | team | ) | const |
Inverse of GetTeamByIndex()
[in] | team | Which taem |
TeamManager* RakNet::TM_World::GetTeamManager | ( | void | ) | const |
TM_TeamMember* RakNet::TM_World::GetTeamMemberByIndex | ( | unsigned int | index | ) | const |
[in] | index | A value between 0 and GetTeamMemberCount() |
TM_TeamMember* RakNet::TM_World::GetTeamMemberByNetworkID | ( | NetworkID | teamMemberId | ) |
[in] | teamId | Value passed to ReferenceTeamMember() |
unsigned int RakNet::TM_World::GetTeamMemberCount | ( | void | ) | const |
NetworkID RakNet::TM_World::GetTeamMemberIDByIndex | ( | unsigned int | index | ) | const |
[in] | index | A value between 0 and GetTeamMemberCount() |
unsigned int RakNet::TM_World::GetTeamMemberIndex | ( | const TM_TeamMember * | teamMember | ) | const |
Inverse of GetTeamMemberByIndex()
[in] | team | Which team member |
WorldId RakNet::TM_World::GetWorldId | ( | void | ) | const |
void RakNet::TM_World::ReferenceTeam | ( | TM_Team * | team, |
NetworkID | networkId, | ||
bool | applyBalancing | ||
) |
Register a TM_Team object with this system.
Your game should contain instances of TM_Team, for example by using composition with your game's Team or PlayerList class Tell TeamManager about these instances using ReferenceTeam().
[in] | team | The instance you are registering |
[in] | networkId | Identifies this instance. This value is independent of values used by NetworkIDManager. You can use the same value as the object that contains this instance. |
[in] | applyBalancing | Whether or not to include this team for balancing when calling SetBalanceTeams(). |
void RakNet::TM_World::ReferenceTeamMember | ( | TM_TeamMember * | teamMember, |
NetworkID | networkId | ||
) |
Register a TM_TeamMember object with this system.
Your game should contain instances of TM_TeamMember, for example by using composition with your game's User or Player classes Tell TeamManager about these instances using ReferenceTeamMember().
[in] | teamMember | The instance you are registering |
[in] | networkId | Identifies this instance. This value is independent of values used by NetworkIDManager. You can use the same value as the object that contains this instance |
void RakNet::TM_World::RemoveParticipant | ( | RakNetGUID | rakNetGUID | ) |
Remove a system that was previously added with AddParticipant()
Systems that disconnect are removed automatically
[in] | rakNetGUID | GUID of the system you are removing. See Packet::rakNetGUID or RakPeerInterface::GetGUIDFromSystemAddress() |
void RakNet::TM_World::SetAutoManageConnections | ( | bool | autoAdd | ) |
If true, all new connections are added to this world using AddParticipant()
Defaults to true
[in] | autoAdd | Setting to set |
bool RakNet::TM_World::SetBalanceTeams | ( | bool | balanceTeams, |
NoTeamId | noTeamSubcategory | ||
) |
Force or stop forcing teams to be balanced.
For each team added with ReferenceTeam() and applyBalancing set to true, players on unbalanced teams will be redistributed While active, players can only join balanced teams if doing so would not cause that team to become unbalanced. If a player on the desired team also wants to switch, then both players will switch simultaneously. Otherwise, ID_TEAM_BALANCER_REQUESTED_TEAM_FULL will be returned to the requester and switching will occur when possible. If balanceTeams is true and later set to false, players waiting on ID_TEAM_BALANCER_REQUESTED_TEAM_FULL will be able to join the desired team immediately provided it is not full.
[in] | balanceTeams | Whether to activate or deactivate team balancing. |
[in] | noTeamSubcategory | If a player is kicked off a team and is no longer on any team, his or her noTeamSubcategory is set to this value |
void RakNet::TM_World::SetHost | ( | RakNetGUID | _hostGuid | ) |
Set the host that will perform balancing calculations and send notifications.
Operations that can cause conflicts due to latency, such as joining teams, are operated on by the host. The result is sent to all systems added with AddParticipant() For a client/server game, call SetHost() with the server's RakNetGUID value on all systems (including the server itself). If you call TeamManager::SetTopology(TM_CLIENT_SERVER), the server will also relay messages between participants. For a peer to peer game, call SetHost() on the same peer when host migration occurs. Use TeamManager::SetTopology(TM_PEER_TO_PEER) in this case.
[in] | _hostGuid | The host, which is the system that will serialize and resolve team disputes and calculate team balancing. |