| 177 | |
| 178 | |
| 179 | void cPlayer::Tick(float a_Dt, cChunk & a_Chunk) |
| 180 | { |
| 181 | if (m_ClientHandle != NULL) |
| 182 | { |
| 183 | if (m_ClientHandle->IsDestroyed()) |
| 184 | { |
| 185 | // This should not happen, because destroying a client will remove it from the world, but just in case |
| 186 | m_ClientHandle = NULL; |
| 187 | return; |
| 188 | } |
| 189 | |
| 190 | if (!m_ClientHandle->IsPlaying()) |
| 191 | { |
| 192 | // We're not yet in the game, ignore everything |
| 193 | return; |
| 194 | } |
| 195 | } |
| 196 | |
| 197 | if (!a_Chunk.IsValid()) |
| 198 | { |
| 199 | // This may happen if the cPlayer is created before the chunks have the chance of being loaded / generated (#83) |
| 200 | return; |
| 201 | } |
| 202 | |
| 203 | super::Tick(a_Dt, a_Chunk); |
| 204 | |
| 205 | // Handle charging the bow: |
| 206 | if (m_IsChargingBow) |
| 207 | { |
| 208 | m_BowCharge += 1; |
| 209 | } |
| 210 | |
| 211 | //handle updating experience |
| 212 | if (m_bDirtyExperience) |
| 213 | { |
| 214 | SendExperience(); |
| 215 | } |
| 216 | |
| 217 | if (m_bDirtyPosition) |
| 218 | { |
| 219 | // Apply food exhaustion from movement: |
| 220 | ApplyFoodExhaustionFromMovement(); |
| 221 | |
| 222 | cRoot::Get()->GetPluginManager()->CallHookPlayerMoving(*this); |
| 223 | BroadcastMovementUpdate(m_ClientHandle); |
| 224 | m_ClientHandle->StreamChunks(); |
| 225 | } |
| 226 | else |
| 227 | { |
| 228 | BroadcastMovementUpdate(m_ClientHandle); |
| 229 | } |
| 230 | |
| 231 | if (m_Health > 0) // make sure player is alive |
| 232 | { |
| 233 | m_World->CollectPickupsByPlayer(this); |
| 234 | |
| 235 | if ((m_EatingFinishTick >= 0) && (m_EatingFinishTick <= m_World->GetWorldAge())) |
| 236 | { |
nothing calls this directly
no test coverage detected