Advertisement
Guest User

Untitled

a guest
Apr 20th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. void APlayerCharacter::ToggleScope(const bool scoped)
  2. {
  3. const auto controller = Cast<APlayerController>(GetController());
  4. if (!controller) return;
  5. const auto hud = Cast<ASchimmelHUD>(controller->GetHUD());
  6. if (!hud) return;
  7. isScoped = scoped;
  8. if (isScoped == wasScoped) return;
  9.  
  10. const auto fov = scoped ? Constants::Actor::Agent::PlayerCharacter::Camera::scopedFOV : UOptionsManager::GetFieldOfView();
  11. camera->SetFieldOfView(fov);
  12. OnScopeToggled.Broadcast(scoped);
  13. wasScoped = isScoped;
  14. if (scoped) hud->StartHint(HintContexts::Zoom);
  15. else hud->EndHint();
  16. if (firstPersonMesh) firstPersonMesh->SetHiddenInGame(scoped);
  17. if (currentWeapon)
  18. if (const auto weaponMesh = currentWeapon->GetViewMesh())
  19. weaponMesh->SetHiddenInGame(scoped);
  20. }
  21.  
  22. void APlayerCharacter::ZoomInOrOut(bool zoomIn)
  23. {
  24. const auto oldFOV = camera->FieldOfView;
  25. auto newFOV = oldFOV;
  26. if (zoomIn) newFOV -= Constants::Actor::Agent::PlayerCharacter::Camera::scopedFOVDelta;
  27. else newFOV += Constants::Actor::Agent::PlayerCharacter::Camera::scopedFOVDelta;
  28. newFOV = FMath::Clamp(newFOV, Constants::Actor::Agent::PlayerCharacter::Camera::minScopedFOV, Constants::Actor::Agent::PlayerCharacter::Camera::maxScopedFOV);
  29. camera->SetFieldOfView(newFOV);
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement