CodeHumanH

#pragma once

 

#include "ActorUFO.h"

#include "HumanActorUFO.generated.h"

 

//forward declaration

class AUFOGameMode;

 

UENUM(BlueprintType)

enum class EHumanState : uint8

{

walkingUMETA(DisplayName = "Walking"),

falling UMETA(DisplayName = "Falling"),

idleUMETA(DisplayName = "Idle"),

inBeamUMETA(DisplayName = "InBeam"),

dyingUMETA(DisplayName = "Dying"),

attractUMETA(DisplayName = "Attract")

};

 

 

UCLASS()

class UNREALPROJECT_API AHumanActorUFO : public AActorUFO

{

 

GENERATED_BODY()

 

public:

 

AHumanActorUFO(const FObjectInitializer& ObjectInitializer);

 

//culling called from game mode so needs to be public

void DisableAnimation(bool disableAnimation);

void DisableRendering(bool disableRendering);

 

//main update called from game mode

void UpdateLogic(float deltaTime);

 

UFUNCTION(BlueprintCallable, Category = "Modifiers")

void SetPanicMod( FVector impactLocation );

 

UFUNCTION(BlueprintCallable, Category = "Modifiers")

void SetStunnedMod( );

 

UFUNCTION(BlueprintNativeEvent, Category = "Logic")

void DyingLogic();

virtual void DyingLogic_Implementation();

 

UFUNCTION(BlueprintNativeEvent, Category = "Logic")

void InBeamLogic();

virtual void InBeamLogic_Implementation();

 

UFUNCTION(BlueprintNativeEvent, Category = "Logic")

void AttractLogic();

virtual void AttractLogic_Implementation();

 

UFUNCTION(BlueprintCallable, Category = "States")

void TryChangeStateToFalling();

 

UFUNCTION(BlueprintCallable, Category = "States")

void TryChangeStateToWalking();

 

UFUNCTION(BlueprintCallable, Category = "States")

void TryChangeStateToDying();

 

UFUNCTION(BlueprintCallable, Category = "States")

void TryChangeStateToInBeam();

 

UFUNCTION(BlueprintCallable, Category = "States")

void TryChangeStateToAttract();

 

UFUNCTION(BlueprintCallable, Category = "Modifiers")

bool TrySetCrawlingMod( );

 

UFUNCTION(BlueprintCallable, Category = "Modifiers")

float RemoveHealth( float health );

 

UPROPERTY( EditDefaultsOnly, BlueprintReadWrite, Category = Components)

USkeletalMeshComponent* SkeletalMesh1;

 

UPROPERTY( EditDefaultsOnly, BlueprintReadWrite, Category = Components)

UBoxComponent* Box1;

 

UPROPERTY( EditDefaultsOnly, Category = "Blood")

TSubclassOf<class AActor> blood;

 

UPROPERTY( BlueprintReadOnly, Category = States)

EHumanState currentHumanState;

 

UPROPERTY( EditDefaultsOnly, BlueprintReadWrite, Category = "Blood")

UMaterialInterface* bloodMaterial;

 

UPROPERTY( BlueprintReadWrite, Category = States)

bool crawling;

 

UPROPERTY( BlueprintReadWrite, Category = States)

bool panic;

 

UPROPERTY( BlueprintReadWrite, Category = States)

bool stunned;

 

UPROPERTY( BlueprintReadWrite, Category = States)

bool attracted;

 

UPROPERTY( BlueprintReadWrite, Category = States)

bool spawning;

 

UPROPERTY( BlueprintReadWrite, Category = Speed)

float walkingSpeed;

 

UPROPERTY( BlueprintReadWrite, Category = Speed)

float panicSpeed;

 

UPROPERTY( BlueprintReadWrite, Category = Speed)

float crawlingSpeed;

 

UPROPERTY( BlueprintReadWrite, Category = Speed)

float distanceToTraceGround;

 

UPROPERTY(BlueprintReadWrite, Category = Speed)

float deltaTime;

 

 

private:

 

//generic functions

virtual void BeginPlay() override;

float CalculateFallDamage(const FVector& startLocation, const FVector& endLocation);

void CalculateFallingSpeed();

bool IsStandingOnGround(float startOffset, float offsetForward);

bool IsWallInFront(float startOffsetForward);

void SpawnBlood();

 

//movement functions

void MoveActorForward();

void MoveActorDown( );

bool MoveActorDownToGround(float startOffsetZ, float distanceToCheck, FVector& endPosition);

void RotateActorRandom(float maxRotDeviation);

 

//statelogic

void WalkingLogic();

void FallingLogic();

 

//state and modifiers

void CheckAndUpdateSpeedModifiers();

 

 

//---------------------variables----------------------------------

AUFOGameMode* gameMode;

float currentSpeed;

float currentHealth;

float maxHealth;

 

//spawn

float currentTimeSpawnMod;

float maxTimeSpawnMod;

 

//panic

float currentTimePanicMod;

float maxTimePanicMod;

 

//stunned

float currentTimeStunnedMod;

float maxTimeStunnedMod;

 

//walking

float checkWallStartOffset;

 

//falling

FVector startFallingLocation;

FVector endFallingLocation;

float groundTraceOffset;

float groundTraceOffsetForward;

float currentFallingSpeed;

float fallingSpeedStart;

float fallingSpeedMax;

float gravity;

 

//dying

float currentTimeDying;

float maxTimeDying;

 

//clulling

bool isAnimationDisabled;

bool isRenderingDisabled;

 

//Generic trace function

bool Trace(AActor* ActorToIgnore, FHitResult &OutHit, FVector &Start, FVector &End, ECollisionChannel CollisionChannel, bool Debug);

 

 

};