| 456 | } |
| 457 | |
| 458 | void CCharacterCore::TickDeferred() |
| 459 | { |
| 460 | if(m_pWorld) |
| 461 | { |
| 462 | for(int i = 0; i < MAX_CLIENTS; i++) |
| 463 | { |
| 464 | CCharacterCore *pCharCore = m_pWorld->m_apCharacters[i]; |
| 465 | if(!pCharCore) |
| 466 | continue; |
| 467 | |
| 468 | if(pCharCore == this || (m_Id != -1 && !m_pTeams->CanCollide(m_Id, i))) |
| 469 | continue; // make sure that we don't nudge our self |
| 470 | |
| 471 | if(!(m_Super || pCharCore->m_Super) && (m_Solo || pCharCore->m_Solo)) |
| 472 | continue; |
| 473 | |
| 474 | // handle player <-> player collision |
| 475 | float Distance = distance(m_Pos, pCharCore->m_Pos); |
| 476 | if(Distance > 0) |
| 477 | { |
| 478 | vec2 Dir = normalize(m_Pos - pCharCore->m_Pos); |
| 479 | |
| 480 | bool CanCollide = (m_Super || pCharCore->m_Super) || (!m_CollisionDisabled && !pCharCore->m_CollisionDisabled && m_Tuning.m_PlayerCollision); |
| 481 | |
| 482 | if(CanCollide && Distance < PhysicalSize() * 1.25f) |
| 483 | { |
| 484 | float a = (PhysicalSize() * 1.45f - Distance); |
| 485 | float Velocity = 0.5f; |
| 486 | |
| 487 | // make sure that we don't add excess force by checking the |
| 488 | // direction against the current velocity. if not zero. |
| 489 | if(length(m_Vel) > 0.0001f) |
| 490 | Velocity = 1 - (dot(normalize(m_Vel), Dir) + 1) / 2; // Wdouble-promotion don't fix this as this might change game physics |
| 491 | |
| 492 | m_Vel += Dir * a * (Velocity * 0.75f); |
| 493 | m_Vel *= 0.85f; |
| 494 | } |
| 495 | |
| 496 | // handle hook influence |
| 497 | if(!m_HookHitDisabled && m_HookedPlayer == i && m_Tuning.m_PlayerHooking) |
| 498 | { |
| 499 | if(Distance > PhysicalSize() * 1.50f) |
| 500 | { |
| 501 | float HookAccel = m_Tuning.m_HookDragAccel * (Distance / m_Tuning.m_HookLength); |
| 502 | float DragSpeed = m_Tuning.m_HookDragSpeed; |
| 503 | |
| 504 | vec2 Temp; |
| 505 | // add force to the hooked player |
| 506 | Temp.x = SaturatedAdd(-DragSpeed, DragSpeed, pCharCore->m_Vel.x, HookAccel * Dir.x * 1.5f); |
| 507 | Temp.y = SaturatedAdd(-DragSpeed, DragSpeed, pCharCore->m_Vel.y, HookAccel * Dir.y * 1.5f); |
| 508 | pCharCore->m_Vel = ClampVel(pCharCore->m_MoveRestrictions, Temp); |
| 509 | // add a little bit force to the guy who has the grip |
| 510 | Temp.x = SaturatedAdd(-DragSpeed, DragSpeed, m_Vel.x, -HookAccel * Dir.x * 0.25f); |
| 511 | Temp.y = SaturatedAdd(-DragSpeed, DragSpeed, m_Vel.y, -HookAccel * Dir.y * 0.25f); |
| 512 | m_Vel = ClampVel(m_MoveRestrictions, Temp); |
| 513 | } |
| 514 | } |
| 515 | } |
nothing calls this directly
no test coverage detected