#include <Replica.h>
Inheritance diagram for Replica:
Public Member Functions | |
virtual ReplicaReturnResult | SendConstruction (RakNetTime currentTime, PlayerID playerId, RakNet::BitStream *outBitStream, bool *includeTimestamp)=0 |
virtual void | SendDestruction (RakNet::BitStream *outBitStream, PlayerID playerId)=0 |
virtual ReplicaReturnResult | ReceiveDestruction (RakNet::BitStream *inBitStream, PlayerID playerId)=0 |
virtual ReplicaReturnResult | SendScopeChange (bool inScope, RakNet::BitStream *outBitStream, RakNetTime currentTime, PlayerID playerId)=0 |
virtual ReplicaReturnResult | ReceiveScopeChange (RakNet::BitStream *inBitStream, PlayerID playerId)=0 |
virtual ReplicaReturnResult | Serialize (bool *sendTimestamp, RakNet::BitStream *outBitStream, RakNetTime lastSendTime, PacketPriority *priority, PacketReliability *reliability, RakNetTime currentTime, PlayerID playerId)=0 |
virtual ReplicaReturnResult | Deserialize (RakNet::BitStream *inBitStream, RakNetTime timestamp, RakNetTime lastDeserializeTime, PlayerID playerId)=0 |
This is an interface of a replicated object for use in the framework of ReplicaManager You should derive from this class, implementing the functions to provide the behavior you want. If your architecture doesn't allow you to derive from this class, you can store an instance of a derived instance of this class in your base game object. In that case, use GetParent() and SetParent() and propagate the function calls up to your real classes. For an example where I do this, see Monster.h in the ReplicaManagerCS sample.
|
Called when another participant called Serialize with our system as the target
|
|
This function is called when SendDestruction is sent from another system. Delete your object if you want.
|
|
Called when when we get the SendScopeChange message. The new scope should have been encoded (by you) into inBitStream
|
|
This function is called in the first update tick after this object is first passed to ReplicaManager::Replicate for each player, and also when a new participant joins The intent of this function is to tell another system to create an instance of this class. You can do this however you want - I recommend having each class having a string identifier which is registered with StringTable, and then using EncodeString to write the name of the class. In the callback passed to SetReceiveConstructionCB create an instance of the object based on that string.
|
|
The purpose of the function is to send a packet containing the data in outBitStream to playerId telling that system that Dereplicate was called. In the code, this is called in the update cycle after you call ReplicaManager::Destruct(). Then, if you write to outBitStream, a message is sent to that participant. This is the one send you cannot delay because objects may be deleted and we can't read into them past this.
|
|
Called when ReplicaManager::SetScope is called with a different value than what it currently has. It is up to you to write inScope to outBitStream. Not doing so, and returning true, means you want to cancel the scope change call. If inScope is true, you return true, and data is written to outBitStream, then Serialize will be called automatically This is a convenience feature, since there's almost no case where an object would go in scope but not be serialized
|
|
Called when ReplicaManager::SignalSerializeNeeded is called with this object as the parameter. The system will ensure that Serialize only occurs for participants that have this object constructed and in scope The intent of this function is to serialize all your class member variables for remote transmission.
|