private void SendCommand(TankNode tankNode, MoveCommand moveCommand) { TankMovementSenderComponent tankMovementSender = tankNode.tankMovementSender; Movement?movement = moveCommand.Movement; if (movement != null) { if (!PhysicsUtil.ValidateMovement(movement.Value)) { return; } tankMovementSender.LastSentMovement = movement; tankMovementSender.LastSentMovementTime = PreciseTime.Time; base.Log.Debug("SEND MOVEMENT"); } if (moveCommand.WeaponRotation != null) { if (!PhysicsUtil.IsValidFloat(moveCommand.WeaponRotation.Value)) { LoggerProvider.GetLogger(typeof(PhysicsUtil)).ErrorFormat("Invalid WeaponRotation. StackTrace:[{0}]", Environment.StackTrace); return; } tankMovementSender.LastSentWeaponRotationTime = PreciseTime.Time; base.Log.Debug("SEND WEAPON_ROTATION"); } base.ScheduleEvent(new MoveCommandEvent(moveCommand), tankNode.Entity); base.Log.Debug("SEND DISCRETE"); }
protected static float ReadFloat(BitArray bits, ref int position, int size, float factor) { float val = (Read(bits, ref position, size) - (1 << ((size - 1) & 0x1f))) * factor; if (PhysicsUtil.IsValidFloat(val)) { return(val); } Debug.LogError("AbstractMoveCodec.ReadFloat: invalid float: " + val); return(0f); }