2021-08-28 06:37:22 +02:00
|
|
|
#include "framework.h"
|
2021-12-24 11:08:16 +03:00
|
|
|
#include "Objects/Generic/Switches/pulley_switch.h"
|
2021-12-22 16:23:57 +03:00
|
|
|
#include "Game/control/control.h"
|
|
|
|
#include "Specific/input.h"
|
|
|
|
#include "Game/Lara/lara.h"
|
2022-02-08 20:45:21 +11:00
|
|
|
#include "Game/Lara/lara_helpers.h"
|
2021-12-24 03:32:19 +03:00
|
|
|
#include "Objects/Generic/Switches/generic_switch.h"
|
2021-12-19 05:24:12 +03:00
|
|
|
#include "Sound/sound.h"
|
2021-12-22 16:23:57 +03:00
|
|
|
#include "Game/pickup/pickup.h"
|
|
|
|
#include "Specific/level.h"
|
|
|
|
#include "Game/collision/collide_item.h"
|
|
|
|
#include "Game/items.h"
|
2021-09-25 11:27:47 +02:00
|
|
|
|
2021-08-28 06:37:22 +02:00
|
|
|
namespace TEN::Entities::Switches
|
|
|
|
{
|
|
|
|
OBJECT_COLLISION_BOUNDS PulleyBounds =
|
|
|
|
{
|
|
|
|
-256, 256,
|
|
|
|
0, 0,
|
|
|
|
-512, 512,
|
|
|
|
-ANGLE(10), ANGLE(10),
|
|
|
|
-ANGLE(30), ANGLE(30),
|
|
|
|
-ANGLE(10), ANGLE(10)
|
|
|
|
};
|
|
|
|
|
|
|
|
PHD_VECTOR PulleyPos = { 0, 0, -148 };
|
|
|
|
|
|
|
|
void InitialisePulleySwitch(short itemNumber)
|
|
|
|
{
|
|
|
|
ITEM_INFO* item = &g_Level.Items[itemNumber];
|
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
item->ItemFlags[3] = item->TriggerFlags;
|
|
|
|
item->TriggerFlags = abs(item->TriggerFlags);
|
2021-08-28 06:37:22 +02:00
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
if (item->Status == ITEM_INVISIBLE)
|
2021-08-28 06:37:22 +02:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
item->ItemFlags[1] = 1;
|
|
|
|
item->Status = ITEM_NOT_ACTIVE;
|
2021-08-28 06:37:22 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void PulleySwitchCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll)
|
|
|
|
{
|
|
|
|
ITEM_INFO* item = &g_Level.Items[itemNum];
|
|
|
|
|
|
|
|
if ((TrInput & IN_ACTION)
|
2022-02-11 01:31:54 +11:00
|
|
|
&& Lara.Control.HandStatus == HandStatus::Free
|
2022-02-09 16:55:46 +11:00
|
|
|
&& l->ActiveState == LS_IDLE
|
|
|
|
&& l->AnimNumber == LA_STAND_IDLE
|
2022-02-09 13:20:57 +11:00
|
|
|
&& l->Airborne == false
|
2022-02-10 01:38:32 +11:00
|
|
|
|| Lara.Control.IsMoving && Lara.interactedItem == itemNum)
|
2021-08-28 06:37:22 +02:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
short oldYrot = item->Position.yRot;
|
|
|
|
item->Position.yRot = l->Position.yRot;
|
2021-08-28 06:37:22 +02:00
|
|
|
if (TestLaraPosition(&PulleyBounds, item, l))
|
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
if (item->ItemFlags[1])
|
2021-08-28 06:37:22 +02:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
if (OldPickupPos.x != l->Position.xPos || OldPickupPos.y != l->Position.yPos || OldPickupPos.z != l->Position.zPos)
|
2021-08-28 06:37:22 +02:00
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
OldPickupPos.x = l->Position.xPos;
|
|
|
|
OldPickupPos.y = l->Position.yPos;
|
|
|
|
OldPickupPos.z = l->Position.zPos;
|
2021-08-28 06:37:22 +02:00
|
|
|
SayNo();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (MoveLaraPosition(&PulleyPos, item, l))
|
|
|
|
{
|
2022-02-09 16:55:46 +11:00
|
|
|
l->AnimNumber = LA_PULLEY_GRAB;
|
|
|
|
l->ActiveState = LS_PULLEY;
|
|
|
|
l->FrameNumber = g_Level.Anims[l->AnimNumber].frameBase;
|
2021-08-28 06:37:22 +02:00
|
|
|
|
|
|
|
AddActiveItem(itemNum);
|
|
|
|
|
2022-02-09 16:55:46 +11:00
|
|
|
item->Position.yRot = oldYrot;
|
|
|
|
item->Status = ITEM_ACTIVE;
|
2021-08-28 06:37:22 +02:00
|
|
|
|
2022-02-10 01:38:32 +11:00
|
|
|
Lara.Control.IsMoving = false;
|
2022-02-08 20:45:21 +11:00
|
|
|
ResetLaraFlex(l);
|
2022-02-11 01:31:54 +11:00
|
|
|
Lara.Control.HandStatus = HandStatus::Busy;
|
2021-09-05 11:18:37 +02:00
|
|
|
Lara.interactedItem = itemNum;
|
2021-08-28 06:37:22 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-09-05 11:18:37 +02:00
|
|
|
Lara.interactedItem = itemNum;
|
2021-08-28 06:37:22 +02:00
|
|
|
}
|
2022-02-09 16:55:46 +11:00
|
|
|
item->Position.yRot = oldYrot;
|
2021-08-28 06:37:22 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-02-10 01:38:32 +11:00
|
|
|
if (Lara.Control.IsMoving && Lara.interactedItem == itemNum)
|
2021-08-28 06:37:22 +02:00
|
|
|
{
|
2022-02-10 01:38:32 +11:00
|
|
|
Lara.Control.IsMoving = false;
|
2022-02-11 01:31:54 +11:00
|
|
|
Lara.Control.HandStatus = HandStatus::Free;
|
2021-08-28 06:37:22 +02:00
|
|
|
}
|
2022-02-09 16:55:46 +11:00
|
|
|
item->Position.yRot = oldYrot;
|
2021-08-28 06:37:22 +02:00
|
|
|
}
|
|
|
|
}
|
2022-02-09 16:55:46 +11:00
|
|
|
else if (l->ActiveState != LS_PULLEY)
|
2021-08-28 06:37:22 +02:00
|
|
|
{
|
|
|
|
ObjectCollision(itemNum, l, coll);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|