本文整理汇总了C#中IMyReplicable.OnSave方法的典型用法代码示例。如果您正苦于以下问题:C# IMyReplicable.OnSave方法的具体用法?C# IMyReplicable.OnSave怎么用?C# IMyReplicable.OnSave使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMyReplicable
的用法示例。
在下文中一共展示了IMyReplicable.OnSave方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SendReplicationCreate
void SendReplicationCreate(IMyReplicable obj, EndpointId clientEndpoint)
{
var typeId = GetTypeIdByType(obj.GetType());
var networkId = GetNetworkIdByObject(obj);
var groups = m_replicableGroups[obj];
Debug.Assert(groups.Count <= 255, "Unexpectedly high number of groups");
m_sendStream.ResetWrite();
m_sendStream.WriteTypeId(typeId);
m_sendStream.WriteNetworkId(networkId);
m_sendStream.WriteByte((byte)groups.Count);
for (int i = 0; i < groups.Count; i++)
{
m_sendStream.WriteNetworkId(GetNetworkIdByObject(groups[i]));
}
obj.OnSave(m_sendStream);
m_callback.SendReplicationCreate(m_sendStream, clientEndpoint);
//Server.SendMessage(m_sendStream, clientId, PacketReliabilityEnum.RELIABLE, PacketPriorityEnum.LOW_PRIORITY, MyChannelEnum.Replication);
}
示例2: SendReplicationCreate
void SendReplicationCreate(IMyReplicable obj, ClientData clientData, EndpointId clientEndpoint)
{
if (m_replicationPaused)
{
clientData.PausedReplicables.Add(obj);
return;
}
ProfilerShort.Begin("PrepareSave");
var typeId = GetTypeIdByType(obj.GetType());
var networkId = GetNetworkIdByObject(obj);
var groups = m_replicableGroups[obj];
Debug.Assert(groups.Count <= 255, "Unexpectedly high number of groups");
m_sendStream.ResetWrite();
m_sendStream.WriteTypeId(typeId);
m_sendStream.WriteNetworkId(networkId);
var streamable = obj as IMyStreamableReplicable;
bool sendStreamed = streamable != null && streamable.NeedsToBeStreamed;
if (streamable != null && streamable.NeedsToBeStreamed == false)
{
m_sendStream.WriteByte((byte)(groups.Count - 1));
}
else
{
m_sendStream.WriteByte((byte)groups.Count);
}
for (int i = 0; i < groups.Count; i++)
{
if (sendStreamed == false && groups[i].GroupType == StateGroupEnum.Streamining)
{
continue;
}
m_sendStream.WriteNetworkId(GetNetworkIdByObject(groups[i]));
}
ProfilerShort.End();
ProfilerShort.Begin("SaveReplicable");
if (sendStreamed)
{
clientData.Replicables[obj].IsStreaming = true;
m_callback.SendReplicationCreateStreamed(m_sendStream, clientEndpoint);
}
else
{
obj.OnSave(m_sendStream);
ProfilerShort.Begin("Send");
m_callback.SendReplicationCreate(m_sendStream, clientEndpoint);
ProfilerShort.End();
}
ProfilerShort.End();
//Server.SendMessage(m_sendStream, clientId, PacketReliabilityEnum.RELIABLE, PacketPriorityEnum.LOW_PRIORITY, MyChannelEnum.Replication);
}