mirror of
https://github.com/TombEngine/TombEngine.git
synced 2025-05-02 09:47:58 +03:00
Added rudimentary implementation of EXPANDING_PLATFORM
This commit is contained in:
parent
db6f0ea131
commit
28f377789e
5 changed files with 203 additions and 0 deletions
|
@ -32,6 +32,7 @@
|
|||
#include "tr5_twoblockplatform.h"
|
||||
#include "tr5_raisingcog.h"
|
||||
#include "tr5_raisingblock.h"
|
||||
#include "tr5_expandingplatform.h"
|
||||
#include "tr5_light.h"
|
||||
#include "tr5_bodypart.h"
|
||||
#include "tr5_teleporter.h"
|
||||
|
@ -914,6 +915,20 @@ static void StartObject(OBJECT_INFO *obj)
|
|||
}
|
||||
}
|
||||
|
||||
obj = &Objects[ID_EXPANDING_PLATFORM];
|
||||
if (obj->loaded)
|
||||
{
|
||||
obj->initialise = InitialiseExpandingPlatform;
|
||||
obj->control = ControlExpandingPlatform;
|
||||
obj->floor = ExpandingPlatformFloor;
|
||||
obj->ceiling = ExpandingPlatformCeiling;
|
||||
obj->floorBorder = ExpandingPlatformFloorBorder;
|
||||
obj->ceilingBorder = ExpandingPlatformCeilingBorder;
|
||||
obj->saveFlags = true;
|
||||
obj->savePosition = true;
|
||||
obj->saveAnim = true;
|
||||
}
|
||||
|
||||
obj = &Objects[ID_ELECTRICAL_LIGHT];
|
||||
if (obj->loaded)
|
||||
{
|
||||
|
|
|
@ -494,6 +494,7 @@ namespace T5M::Renderer
|
|||
void drawAnimatingItem(RenderView& view,RendererItem* item, bool transparent, bool animated);
|
||||
void drawBaddieGunflashes(RenderView& view);
|
||||
void drawScaledSpikes(RenderView& view,RendererItem* item, bool transparent, bool animated);
|
||||
void drawExpandingPlatform(RenderView& view, RendererItem* item, bool transparent, bool animated);
|
||||
void drawStatics(bool transparent, RenderView& view);
|
||||
void renderShadowMap(RenderView& view);
|
||||
void drawWraithExtra(RenderView& view,RendererItem* item, bool transparent, bool animated);
|
||||
|
|
|
@ -2764,6 +2764,11 @@ namespace T5M::Renderer
|
|||
// Raising blocks and teeth spikes are normal animating objects but scaled on Y direction
|
||||
drawScaledSpikes(view,item, transparent, animated);
|
||||
}
|
||||
else if (objectNumber == ID_EXPANDING_PLATFORM)
|
||||
{
|
||||
// Raising blocks and teeth spikes are normal animating objects but scaled on Y direction
|
||||
drawExpandingPlatform(view, item, transparent, animated);
|
||||
}
|
||||
else if (objectNumber >= ID_WATERFALL1 && objectNumber <= ID_WATERFALLSS2)
|
||||
{
|
||||
// We'll draw waterfalls later
|
||||
|
@ -2856,6 +2861,17 @@ namespace T5M::Renderer
|
|||
}
|
||||
}
|
||||
|
||||
void Renderer11::drawExpandingPlatform(RenderView& view, RendererItem* item, bool transparent, bool animated)
|
||||
{
|
||||
short objectNumber = item->Item->objectNumber;
|
||||
float xTranslate = item->Item->pos.yRot == ANGLE(90) ? CLICK(2) : item->Item->pos.yRot == ANGLE(270) ? -CLICK(2) : 0.0f;
|
||||
float zTranslate = item->Item->pos.yRot == 0 ? CLICK(2) : item->Item->pos.yRot == ANGLE(180) ? -CLICK(2) : 0.0f;
|
||||
item->Translation *= Matrix::CreateTranslation(xTranslate, 0.0f, zTranslate);
|
||||
item->Scale = Matrix::CreateScale(1.0f, 1.0f, item->Item->itemFlags[1] / 4096.0f);
|
||||
item->World = item->Scale * item->Rotation * item->Translation;
|
||||
return drawAnimatingItem(view, item, transparent, animated);
|
||||
}
|
||||
|
||||
void Renderer11::drawWraithExtra(RenderView& view,RendererItem* item, bool transparent, bool animated)
|
||||
{
|
||||
ITEM_INFO* nativeItem = item->Item;
|
||||
|
|
163
TR5Main/tr5_expandingplatform.cpp
Normal file
163
TR5Main/tr5_expandingplatform.cpp
Normal file
|
@ -0,0 +1,163 @@
|
|||
#include "framework.h"
|
||||
#include "tr5_ExpandingPlatform.h"
|
||||
#include "items.h"
|
||||
#include "level.h"
|
||||
#include "control.h"
|
||||
#include "box.h"
|
||||
#include "objectslist.h"
|
||||
#include "sound.h"
|
||||
#include "camera.h"
|
||||
|
||||
void InitialiseExpandingPlatform(short itemNumber)
|
||||
{
|
||||
ITEM_INFO* item = &g_Level.Items[itemNumber];
|
||||
|
||||
short roomNumber = item->roomNumber;
|
||||
FLOOR_INFO* floor = GetFloor(item->pos.xPos, item->pos.yPos, item->pos.zPos, &roomNumber);
|
||||
g_Level.Boxes[floor->box].flags &= ~BLOCKED;
|
||||
|
||||
if (item->triggerFlags < 0)
|
||||
{
|
||||
item->aiBits |= ALL_AIOBJ;
|
||||
AddActiveItem(itemNumber);
|
||||
item->status = ITEM_ACTIVE;
|
||||
}
|
||||
|
||||
// Get height from animations
|
||||
ANIM_FRAME* frame = &g_Level.Frames[g_Level.Anims[Objects[item->objectNumber].animIndex].framePtr];
|
||||
item->itemFlags[7] = (short)abs(frame->boundingBox.Y1 - frame->boundingBox.Y2);
|
||||
T5M::Floordata::AddBridge(itemNumber);
|
||||
}
|
||||
|
||||
void ControlExpandingPlatform(short itemNumber)
|
||||
{
|
||||
ITEM_INFO* item = &g_Level.Items[itemNumber];
|
||||
|
||||
if (TriggerActive(item))
|
||||
{
|
||||
if (!item->itemFlags[2])
|
||||
{
|
||||
if (item->objectNumber == ID_RAISING_BLOCK1)
|
||||
{
|
||||
if (item->triggerFlags == -1)
|
||||
{
|
||||
//AlterFloorHeight(item, -255);
|
||||
}
|
||||
else if (item->triggerFlags == -3)
|
||||
{
|
||||
//AlterFloorHeight(item, -1023);
|
||||
}
|
||||
else
|
||||
{
|
||||
//AlterFloorHeight(item, -item->itemFlags[7]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//AlterFloorHeight(item, -item->itemFlags[7]);
|
||||
}
|
||||
|
||||
item->itemFlags[2] = 1;
|
||||
}
|
||||
|
||||
if (item->triggerFlags < 0)
|
||||
{
|
||||
item->itemFlags[1] = 1;
|
||||
}
|
||||
else if (item->itemFlags[1] < 4096)
|
||||
{
|
||||
SoundEffect(SFX_TR4_BLK_PLAT_RAISE_AND_LOW, &item->pos, 0);
|
||||
|
||||
item->itemFlags[1] += 64;
|
||||
|
||||
if (item->triggerFlags > 0)
|
||||
{
|
||||
if (abs(item->pos.xPos - Camera.pos.x) < 10240 &&
|
||||
abs(item->pos.xPos - Camera.pos.x) < 10240 &&
|
||||
abs(item->pos.xPos - Camera.pos.x) < 10240)
|
||||
{
|
||||
if (item->itemFlags[1] == 64 || item->itemFlags[1] == 4096)
|
||||
Camera.bounce = -32;
|
||||
else
|
||||
Camera.bounce = -16;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (item->itemFlags[1] <= 0 || item->triggerFlags < 0)
|
||||
{
|
||||
if (item->itemFlags[2])
|
||||
{
|
||||
item->itemFlags[1] = 0;
|
||||
|
||||
if (item->objectNumber == ID_RAISING_BLOCK1)
|
||||
{
|
||||
if (item->triggerFlags == -1)
|
||||
{
|
||||
//AlterFloorHeight(item, 255);
|
||||
item->itemFlags[2] = 0;
|
||||
}
|
||||
else if (item->triggerFlags == -3)
|
||||
{
|
||||
//AlterFloorHeight(item, 1023);
|
||||
item->itemFlags[2] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
//AlterFloorHeight(item, item->itemFlags[7]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//AlterFloorHeight(item, item->itemFlags[7]);
|
||||
}
|
||||
|
||||
item->itemFlags[2] = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SoundEffect(SFX_TR4_BLK_PLAT_RAISE_AND_LOW, &item->pos, 0);
|
||||
|
||||
if (item->triggerFlags >= 0)
|
||||
{
|
||||
if (abs(item->pos.xPos - Camera.pos.x) < 10240 &&
|
||||
abs(item->pos.xPos - Camera.pos.x) < 10240 &&
|
||||
abs(item->pos.xPos - Camera.pos.x) < 10240)
|
||||
{
|
||||
if (item->itemFlags[1] == 64 || item->itemFlags[1] == 4096)
|
||||
Camera.bounce = -32;
|
||||
else
|
||||
Camera.bounce = -16;
|
||||
}
|
||||
}
|
||||
|
||||
item->itemFlags[1] -= 64;
|
||||
}
|
||||
}
|
||||
|
||||
std::optional<int> ExpandingPlatformFloor(short itemNumber, int x, int y, int z)
|
||||
{
|
||||
const auto& item = g_Level.Items[itemNumber];
|
||||
const auto height = item.pos.yPos + CLICK(2) - item.itemFlags[7] * (item.itemFlags[1] > 0 ? 1 : 0);
|
||||
return std::optional{ height };
|
||||
}
|
||||
|
||||
std::optional<int> ExpandingPlatformCeiling(short itemNumber, int x, int y, int z)
|
||||
{
|
||||
const auto& item = g_Level.Items[itemNumber];
|
||||
return std::optional{ item.pos.yPos + CLICK(2) + 1 };
|
||||
}
|
||||
|
||||
int ExpandingPlatformFloorBorder(short itemNumber)
|
||||
{
|
||||
const auto& item = g_Level.Items[itemNumber];
|
||||
const auto height = item.pos.yPos - item.itemFlags[7];
|
||||
return height;
|
||||
}
|
||||
|
||||
int ExpandingPlatformCeilingBorder(short itemNumber)
|
||||
{
|
||||
const auto& item = g_Level.Items[itemNumber];
|
||||
return item.pos.yPos + 1;
|
||||
}
|
8
TR5Main/tr5_expandingplatform.h
Normal file
8
TR5Main/tr5_expandingplatform.h
Normal file
|
@ -0,0 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
void InitialiseExpandingPlatform(short itemNumber);
|
||||
void ControlExpandingPlatform(short itemNumber);
|
||||
std::optional<int> ExpandingPlatformFloor(short itemNumber, int x, int y, int z);
|
||||
std::optional<int> ExpandingPlatformCeiling(short itemNumber, int x, int y, int z);
|
||||
int ExpandingPlatformFloorBorder(short itemNumber);
|
||||
int ExpandingPlatformCeilingBorder(short itemNumber);
|
Loading…
Add table
Add a link
Reference in a new issue