Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Copyright 2015 Dirt Productions. All rights reserved.
- #pragma once
- #include "GameFramework/Character.h"
- #include "DistantHome.h"
- #include "Public/Items/Weapons/ProjectileWeapons/DHProjectileWeapon.h"
- #include "Public/Gameplay/Infos/DHPlayerInfo.h"
- #include "Public/Gameplay/Utility/DHUtility.h"
- #include "DHCharacter.generated.h"
- UCLASS()
- class DISTANTHOME_API ADHCharacter : public ACharacter
- {
- GENERATED_BODY()
- //** VARIABLES **//
- public:
- UPROPERTY()
- // Base control rate for rate-based view control
- float ViewRate;
- UPROPERTY()
- // Walking speed
- float WalkingSpeed;
- UPROPERTY()
- // Sprinting speed - default walk speed
- float AdditiveSprintingSpeed;
- UPROPERTY()
- // Player information
- FPlayerData PlayerData;
- protected:
- UPROPERTY()
- // True if moving, otherwise false
- bool bIsMoving;
- UPROPERTY()
- // True if moving forward, otherwise false
- bool bIsMovingForward;
- UPROPERTY()
- // True if in air, otherwise false
- bool bIsAirborne;
- UPROPERTY()
- // True if sprinting, otherwise false
- bool bIsSprinting;
- UPROPERTY()
- // True if receiving sprint input, otherwise false
- bool bWantsToSprint;
- UPROPERTY()
- // True if firing, otherwise false
- bool bIsFiring;
- UPROPERTY()
- // True if receiving fire input, otherwise false
- bool bWantsToFire;
- UPROPERTY()
- // True if crouching, otherwise false
- bool bIsCrouching;
- UPROPERTY()
- // True if receiving crouch input, otherwise false
- bool bWantsToCrouch;
- UPROPERTY()
- // True if aiming, otherwise false
- bool bIsAiming;
- UPROPERTY()
- // True if receiving aim input, otherwise false
- bool bWantsToAim;
- UPROPERTY()
- // True if reloading, otherwise false
- bool bIsReloading;
- UPROPERTY()
- // True if receiving reload input, otherwise false
- bool bWantsToReload;
- UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Character|Components")
- // First person camera component
- UCameraComponent* FirstPersonCamera;
- UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Character|Components")
- // Orbit camera component
- UCameraComponent* OrbitViewCamera;
- UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Character|Components")
- // Spring arm component
- USpringArmComponent* OrbitSpringArm;
- private:
- UPROPERTY()
- // True to call OnStartSprint() on next tick, otherwise false
- bool bSprintOnNextTick;
- UPROPERTY()
- // True if first fire, otherwise false
- bool bIsFirstFire;
- //** FUNCTIONS **//
- public:
- // Sets default values for this character's properties
- ADHCharacter(const FObjectInitializer& ObjectInitializer);
- // Called when the game starts or when spawned
- virtual void BeginPlay() override;
- // Called every frame
- virtual void Tick( float DeltaSeconds ) override;
- // Called to bind functionality to input
- virtual void SetupPlayerInputComponent(class UInputComponent* InputComponent) override;
- UFUNCTION(BlueprintCallable, Category = "Character")
- // Get firing state
- bool IsFiring() const;
- UFUNCTION(BlueprintCallable, Category = "Character")
- // Get sprinting state
- bool IsSprinting() const;
- UFUNCTION(BlueprintCallable, Category = "Character")
- // Get crouching state
- bool IsCrouching() const;
- UFUNCTION(BlueprintCallable, Category = "Character")
- // Get aiming state
- bool IsAiming() const;
- UFUNCTION(BlueprintCallable, Category = "Character")
- // Get moving state
- bool IsMoving() const;
- UFUNCTION(BlueprintCallable, Category = "Character|Damage")
- // Check if character is alive
- bool IsAlive() const;
- UFUNCTION(BlueprintCallable, Category = "Character|Weapon|Control")
- /**
- * Check if character meets the requirements to fire
- * @param bCheckMovement : true to check movement, otherwise false
- * @param bFalseIfFiring : true to account for current fire state, otherwise false
- */
- bool CanFire(bool bCheckMovement, bool bFalseIfFiring) const;
- UFUNCTION(BlueprintCallable, Category = "Character|Weapon")
- // Gets instance of weapon from EWeaponSlot
- ADHWeapon* GetWeaponInstance(EWeaponSlot SlotToGet);
- protected:
- UFUNCTION(BlueprintCallable, Category = "Character|Movement|Basic")
- // Handles X axis movement
- void MoveForward(float Value);
- UFUNCTION(BlueprintCallable, Category = "Character|Movement|Basic")
- // Hanldes Y axis movement
- void MoveRight(float Value);
- UFUNCTION(BlueprintCallable, Category = "Character|View")
- // Handles mouse yaw
- void Turn(float Value);
- UFUNCTION(BlueprintCallable, Category = "Character|View")
- // Handles mouse pitch
- void LookUp(float Value);
- UFUNCTION(BlueprintCallable, Category = "Character|View")
- // Handles stick yaw
- void TurnAtRate(float Value);
- UFUNCTION(BlueprintCallable, Category = "Character|View")
- // Handles stick pitch
- void LookUpAtRate(float Value);
- UFUNCTION()
- // Called when MoveBackward released
- void OnStopMovingBackward();
- UFUNCTION(BlueprintCallable, Category = "Character|Movement|Advanced")
- // Called when jump pressed
- void OnStartJumping();
- UFUNCTION(BlueprintCallable, Category = "Character|Movement|Advanced")
- // Called when sprint pressed
- void OnStartSprinting();
- UFUNCTION(BlueprintCallable, Category = "Character|Movement|Advanced")
- // Called when sprint released
- void OnStopSprinting();
- UFUNCTION(BlueprintCallable, Category = "Character|Movement|Advanced")
- // Called when crouch pressed
- void OnStartCrouching();
- UFUNCTION(BlueprintCallable, Category = "Character|Movement|Advanced")
- // Called when crouch released
- void OnStopCrouching();
- UFUNCTION(BlueprintCallable, Category = "Character|Movement|Advanced")
- // Called when aim pressed
- void OnStartAiming();
- UFUNCTION(BlueprintCallable, Category = "Character|Movement|Advanced")
- // Called when aim released
- void OnStopAiming();
- UFUNCTION(BlueprintCallable, Category = "Character|Weapon|Control")
- // Called when fire pressed
- void OnStartFiring();
- UFUNCTION(BlueprintCallable, Category = "Character|Weapon|Control")
- // Called when fire released
- void OnStopFiring();
- UFUNCTION(BlueprintCallable, Category = "Character|Weapon|Control")
- // Calculates bullet spread, fires line trace, then spawns projectile to calculated destination
- void FireWeapon(EWeaponSlot WeaponToFire);
- UFUNCTION(BlueprintCallable, Category = "Character|Weapon|Control")
- // Fires current weapon
- void FireCurrentWeapon();
- UFUNCTION(BlueprintCallable, Category = "Character|Weapon|Switch")
- /**
- * Equips weapon from inventory
- * @param WeaponToEquip : Desired EWeaponSlot Value
- */
- void EquipWeapon(EWeaponSlot WeaponToEquip);
- UFUNCTION(BlueprintCallable, Category = "Character|Weapon|Switch")
- /**
- * Called when weapon changed
- * @param PreviousWeapon : Previous weapon as EWeaponSlot
- */
- void OnWeaponChanged(EWeaponSlot PreviousWeapon);
- UFUNCTION(BlueprintCallable, Category = "Character|Weapon|Control")
- /**
- * Reloads weapon
- * @param WeaponToReload : EWeaponSlot value of desired weapon
- */
- void ReloadWeapon(EWeaponSlot WeaponToReload);
- UFUNCTION(BlueprintCallable, Category = "Character|Weapon|Control")
- // Called when reload pressed
- void OnStartReloading();
- UFUNCTION(BlueprintCallable, Category = "Character|Weapon|Control")
- // Called when reload released
- void OnStopReloading();
- UFUNCTION(BlueprintCallable, Category = "Character|Weapon")
- /**
- * Spawns new weapon then adds to inventory
- * @param WeaponToSpawn : Weapon to spawn
- * @param SlotToUse : Slot to add weapon to
- */
- void MakeWeapon(ADHWeapon* WeaponToSpawn, EWeaponSlot SlotToUse);
- UFUNCTION(BlueprintCallable, Category = "Character|Weapon")
- /**
- * Gets fire delay of EWeaponSlot value
- * @param WeaponToGet : EWeaponSlot value of desired weapon
- */
- float GetWeaponFireDelay(EWeaponSlot WeaponToGet);
- UFUNCTION(BlueprintCallable, Category = "Character|Weapon")
- // Gets fire delay of current weapon
- float GetCurrentFireDelay();
- UFUNCTION(BlueprintCallable, Category = "Character|Weapon|Switch")
- // Handles SwitchWeapon axis input
- void OnSwitchWeaponAxis(float Value);
- UFUNCTION(BlueprintCallable, Category = "Character|Weapon|Switch")
- // Handles PrimaryWeapon switch input
- void OnSwitchToPrimary();
- UFUNCTION(BlueprintCallable, Category = "Character|Weapon|Switch")
- // Handles SecondaryWeapon switch input
- void OnSwitchToSecondary();
- UFUNCTION(BlueprintCallable, Category = "Character|Weapon|Switch")
- // Handles MeleeWeapon switch input
- void OnSwitchToMelee();
- UFUNCTION(BlueprintCallable, Category = "Character|Weapon|Switch")
- // Handles MeleeWeaponUse input
- void OnUseMelee();
- UFUNCTION(BlueprintCallable, Category = "Character|Weapon|Switch")
- // Handles SpecialWeapon switch input
- void OnSwitchToSpecial();
- UFUNCTION(BlueprintCallable, Category = "Character|Weapon|Switch")
- // Handles SpecialWeaponUse input
- void OnUseSpecial();
- UFUNCTION(BlueprintCallable, Category = "Character")
- // Updates camera view and misc. properties
- void UpdateCameraView();
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement