mirror of
https://github.com/TombEngine/TombEngine.git
synced 2025-05-01 17:28:00 +03:00
61 lines
1.5 KiB
C++
61 lines
1.5 KiB
C++
![]() |
#include "footprint.h"
|
||
|
#include "control.h"
|
||
|
#include "lara.h"
|
||
|
|
||
|
std::deque<FOOTPRINT_STRUCT> footprints = deque<FOOTPRINT_STRUCT>();
|
||
|
bool CheckFootOnFloor(ITEM_INFO& const item, int mesh, PHD_3DPOS& outFootprintPosition){
|
||
|
int x = item.pos.xPos;
|
||
|
int y = item.pos.yPos;
|
||
|
int z = item.pos.zPos;
|
||
|
short roomNumber = item.roomNumber;
|
||
|
FLOOR_INFO* floor = GetFloor(x, y, z, &roomNumber);
|
||
|
int height = GetFloorHeight(floor, x, y, z);
|
||
|
int diff;
|
||
|
PHD_VECTOR pos;
|
||
|
pos.x = pos.z = 0;
|
||
|
pos.y = FOOT_HEIGHT_OFFSET;
|
||
|
GetLaraJointPosition(&pos, mesh);
|
||
|
outFootprintPosition.xPos = pos.x;
|
||
|
outFootprintPosition.zPos = pos.z;
|
||
|
outFootprintPosition.yPos = height-1;
|
||
|
outFootprintPosition.yRot = item.pos.yRot;
|
||
|
return abs(pos.y - height) < 32;
|
||
|
}
|
||
|
|
||
|
int getFootprintIndexWithLowestLife()
|
||
|
{
|
||
|
int lowestLife = footprints[0].life;
|
||
|
int index = 0;
|
||
|
for (int i = 1; i < MAX_FOOTPRINTS; i++) {
|
||
|
if (!footprints[i].active) {
|
||
|
index = i;
|
||
|
break;
|
||
|
}
|
||
|
if (footprints[i].life < lowestLife) {
|
||
|
index = i;
|
||
|
}
|
||
|
}
|
||
|
return index;
|
||
|
}
|
||
|
|
||
|
void updateFootprints()
|
||
|
{
|
||
|
if (footprints.size() == 0) {
|
||
|
return;
|
||
|
}
|
||
|
for (auto i = footprints.begin(); i != footprints.end(); i++) {
|
||
|
FOOTPRINT_STRUCT& footprint = *i;
|
||
|
footprint.life--;
|
||
|
if (footprint.life <= 0) {
|
||
|
footprints.pop_back();
|
||
|
}
|
||
|
if (footprint.life > footprint.lifeStartFading) {
|
||
|
footprint.opacity = footprint.startOpacity;
|
||
|
}
|
||
|
else {
|
||
|
float opacity = lerp(0, footprint.startOpacity, fmax(0, fmin(1, footprint.life / (float)footprint.lifeStartFading)));
|
||
|
footprint.opacity = opacity;
|
||
|
}
|
||
|
}
|
||
|
}
|