TombEngine/TR5Main/Objects/Generic/Object/generic_bridge.h

29 lines
1.1 KiB
C
Raw Normal View History

2020-09-27 20:48:01 -03:00
#pragma once
#include "phd_global.h"
int GetOffset(short angle, int x, int z);
template <int tilt>
std::tuple<std::optional<int>, bool> BridgeFloor(short itemNumber, int x, int y, int z)
{
const auto& item = g_Level.Items[itemNumber];
if (abs(item.pos.xPos - x) <= SECTOR(1) / 2 && abs(item.pos.zPos - z) <= SECTOR(1) / 2)
{
auto height = item.pos.yPos + tilt * (GetOffset(item.pos.yRot, x, z) / 4 + SECTOR(1) / 8);
2020-12-20 14:04:27 -03:00
return std::make_tuple(std::optional{height}, y > height && y <= height + SECTOR(1) / 16);
}
return std::make_tuple(std::nullopt, false);
}
template <int tilt>
std::tuple<std::optional<int>, bool> BridgeCeiling(short itemNumber, int x, int y, int z)
{
const auto& item = g_Level.Items[itemNumber];
if (abs(item.pos.xPos - x) <= SECTOR(1) / 2 && abs(item.pos.zPos - z) <= SECTOR(1) / 2)
{
auto height = item.pos.yPos + tilt * (GetOffset(item.pos.yRot, x, z) / 4 + SECTOR(1) / 8);
2020-12-20 14:04:27 -03:00
return std::make_tuple(std::optional{height + SECTOR(1) / 16}, y >= height && y < height + SECTOR(1) / 16);
}
return std::make_tuple(std::nullopt, false);
}