Implemented SteerVehicle packet.
This commit is contained in:
parent
e8d1ed36c5
commit
f300ed54e5
@ -1090,6 +1090,15 @@ void cClientHandle::HandleSlotSelected(short a_SlotNum)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cClientHandle::HandleSteerVehicle(float a_Forward, float a_Sideways)
|
||||||
|
{
|
||||||
|
m_Player->SteerVehicle(a_Forward, a_Sideways);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cClientHandle::HandleWindowClose(char a_WindowID)
|
void cClientHandle::HandleWindowClose(char a_WindowID)
|
||||||
{
|
{
|
||||||
m_Player->CloseWindowIfID(a_WindowID);
|
m_Player->CloseWindowIfID(a_WindowID);
|
||||||
|
@ -177,6 +177,7 @@ public:
|
|||||||
void HandleRespawn (void);
|
void HandleRespawn (void);
|
||||||
void HandleRightClick (int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, const cItem & a_HeldItem);
|
void HandleRightClick (int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, const cItem & a_HeldItem);
|
||||||
void HandleSlotSelected (short a_SlotNum);
|
void HandleSlotSelected (short a_SlotNum);
|
||||||
|
void HandleSteerVehicle (float Forward, float Sideways);
|
||||||
void HandleTabCompletion (const AString & a_Text);
|
void HandleTabCompletion (const AString & a_Text);
|
||||||
void HandleUpdateSign (
|
void HandleUpdateSign (
|
||||||
int a_BlockX, int a_BlockY, int a_BlockZ,
|
int a_BlockX, int a_BlockY, int a_BlockZ,
|
||||||
|
@ -546,6 +546,8 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// TODO: This condition belongs to minecarts, without it, they derails too much.
|
||||||
|
// But it shouldn't be here for other entities. We need a complete minecart physics overhaul.
|
||||||
if (
|
if (
|
||||||
(BlockBelow != E_BLOCK_RAIL) &&
|
(BlockBelow != E_BLOCK_RAIL) &&
|
||||||
(BlockBelow != E_BLOCK_DETECTOR_RAIL) &&
|
(BlockBelow != E_BLOCK_DETECTOR_RAIL) &&
|
||||||
@ -556,12 +558,12 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
|
|||||||
// Friction
|
// Friction
|
||||||
if (NextSpeed.SqrLength() > 0.0004f)
|
if (NextSpeed.SqrLength() > 0.0004f)
|
||||||
{
|
{
|
||||||
NextSpeed.x *= 0.7f / (1 + a_Dt);
|
NextSpeed.x *= 0.6666;
|
||||||
if (fabs(NextSpeed.x) < 0.05)
|
if (fabs(NextSpeed.x) < 0.05)
|
||||||
{
|
{
|
||||||
NextSpeed.x = 0;
|
NextSpeed.x = 0;
|
||||||
}
|
}
|
||||||
NextSpeed.z *= 0.7f / (1 + a_Dt);
|
NextSpeed.z *= 0.6666;
|
||||||
if (fabs(NextSpeed.z) < 0.05)
|
if (fabs(NextSpeed.z) < 0.05)
|
||||||
{
|
{
|
||||||
NextSpeed.z = 0;
|
NextSpeed.z = 0;
|
||||||
@ -1225,6 +1227,25 @@ void cEntity::AddSpeedZ(double a_AddSpeedZ)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cEntity::SteerVehicle(float a_Forward, float a_Sideways)
|
||||||
|
{
|
||||||
|
if (m_AttachedTo == NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ((a_Forward != 0) || (a_Sideways != 0))
|
||||||
|
{
|
||||||
|
Vector3d LookVector = GetLookVector();
|
||||||
|
double AddSpeedX = LookVector.x * a_Forward + LookVector.z * a_Sideways;
|
||||||
|
double AddSpeedZ = LookVector.z * a_Forward - LookVector.x * a_Sideways;
|
||||||
|
m_AttachedTo->AddSpeed(AddSpeedX, 0, AddSpeedZ);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
// Get look vector (this is NOT a rotation!)
|
// Get look vector (this is NOT a rotation!)
|
||||||
Vector3d cEntity::GetLookVector(void) const
|
Vector3d cEntity::GetLookVector(void) const
|
||||||
|
@ -186,6 +186,8 @@ public:
|
|||||||
void AddSpeedY (double a_AddSpeedY);
|
void AddSpeedY (double a_AddSpeedY);
|
||||||
void AddSpeedZ (double a_AddSpeedZ);
|
void AddSpeedZ (double a_AddSpeedZ);
|
||||||
|
|
||||||
|
void SteerVehicle(float a_Forward, float a_Sideways);
|
||||||
|
|
||||||
inline int GetUniqueID(void) const { return m_UniqueID; }
|
inline int GetUniqueID(void) const { return m_UniqueID; }
|
||||||
inline bool IsDestroyed(void) const { return !m_IsInitialized; }
|
inline bool IsDestroyed(void) const { return !m_IsInitialized; }
|
||||||
|
|
||||||
|
@ -213,6 +213,10 @@ int cProtocol161::ParseSteerVehicle(void)
|
|||||||
{
|
{
|
||||||
m_Client->HandleUnmount();
|
m_Client->HandleUnmount();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_Client->HandleSteerVehicle(Forward, Sideways);
|
||||||
|
}
|
||||||
return PARSE_OK;
|
return PARSE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user