| 2030 | } |
| 2031 | |
| 2032 | void Vehicle::update(GameState &state, unsigned int ticks) |
| 2033 | { |
| 2034 | if (isDead() && status == VehicleStatus::Operational) |
| 2035 | { |
| 2036 | status = VehicleStatus::Destroyed; |
| 2037 | |
| 2038 | // Remove from building |
| 2039 | if (currentBuilding) |
| 2040 | { |
| 2041 | currentBuilding->currentVehicles.erase({&state, shared_from_this()}); |
| 2042 | } |
| 2043 | } |
| 2044 | |
| 2045 | if (isDead()) |
| 2046 | { |
| 2047 | return; |
| 2048 | } |
| 2049 | |
| 2050 | bool turbo = ticks > TICKS_PER_SECOND; |
| 2051 | bool IsIdle; |
| 2052 | |
| 2053 | if (stunTicksRemaining >= ticks) |
| 2054 | { |
| 2055 | stunTicksRemaining -= ticks; |
| 2056 | return; |
| 2057 | } |
| 2058 | else if (stunTicksRemaining > 0) |
| 2059 | { |
| 2060 | ticks -= stunTicksRemaining; |
| 2061 | stunTicksRemaining = 0; |
| 2062 | } |
| 2063 | |
| 2064 | if (cloakTicksAccumulated < CLOAK_TICKS_REQUIRED_VEHICLE) |
| 2065 | { |
| 2066 | cloakTicksAccumulated += ticks; |
| 2067 | } |
| 2068 | if (!hasCloak()) |
| 2069 | { |
| 2070 | cloakTicksAccumulated = 0; |
| 2071 | } |
| 2072 | if (teleportTicksAccumulated < TELEPORT_TICKS_REQUIRED_VEHICLE) |
| 2073 | { |
| 2074 | teleportTicksAccumulated += ticks; |
| 2075 | } |
| 2076 | if (!hasTeleporter()) |
| 2077 | { |
| 2078 | teleportTicksAccumulated = 0; |
| 2079 | } |
| 2080 | |
| 2081 | IsIdle = this->missions.empty(); |
| 2082 | if (!IsIdle) |
| 2083 | { |
| 2084 | this->missions.front().update(state, *this, ticks); |
| 2085 | } |
| 2086 | |
| 2087 | popFinishedMissions(state); |
| 2088 | |
| 2089 | int maxShield = this->getMaxShield(); |
no test coverage detected