[saco] Implement/match CEntity::EnforceWorldBoundries(...)

This commit is contained in:
RD42 2024-08-07 18:54:50 +08:00
parent 65d1cb2201
commit c7ae0d329c
2 changed files with 64 additions and 0 deletions

View File

@ -321,6 +321,68 @@ void CEntity::Remove()
//-----------------------------------------------------------
BOOL CEntity::EnforceWorldBoundries(float fPX, float fZX, float fPY, float fNY)
{
MATRIX4X4 matWorld;
VECTOR vecMoveSpeed;
if(!m_pEntity) return FALSE;
GetMatrix(&matWorld);
GetMoveSpeedVector(&vecMoveSpeed);
if(matWorld.pos.X > fPX)
{
if(vecMoveSpeed.X != 0.0f) {
vecMoveSpeed.X = -0.2f;
vecMoveSpeed.Z = 0.1f;
}
SetMoveSpeedVector(vecMoveSpeed);
matWorld.pos.Z += 0.04f;
SetMatrix(matWorld);
return TRUE;
}
else if(matWorld.pos.X < fZX)
{
if(vecMoveSpeed.X != 0.0f) {
vecMoveSpeed.X = 0.2f;
vecMoveSpeed.Z = 0.1f;
}
SetMoveSpeedVector(vecMoveSpeed);
matWorld.pos.Z += 0.04f;
SetMatrix(matWorld);
return TRUE;
}
else if(matWorld.pos.Y > fPY)
{
if(vecMoveSpeed.Y != 0.0f) {
vecMoveSpeed.Y = -0.2f;
vecMoveSpeed.Z = 0.1f;
}
SetMoveSpeedVector(vecMoveSpeed);
matWorld.pos.Z += 0.04f;
SetMatrix(matWorld);
return TRUE;
}
else if(matWorld.pos.Y < fNY)
{
if(vecMoveSpeed.Y != 0.0f) {
vecMoveSpeed.Y = 0.2f;
vecMoveSpeed.Z = 0.1f;
}
SetMoveSpeedVector(vecMoveSpeed);
matWorld.pos.Z += 0.04f;
SetMatrix(matWorld);
return TRUE;
}
return FALSE;
}
//-----------------------------------------------------------

View File

@ -29,6 +29,8 @@ public:
float GetDistanceFromPoint(float X, float Y, float Z);
BOOL IsStationary();
BOOL EnforceWorldBoundries(float fPX, float fZX, float fPY, float fNY);
virtual void Add();
virtual void Remove();
BOOL IsAdded();