| 91 | } |
| 92 | |
| 93 | void ControlZipLine(short itemNumber) |
| 94 | { |
| 95 | constexpr auto VEL_ACCEL = 5.0f; |
| 96 | constexpr auto VEL_MAX = 100.0f; |
| 97 | |
| 98 | auto& zipLineItem = g_Level.Items[itemNumber]; |
| 99 | auto& laraItem = *LaraItem; |
| 100 | |
| 101 | if (zipLineItem.Status != ITEM_ACTIVE) |
| 102 | return; |
| 103 | |
| 104 | if (!(zipLineItem.Flags & IFLAG_INVISIBLE)) |
| 105 | { |
| 106 | auto& prevPos = *(GameVector*)zipLineItem.Data; |
| 107 | |
| 108 | zipLineItem.Pose.Position = prevPos.ToVector3i(); |
| 109 | |
| 110 | if (prevPos.RoomNumber != zipLineItem.RoomNumber) |
| 111 | ItemNewRoom(itemNumber, prevPos.RoomNumber); |
| 112 | |
| 113 | zipLineItem.Status = ITEM_NOT_ACTIVE; |
| 114 | SetAnimation(zipLineItem, 0); |
| 115 | |
| 116 | RemoveActiveItem(itemNumber); |
| 117 | return; |
| 118 | } |
| 119 | |
| 120 | if (zipLineItem.Animation.ActiveState == 1) |
| 121 | { |
| 122 | AnimateItem(zipLineItem); |
| 123 | return; |
| 124 | } |
| 125 | |
| 126 | AnimateItem(zipLineItem); |
| 127 | |
| 128 | // Accelerate. |
| 129 | if (zipLineItem.Animation.Velocity.y < VEL_MAX) |
| 130 | zipLineItem.Animation.Velocity.y += VEL_ACCEL; |
| 131 | |
| 132 | // Translate. |
| 133 | // TODO: Use proper calculation of the trajectory instead of bitwise operation. |
| 134 | auto headingOrient = EulerAngles(0, zipLineItem.Pose.Orientation.y, 0); |
| 135 | zipLineItem.Pose.Translate(headingOrient, zipLineItem.Animation.Velocity.y); |
| 136 | zipLineItem.Pose.Position.y += ((int)zipLineItem.Animation.Velocity.y >> 2); |
| 137 | |
| 138 | int vPos = zipLineItem.Pose.Position.y + CLICK(0.25f); |
| 139 | auto pointColl = GetPointCollision(zipLineItem, zipLineItem.Pose.Orientation.y, zipLineItem.Animation.Velocity.y); |
| 140 | |
| 141 | // Update zip line room number. |
| 142 | if (pointColl.GetRoomNumber() != zipLineItem.RoomNumber) |
| 143 | ItemNewRoom(itemNumber, pointColl.GetRoomNumber()); |
| 144 | |
| 145 | if (pointColl.GetFloorHeight() <= (vPos + CLICK(1)) || pointColl.GetCeilingHeight() >= (vPos - CLICK(1))) |
| 146 | { |
| 147 | // Dismount. |
| 148 | if (laraItem.Animation.ActiveState == LS_ZIP_LINE) |
| 149 | { |
| 150 | laraItem.Animation.TargetState = LS_JUMP_FORWARD; |
nothing calls this directly
no test coverage detected