Base class for game objects that use the ReplicaManager2 system. More...
#include <ReplicaManager2.h>
Inherits NetworkIDObject.
Classes | |
struct | AutoSerializeEvent |
Public Member Functions | |
Replica2 () | |
virtual | ~Replica2 () |
void | SetReplicaManager (ReplicaManager2 *rm) |
ReplicaManager2 * | GetReplicaManager (void) const |
virtual void | SendConstruction (SystemAddress recipientAddress, SerializationType serializationType=UNDEFINED_REASON) |
virtual void | SendDestruction (SystemAddress recipientAddress, SerializationType serializationType=UNDEFINED_REASON) |
virtual void | SendSerialize (SystemAddress recipientAddress, SerializationType serializationType=UNDEFINED_REASON) |
virtual void | SendVisibility (SystemAddress recipientAddress, SerializationType serializationType=UNDEFINED_REASON) |
virtual void | BroadcastConstruction (SerializationContext *serializationContext=0) |
virtual void | BroadcastSerialize (SerializationContext *serializationContext=0) |
virtual void | BroadcastDestruction (SerializationContext *serializationContext=0) |
virtual void | BroadcastVisibility (bool isVisible, SerializationContext *serializationContext=0) |
virtual bool | SerializeConstruction (RakNet::BitStream *bitStream, SerializationContext *serializationContext)=0 |
virtual bool | SerializeDestruction (RakNet::BitStream *bitStream, SerializationContext *serializationContext) |
virtual bool | Serialize (RakNet::BitStream *bitStream, SerializationContext *serializationContext) |
virtual bool | SerializeVisibility (RakNet::BitStream *bitStream, SerializationContext *serializationContext) |
virtual void | DeserializeDestruction (RakNet::BitStream *bitStream, SerializationType serializationType, SystemAddress sender, RakNetTime timestamp) |
virtual void | Deserialize (RakNet::BitStream *bitStream, SerializationType serializationType, SystemAddress sender, RakNetTime timestamp) |
virtual void | DeserializeVisibility (RakNet::BitStream *bitStream, SerializationType serializationType, SystemAddress sender, RakNetTime timestamp) |
virtual BooleanQueryResult | QueryConstruction (Connection_RM2 *connection) |
virtual BooleanQueryResult | QueryVisibility (Connection_RM2 *connection) |
virtual bool | QueryIsConstructionAuthority (void) const |
virtual bool | QueryIsDestructionAuthority (void) const |
virtual bool | QueryIsVisibilityAuthority (void) const |
virtual bool | QueryIsSerializationAuthority (void) const |
virtual bool | AllowRemoteConstruction (SystemAddress sender, RakNet::BitStream *replicaData, SerializationType type, RakNetTime timestamp) |
virtual void | AddAutoSerializeTimer (RakNetTime interval, SerializationType serializationType=AUTOSERIALIZE_DEFAULT, RakNetTime countdown=(RakNetTime)-1) |
virtual void | ElapseAutoSerializeTimers (RakNetTime timeElapsed, bool resynchOnly) |
RakNetTime | GetTimeToNextAutoSerialize (SerializationType serializationType=AUTOSERIALIZE_DEFAULT) |
virtual void | BroadcastAutoSerialize (SerializationContext *serializationContext, RakNet::BitStream *serializedObject) |
virtual void | CancelAutoSerializeTimer (SerializationType serializationType=AUTOSERIALIZE_DEFAULT) |
virtual void | ClearAutoSerializeTimers (void) |
Remove and deallocate all previously added autoSerialize timers. | |
virtual void | OnAutoSerializeTimerElapsed (SerializationType serializationType, RakNet::BitStream *output, RakNet::BitStream *lastOutput, RakNetTime lastAutoSerializeCountdown, bool resynchOnly) |
virtual void | ForceElapseAllAutoserializeTimers (bool resynchOnly) |
virtual void | OnConstructionComplete (RakNet::BitStream *replicaData, SystemAddress sender, SerializationType type, ReplicaManager2 *replicaManager, RakNetTime timestamp, NetworkID networkId, bool networkIDCollision) |
Protected Member Functions | |
virtual void | ReceiveSerialize (SystemAddress sender, RakNet::BitStream *serializedObject, SerializationType serializationType, RakNetTime timestamp, DataStructures::OrderedList< SystemAddress, SystemAddress > &exclusionList) |
virtual void | ReceiveDestruction (SystemAddress sender, RakNet::BitStream *serializedObject, SerializationType serializationType, RakNetTime timestamp, DataStructures::OrderedList< SystemAddress, SystemAddress > &exclusionList) |
virtual void | DeleteOnReceiveDestruction (SystemAddress sender, RakNet::BitStream *serializedObject, SerializationType serializationType, RakNetTime timestamp, DataStructures::OrderedList< SystemAddress, SystemAddress > &exclusionList) |
virtual void | ReceiveVisibility (SystemAddress sender, RakNet::BitStream *serializedObject, SerializationType serializationType, RakNetTime timestamp, DataStructures::OrderedList< SystemAddress, SystemAddress > &exclusionList) |
virtual Replica2 * | ReceiveConstructionReply (SystemAddress sender, BitStream *replicaData, bool constructionAllowed) |
void | DereferenceFromDestruction (void) |
Protected Attributes | |
bool | hasClientID |
unsigned char | clientID |
ReplicaManager2 * | rm2 |
DataStructures::Map < SerializationType, AutoSerializeEvent * > | autoSerializeTimers |
Static Protected Attributes | |
static unsigned char | clientSharedID = 0 |
static Replica2 * | clientPtrArray [256] |
Friends | |
class | ReplicaManager2 |
class | Connection_RM2 |
Base class for game objects that use the ReplicaManager2 system.
All game objects that want to use the ReplicaManager2 functionality must inherit from Replica2.
Generally you will want to implement at a minimum Serialize(), Deserialize(), and SerializeConstruction()
Definition at line 451 of file ReplicaManager2.h.
Replica2::Replica2 | ( | ) |
Definition at line 1083 of file ReplicaManager2.cpp.
Replica2::~Replica2 | ( | ) | [virtual] |
void Replica2::AddAutoSerializeTimer | ( | RakNetTime | interval, | |
SerializationType | serializationType = AUTOSERIALIZE_DEFAULT , |
|||
RakNetTime | countdown = (RakNetTime)-1 | |||
) | [virtual] |
Adds a timer that will elapse every countdown milliseconds, calling Serialize with AUTOSERIALIZE_DEFAULT or whatever value was passed to serializationType Every time this timer elapses, the value returned from Serialize() will be compared to the last value returned by Serialize(). If different, SendSerialize() will be called automatically. It is possible to create your own AUTOSERIALIZE enumerations and thus control which parts of the object is serialized Use CancelAutoSerializeTimer() or ClearAutoSerializeTimers() to stop the timer. If this timer already exists, it will simply override the existing countdown This timer will automatically repeat every countdown milliseconds
[in] | interval | Time in milliseconds between autoserialize ticks. Use 0 to process immediately, and every tick |
[in] | serializationType | User-defined identifier for what type of serialization operation to perform. Returned in Deserialize() as the serializationType parameter. |
[in] | countdown | Amount of time before doing the next autoserialize. Defaults to interval |
Definition at line 1670 of file ReplicaManager2.cpp.
bool Replica2::AllowRemoteConstruction | ( | SystemAddress | sender, | |
RakNet::BitStream * | replicaData, | |||
SerializationType | type, | |||
RakNetTime | timestamp | |||
) | [virtual] |
CALLBACK: If QueryIsConstructionAuthority() is false for a remote system, should that system be able to create this kind of object?
[in] | sender | Which system sent this message to us? Also happens to be the system that is requesting to create an object |
[in] | replicaData | Construction data used to create this object |
[in] | type | Which type of serialization operation was performed |
[in] | timestamp | Written timestamp with the packet. 0 if not used. |
Definition at line 1586 of file ReplicaManager2.cpp.
void Replica2::BroadcastAutoSerialize | ( | SerializationContext * | serializationContext, | |
RakNet::BitStream * | serializedObject | |||
) | [virtual] |
Do the actual send call when needed to support autoSerialize If you want to do different types of send calls (UNRELIABLE for example) override this function.
[in] | serializationContext | Describes the recipient, sender. serializationContext::timestamp is an [out] parameter which if you write to, will be send along with the message |
[in] | serializedObject | Data to pass to ReplicaManager2::SendSerialize() |
Definition at line 1665 of file ReplicaManager2.cpp.
void Replica2::BroadcastConstruction | ( | SerializationContext * | serializationContext = 0 |
) | [virtual] |
Construct this object on other systems
[in] | serializationContext | Which system to send to, an input timestamp, and the SerializationType. 0 to use defaults, no timestamp. |
Definition at line 1311 of file ReplicaManager2.cpp.
void Replica2::BroadcastDestruction | ( | SerializationContext * | serializationContext = 0 |
) | [virtual] |
Destroy this object on all current connections Triggers a call to SerializeDestruction() for each connection (you can serialize differently per connection).
[in] | serializationContext | Which system to send to, an input timestamp, and the SerializationType. 0 to use defaults, no timestamp. |
Definition at line 1390 of file ReplicaManager2.cpp.
void Replica2::BroadcastSerialize | ( | SerializationContext * | serializationContext = 0 |
) | [virtual] |
Serialize this object to all current connections Triggers a call to SerializeConstruction() for each connection (you can serialize differently per connection).
[in] | serializationContext | Which system to send to, an input timestamp, and the SerializationType. 0 to use defaults, no timestamp. |
Definition at line 1228 of file ReplicaManager2.cpp.
void Replica2::BroadcastVisibility | ( | bool | isVisible, | |
SerializationContext * | serializationContext = 0 | |||
) | [virtual] |
Update the visibility state of this object on all other systems Use SEND_VISIBILITY_TRUE_TO_SYSTEM or SEND_VISIBILITY_FALSE_TO_SYSTEM in serializationContext::serializationType Triggers a call to SerializeVisibility() for each connection (you can serialize differently per connection).
[in] | serializationContext | Which system to send to, an input timestamp, and the SerializationType. 0 to use defaults, no timestamp, true visibility |
Definition at line 1421 of file ReplicaManager2.cpp.
void Replica2::CancelAutoSerializeTimer | ( | SerializationType | serializationType = AUTOSERIALIZE_DEFAULT |
) | [virtual] |
Stop calling an autoSerialize timer previously setup with AddAutoSerializeTimer()
[in] | serializationType | Corresponding value passed to serializationType |
Definition at line 1732 of file ReplicaManager2.cpp.
void Replica2::ClearAutoSerializeTimers | ( | void | ) | [virtual] |
Remove and deallocate all previously added autoSerialize timers.
Definition at line 1746 of file ReplicaManager2.cpp.
void Replica2::DeleteOnReceiveDestruction | ( | SystemAddress | sender, | |
RakNet::BitStream * | serializedObject, | |||
SerializationType | serializationType, | |||
RakNetTime | timestamp, | |||
DataStructures::OrderedList< SystemAddress, SystemAddress > & | exclusionList | |||
) | [protected, virtual] |
void Replica2::DereferenceFromDestruction | ( | void | ) | [protected] |
Definition at line 1382 of file ReplicaManager2.cpp.
void Replica2::Deserialize | ( | RakNet::BitStream * | bitStream, | |
SerializationType | serializationType, | |||
SystemAddress | sender, | |||
RakNetTime | timestamp | |||
) | [virtual] |
CALLBACK: Receives data written by Serialize()
[in] | bitStream | Data sent |
[in] | serializationType | SerializationContext::serializationType |
[in] | sender | Which system sent this message to us |
[in] | timestamp | If a timestamp was written, will be whatever was written adjusted to the local system time. 0 if not used. |
Definition at line 1134 of file ReplicaManager2.cpp.
void Replica2::DeserializeDestruction | ( | RakNet::BitStream * | bitStream, | |
SerializationType | serializationType, | |||
SystemAddress | sender, | |||
RakNetTime | timestamp | |||
) | [virtual] |
CALLBACK: Receives data written by SerializeDestruction()
[in] | bitStream | Data sent |
[in] | serializationType | SerializationContext::serializationType |
[in] | sender | Which system sent this message to us |
[in] | timestamp | If a timestamp was written, will be whatever was written adjusted to the local system time. 0 if not used. |
Definition at line 1126 of file ReplicaManager2.cpp.
void Replica2::DeserializeVisibility | ( | RakNet::BitStream * | bitStream, | |
SerializationType | serializationType, | |||
SystemAddress | sender, | |||
RakNetTime | timestamp | |||
) | [virtual] |
CALLBACK: Receives data written by SerializeVisibility()
[in] | bitStream | Data sent |
[in] | serializationType | SerializationContext::serializationType |
[in] | sender | Which system sent this message to us |
[in] | timestamp | If a timestamp was written, will be whatever was written adjusted to the local system time. 0 if not used. |
Definition at line 1141 of file ReplicaManager2.cpp.
void Replica2::ElapseAutoSerializeTimers | ( | RakNetTime | timeElapsed, | |
bool | resynchOnly | |||
) | [virtual] |
Elapse time for all timers added with AddAutoSerializeTimer() Only necessary to call this if you call Replica2::SetDoReplicaAutoSerializeUpdate(false) (which defaults to true)
[in] | timeElapsed | How many milliseconds have elapsed since the last call |
[in] | resynchOnly | True to only update what was considered the last send, without actually doing a send. |
Definition at line 1609 of file ReplicaManager2.cpp.
void Replica2::ForceElapseAllAutoserializeTimers | ( | bool | resynchOnly | ) | [virtual] |
Immediately elapse all autoserialize timers Used internally when a Deserialize() event occurs, so that the deserialize does not trigger an autoserialize itself
Definition at line 1595 of file ReplicaManager2.cpp.
ReplicaManager2 * Replica2::GetReplicaManager | ( | void | ) | const |
Returns what was passed to SetReplicaManager(), or 0 if no value ever passed
Definition at line 1101 of file ReplicaManager2.cpp.
RakNetTime Replica2::GetTimeToNextAutoSerialize | ( | SerializationType | serializationType = AUTOSERIALIZE_DEFAULT |
) |
Returns how many milliseconds are remaining until the next autoserialize update
[in] | serializationType | User-defined identifier for what type of serialization operation to perform. Returned in Deserialize() as the serializationType parameter. |
Definition at line 1723 of file ReplicaManager2.cpp.
void Replica2::OnAutoSerializeTimerElapsed | ( | SerializationType | serializationType, | |
RakNet::BitStream * | output, | |||
RakNet::BitStream * | lastOutput, | |||
RakNetTime | lastAutoSerializeCountdown, | |||
bool | resynchOnly | |||
) | [virtual] |
A timer has elapsed. Compare the last value sent to the current value, and if different, send the new value
Definition at line 1642 of file ReplicaManager2.cpp.
void Replica2::OnConstructionComplete | ( | RakNet::BitStream * | replicaData, | |
SystemAddress | sender, | |||
SerializationType | type, | |||
ReplicaManager2 * | replicaManager, | |||
RakNetTime | timestamp, | |||
NetworkID | networkId, | |||
bool | networkIDCollision | |||
) | [virtual] |
A call to Connection_RM2 Construct() has completed and the object is now internally referenced
[in] | replicaData | Whatever was written bitStream in Replica2::SerializeConstruction() |
[in] | type | Whatever was written serializationType in Replica2::SerializeConstruction() |
[in] | replicaManager | ReplicaManager2 instance that created this class. |
[in] | timestamp | timestamp sent with Replica2::SerializeConstruction(), 0 for none. |
[in] | networkId | NetworkID that will be assigned automatically to the new object after this function returns |
[in] | networkIDCollision | True if the network ID that should be assigned to this object is already in use. Usuallly this is because the object already exists, and you should just read your data and return 0. |
Definition at line 1599 of file ReplicaManager2.cpp.
BooleanQueryResult Replica2::QueryConstruction | ( | Connection_RM2 * | connection | ) | [virtual] |
CALLBACK: For a given connection, should this object exist? Checked every Update cycle if ReplicaManager2::SetAutoUpdateScope() parameter construction is true Defaults to BQR_ALWAYS
[in] | connection | Which connection we are referring to. 0 means unknown, in which case the system is checking for BQR_ALWAYS or BQR_NEVER as an optimization. |
Definition at line 1558 of file ReplicaManager2.cpp.
bool Replica2::QueryIsConstructionAuthority | ( | void | ) | const [virtual] |
CALLBACK: Does this system have control over construction of this object? While not strictly required, it is best to have this consistently return true for only one system. Otherwise systems may fight and override each other. Defaults to NetworkIDManager::IsNetworkIDAuthority();
Definition at line 1570 of file ReplicaManager2.cpp.
bool Replica2::QueryIsDestructionAuthority | ( | void | ) | const [virtual] |
CALLBACK: Does this system have control over deletion of this object? While not strictly required, it is best to have this consistently return true for only one system. Otherwise systems may fight and override each other. Defaults to NetworkIDManager::IsNetworkIDAuthority();
Definition at line 1574 of file ReplicaManager2.cpp.
bool Replica2::QueryIsSerializationAuthority | ( | void | ) | const [virtual] |
CALLBACK: Does this system have control over serialization of object members of this object? It is reasonable to have this be true for more than one system, but you would want to serialize different variables so those systems do not conflict. Defaults to NetworkIDManager::IsNetworkIDAuthority();
Definition at line 1582 of file ReplicaManager2.cpp.
bool Replica2::QueryIsVisibilityAuthority | ( | void | ) | const [virtual] |
CALLBACK: Does this system have control over visibility of this object? While not strictly required, it is best to have this consistently return true for only one system. Otherwise systems may fight and override each other. Defaults to NetworkIDManager::IsNetworkIDAuthority();
Definition at line 1578 of file ReplicaManager2.cpp.
BooleanQueryResult Replica2::QueryVisibility | ( | Connection_RM2 * | connection | ) | [virtual] |
CALLBACK: For a given connection, should this object be visible (updatable?) Checked every Update cycle if ReplicaManager2::SetAutoUpdateScope() parameter serializationVisiblity is true Defaults to BQR_ALWAYS
[in] | connection | Which connection we are referring to. 0 means unknown, in which case the system is checking for BQR_ALWAYS or BQR_NEVER as an optimization. |
Definition at line 1564 of file ReplicaManager2.cpp.
Replica2 * Replica2::ReceiveConstructionReply | ( | SystemAddress | sender, | |
BitStream * | replicaData, | |||
bool | constructionAllowed | |||
) | [protected, virtual] |
void Replica2::ReceiveDestruction | ( | SystemAddress | sender, | |
RakNet::BitStream * | serializedObject, | |||
SerializationType | serializationType, | |||
RakNetTime | timestamp, | |||
DataStructures::OrderedList< SystemAddress, SystemAddress > & | exclusionList | |||
) | [protected, virtual] |
Definition at line 1483 of file ReplicaManager2.cpp.
void Replica2::ReceiveSerialize | ( | SystemAddress | sender, | |
RakNet::BitStream * | serializedObject, | |||
SerializationType | serializationType, | |||
RakNetTime | timestamp, | |||
DataStructures::OrderedList< SystemAddress, SystemAddress > & | exclusionList | |||
) | [protected, virtual] |
Definition at line 1268 of file ReplicaManager2.cpp.
void Replica2::ReceiveVisibility | ( | SystemAddress | sender, | |
RakNet::BitStream * | serializedObject, | |||
SerializationType | serializationType, | |||
RakNetTime | timestamp, | |||
DataStructures::OrderedList< SystemAddress, SystemAddress > & | exclusionList | |||
) | [protected, virtual] |
Definition at line 1524 of file ReplicaManager2.cpp.
void Replica2::SendConstruction | ( | SystemAddress | recipientAddress, | |
SerializationType | serializationType = UNDEFINED_REASON | |||
) | [virtual] |
Construct this object on other systems Triggers a call to SerializeConstruction()
[in] | recipientAddress | Which system to send to |
[in] | serializationType | What type of command this is. Use UNDEFINED_REASON to have a type chosen automatically |
Definition at line 1148 of file ReplicaManager2.cpp.
void Replica2::SendDestruction | ( | SystemAddress | recipientAddress, | |
SerializationType | serializationType = UNDEFINED_REASON | |||
) | [virtual] |
Destroy this object on other systems Triggers a call to SerializeDestruction()
[in] | recipientAddress | Which system to send to |
[in] | serializationType | What type of command this is. Use UNDEFINED_REASON to have a type chosen automatically |
Definition at line 1182 of file ReplicaManager2.cpp.
void Replica2::SendSerialize | ( | SystemAddress | recipientAddress, | |
SerializationType | serializationType = UNDEFINED_REASON | |||
) | [virtual] |
Serialize this object to another system Triggers a call to Serialize()
[in] | recipientAddress | Which system to send to |
[in] | serializationType | What type of command this is. Use UNDEFINED_REASON to have a type chosen automatically |
Definition at line 1196 of file ReplicaManager2.cpp.
void Replica2::SendVisibility | ( | SystemAddress | recipientAddress, | |
SerializationType | serializationType = UNDEFINED_REASON | |||
) | [virtual] |
Update the visibility of this object on another system Triggers a call to SerializeVisibility()
[in] | recipientAddress | Which system to send to |
[in] | serializationType | What type of command this is. Use UNDEFINED_REASON to have a type chosen automatically |
Definition at line 1212 of file ReplicaManager2.cpp.
bool Replica2::Serialize | ( | RakNet::BitStream * | bitStream, | |
SerializationContext * | serializationContext | |||
) | [virtual] |
CALLBACK: Override in order to write to bitStream data to send as regular class serialization, for normal per-tick data. Will be received by Deserialize()
[out] | bitStream | Data to send |
[in] | serializationContext | Describes which system we are sending to, and a timestamp as an out parameter |
Definition at line 1112 of file ReplicaManager2.cpp.
virtual bool RakNet::Replica2::SerializeConstruction | ( | RakNet::BitStream * | bitStream, | |
SerializationContext * | serializationContext | |||
) | [pure virtual] |
CALLBACK: Override in order to write to bitStream data identifying this class for the class factory. Will be received by Connection_RM2::Construct() to create an instance of this class.
[out] | bitStream | Data used to identify this class, along with any data you also want to send when constructing the class |
[in] | serializationContext | serializationType passed to Replica2::SendConstruction(), along with destination system, and a timestamp you can write to. |
bool Replica2::SerializeDestruction | ( | RakNet::BitStream * | bitStream, | |
SerializationContext * | serializationContext | |||
) | [virtual] |
CALLBACK: Override in order to write to bitStream data to send along with destruction requests. Will be received by DeserializeDestruction()
[out] | bitStream | Data to send |
[in] | serializationContext | Describes which system we are sending to, and a timestamp as an out parameter |
Definition at line 1105 of file ReplicaManager2.cpp.
bool Replica2::SerializeVisibility | ( | RakNet::BitStream * | bitStream, | |
SerializationContext * | serializationContext | |||
) | [virtual] |
CALLBACK: Override in order to write to bitStream data to send along with visibility changes. Will be received by DeserializeVisibility()
[out] | bitStream | Data to send |
[in] | serializationContext | Describes which system we are sending to, and a timestamp as an out parameter |
Definition at line 1119 of file ReplicaManager2.cpp.
void Replica2::SetReplicaManager | ( | ReplicaManager2 * | rm | ) |
Sets the replica manager to use with this Replica. Will also set the NetworkIDManager associated with RakPeerInterface::SetNetworkIDManager() Call this before using any of the functions below!
[in] | rm | A pointer to your instance of ReplicaManager 2 |
Definition at line 1095 of file ReplicaManager2.cpp.
friend class Connection_RM2 [friend] |
Definition at line 688 of file ReplicaManager2.h.
friend class ReplicaManager2 [friend] |
Definition at line 687 of file ReplicaManager2.h.
DataStructures::Map<SerializationType, AutoSerializeEvent*> RakNet::Replica2::autoSerializeTimers [protected] |
Definition at line 707 of file ReplicaManager2.h.
unsigned char RakNet::Replica2::clientID [protected] |
Definition at line 694 of file ReplicaManager2.h.
Replica2 * Replica2::clientPtrArray [static, protected] |
Definition at line 691 of file ReplicaManager2.h.
unsigned char Replica2::clientSharedID = 0 [static, protected] |
Definition at line 690 of file ReplicaManager2.h.
bool RakNet::Replica2::hasClientID [protected] |
Definition at line 693 of file ReplicaManager2.h.
ReplicaManager2* RakNet::Replica2::rm2 [protected] |
Definition at line 695 of file ReplicaManager2.h.