public override void OnReplicationSerialize(P2PNetworkWriter writer, bool initial_state) { if (initial_state) { this.m_QuadTree.SerializeAllObjects(writer); } }
public virtual void OnReplicationSerialize_CJGenerated(P2PNetworkWriter writer, bool initial_state) { writer.Write(this.m_BestTriggerReplObj_Repl); writer.Write(this.m_ExecutedTriggerReplObj_Repl); if (this.m_BestTriggerChildIdx_Repl == null) { writer.WritePackedUInt32(0u); } else { writer.WritePackedUInt32((uint)this.m_BestTriggerChildIdx_Repl.Count); for (int i = 0; i < this.m_BestTriggerChildIdx_Repl.Count; i++) { writer.Write(this.m_BestTriggerChildIdx_Repl[i]); } } if (this.m_ExecutedTriggerChildIdx_Repl == null) { writer.WritePackedUInt32(0u); return; } writer.WritePackedUInt32((uint)this.m_ExecutedTriggerChildIdx_Repl.Count); for (int j = 0; j < this.m_ExecutedTriggerChildIdx_Repl.Count; j++) { writer.Write(this.m_ExecutedTriggerChildIdx_Repl[j]); } }
public void Serialize(P2PNetworkWriter writer) { writer.Write(this.m_Position); writer.Write((int)this.m_ItemID); writer.Write(this.m_ActiveChildrenMask); writer.Write((short)this.m_Group.index); }
public override void OnReplicationSerialize(P2PNetworkWriter writer, bool initialState) { if (this.m_AnimatorParamsDirty || initialState) { writer.Write(this.m_AnimatorParams.Count); for (int i = 0; i < this.m_AnimatorParams.Count; i++) { this.m_AnimatorParams[i].Serialize(writer); } this.m_AnimatorParamsDirty = false; } else { writer.Write(0); } if (this.m_LayeredAnimationsDirty || initialState) { writer.Write(this.m_LayeredAnimationStringHashes.Length); for (int j = 0; j < this.m_LayeredAnimationStringHashes.Length; j++) { writer.Write(this.m_LayeredAnimationStringHashes[j]); } this.m_LayeredAnimationsDirty = false; return; } writer.Write(0); }
public virtual void OnReplicationSerialize_CJGenerated(P2PNetworkWriter writer, bool initial_state) { if (this.m_ReplActiveElements_Repl == null) { writer.WritePackedUInt32(0u); } else { writer.WritePackedUInt32((uint)this.m_ReplActiveElements_Repl.Length); for (int i = 0; i < this.m_ReplActiveElements_Repl.Length; i++) { writer.Write(this.m_ReplActiveElements_Repl[i]); } } if (initial_state) { if (this.m_ReplActiveElementsHash == null) { writer.WritePackedUInt32(0u); return; } writer.WritePackedUInt32((uint)this.m_ReplActiveElementsHash.Length); for (int j = 0; j < this.m_ReplActiveElementsHash.Length; j++) { writer.Write(this.m_ReplActiveElementsHash[j]); } } }
public override void OnReplicationSerialize(P2PNetworkWriter writer, bool initialState) { if (this.IsAttached()) { writer.Write('\0'); return; } writer.Write((char)this.transformSyncMode); switch (this.transformSyncMode) { case ReplicatedTransform.TransformSyncMode.SyncNone: return; case ReplicatedTransform.TransformSyncMode.SyncTransform: this.SerializeModeTransform(writer); return; case ReplicatedTransform.TransformSyncMode.SyncRigidbody2D: this.SerializeMode2D(writer); return; case ReplicatedTransform.TransformSyncMode.SyncRigidbody3D: this.SerializeMode3D(writer); return; case ReplicatedTransform.TransformSyncMode.SyncCharacterController: this.SerializeModeCharacterController(writer); return; default: return; } }
private void SerializeMode3D(P2PNetworkWriter writer) { if (base.gameObject.activeSelf) { writer.Write(this.m_RigidBody3D.worldCenterOfMass); } else { writer.Write(base.transform.position); } ReplicatedTransform.SerializeVelocity3D(writer, this.m_RigidBody3D.velocity, ReplicatedTransform.CompressionSyncMode.None); if (this.syncRotationAxis != ReplicatedTransform.AxisSyncMode.None) { if (base.gameObject.activeSelf) { ReplicatedTransform.SerializeRotation3D(writer, this.m_RigidBody3D.rotation, this.syncRotationAxis, this.rotationSyncCompression); } else { ReplicatedTransform.SerializeRotation3D(writer, base.transform.rotation, this.syncRotationAxis, this.rotationSyncCompression); } } if (this.m_SyncSpin) { ReplicatedTransform.SerializeSpin3D(writer, this.m_RigidBody3D.angularVelocity, this.syncRotationAxis, this.rotationSyncCompression); } this.m_PrevPosition = (base.gameObject.activeSelf ? this.m_RigidBody3D.position : base.transform.position); this.m_PrevRotation = (base.gameObject.activeSelf ? this.m_RigidBody3D.rotation : base.transform.rotation); this.m_PrevVelocity = this.m_RigidBody3D.velocity.sqrMagnitude; }
// Create a P2PNetworkWriter from a list of entities. This P2PNetworkWriter can then be sent to peers private P2PNetworkWriter CreateNetworkWriterForChangedEntities(List <EntityData> changedEntities) { for (int i = changedEntities.Count - 1; i >= 0; i--) { if (!changedEntities[i].transform) { changedEntities.RemoveAt(i); } } if (changedEntities.Count == 0) { return(null); } P2PNetworkWriter writer = new P2PNetworkWriter(); writer.StartMessage(ENTITY_SCALE_SYNC_MESSAGE_TYPE); writer.Write((byte)changedEntities.Count); for (int i = 0; i < changedEntities.Count; i++) { writer.Write(changedEntities[i].transform.gameObject); writer.Write(changedEntities[i].transform.localScale.x); } writer.FinishMessage(); return(writer); }
public override void Serialize(P2PNetworkWriter writer) { writer.Write(this.guid_bytes, GuidComponent.GUID_BYTES_CNT); writer.Write(this.assetId); writer.Write(this.position); writer.WriteBytesFull(this.payload); }
public override void OnReplicationSerialize_CJGenerated(P2PNetworkWriter writer, bool initial_state) { base.OnReplicationSerialize_CJGenerated(writer, initial_state); writer.Write((int)this.m_LCInfo_m_LiquidType_Repl); writer.Write(this.m_LCInfo_m_Capacity_Repl); writer.Write(this.m_LCInfo_m_Amount_Repl); }
public override void OnReplicationSerialize(P2PNetworkWriter writer, bool initialState) { writer.Write(MainLevel.s_GameTime); writer.Write(MainLevel.Instance.m_TODSky.Cycle.Day); writer.Write(MainLevel.Instance.m_TODSky.Cycle.Hour); writer.Write(MainLevel.Instance.m_TODSky.Cycle.Month); writer.Write(MainLevel.Instance.m_TODSky.Cycle.Year); }
public override void OnReplicationSerialize(P2PNetworkWriter writer, bool initial_state) { writer.Write((int)this.m_ReplControllerType); if (this.m_ReplControllerType != PlayerControllerType.Unknown) { writer.Write(this.m_ReplItemName); } }
public virtual bool SendWriter(P2PNetworkWriter writer, int channelId) { if (this.m_LogNetworkMessages) { this.LogSend(writer.ToArray()); } return(this.CheckChannel(channelId) && this.m_Channels[channelId].SendWriter(writer)); }
public override void OnReplicationSerialize(P2PNetworkWriter writer, bool initial_state) { writer.Write(this.m_WeatherInterpolated); writer.Write(this.m_CurrentDataIndex); writer.Write((this.m_CurrentRainData != null) ? this.m_CurrentRainData.m_ExecutionTime : 0f); writer.Write(this.m_CurrentPeriod); writer.Write(this.m_PeriodStartTime); writer.Write(this.m_LastRainTime); }
public override void Serialize(P2PNetworkWriter writer) { writer.Write((ushort)this.scripts.Length); foreach (P2PCRCMessageEntry p2PCRCMessageEntry in this.scripts) { writer.Write(p2PCRCMessageEntry.name); writer.Write(p2PCRCMessageEntry.channel); } }
public void SendTextChatMessage(string message) { P2PNetworkWriter p2PNetworkWriter = new P2PNetworkWriter(); p2PNetworkWriter.StartMessage(10); p2PNetworkWriter.Write(message); p2PNetworkWriter.FinishMessage(); this.SendWriterToAll(p2PNetworkWriter, 1); }
public override void OnReplicationSerialize(P2PNetworkWriter writer, bool initial_state) { base.OnReplicationSerialize(writer, initial_state); writer.Write(this.m_CurrentHitsCount); foreach (ConstructionSlot constructionSlot in this.m_ConstructionSlots) { writer.Write((constructionSlot.m_Construction != null) ? constructionSlot.m_Construction.gameObject : null); } }
public void SendWriterToAll(P2PNetworkWriter writer, int channelId) { for (int i = 0; i < this.m_Connections.Count; i++) { if (this.m_Connections[i] != null && this.m_Connections[i].m_IsReady) { this.m_Connections[i].SendWriter(writer, channelId); } } }
private void SendWriterToAllExcept(int connection_id, P2PNetworkWriter writer, int channel_id) { for (int i = 0; i < this.m_Connections.Count; i++) { if (this.m_Connections[i] != null && this.m_Connections[i].m_ConnectionId != connection_id) { this.m_Connections[i].SendWriter(writer, channel_id); } } }
private void SendWriterTo(int connection_id, P2PNetworkWriter writer, int channel_id) { P2PConnection p2PConnection = this.FindConnection(connection_id); if (p2PConnection == null) { return; } p2PConnection.SendWriter(writer, channel_id); }
private void SerializeModeCharacterController(P2PNetworkWriter writer) { writer.Write(base.transform.position); if (this.syncRotationAxis != ReplicatedTransform.AxisSyncMode.None) { ReplicatedTransform.SerializeRotation3D(writer, base.transform.rotation, this.syncRotationAxis, this.rotationSyncCompression); } this.m_PrevPosition = base.transform.position; this.m_PrevRotation = base.transform.rotation; this.m_PrevVelocity = 0f; }
public override void OnReplicationSerialize(P2PNetworkWriter writer, bool initialState) { if (!initialState) { writer.WritePackedUInt32((uint)this.m_ReplDestroyedObject.Count); for (int i = 0; i < this.m_ReplDestroyedObject.Count; i++) { writer.Write(this.m_ReplDestroyedObject[i]); } this.m_ReplDestroyedObject.Clear(); } }
public override void OnReplicationSerialize(P2PNetworkWriter writer, bool initial_state) { if (initial_state) { List <Vector3> allPoints = this.m_DestroyedObjects.GetAllPoints(); writer.Write((ushort)allPoints.Count); for (int i = 0; i < allPoints.Count; i++) { writer.Write(allPoints[i]); } } }
public override void OnReplicationSerialize(P2PNetworkWriter writer, bool initial_state) { writer.Write(this.m_IsRunning); writer.Write(this.m_IsInWater); writer.Write(this.m_IsSwimming); writer.Write(this.m_IsSleeping); writer.Write(this.m_LastCollisionFlags); writer.Write(this.m_WantedSpeed2d); writer.Write(this.m_IsDead); writer.Write(this.m_IsInSafeZone); writer.Write(this.m_Health); writer.Write(this.m_MaxHealth); }
public virtual void OnReplicationSerialize_CJGenerated(P2PNetworkWriter writer, bool initial_state) { if (this.m_Rotation_Repl == null) { writer.WritePackedUInt32(0u); return; } writer.WritePackedUInt32((uint)this.m_Rotation_Repl.Length); for (int i = 0; i < this.m_Rotation_Repl.Length; i++) { writer.Write(this.m_Rotation_Repl[i]); } }
// Synchronize IsEnabled's value with peers private void SendEnabledStateToPeers() { enabledStateNextSyncTime = Time.realtimeSinceStartup + ENABLED_STATE_SYNC_INTERVAL; // Master (host) determines whether or not the mod is enabled if (ReplTools.AmIMaster() && !ReplTools.IsPlayingAlone()) { P2PNetworkWriter writer = new P2PNetworkWriter(); writer.StartMessage(ENABLED_STATE_SYNC_MESSAGE_TYPE); writer.Write(IsEnabled); writer.FinishMessage(); P2PSession.Instance.SendWriterToAll(writer, 0); // 0: TCP, 1: UDP } }
public bool Despawn(ReplicationComponent obj) { if (ReplTools.IsPlayingAlone()) { return(false); } P2PNetworkWriter p2PNetworkWriter = this.BuildDespawnWriter(obj); if (p2PNetworkWriter != null) { P2PSession.Instance.SendWriterToAll(p2PNetworkWriter, 0); } return(p2PNetworkWriter != null); }
public bool DespawnForPeer(ReplicationComponent obj, P2PPeer peer) { P2PNetworkWriter p2PNetworkWriter = this.BuildDespawnWriter(obj); if (p2PNetworkWriter != null) { if (P2PLogFilter.logPedantic) { Debug.Log(string.Format("DespawnForPeer [{0}] called for {1} guid: {2}", peer.GetHostId(), obj.name, obj.GetGuidComponent.GetGuid()), obj); } P2PSession.Instance.SendWriterTo(peer, p2PNetworkWriter, 0); } return(p2PNetworkWriter != null); }
public virtual void OnReplicationSerialize_CJGenerated(P2PNetworkWriter writer, bool initial_state) { writer.Write((int)this.m_WeaponType_Repl); writer.Write(this.m_PrimaryWeapon_Repl ? this.m_PrimaryWeapon_Repl.gameObject : null); writer.Write(this.m_PrimaryWeapon_Repl ? this.m_PrimaryWeapon_Repl.GetReplicationComponent().GetComponentIndex(this.m_PrimaryWeapon_Repl) : -1); writer.Write(this.m_AdditionalWeapon_Repl ? this.m_AdditionalWeapon_Repl.gameObject : null); writer.Write(this.m_AdditionalWeapon_Repl ? this.m_AdditionalWeapon_Repl.GetReplicationComponent().GetComponentIndex(this.m_AdditionalWeapon_Repl) : -1); writer.Write(this.m_SecondaryWeapon_Repl ? this.m_SecondaryWeapon_Repl.gameObject : null); writer.Write(this.m_SecondaryWeapon_Repl ? this.m_SecondaryWeapon_Repl.GetReplicationComponent().GetComponentIndex(this.m_SecondaryWeapon_Repl) : -1); writer.Write(this.m_CurrentWeapon_Repl ? this.m_CurrentWeapon_Repl.gameObject : null); writer.Write(this.m_CurrentWeapon_Repl ? this.m_CurrentWeapon_Repl.GetReplicationComponent().GetComponentIndex(this.m_CurrentWeapon_Repl) : -1); writer.Write(this.m_CurrentAdditionalWeapon_Repl ? this.m_CurrentAdditionalWeapon_Repl.gameObject : null); writer.Write(this.m_CurrentAdditionalWeapon_Repl ? this.m_CurrentAdditionalWeapon_Repl.GetReplicationComponent().GetComponentIndex(this.m_CurrentAdditionalWeapon_Repl) : -1); }
private void SyncScale(bool tcp) { if (!ReplTools.IsPlayingAlone()) { float scale = targetTransform.localScale.x; remoteScale = scale; P2PNetworkWriter writer = new P2PNetworkWriter(); writer.StartMessage(GulliverMod.PLAYER_SCALE_SYNC_MESSAGE_TYPE); writer.Write(gameObject); writer.Write(scale); writer.FinishMessage(); P2PSession.Instance.SendWriterToAll(writer, tcp ? 0 : 1); // 0: TCP, 1: UDP } }