Partially integrate ScriptInterfaceFlow and replace instances of direct access to Animations members.

This commit is contained in:
hispidence 2022-01-25 23:52:20 +00:00
parent 4429bd8aa2
commit 2a9175f5fb
9 changed files with 37 additions and 22 deletions

View file

@ -8,6 +8,7 @@
#include "GameScriptAudioTrack.h"
#include "GameScriptAnimations.h"
#include "ScriptInterfaceGame.h"
#include "ScriptInterfaceFlow.h"
enum class TITLE_TYPE
{
@ -15,7 +16,7 @@ enum class TITLE_TYPE
BACKGROUND
};
class GameFlow : public LuaHandler
class GameFlow : public LuaHandler, public ScriptInterfaceFlow
{
private:
GameScriptSettings m_settings;
@ -63,7 +64,16 @@ public:
void SetIntroImagePath(std::string const& path);
void SetTitleScreenImagePath(std::string const& path);
void SetGameFarView(byte val);
bool IsFlyCheatEnabled() const;
bool HasCrawlExtended() const { return Animations.CrawlExtended; }
bool HasCrouchRoll() const { return Animations.CrouchRoll; }
bool HasCrawlspaceSwandive() const { return Animations.CrawlspaceSwandive; }
bool HasMonkeyTurn180() const { return Animations.MonkeyTurn180; }
bool HasMonkeyAutoJump() const { return Animations.MonkeyAutoJump; }
bool HasOscillateHang() const { return Animations.OscillateHang; }
bool HasAFKPose() const { return Animations.Pose; }
};
extern GameFlow* g_GameFlow;
extern ScriptInterfaceFlow* g_GameFlow;
extern ScriptInterfaceGame* g_GameScript;

View file

@ -16,7 +16,7 @@ using std::string;
using std::vector;
using std::unordered_map;
GameFlow* g_GameFlow;
ScriptInterfaceFlow* g_GameFlow;
ScriptInterfaceGame* g_GameScript;
GameFlow::GameFlow(sol::state* lua) : LuaHandler{ lua }
@ -231,6 +231,11 @@ int GameFlow::GetNumLevels() const
return Levels.size();
}
bool GameFlow::IsFlyCheatEnabled() const
{
return FlyCheat;
}
bool GameFlow::DoGameflow()
{
// We start with the title level

View file

@ -492,7 +492,7 @@ void lara_as_idle(ITEM_INFO* item, COLL_INFO* coll)
// movement lock will be rather obnoxious.
// Adding some idle breathing would also be nice. @Sezz 2021.10.31
if (info->poseCount >= LARA_POSE_TIME && TestLaraPose(item, coll) &&
g_GameFlow->Animations.Pose)
g_GameFlow->HasAFKPose())
{
item->goalAnimState = LS_POSE;
return;

View file

@ -67,7 +67,7 @@ void lara_as_swimcheat(ITEM_INFO* item, COLL_INFO* coll)
void LaraCheatyBits()
{
if (g_GameFlow->FlyCheat)
if (g_GameFlow->IsFlyCheatEnabled())
{
if (KeyMap[DIK_O])
{

View file

@ -63,7 +63,7 @@ void lara_as_crouch_idle(ITEM_INFO* item, COLL_INFO* coll)
{
if (TrInput & IN_SPRINT && TestLaraCrouchRoll(item, coll) &&
info->gunStatus == LG_HANDS_FREE &&
g_GameFlow->Animations.CrouchRoll)
g_GameFlow->HasCrouchRoll())
{
item->goalAnimState = LS_CROUCH_ROLL;
return;
@ -242,7 +242,7 @@ void lara_as_crouch_turn_left(ITEM_INFO* item, COLL_INFO* coll)
info->waterStatus != LW_WADE)
{
if (TrInput & IN_SPRINT && TestLaraCrouchRoll(item, coll) &&
g_GameFlow->Animations.CrouchRoll)
g_GameFlow->HasCrouchRoll())
{
item->goalAnimState = LS_CROUCH_ROLL;
return;
@ -298,7 +298,7 @@ void lara_as_crouch_turn_right(ITEM_INFO* item, COLL_INFO* coll)
info->waterStatus != LW_WADE)
{
if (TrInput & IN_SPRINT && TestLaraCrouchRoll(item, coll) &&
g_GameFlow->Animations.CrouchRoll)
g_GameFlow->HasCrouchRoll())
{
item->goalAnimState = LS_CROUCH_ROLL;
return;
@ -380,7 +380,7 @@ void lara_as_crawl_idle(ITEM_INFO* item, COLL_INFO* coll)
if (TrInput & IN_FORWARD)
{
if (TrInput & (IN_ACTION | IN_JUMP) && TestLaraCrawlVault(item, coll) &&
g_GameFlow->Animations.CrawlExtended)
g_GameFlow->HasCrawlExtended())
{
DoLaraCrawlVault(item, coll);
return;

View file

@ -218,7 +218,7 @@ void HandleLaraMovementParameters(ITEM_INFO* item, COLL_INFO* coll)
if (info->poseCount < LARA_POSE_TIME &&
TestLaraPose(item, coll) &&
!(TrInput & (IN_WAKE | IN_LOOK)) &&
g_GameFlow->Animations.Pose)
g_GameFlow->HasAFKPose())
{
info->poseCount++;
}

View file

@ -601,7 +601,7 @@ void lara_col_swandive(ITEM_INFO* item, COLL_INFO* coll)
;
else if (info->keepCrouched ||
abs(probe.Position.Ceiling - probe.Position.Floor) < LARA_HEIGHT &&
g_GameFlow->Animations.CrawlspaceSwandive)
g_GameFlow->HasCrawlspaceSwandive())
{
SetAnimation(item, LA_SPRINT_TO_CROUCH_LEFT, 10);

View file

@ -92,7 +92,7 @@ void lara_col_monkey_idle(ITEM_INFO* item, COLL_INFO* coll)
{
item->goalAnimState = LS_MONKEYSWING_TURN_RIGHT;
}
else if (TrInput & IN_ROLL && g_GameFlow->Animations.MonkeyTurn180)
else if (TrInput & IN_ROLL && g_GameFlow->HasMonkeyTurn180())
{
item->goalAnimState = LS_MONKEYSWING_TURN_180;
}

View file

@ -121,7 +121,7 @@ bool TestLaraVault(ITEM_INFO* item, COLL_INFO* coll)
// Vault to crouch up one step.
if (coll->Front.Floor < 0 && // Lower floor bound.
coll->Front.Floor > -STEPUP_HEIGHT && // Upper floor bound.
g_GameFlow->Animations.CrawlExtended)
g_GameFlow->HasCrawlExtended())
{
if (abs((coll->Front.Ceiling - coll->Setup.Height) - coll->Front.Floor) > LARA_HEIGHT_CRAWL) // Front clamp buffer. Presumably, nothing more is necessary, but tend to this in the future. @Sezz 2021.11.06
{
@ -153,7 +153,7 @@ bool TestLaraVault(ITEM_INFO* item, COLL_INFO* coll)
else if (abs((coll->Front.Ceiling - coll->Setup.Height) - coll->Front.Floor) > LARA_HEIGHT_CRAWL && // Front clamp buffer.
abs((coll->FrontLeft.Ceiling - coll->Setup.Height) - coll->FrontLeft.Floor) > LARA_HEIGHT_CRAWL && // Left clamp buffer.
abs((coll->FrontRight.Ceiling - coll->Setup.Height) - coll->FrontRight.Floor) > LARA_HEIGHT_CRAWL && // Right clamp buffer.
g_GameFlow->Animations.CrawlExtended)
g_GameFlow->HasCrawlExtended())
{
item->animNumber = LA_VAULT_TO_CROUCH_2CLICK;
item->frameNumber = GetFrameNumber(item, 0);
@ -183,7 +183,7 @@ bool TestLaraVault(ITEM_INFO* item, COLL_INFO* coll)
else if (abs((coll->Front.Ceiling - coll->Setup.Height) - coll->Front.Floor) > LARA_HEIGHT_CRAWL && // Front clamp buffer.
abs((coll->FrontLeft.Ceiling - coll->Setup.Height) - coll->FrontLeft.Floor) > LARA_HEIGHT_CRAWL && // Left clamp buffer.
abs((coll->FrontRight.Ceiling - coll->Setup.Height) - coll->FrontRight.Floor) > LARA_HEIGHT_CRAWL && // Right clamp buffer.
g_GameFlow->Animations.CrawlExtended)
g_GameFlow->HasCrawlExtended())
{
item->animNumber = LA_VAULT_TO_CROUCH_3CLICK;
item->frameNumber = GetFrameNumber(item, 0);
@ -266,7 +266,7 @@ bool TestLaraVault(ITEM_INFO* item, COLL_INFO* coll)
// Auto jump to monkey swing.
if (info->canMonkeySwing &&
!TestLaraSwamp(item) &&
g_GameFlow->Animations.MonkeyAutoJump)
g_GameFlow->HasMonkeyAutoJump())
{
short roomNum = item->roomNumber;
int ceiling = (GetCeiling(GetFloor(item->pos.xPos, item->pos.yPos, item->pos.zPos, &roomNum),
@ -545,7 +545,7 @@ bool TestLaraHangJump(ITEM_INFO* item, COLL_INFO* coll)
if (TestHangSwingIn(item, angle))
{
if (g_GameFlow->Animations.OscillateHang)
if (g_GameFlow->HasOscillateHang())
{
ResetLaraFlex(item);
SetAnimation(item, LA_REACH_TO_HANG_OSCILLATE);
@ -1107,7 +1107,7 @@ bool TestHangSwingIn(ITEM_INFO* item, short angle)
if (floorHeight != NO_HEIGHT)
{
if (g_GameFlow->Animations.OscillateHang)
if (g_GameFlow->HasOscillateHang())
{
if (floorHeight - y > 0 && ceilingHeight - y < -400)
return true;
@ -1370,7 +1370,7 @@ bool TestLaraWaterClimbOut(ITEM_INFO* item, COLL_INFO* coll)
{
if (headroom < LARA_HEIGHT)
{
if (g_GameFlow->Animations.CrawlExtended)
if (g_GameFlow->HasCrawlExtended())
SetAnimation(item, LA_ONWATER_TO_CROUCH_1CLICK);
else
return false;
@ -1382,7 +1382,7 @@ bool TestLaraWaterClimbOut(ITEM_INFO* item, COLL_INFO* coll)
{
if (headroom < LARA_HEIGHT)
{
if (g_GameFlow->Animations.CrawlExtended)
if (g_GameFlow->HasCrawlExtended())
SetAnimation(item, LA_ONWATER_TO_CROUCH_M1CLICK);
else
return false;
@ -1395,7 +1395,7 @@ bool TestLaraWaterClimbOut(ITEM_INFO* item, COLL_INFO* coll)
{
if (headroom < LARA_HEIGHT)
{
if (g_GameFlow->Animations.CrawlExtended)
if (g_GameFlow->HasCrawlExtended())
SetAnimation(item, LA_ONWATER_TO_CROUCH_0CLICK);
else
return false;