public void Deserialize(P2PNetworkReader reader) { this.m_Position = reader.ReadVector3(); this.m_ItemID = (ItemID)reader.ReadInt32(); this.m_ActiveChildrenMask = reader.ReadInt32(); this.m_Group = BalanceSystem20.Get().GetGroupByIndex((int)reader.ReadInt16()); }
private static float ReadAngle(P2PNetworkReader reader, ReplicatedTransform.CompressionSyncMode compression) { switch (compression) { case ReplicatedTransform.CompressionSyncMode.None: return(reader.ReadFloat()); case ReplicatedTransform.CompressionSyncMode.Low: return((float)reader.ReadInt16()); case ReplicatedTransform.CompressionSyncMode.High: return((float)reader.ReadInt16()); default: return(0f); } }
protected void HandleReader(P2PNetworkReader reader, int received_size, int channel_id) { while ((ulong)reader.Position < (ulong)((long)received_size)) { ushort num = reader.ReadUInt16(); short num2 = reader.ReadInt16(); uint position = reader.Position; reader.SetGuard(position + (uint)num); P2PConnection.s_Size = position + (uint)num; if (this.m_LogNetworkMessages) { Debug.Log(string.Concat(new object[] { "ConnectionRecv con:", this.m_ConnectionId, " bytes:", num, " msgId:", num2 })); } List <P2PNetworkMessageDelegate> list = null; if (this.m_MessageHandlersDict.ContainsKey(num2)) { list = this.m_MessageHandlersDict[num2]; } if (list != null) { this.m_NetMsg.m_MsgType = num2; this.m_NetMsg.m_Reader = reader; this.m_NetMsg.m_Connection = this; this.m_NetMsg.m_ChannelId = channel_id; for (int i = 0; i < list.Count; i++) { list[i](this.m_NetMsg); } this.m_LastMessageTime = Time.time; } else if (P2PLogFilter.logError) { Debug.LogError(string.Format("Unknown message type {0} connection id: {1}", P2PMsgType.MsgTypeToString(num2), this.m_ConnectionId)); } if (position + (uint)num != reader.Position) { int num3 = (int)(position + (uint)num - reader.Position); if (num3 > 0 && P2PLogFilter.logInfo) { Debug.Log(string.Format("Message {0} conn_id: {1} was not fully read, performing seek by {2} bytes", P2PMsgType.MsgTypeToString(num2), this.m_ConnectionId, num3)); } if (num3 < 0 && P2PLogFilter.logError) { Debug.LogError(string.Format("Message {0} conn_id: {1} reading over the buffer limit (this is really bad), performing seek by {2} bytes", P2PMsgType.MsgTypeToString(num2), this.m_ConnectionId, num3)); } reader.Seek(num3); } reader.RemoveGuard(); } }
public void ReplicationReceive(P2PNetworkReader reader, bool initial_state) { if (P2PLogFilter.logPedantic) { Debug.Log(string.Format("ReplicationReceive called for {0} with guid {1}", base.name, this.GetGuidComponent.GetGuid()), this); } int num = reader.ReadInt32(); if (num <= this.m_Revision && !initial_state) { return; } ReplicationComponent.s_DeserializedComponent = this; this.m_Revision = num; this.m_LastReplicationTime = Time.time; this.m_LastReplicationTimeReal = Time.realtimeSinceStartup; short num2 = reader.ReadInt16(); if (this.m_OwnerPeer.GetHostId() != num2) { this.ReplOnChangedOwner(ReplTools.GetPeerById(num2)); if (this.m_OwnerPeer == ReplTools.GetLocalPeer()) { this.ReplRequestOwnership(); } } this.ReplBlockChangeOwnership(!reader.ReadBoolean()); for (int i = 0; i < this.GetReplBehaviours.Length; i++) { IReplicatedBehaviour replicatedBehaviour = this.GetReplBehaviours[i]; if (replicatedBehaviour as UnityEngine.Object == null) { if (reader.ReadBoolean()) { ReplicationComponent.s_DeserializedComponent = null; return; } this.m_ReplBehavioursFlag[i] = false; } else if (reader.ReadBoolean()) { int uniqueIdForType = replicatedBehaviour.GetUniqueIdForType(); int num3 = reader.ReadInt32(); if (uniqueIdForType != num3) { ReplicationComponent.s_DeserializedComponent = null; return; } replicatedBehaviour.OnReplicationDeserialize(reader, initial_state); this.CallReplicationDeserialize_Gen(replicatedBehaviour, reader, initial_state); this.m_ReplBehavioursFlag[i] = true; } else { this.m_ReplBehavioursFlag[i] = false; } } for (int j = 0; j < this.GetReplBehaviours.Length; j++) { if (this.m_ReplBehavioursFlag[j]) { IReplicatedBehaviour replicatedBehaviour2 = this.GetReplBehaviours[j]; replicatedBehaviour2.OnReplicationResolve(); this.CallReplicationResolve_Gen(replicatedBehaviour2); } } if (P2PConnection.s_Size > reader.Position && !initial_state) { Debug.LogError(string.Format("Didn't read whole buffer! (number of bytes unread: {0})", P2PConnection.s_Size - reader.Position), this); } ReplicationComponent.s_DeserializedComponent = null; }