private void UnserializeModeCharacterController(P2PNetworkReader reader, bool initial_state) { if (this.m_MoveCallback3D != null) { Vector3 targetSyncPosition = reader.ReadVector3(); Quaternion targetSyncRotation3D = Quaternion.identity; if (this.syncRotationAxis != ReplicatedTransform.AxisSyncMode.None) { targetSyncRotation3D = ReplicatedTransform.UnserializeRotation3D(reader, this.syncRotationAxis, this.rotationSyncCompression); } Vector3 targetSyncVelocity = (this.m_CharacterController != null) ? this.m_CharacterController.velocity : Vector3.zero; if (!this.m_MoveCallback3D(ref targetSyncPosition, ref targetSyncVelocity, ref targetSyncRotation3D)) { return; } this.m_TargetSyncPosition = targetSyncPosition; this.m_TargetSyncVelocity = targetSyncVelocity; if (this.syncRotationAxis != ReplicatedTransform.AxisSyncMode.None) { this.m_TargetSyncRotation3D = targetSyncRotation3D; } } else { this.m_TargetSyncPosition = reader.ReadVector3(); if (this.syncRotationAxis != ReplicatedTransform.AxisSyncMode.None) { this.m_TargetSyncRotation3D = ReplicatedTransform.UnserializeRotation3D(reader, this.syncRotationAxis, this.rotationSyncCompression); } } if (this.m_CharacterController != null) { if (initial_state || this.ReplGetReplicationInterval() <= 0f) { base.transform.position = this.m_TargetSyncPosition; if (this.syncRotationAxis != ReplicatedTransform.AxisSyncMode.None) { base.transform.rotation = this.m_TargetSyncRotation3D; } this.m_FixedPosDiff = Vector3.zero; return; } Vector3 a = (this.m_TargetSyncPosition - base.transform.position) / this.ReplGetReplicationInterval(); this.m_FixedPosDiff = a * Time.fixedDeltaTime; if ((base.transform.position - this.m_TargetSyncPosition).magnitude > this.snapThreshold) { base.transform.position = this.m_TargetSyncPosition; this.m_FixedPosDiff = Vector3.zero; } if (this.interpolateRotation == 0f && this.syncRotationAxis != ReplicatedTransform.AxisSyncMode.None) { base.transform.rotation = this.m_TargetSyncRotation3D; } if (this.m_InterpolateMovement == 0f) { base.transform.position = this.m_TargetSyncPosition; } } }
public override void Deserialize(P2PNetworkReader reader) { this.guid_bytes = reader.ReadGuidBytesTemporary(); this.assetId = reader.ReadNetworkHash128(); this.position = reader.ReadVector3(); this.payload = reader.ReadBytesAndSize(); }
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 void UnserializeModeTransform(P2PNetworkReader reader, bool initial_state) { if (initial_state) { this.m_TargetSyncPosition = (base.transform.position = reader.ReadVector3()); if (this.syncRotationAxis != ReplicatedTransform.AxisSyncMode.None) { this.m_TargetSyncRotation3D = (base.transform.rotation = ReplicatedTransform.UnserializeRotation3D(reader, this.syncRotationAxis, this.rotationSyncCompression)); } this.m_FixedPosDiff = Vector3.zero; return; } this.m_TargetSyncPosition = reader.ReadVector3(); if (this.syncRotationAxis != ReplicatedTransform.AxisSyncMode.None) { this.m_TargetSyncRotation3D = ReplicatedTransform.UnserializeRotation3D(reader, this.syncRotationAxis, this.rotationSyncCompression); } Vector3 a = (this.m_TargetSyncPosition - base.transform.position) / this.ReplGetReplicationInterval(); this.m_FixedPosDiff = a * Time.fixedDeltaTime; }
public override void OnReplicationDeserialize(P2PNetworkReader reader, bool initialState) { if (!initialState) { uint num = reader.ReadPackedUInt32(); int num2 = 0; while ((long)num2 < (long)((ulong)num)) { StaticObjectsManager.Get().ObjectDestroyed(reader.ReadVector3()); num2++; } } }
public override void OnReplicationDeserialize(P2PNetworkReader reader, bool initial_state) { if (initial_state) { foreach (GameObject obj in this.m_ReplacedMap.Values) { UnityEngine.Object.Destroy(obj); } this.m_ReplacedMap.Clear(); this.m_ObjectsRemovedFromStatic.Clear(); this.EnableObjectsInQuadTree(); List <Vector3> allPoints = this.m_DestroyedObjects.GetAllPoints(); for (int i = 0; i < allPoints.Count; i++) { StaticObjectClass objectsInPos = this.m_QuadTree.GetObjectsInPos(allPoints[i]); if (objectsInPos != null && objectsInPos.m_GameObject != null) { objectsInPos.m_GameObject.SetActive(true); if (objectsInPos.m_GameObject.transform.parent != null) { objectsInPos.m_GameObject.transform.parent.gameObject.SetActive(true); } objectsInPos.m_State = 0; } } this.m_DestroyedObjects.Clear(); ushort num = reader.ReadUInt16(); for (int j = 0; j < (int)num; j++) { Vector3 vector = reader.ReadVector3(); StaticObjectClass objectsInPos2 = this.m_QuadTree.GetObjectsInPos(vector); if (objectsInPos2 != null && objectsInPos2.m_GameObject != null) { objectsInPos2.m_GameObject.SetActive(false); if (objectsInPos2.m_GameObject.transform.parent != null) { objectsInPos2.m_GameObject.transform.parent.gameObject.SetActive(false); } } this.m_DestroyedObjects.InsertPoint(vector, false); } ObjectWithTrunk.OnLoad(); this.OnLoaded(); } }
public override void OnReplicationDeserialize(P2PNetworkReader reader, bool initial_state) { if (initial_state) { foreach (string key in this.m_Groups.Keys) { this.m_ObjectsInArea[key].Clear(); } this.m_QuadTree.Clear(); int num = reader.ReadInt32(); for (int i = 0; i < num; i++) { BalanceSystemObject balanceSystemObject = new BalanceSystemObject(); reader.ReadVector3(); balanceSystemObject.Deserialize(reader); this.m_QuadTree.InsertObject(balanceSystemObject, balanceSystemObject.m_Position); } this.SpawnObjectsIfNeeded(); } }
private void UnserializeMode3D(P2PNetworkReader reader, bool initial_state) { if (this.m_MoveCallback3D != null) { Vector3 targetSyncPosition = reader.ReadVector3(); Vector3 targetSyncVelocity = reader.ReadVector3(); Quaternion targetSyncRotation3D = Quaternion.identity; if (this.syncRotationAxis != ReplicatedTransform.AxisSyncMode.None) { targetSyncRotation3D = ReplicatedTransform.UnserializeRotation3D(reader, this.syncRotationAxis, this.rotationSyncCompression); } if (!this.m_MoveCallback3D(ref targetSyncPosition, ref targetSyncVelocity, ref targetSyncRotation3D)) { return; } this.m_TargetSyncPosition = targetSyncPosition; this.m_TargetSyncVelocity = targetSyncVelocity; if (this.syncRotationAxis != ReplicatedTransform.AxisSyncMode.None) { this.m_TargetSyncRotation3D = targetSyncRotation3D; } } else { this.m_TargetSyncPosition = reader.ReadVector3(); if (this.m_RigidBody3D != null) { this.m_TargetSyncTransformPosition = this.m_RigidBody3D.position - this.m_RigidBody3D.worldCenterOfMass + this.m_TargetSyncPosition; } else { Renderer rendererComponent = this.RendererComponent; if (rendererComponent != null) { this.m_TargetSyncTransformPosition = base.transform.position - rendererComponent.bounds.center + this.m_TargetSyncPosition; } } this.m_TargetSyncVelocity = reader.ReadVector3(); if (this.syncRotationAxis != ReplicatedTransform.AxisSyncMode.None) { this.m_TargetSyncRotation3D = ReplicatedTransform.UnserializeRotation3D(reader, this.syncRotationAxis, this.rotationSyncCompression); } } if (this.syncSpin) { this.m_TargetSyncAngularVelocity3D = ReplicatedTransform.UnserializeSpin3D(reader, this.syncRotationAxis, this.rotationSyncCompression); } if (!base.gameObject.activeSelf || initial_state) { base.transform.position = this.m_TargetSyncTransformPosition; base.transform.rotation = this.m_TargetSyncRotation3D; } if (this.m_RigidBody3D != null) { if (this.ReplGetReplicationInterval() <= 0f) { this.m_RigidBody3D.MovePosition(this.m_TargetSyncTransformPosition); this.m_RigidBody3D.velocity = this.m_TargetSyncVelocity; if (this.syncRotationAxis != ReplicatedTransform.AxisSyncMode.None) { this.m_RigidBody3D.MoveRotation(this.m_TargetSyncRotation3D); } if (this.syncSpin) { this.m_RigidBody3D.angularVelocity = this.m_TargetSyncAngularVelocity3D; } return; } if ((this.m_RigidBody3D.worldCenterOfMass - this.m_TargetSyncPosition).magnitude > this.snapThreshold) { this.m_RigidBody3D.MovePosition(this.m_TargetSyncTransformPosition); this.m_RigidBody3D.velocity = this.m_TargetSyncVelocity; } if (this.interpolateRotation == 0f && this.syncRotationAxis != ReplicatedTransform.AxisSyncMode.None) { this.m_RigidBody3D.rotation = this.m_TargetSyncRotation3D; if (this.syncSpin) { this.m_RigidBody3D.angularVelocity = this.m_TargetSyncAngularVelocity3D; } } if (this.m_InterpolateMovement == 0f) { this.m_RigidBody3D.position = this.m_TargetSyncTransformPosition; } if (initial_state && this.syncRotationAxis != ReplicatedTransform.AxisSyncMode.None) { this.m_RigidBody3D.rotation = this.m_TargetSyncRotation3D; } } }
public static Vector3 UnserializeVelocity3D(P2PNetworkReader reader, ReplicatedTransform.CompressionSyncMode compression) { return(reader.ReadVector3()); }