#include <TeamManager.h>
Public Member Functions | |
TM_World * | AddWorld (WorldId worldId) |
Allocate a world to hold a list of teams and players for that team. Use the returned TM_World object for actual team functionality. | |
void | RemoveWorld (WorldId worldId) |
Deallocate a world created with AddWorld(). | |
unsigned int | GetWorldCount (void) const |
TM_World * | GetWorldAtIndex (unsigned int index) const |
TM_World * | GetWorldWithId (WorldId worldId) const |
void | SetAutoManageConnections (bool autoAdd) |
When auto managing connections, call TM_World::AddParticipant() on all worlds for all new connections automatically Defaults to true. | |
void | SetTopology (TMTopology _topology) |
If _topology is set to TM_CLIENT_SERVER, the host will relay messages to participants. | |
void | DecomposeTeamFull (Packet *packet, TM_World **world, TM_TeamMember **teamMember, TM_Team **team, uint16_t ¤tMembers, uint16_t &memberLimitIncludingBalancing, bool &balancingIsActive, JoinPermissions &joinPermissions) |
When you get ID_TEAM_BALANCER_REQUESTED_TEAM_FULL, pass the packet to this function to read out parameters. | |
void | DecomposeTeamLocked (Packet *packet, TM_World **world, TM_TeamMember **teamMember, TM_Team **team, uint16_t ¤tMembers, uint16_t &memberLimitIncludingBalancing, bool &balancingIsActive, JoinPermissions &joinPermissions) |
When you get ID_TEAM_BALANCER_REQUESTED_TEAM_LOCKED, pass the packet to this function to read out parameters. | |
void | Clear (void) |
Clear all memory and reset everything. | |
void | DecodeTeamAssigned (Packet *packet, TM_World **world, TM_TeamMember **teamMember) |
Reads out the world and teamMember from ID_TEAM_BALANCER_TEAM_ASSIGNED. | |
void | DecodeTeamCancelled (Packet *packet, TM_World **world, TM_TeamMember **teamMember, TM_Team **teamCancelled) |
Protected Member Functions | |
virtual void | Update (void) |
Update is called every time a packet is checked for . | |
virtual PluginReceiveResult | OnReceive (Packet *packet) |
virtual void | OnClosedConnection (const SystemAddress &systemAddress, RakNetGUID rakNetGUID, PI2_LostConnectionReason lostConnectionReason) |
virtual void | OnNewConnection (const SystemAddress &systemAddress, RakNetGUID rakNetGUID, bool isIncoming) |
void | DecodeTeamAssigned (RakNet::BitStream *bsIn, TM_World **world, TM_TeamMember **teamMember, NoTeamId &noTeamSubcategory, JoinTeamType &joinTeamType, DataStructures::List< TM_Team * > &newTeam, DataStructures::List< TM_Team * > &teamsLeft, DataStructures::List< TM_Team * > &teamsJoined) |
When you get ID_TEAM_BALANCER_TEAM_ASSIGNED, pass the packet to this function to read out parameters. |
TeamManager provides support for teams. A team is a list of team members. Teams contain properties including the number of team members per team, whether or not tagged teams must have equal numbers of members, and if a team is locked or not to certain entry conditions Team members contain properties including which teams they are on and which teams they want to join if a team is not immediately joinable Advanced functionality includes the ability for a team member to be on multiple teams simultaneously, the ability to swap teams with other members, and the ability to resize the number of members supported per team The architecture is designed for easy integration with ReplicaManager3
Usage:
1. Define your game classes to represent teams and team members. Your game classes should hold game-specific information such as team name and color.
2. Have those game classes contain a corresponding TM_Team or TM_TeamMember instance. Operations on teams will be performed by those instances. Use SetOwner() to refer to the parent object when using composition.
3. Call TeamManager::SetTopology() for client/server or peer to peer.
4. Call AddWorld() to instantiate a TM_World object which will contain references to your TM_TeamMember and TM_Team instances.
5. When you instantiate a TM_TeamMember or TM_Team object, call ReferenceTeam() and ReferenceTeamMember() for each corresponding object
6. When sending world state to a new connection, for example in ReplicaManager3::SerializeConstruction(), call TM_SerializeConstruction() on the corresponding TM_TeamMember and TM_Team objects. TM_Team instances on the new connection must be created before TM_TeamMember instances.
7. Call TM_DeserializeConstruction() on your new corresponding TM_TeamMember and TM_Team instances.
8. Execute team operations. ID_TEAM_BALANCER_REQUESTED_TEAM_FULL, ID_TEAM_BALANCER_REQUESTED_TEAM_LOCKED, ID_TEAM_BALANCER_TEAM_REQUESTED_CANCELLED, and ID_TEAM_BALANCER_TEAM_ASSIGNED are returned to all systems when the corresponding event occurs for a team member.
9. As the peer to peer session host changes, call SetHost() (Not necessary if using FullyConnectedMesh2). If using client/server, you must set the host
Allocate a world to hold a list of teams and players for that team. Use the returned TM_World object for actual team functionality.
[in] | worldId | Arbitrary user-defined id of the world to create. Each world instance must have a unique id. |
void RakNet::TeamManager::Clear | ( | void | ) |
Clear all memory and reset everything.
Deallocates TM_World instances. It is up to the user to deallocate pointers passed to ReferenceTeamMember() or ReferenceTeam(), if so desired.
void RakNet::TeamManager::DecodeTeamAssigned | ( | RakNet::BitStream * | bsIn, | |
TM_World ** | world, | |||
TM_TeamMember ** | teamMember, | |||
NoTeamId & | noTeamSubcategory, | |||
JoinTeamType & | joinTeamType, | |||
DataStructures::List< TM_Team * > & | newTeam, | |||
DataStructures::List< TM_Team * > & | teamsLeft, | |||
DataStructures::List< TM_Team * > & | teamsJoined | |||
) | [protected] |
When you get ID_TEAM_BALANCER_TEAM_ASSIGNED, pass the packet to this function to read out parameters.
[in] | A | packet where packet->data[0]==ID_TEAM_BALANCER_TEAM_ASSIGNED |
void RakNet::TeamManager::DecodeTeamAssigned | ( | Packet * | packet, | |
TM_World ** | world, | |||
TM_TeamMember ** | teamMember | |||
) |
Reads out the world and teamMember from ID_TEAM_BALANCER_TEAM_ASSIGNED.
[in] | A | packet where packet->data[0]==ID_TEAM_BALANCER_TEAM_ASSIGNED |
[out] | world | Set to the world this teamMember is on. 0 on bad lookup. |
[out] | teamMember | Set to the teamMember affected. 0 on bad lookup. |
void RakNet::TeamManager::DecodeTeamCancelled | ( | Packet * | packet, | |
TM_World ** | world, | |||
TM_TeamMember ** | teamMember, | |||
TM_Team ** | teamCancelled | |||
) |
[in] | A | packet where packet->data[0]==ID_TEAM_BALANCER_TEAM_REQUESTED_CANCELLED |
[out] | world | Set to the world this teamMember is on. 0 on bad lookup. |
[out] | teamMember | Set to the teamMember affected. 0 on bad lookup. |
[out] | teamCancelled | Set to the team that was cancelled. 0 for all teams. |
void RakNet::TeamManager::DecomposeTeamFull | ( | Packet * | packet, | |
TM_World ** | world, | |||
TM_TeamMember ** | teamMember, | |||
TM_Team ** | team, | |||
uint16_t & | currentMembers, | |||
uint16_t & | memberLimitIncludingBalancing, | |||
bool & | balancingIsActive, | |||
JoinPermissions & | joinPermissions | |||
) |
When you get ID_TEAM_BALANCER_REQUESTED_TEAM_FULL, pass the packet to this function to read out parameters.
[in] | A | packet where packet->data[0]==ID_TEAM_BALANCER_REQUESTED_TEAM_FULL |
void RakNet::TeamManager::DecomposeTeamLocked | ( | Packet * | packet, | |
TM_World ** | world, | |||
TM_TeamMember ** | teamMember, | |||
TM_Team ** | team, | |||
uint16_t & | currentMembers, | |||
uint16_t & | memberLimitIncludingBalancing, | |||
bool & | balancingIsActive, | |||
JoinPermissions & | joinPermissions | |||
) |
When you get ID_TEAM_BALANCER_REQUESTED_TEAM_LOCKED, pass the packet to this function to read out parameters.
[in] | A | packet where packet->data[0]==ID_TEAM_BALANCER_REQUESTED_TEAM_LOCKED |
TM_World* RakNet::TeamManager::GetWorldAtIndex | ( | unsigned int | index | ) | const |
[in] | index | A value beteween 0 and GetWorldCount()-1 inclusive. |
unsigned int RakNet::TeamManager::GetWorldCount | ( | void | ) | const |
[in] | worldId | worldId value passed to AddWorld() |
virtual void RakNet::TeamManager::OnClosedConnection | ( | const SystemAddress & | systemAddress, | |
RakNetGUID | rakNetGUID, | |||
PI2_LostConnectionReason | lostConnectionReason | |||
) | [protected, virtual] |
Called when a connection is dropped because the user called RakPeer::CloseConnection() for a particular system
[in] | systemAddress | The system whose connection was closed |
[in] | rakNetGuid | The guid of the specified system |
[in] | lostConnectionReason | How the connection was closed: manually, connection lost, or notification of disconnection |
Reimplemented from RakNet::PluginInterface2.
virtual void RakNet::TeamManager::OnNewConnection | ( | const SystemAddress & | systemAddress, | |
RakNetGUID | rakNetGUID, | |||
bool | isIncoming | |||
) | [protected, virtual] |
Called when we got a new connection
[in] | systemAddress | Address of the new connection |
[in] | rakNetGuid | The guid of the specified system |
[in] | isIncoming | If true, this is ID_NEW_INCOMING_CONNECTION, or the equivalent |
Reimplemented from RakNet::PluginInterface2.
virtual PluginReceiveResult RakNet::TeamManager::OnReceive | ( | Packet * | packet | ) | [protected, virtual] |
OnReceive is called for every packet.
[in] | packet | the packet that is being returned to the user |
Reimplemented from RakNet::PluginInterface2.
void RakNet::TeamManager::RemoveWorld | ( | WorldId | worldId | ) |
void RakNet::TeamManager::SetAutoManageConnections | ( | bool | autoAdd | ) |
When auto managing connections, call TM_World::AddParticipant() on all worlds for all new connections automatically Defaults to true.
[in] | autoAdd | Automatically call TM_World::AddParticipant() all worlds each new connection. Defaults to true. |
void RakNet::TeamManager::SetTopology | ( | TMTopology | _topology | ) |
If _topology is set to TM_CLIENT_SERVER, the host will relay messages to participants.
If topology is set to TM_PEER_TO_PEER, the host assumes the original message source was connected to all other participants and does not relay messages.
Defaults to TM_PEER_TO_PEER
[in] | _topology | Topology to use |