/// <summary> /// 更新插值字段 /// </summary> public void ReadDirtyFields(NetDataReader reader) { ulong timestep = 0; reader.GetBytes(_readDirtyFlags, 1); if ((0x1 & _readDirtyFlags[0]) != 0) { if (positionInterpolation.Enabled) { positionInterpolation.target = reader.GetVector3(); positionInterpolation.Timestep = timestep; } else { _position = reader.GetVector3(); this.RunChange_Position(timestep); } } if ((0x2 & _readDirtyFlags[0]) != 0) { if (rotationInterpolation.Enabled) { rotationInterpolation.target = reader.GetQuaternion(); rotationInterpolation.Timestep = timestep; } else { _rotation = reader.GetQuaternion(); this.RunChange_Rotation(timestep); } } }
public void Pass(NetDataReader reader) { reader.GetVector3(); reader.GetQuaternion(); reader.GetVector3(); reader.GetVector3(); }
public void Read(NetDataReader reader) { Vector3 position = reader.GetVector3(); Quaternion rotation = reader.GetQuaternion(); Vector3 velocity = reader.GetVector3(); Vector3 angularVelocity = reader.GetVector3(); // Check if the new updates are very similiar to the current position. // If they are, they will not be applied to allow this object to fall asleep. // TODO: A better way of handling this. float epsilon = 0.00001f; if (!rb.position.PerComponentIsEqual(position, epsilon)) { rb.position = position; } if (!rb.rotation.PerComponentIsEqual(rotation, epsilon)) { rb.rotation = rotation; } if (!rb.velocity.PerComponentIsEqual(velocity, epsilon)) { rb.velocity = velocity; } if (!rb.angularVelocity.PerComponentIsEqual(angularVelocity, epsilon)) { rb.angularVelocity = angularVelocity; } }
public override void OnMessage(NetPeer peer, NetDataReader reader) { var count = reader.GetInt(); for (int i = 0; i < count; i++) { var npcid = reader.GetLong(); var npcType = (NpcType)reader.GetUShort(); var position = reader.GetVector3(); var rotation = reader.GetQuaternion(); NPCView npcView = null; switch (npcType) { case NpcType.Player: npcView = npcMgr.CreateNpc <TankView>(); break; case NpcType.Monster: npcView = npcMgr.CreateNpc <AnimalView>(); break; } if (npcView != null) { npcView.Initialize(npcid); npcView.InitInterpolateFields(position, rotation); } Debugger.LogWarning("OnResNpcs--->>>" + npcid + " " + npcType + " " + position); } }
public void Deserialize(NetDataReader reader) { NetworkId = reader.GetUShort(); Position = reader.GetVector3(); Rotation = reader.GetQuaternion(); Velocity = reader.GetVector3(); Grounded = reader.GetBool(); }
public void Deserialize(NetDataReader reader) { StartWorldTick = reader.GetUInt(); var length = reader.GetInt(); Inputs = new PlayerInputs[length]; ClientWorldTickDeltas = new short[length]; for (int i = 0; i < length; i++) { Inputs[i].ApplyKeyBitfield(reader.GetByte()); Inputs[i].ViewDirection = reader.GetQuaternion(); ClientWorldTickDeltas[i] = reader.GetShort(); } }
public override void OnMessage(NetPeer peer, NetDataReader reader) { var playerId = reader.GetLong(); var spawnPos = reader.GetVector3(); var rotation = reader.GetQuaternion(); string name = "Player_" + playerId; var npcView = npcMgr.CreateNpc <TankView>(); var playerView = npcView as TankView; if (playerView != null) { playerView.Initialize(playerId); playerView.InitInterpolateFields(spawnPos, rotation); } //lockstepMgr.UpdateClientCount(playerId); Debugger.LogWarning("OnNewPlayer--->>>" + name + " " + spawnPos); }
public override void OnMessage(NetPeer peer, NetDataReader reader) { var npcid = reader.GetLong(); reader.GetBytes(_readDirtyFlags, 1); var npcView = NpcMgr.GetNpc(npcid); if (npcView != null) { if ((0x1 & _readDirtyFlags[0]) != 0) { npcView.position = reader.GetVector3(); } if ((0x2 & _readDirtyFlags[0]) != 0) { npcView.rotation = reader.GetQuaternion(); } } base.IntactTransterMessage(peer, reader); }
public override void OnMessage(NetPeer peer, NetDataReader reader) { var npcid = reader.GetLong(); var spawnPos = reader.GetVector3(); var rotation = reader.GetQuaternion(); var npcView = npcMgr.CreateNpc <TankView>(); var mainRoleView = npcView as TankView; if (mainRoleView != null) { mainRoleView.Initialize(npcid, true); //创建主角自身 mainRoleView.InitInterpolateFields(spawnPos, rotation); } //lockstepMgr.Identity = npcid; ///启动Lockstep同步 //lockstepMgr.Initialize(); //lockstepMgr.StartLockstep(); Debugger.LogWarning("RetUserInfoHandler npcid:>" + npcid + " spawnPos:>" + spawnPos + " rotation:>" + rotation); }
public void Deserialize(NetDataReader reader) { Buttons.Deserialize(reader); Rotation = reader.GetQuaternion(); }
public override void Read(NetDataReader reader) { Set(reader.GetQuaternion()); }
public override void Pass(NetDataReader reader) { reader.GetQuaternion(); }
public void Deserialize(NetDataReader reader) { position = reader.GetVector3(); rotation = reader.GetQuaternion(); }