#include <ReplicaManager2.h>
Public Member Functions | |
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) |
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()
virtual void RakNet::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 |
virtual bool RakNet::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. |
virtual void RakNet::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() |
virtual void RakNet::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. |
virtual void RakNet::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. |
virtual void RakNet::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. |
virtual void RakNet::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 |
virtual void RakNet::Replica2::CancelAutoSerializeTimer | ( | SerializationType | serializationType = AUTOSERIALIZE_DEFAULT |
) | [virtual] |
Stop calling an autoSerialize timer previously setup with AddAutoSerializeTimer()
[in] | serializationType | Corresponding value passed to serializationType |
virtual void RakNet::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. |
virtual void RakNet::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. |
virtual void RakNet::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. |
virtual void RakNet::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. |
virtual void RakNet::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
ReplicaManager2* RakNet::Replica2::GetReplicaManager | ( | void | ) | const |
Returns what was passed to SetReplicaManager(), or 0 if no value ever passed
RakNetTime RakNet::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. |
virtual void RakNet::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
virtual void RakNet::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. |
virtual BooleanQueryResult RakNet::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. |
virtual bool RakNet::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();
virtual bool RakNet::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();
virtual bool RakNet::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();
virtual bool RakNet::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();
virtual BooleanQueryResult RakNet::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. |
virtual void RakNet::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 |
virtual void RakNet::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 |
virtual void RakNet::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 |
virtual void RakNet::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 |
virtual bool RakNet::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 |
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. |
virtual bool RakNet::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 |
virtual bool RakNet::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 |
void RakNet::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 |