2020-12-21 13:16:29 -03:00
|
|
|
#pragma once
|
2021-12-22 16:23:57 +03:00
|
|
|
#include "Specific/phd_global.h"
|
|
|
|
#include "Specific/level.h"
|
|
|
|
#include "Game/items.h"
|
|
|
|
#include "Game/collision/floordata.h"
|
2021-09-29 03:41:36 +03:00
|
|
|
|
|
|
|
using namespace TEN::Floordata;
|
2021-09-25 11:27:47 +02:00
|
|
|
|
2021-01-06 17:53:13 -03:00
|
|
|
void InitialiseBridge(short itemNumber);
|
2020-12-21 13:16:29 -03:00
|
|
|
int GetOffset(short angle, int x, int z);
|
|
|
|
|
|
|
|
template <int tilt>
|
2021-01-06 17:53:13 -03:00
|
|
|
std::optional<int> BridgeFloor(short itemNumber, int x, int y, int z)
|
2020-12-21 13:16:29 -03:00
|
|
|
{
|
2022-02-24 14:22:30 +11:00
|
|
|
auto* item = &g_Level.Items[itemNumber];
|
2021-09-29 03:41:36 +03:00
|
|
|
auto bboxHeight = GetBridgeItemIntersect(itemNumber, x, y, z, false);
|
|
|
|
|
|
|
|
if (bboxHeight.has_value() && tilt != 0)
|
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
const auto height = item->Position.yPos + tilt * (GetOffset(item->Position.yRot, x, z) / 4 + SECTOR(1) / 8);
|
2021-09-29 03:41:36 +03:00
|
|
|
return std::optional{ height };
|
|
|
|
}
|
2022-02-24 14:22:30 +11:00
|
|
|
|
2021-09-29 03:41:36 +03:00
|
|
|
return bboxHeight;
|
2020-12-21 13:16:29 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
template <int tilt>
|
2021-01-06 17:53:13 -03:00
|
|
|
std::optional<int> BridgeCeiling(short itemNumber, int x, int y, int z)
|
2020-12-21 13:16:29 -03:00
|
|
|
{
|
2022-02-24 14:22:30 +11:00
|
|
|
auto* item = &g_Level.Items[itemNumber];
|
2021-09-29 03:41:36 +03:00
|
|
|
auto bboxHeight = GetBridgeItemIntersect(itemNumber, x, y, z, true);
|
|
|
|
|
|
|
|
if (bboxHeight.has_value() && tilt != 0)
|
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
const auto height = item->Position.yPos + tilt * (GetOffset(item->Position.yRot, x, z) / 4 + SECTOR(1) / 8);
|
2021-12-22 05:00:42 +03:00
|
|
|
return std::optional{ height + CLICK(1) }; // To be customized with Lua
|
2021-09-29 03:41:36 +03:00
|
|
|
}
|
|
|
|
return bboxHeight;
|
2020-12-21 13:16:29 -03:00
|
|
|
}
|
2021-01-27 01:04:31 -03:00
|
|
|
|
|
|
|
template <int tilt>
|
|
|
|
int BridgeFloorBorder(short itemNumber)
|
|
|
|
{
|
2021-09-29 03:41:36 +03:00
|
|
|
return GetBridgeBorder(itemNumber, false);
|
2021-01-27 01:04:31 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
template <int tilt>
|
|
|
|
int BridgeCeilingBorder(short itemNumber)
|
|
|
|
{
|
2021-09-29 03:41:36 +03:00
|
|
|
return GetBridgeBorder(itemNumber, true);
|
2021-01-27 01:04:31 -03:00
|
|
|
}
|