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