162 lines
		
	
	
		
			3.4 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			162 lines
		
	
	
		
			3.4 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
| // Fill out your copyright notice in the Description page of Project Settings.
 | |
| 
 | |
| #pragma once
 | |
| 
 | |
| #include "CoreMinimal.h"
 | |
| #include "GameFramework/Pawn.h"
 | |
| #include "Components/BoxComponent.h"
 | |
| #include "Kismet/KismetMathLibrary.h"
 | |
| #include "BasePawn.generated.h"
 | |
| 
 | |
| class UFloatingPawnMovement;
 | |
| 
 | |
| UCLASS()
 | |
| class PRESIDENTSBRIGADE_API ABasePawn : public APawn
 | |
| {
 | |
| 	GENERATED_BODY()
 | |
| 
 | |
| public:
 | |
| 	// Sets default values for this pawn's properties
 | |
| 	ABasePawn(const FObjectInitializer &object_initializer);
 | |
| 
 | |
| 	FVector get_location() const;
 | |
| 
 | |
| 	// Called every frame
 | |
| 	virtual void Tick(float DeltaTime) override;
 | |
| 	virtual void handle_move_right(float axis);
 | |
| 	virtual void handle_move_forward(float axis);
 | |
| 	virtual void update_yaw_x(float x_component);
 | |
| 	virtual void update_yaw_y(float y_component);
 | |
| 	virtual void start_shooting();
 | |
| 	virtual void stop_shooting();
 | |
| 	virtual void shoot();
 | |
| 	virtual void handle_death();
 | |
| protected:
 | |
| 	struct Yaw
 | |
| 	{
 | |
| 		float x_component;
 | |
| 		float y_component;
 | |
| 
 | |
| 		float calculate_yaw() 
 | |
| 		{
 | |
| 			if (x_component < 0)
 | |
| 			{
 | |
| 				const float deg = UKismetMathLibrary::DegAtan2(-1 * x_component, y_component);
 | |
| 				return 360 - deg;
 | |
| 			}
 | |
| 
 | |
|        	    return UKismetMathLibrary::DegAtan2(x_component, y_component);
 | |
| 		};
 | |
| 	};
 | |
| 
 | |
| 	virtual void destroy_self();
 | |
| 
 | |
| 	// Called when the game starts or when spawned
 | |
| 	virtual void BeginPlay() override;
 | |
| 
 | |
| 	UFUNCTION()
 | |
| 	virtual void handle_hit(
 | |
| 		UPrimitiveComponent* hit_component, 
 | |
| 		AActor* other_actor,
 | |
| 		UPrimitiveComponent* other_component,
 | |
| 		FVector normal_impulse,
 | |
| 		const FHitResult& hit
 | |
| 	);
 | |
| 
 | |
| 	virtual UPawnMovementComponent* GetMovementComponent() const;
 | |
| 
 | |
| 	UPROPERTY(EditAnywhere, Category="Player")
 | |
| 	UBoxComponent* collision;
 | |
| 
 | |
| 	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Player")
 | |
| 	USkeletalMeshComponent* player_mesh;
 | |
| 
 | |
| 	UPROPERTY(EditAnywhere, Category="Movement")
 | |
| 	UFloatingPawnMovement* movement_component;
 | |
| 
 | |
| 	/**
 | |
| 	 * Root component.
 | |
|      */
 | |
| 	UPROPERTY(EditAnywhere, Category="Player")
 | |
| 	USceneComponent* root_component;
 | |
| 
 | |
| 	/**
 | |
| 	 * Bullet class for projectiles spawned by this object.
 | |
| 	 */
 | |
| 	UPROPERTY(EditAnywhere, Category = "Attack")
 | |
| 	TSubclassOf<class AActor> bullet_actor_class;
 | |
| 
 | |
| 	/**
 | |
| 	 * Impact class for death scene.
 | |
| 	 */
 | |
| 	UPROPERTY(EditAnywhere, Category = "Attack")
 | |
| 	TSubclassOf<class AActor> death_class;
 | |
| 
 | |
| 	/**
 | |
| 	 * Classes that can do damage to this object.
 | |
| 	 */
 | |
| 	UPROPERTY(EditAnywhere, Category = "Attack")
 | |
| 	TMap<UClass*, int> damage_class_map;
 | |
| 
 | |
| 	/**
 | |
| 	 * Maximum health for this characater. Will spawn
 | |
| 	 * with this amount of health.
 | |
| 	 */
 | |
| 	UPROPERTY(EditAnywhere, Category = "Attack")
 | |
| 	int32 max_health;
 | |
| 
 | |
| 	/**
 | |
| 	 * Bullet fire rate.
 | |
| 	 */
 | |
| 	UPROPERTY(EditAnywhere, Category = "Attack")
 | |
| 	float fire_rate_s;
 | |
| 
 | |
| 	/**
 | |
| 	 * Max ammo.
 | |
| 	 */
 | |
| 	UPROPERTY(EditAnywhere, Category = "Attack")
 | |
| 	int32 max_ammo;
 | |
| 
 | |
| 	/**
 | |
| 	 *
 | |
| 	 */
 | |
| 	UPROPERTY(EditAnywhere, Category = "Attack")
 | |
| 	float aim_assist_distance;
 | |
| 
 | |
| 	UPROPERTY(EditAnywhere, Category = "Attack")
 | |
| 	bool use_aim_assist;
 | |
| 
 | |
| 	/**
 | |
| 	 * Shooting enabled;
 | |
| 	 */
 | |
| 	bool shooting_enabled;
 | |
| 
 | |
| 	/**
 | |
| 	 * Time elapsed since last shot.
 | |
| 	 */
 | |
| 	float shoot_time_elapsed;
 | |
| 
 | |
| 	/**
 | |
| 	 * Current health for character.
 | |
| 	 */
 | |
| 	int32 current_health;
 | |
| 
 | |
| 	/**
 | |
| 	 * Current ammo.
 | |
| 	 */
 | |
| 	int32 current_ammo;
 | |
| 
 | |
| 	/**
 | |
| 	 * Last yaw.
 | |
| 	 */
 | |
| 	Yaw yaw;
 | |
| 
 | |
| 	/**
 | |
| 	 * Spawned death effect actor.
 | |
| 	 */
 | |
| 	AActor* death_effect;
 | |
| 
 | |
| private:
 | |
| 	bool aim_assist(const FVector start, const FRotator rotator, float &yaw_output);
 | |
| };
 | 
