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); }
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); }