|
|
@ -19,7 +19,7 @@
|
|
|
|
#include "game_share/position_or_entity_type.h"
|
|
|
|
#include "game_share/position_or_entity_type.h"
|
|
|
|
#include "entities.h"
|
|
|
|
#include "entities.h"
|
|
|
|
|
|
|
|
|
|
|
|
NLMISC::CVector resolvePositionOrEntityPosition(const CPositionOrEntity& posOrEntity)
|
|
|
|
NLMISC::CVector resolvePositionOrEntityPosition(const CPositionOrEntity& posOrEntity, const TCameraAnimationInputInfo& currCamInfo)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!posOrEntity.isValid())
|
|
|
|
if (!posOrEntity.isValid())
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -29,21 +29,105 @@ NLMISC::CVector resolvePositionOrEntityPosition(const CPositionOrEntity& posOrEn
|
|
|
|
|
|
|
|
|
|
|
|
if (posOrEntity.isPosition())
|
|
|
|
if (posOrEntity.isPosition())
|
|
|
|
return posOrEntity.getPosition();
|
|
|
|
return posOrEntity.getPosition();
|
|
|
|
|
|
|
|
else if (posOrEntity.isPreviousPos())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return currCamInfo.StartCamPos;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (posOrEntity.isReturnPos())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return currCamInfo.AnimStartCamPos;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (posOrEntity.isEntityId())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
CEntityCL *entity = EntitiesMngr.getEntityByCompressedIndex(posOrEntity.getEntityId());
|
|
|
|
|
|
|
|
if (!entity)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
nlwarning("<resolvePositionOrEntityPosition> invalid entity with compressed id %d", posOrEntity.getEntityId());
|
|
|
|
|
|
|
|
return NLMISC::CVector();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
NLMISC::CVector pos;
|
|
|
|
|
|
|
|
if (!entity->getHeadPos(pos))
|
|
|
|
|
|
|
|
pos = entity->pos();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return pos;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return NLMISC::CVector();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CEntityCL *entity = EntitiesMngr.getEntityByCompressedIndex(posOrEntity.getEntityId());
|
|
|
|
NLMISC::CVector resolvePositionOrEntityPosition(const CPositionOrEntity& posOrEntity)
|
|
|
|
if (!entity)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!posOrEntity.isValid())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
nlwarning("<resolvePositionOrEntityPosition> invalid entity with compressed id %d", posOrEntity.getEntityId());
|
|
|
|
nlwarning("<resolvePositionOrEntityPosition> invalid position or entity");
|
|
|
|
return NLMISC::CVector();
|
|
|
|
return NLMISC::CVector();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
|
|
|
|
|
|
|
|
if (posOrEntity.isPosition())
|
|
|
|
|
|
|
|
return posOrEntity.getPosition();
|
|
|
|
|
|
|
|
else if (posOrEntity.isEntityId())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
NLMISC::CVector pos;
|
|
|
|
CEntityCL *entity = EntitiesMngr.getEntityByCompressedIndex(posOrEntity.getEntityId());
|
|
|
|
if (!entity->getHeadPos(pos))
|
|
|
|
if (!entity)
|
|
|
|
pos = entity->pos();
|
|
|
|
{
|
|
|
|
|
|
|
|
nlwarning("<resolvePositionOrEntityPosition> invalid entity with compressed id %d", posOrEntity.getEntityId());
|
|
|
|
return pos;
|
|
|
|
return NLMISC::CVector();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
NLMISC::CVector pos;
|
|
|
|
|
|
|
|
if (!entity->getHeadPos(pos))
|
|
|
|
|
|
|
|
pos = entity->pos();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return pos;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NLMISC::CVector();
|
|
|
|
return NLMISC::CVector();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NLMISC::CVector resolvePositionOrEntityTargetDir(const CPositionOrEntity& posOrEntity, const TCameraAnimationInputInfo& currCamInfo,
|
|
|
|
|
|
|
|
const NLMISC::CVector& currCamPos)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!posOrEntity.isValid())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
nlwarning("<resolvePositionOrEntityPosition> invalid position or entity");
|
|
|
|
|
|
|
|
return NLMISC::CVector();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (posOrEntity.isPosition())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
NLMISC::CVector dir = posOrEntity.getPosition() - currCamPos;
|
|
|
|
|
|
|
|
dir.normalize();
|
|
|
|
|
|
|
|
return dir;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (posOrEntity.isPreviousPos())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return currCamInfo.StartCamLookAtDir;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (posOrEntity.isReturnPos())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return currCamInfo.AnimStartCamLookAtDir;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (posOrEntity.isEntityId())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
CEntityCL *entity = EntitiesMngr.getEntityByCompressedIndex(posOrEntity.getEntityId());
|
|
|
|
|
|
|
|
if (!entity)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
nlwarning("<resolvePositionOrEntityPosition> invalid entity with compressed id %d", posOrEntity.getEntityId());
|
|
|
|
|
|
|
|
return NLMISC::CVector();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
NLMISC::CVector pos;
|
|
|
|
|
|
|
|
if (!entity->getHeadPos(pos))
|
|
|
|
|
|
|
|
pos = entity->pos();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NLMISC::CVector dir = pos - currCamPos;
|
|
|
|
|
|
|
|
dir.normalize();
|
|
|
|
|
|
|
|
return dir;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return NLMISC::CVector();
|
|
|
|
|
|
|
|
}
|
|
|
|