void ASWeapon::StartReload(bool bFromReplication) { /* Push the request to server */ if (!bFromReplication && Role < ROLE_Authority) { ServerStartReload(); } /* If local execute requested or we are running on the server */ if (bFromReplication || CanReload()) { bPendingReload = true; DetermineWeaponState(); float AnimDuration = PlayWeaponAnimation(ReloadAnim); if (AnimDuration <= 0.0f) { AnimDuration = NoAnimReloadDuration; } GetWorldTimerManager().SetTimer(TimerHandle_StopReload, this, &ASWeapon::StopSimulateReload, AnimDuration, false); if (Role == ROLE_Authority) { GetWorldTimerManager().SetTimer(TimerHandle_ReloadWeapon, this, &ASWeapon::ReloadWeapon, FMath::Max(0.1f, AnimDuration - 0.1f), false); } if (MyPawn && MyPawn->IsLocallyControlled()) { PlayWeaponSound(ReloadSound); } } }
void AShooterWeapon::StartReload(bool bFromReplication) { if (!bFromReplication && Role < ROLE_Authority) { ServerStartReload(); } if (bFromReplication || CanReload()) { bPendingReload = true; DetermineWeaponState(); float AnimDuration = PlayWeaponAnimation(ReloadAnim); if (AnimDuration <= 0.0f) { AnimDuration = WeaponConfig.NoAnimReloadDuration; } GetWorldTimerManager().SetTimer(TimerHandle_StopReload, this, &AShooterWeapon::StopReload, AnimDuration, false); if (Role == ROLE_Authority) { GetWorldTimerManager().SetTimer(TimerHandle_ReloadWeapon, this, &AShooterWeapon::ReloadWeapon, FMath::Max(0.1f, AnimDuration - 0.1f), false); } if (MyPawn && MyPawn->IsLocallyControlled()) { PlayWeaponSound(ReloadSound); } } }
void AWeapon::StartReload(bool bFromReplication) { if (!bFromReplication && Role < ROLE_Authority) { ServerStartReload(); } if (bFromReplication || CanReload()) { bPendingReload = true; DetermineWeaponState(); GetWorldTimerManager().SetTimer(TimerHandle_StopReload, this, &AWeapon::StopReload, ReloadDuration, false); if (Role == ROLE_Authority) { GetWorldTimerManager().SetTimer(TimerHandle_ReloadWeapon, this, &AWeapon::ReloadWeapon, FMath::Max(0.1f, ReloadDuration - 0.1f), false); } } }