Detaching improvements
* Players now search for an area around themselves to teleport to when detaching from something
This commit is contained in:
parent
1d81db6446
commit
edefa27a48
@ -1107,9 +1107,11 @@ void cEntity::AttachTo(cEntity * a_AttachTo)
|
||||
// Already attached to that entity, nothing to do here
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_AttachedTo != NULL)
|
||||
{
|
||||
// Detach from any previous entity:
|
||||
Detach();
|
||||
}
|
||||
|
||||
// Attach to the new entity:
|
||||
m_AttachedTo = a_AttachTo;
|
||||
|
@ -327,7 +327,7 @@ public:
|
||||
void AttachTo(cEntity * a_AttachTo);
|
||||
|
||||
/// Detaches from the currently attached entity, if any
|
||||
void Detach(void);
|
||||
virtual void Detach(void);
|
||||
|
||||
/// Makes sure head yaw is not over the specified range.
|
||||
void WrapHeadYaw();
|
||||
|
@ -1884,3 +1884,29 @@ void cPlayer::ApplyFoodExhaustionFromMovement()
|
||||
|
||||
|
||||
|
||||
|
||||
void cPlayer::Detach()
|
||||
{
|
||||
super::Detach();
|
||||
int PosX = (int)floor(GetPosX());
|
||||
int PosY = (int)floor(GetPosY());
|
||||
int PosZ = (int)floor(GetPosZ());
|
||||
|
||||
// Search for a position within an area to teleport player after detachment
|
||||
// Position must be solid land, and occupied by a nonsolid block
|
||||
// If nothing found, player remains where they are
|
||||
for (int x = PosX - 2; x <= (PosX + 2); ++x)
|
||||
{
|
||||
for (int y = PosY; y <= (PosY + 3); ++y)
|
||||
{
|
||||
for (int z = PosZ - 2; z <= (PosZ + 2); ++z)
|
||||
{
|
||||
if (!g_BlockIsSolid[m_World->GetBlock(x, y, z)] && g_BlockIsSolid[m_World->GetBlock(x, y - 1, z)])
|
||||
{
|
||||
TeleportToCoords(x, y, z);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -351,6 +351,8 @@ public:
|
||||
virtual bool IsSprinting(void) const { return m_IsSprinting; }
|
||||
virtual bool IsRclking (void) const { return IsEating(); }
|
||||
|
||||
virtual void Detach(void);
|
||||
|
||||
protected:
|
||||
typedef std::map< std::string, bool > PermissionMap;
|
||||
PermissionMap m_ResolvedPermissions;
|
||||
|
Loading…
Reference in New Issue
Block a user