157 lines
3.1 KiB
C++
Executable File
157 lines
3.1 KiB
C++
Executable File
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "BasePawn.h"
|
|
#include "PlayerPawn.generated.h"
|
|
|
|
class UCameraComponent;
|
|
|
|
/**
|
|
*
|
|
*/
|
|
UCLASS()
|
|
class PRESIDENTSBRIGADE_API APlayerPawn : public ABasePawn
|
|
{
|
|
GENERATED_BODY()
|
|
public:
|
|
// Sets default values for this pawn's properties
|
|
APlayerPawn(const FObjectInitializer &object_initializer);
|
|
|
|
virtual void Tick(float delta_time) override;
|
|
|
|
// Called to bind functionality to input
|
|
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
|
|
|
|
UFUNCTION(BlueprintCallable)
|
|
FORCEINLINE float get_president_health() const
|
|
{
|
|
if (president_ref)
|
|
{
|
|
return president_ref->get_current_health_percentage();
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
UFUNCTION(BlueprintCallable)
|
|
FORCEINLINE float get_boost_cooldown_percentage() const
|
|
{
|
|
if (reset_wait_s < reset_threshold_s)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
if (cooldown_wait_s >= cooldown_threshold_s)
|
|
{
|
|
return 1.0f;
|
|
}
|
|
|
|
return cooldown_wait_s / cooldown_threshold_s;
|
|
}
|
|
|
|
UFUNCTION(BlueprintCallable)
|
|
FORCEINLINE int32 get_current_ammo() const
|
|
{
|
|
return current_ammo;
|
|
}
|
|
|
|
UFUNCTION(BlueprintCallable)
|
|
FORCEINLINE int32 get_max_ammo() const
|
|
{
|
|
return max_ammo;
|
|
}
|
|
|
|
protected:
|
|
virtual void BeginPlay() override;
|
|
virtual void destroy_self() override;
|
|
|
|
UPROPERTY(EditAnywhere, Category="Player")
|
|
UCameraComponent* main_camera;
|
|
|
|
/**
|
|
* Time in seconds before respawn.
|
|
*/
|
|
UPROPERTY(EditAnywhere, Category = "Player")
|
|
float respawn_s;
|
|
|
|
/**
|
|
* Classes that can add ammo to this object.
|
|
*/
|
|
UPROPERTY(EditAnywhere, Category = "Player")
|
|
TMap<UClass*, int> ammo_class_map;
|
|
|
|
UPROPERTY(EditAnywhere, Category = "Player")
|
|
TSubclassOf<ABasePawn> president_class;
|
|
|
|
/**
|
|
* Multiplier to apply to current speed while boosting. Applies to max speed and accleration.
|
|
*/
|
|
UPROPERTY(EditAnywhere, Category = "Movement")
|
|
float boost_multiplier;
|
|
|
|
/**
|
|
* Time in seconds before auto resetting boost.
|
|
*/
|
|
UPROPERTY(EditAnywhere, Category = "Movement")
|
|
float reset_threshold_s;
|
|
|
|
/**
|
|
* Time in seconds before allowed to boost again.
|
|
*/
|
|
UPROPERTY(EditAnywhere, Category = "Movement")
|
|
float cooldown_threshold_s;
|
|
|
|
private:
|
|
UFUNCTION()
|
|
void handle_overlap(
|
|
UPrimitiveComponent *overlapped_component,
|
|
AActor *other_actor,
|
|
UPrimitiveComponent *other_component,
|
|
int32 other_body_index,
|
|
bool from_sweep,
|
|
const FHitResult& hit
|
|
);
|
|
|
|
void boost();
|
|
void reset_boost();
|
|
void respawn();
|
|
ABasePawn* get_president() const;
|
|
|
|
/**
|
|
* Default max speed. Cached when boost is called.
|
|
*/
|
|
float default_max_speed;
|
|
|
|
/**
|
|
* Default max acceleration. Cached when boost is called.
|
|
*/
|
|
float default_max_accel;
|
|
|
|
/**
|
|
* Time waited for boost reset.
|
|
*/
|
|
float reset_wait_s;
|
|
|
|
/**
|
|
* Time waited for cooldown.
|
|
*/
|
|
float cooldown_wait_s;
|
|
|
|
/**
|
|
* Time waiting for respawn.
|
|
*/
|
|
float respawn_wait_s;
|
|
|
|
/**
|
|
* True after post tick initialization.
|
|
*/
|
|
bool init;
|
|
|
|
/**
|
|
* Cached reference to the president.
|
|
*/
|
|
ABasePawn* president_ref;
|
|
};
|