lcs bridge

This commit is contained in:
Nikolay Korolev 2021-08-08 13:08:47 +03:00
parent 0c4ab5b609
commit e6b1a0691b
6 changed files with 34 additions and 19 deletions

View File

@ -7,6 +7,8 @@
#include "PathFind.h" #include "PathFind.h"
#include "SaveBuf.h" #include "SaveBuf.h"
//--LCS: file done
void CAutoPilot::ModifySpeed(float speed) void CAutoPilot::ModifySpeed(float speed)
{ {
m_fMaxTrafficSpeed = Max(0.01f, speed); m_fMaxTrafficSpeed = Max(0.01f, speed);

View File

@ -6,6 +6,8 @@
#include "PathFind.h" #include "PathFind.h"
#include "Stats.h" #include "Stats.h"
//--LCS: file done except TODO
CEntity *CBridge::pLiftRoad; CEntity *CBridge::pLiftRoad;
CEntity *CBridge::pLiftPart; CEntity *CBridge::pLiftPart;
CEntity *CBridge::pWeight; CEntity *CBridge::pWeight;
@ -25,14 +27,14 @@ void CBridge::Init()
{ {
#ifdef GTA_BRIDGE #ifdef GTA_BRIDGE
FindBridgeEntities(); FindBridgeEntities();
State = STATE_BRIDGE_LOCKED;
OldLift = -1.0f; OldLift = -1.0f;
if (pLiftPart && pWeight) if (pLiftPart && pWeight)
{ {
DefaultZLiftPart = pLiftPart->GetPosition().z; DefaultZLiftPart = pLiftPart->GetPosition().z;
DefaultZLiftWeight = pWeight->GetPosition().z;
if (pLiftRoad) if (pLiftRoad)
DefaultZLiftRoad = pLiftRoad->GetPosition().z; DefaultZLiftRoad = pLiftRoad->GetPosition().z;
DefaultZLiftWeight = pWeight->GetPosition().z;
ThePaths.SetLinksBridgeLights(-330.0, -230.0, -700.0, -588.0, true); ThePaths.SetLinksBridgeLights(-330.0, -230.0, -700.0, -588.0, true);
} }
@ -49,36 +51,42 @@ void CBridge::Update()
float liftHeight; float liftHeight;
// Set bridge height and state if (State == STATE_BRIDGE_LOCKED) {
if (CStats::CommercialPassed) liftHeight = 25.0f;
{ TimeOfBridgeBecomingOperational = 0;
}
else if (State == STATE_BRIDGE_ALWAYS_UNLOCKED) {
liftHeight = 0.0f;
TimeOfBridgeBecomingOperational = CTimer::GetTimeInMilliseconds() - 20001;
}
else {
if (TimeOfBridgeBecomingOperational == 0) if (TimeOfBridgeBecomingOperational == 0)
TimeOfBridgeBecomingOperational = CTimer::GetTimeInMilliseconds(); TimeOfBridgeBecomingOperational = CTimer::GetTimeInMilliseconds();
// Time remaining for bridge to become operational // Time remaining for bridge to become operational
// uint16, so after about a minute it overflows to 0 and the cycle repeats // this time cycle duration is 0x20000, so ~2:11
uint16 timeElapsed = CTimer::GetTimeInMilliseconds() - TimeOfBridgeBecomingOperational; uint32 timeElapsed = (CTimer::GetTimeInMilliseconds() - TimeOfBridgeBecomingOperational) % 0x20000;
// Calculate lift part height and bridge state // Calculate lift part height and bridge state
if (timeElapsed < 10000) if (timeElapsed < 20000)
{ {
State = STATE_LIFT_PART_MOVING_DOWN; State = STATE_LIFT_PART_MOVING_DOWN;
liftHeight = 25.0f - timeElapsed / 10000.0f * 25.0f; liftHeight = 25.0f - timeElapsed / 20000.0f * 25.0f;
} }
else if (timeElapsed < 40000) else if (timeElapsed < 80000)
{ {
liftHeight = 0.0f; liftHeight = 0.0f;
State = STATE_LIFT_PART_IS_DOWN; State = STATE_LIFT_PART_IS_DOWN;
} }
else if (timeElapsed < 50000) else if (timeElapsed < 90000)
{ {
liftHeight = 0.0f; liftHeight = 0.0f;
State = STATE_LIFT_PART_ABOUT_TO_MOVE_UP; State = STATE_LIFT_PART_ABOUT_TO_MOVE_UP;
} }
else if (timeElapsed < 60000) else if (timeElapsed < 110000)
{ {
State = STATE_LIFT_PART_MOVING_UP; State = STATE_LIFT_PART_MOVING_UP;
liftHeight = (timeElapsed - 50000) / 10000.0f * 25.0f; liftHeight = (timeElapsed - 90000) / 20000.0f * 25.0f;
} }
else else
{ {
@ -86,12 +94,7 @@ void CBridge::Update()
State = STATE_LIFT_PART_IS_UP; State = STATE_LIFT_PART_IS_UP;
} }
} }
else
{
liftHeight = 25.0f;
TimeOfBridgeBecomingOperational = 0;
State = STATE_BRIDGE_LOCKED;
}
// Move bridge part // Move bridge part
if (liftHeight != OldLift) if (liftHeight != OldLift)
@ -112,6 +115,8 @@ void CBridge::Update()
OldLift = liftHeight; OldLift = liftHeight;
} }
// TODO(LCS): cWorldStream
if (State == STATE_LIFT_PART_ABOUT_TO_MOVE_UP && OldState == STATE_LIFT_PART_IS_DOWN) if (State == STATE_LIFT_PART_ABOUT_TO_MOVE_UP && OldState == STATE_LIFT_PART_IS_DOWN)
ThePaths.SetLinksBridgeLights(-330.0, -230.0, -700.0, -588.0, true); ThePaths.SetLinksBridgeLights(-330.0, -230.0, -700.0, -588.0, true);
else if (State == STATE_LIFT_PART_IS_DOWN && OldState == STATE_LIFT_PART_MOVING_DOWN) else if (State == STATE_LIFT_PART_IS_DOWN && OldState == STATE_LIFT_PART_MOVING_DOWN)

View File

@ -21,6 +21,8 @@
#include "World.h" #include "World.h"
#include "ZoneCull.h" #include "ZoneCull.h"
//--LCS: file done
#define DISTANCE_TO_SWITCH_DISTANCE_GOTO 20.0f #define DISTANCE_TO_SWITCH_DISTANCE_GOTO 20.0f
float CCarAI::FindSwitchDistanceClose(CVehicle* pVehicle) float CCarAI::FindSwitchDistanceClose(CVehicle* pVehicle)

View File

@ -38,6 +38,8 @@
#include "Zones.h" #include "Zones.h"
#include "Pickups.h" #include "Pickups.h"
//--LCS: file done except TODO
#define DISTANCE_TO_SPAWN_ROADBLOCK_PEDS (51.0f) #define DISTANCE_TO_SPAWN_ROADBLOCK_PEDS (51.0f)
#define DISTANCE_TO_SCAN_FOR_DANGER (14.0f) #define DISTANCE_TO_SCAN_FOR_DANGER (14.0f)
#define DISTANCE_TO_SCAN_FOR_PED_DANGER (11.0f) #define DISTANCE_TO_SCAN_FOR_PED_DANGER (11.0f)

View File

@ -2,6 +2,8 @@
#include "Curves.h" #include "Curves.h"
//--LCS: file done except TODO
float CCurves::CalcSpeedScaleFactor(CVector* pPoint1, CVector* pPoint2, float dir1X, float dir1Y, float dir2X, float dir2Y) float CCurves::CalcSpeedScaleFactor(CVector* pPoint1, CVector* pPoint2, float dir1X, float dir1Y, float dir2X, float dir2Y)
{ {
CVector2D dir1(dir1X, dir1Y); CVector2D dir1(dir1X, dir1Y);

View File

@ -29,6 +29,8 @@
#include "VarConsole.h" #include "VarConsole.h"
#include "SaveBuf.h" #include "SaveBuf.h"
//--LCS: file done except TODO
#define ROTATED_DOOR_OPEN_SPEED (0.015f) #define ROTATED_DOOR_OPEN_SPEED (0.015f)
#define ROTATED_DOOR_CLOSE_SPEED (0.02f) #define ROTATED_DOOR_CLOSE_SPEED (0.02f)
#define DEFAULT_DOOR_OPEN_SPEED (0.035f) #define DEFAULT_DOOR_OPEN_SPEED (0.035f)