Advertisement
Dirt113

DHCharacter.h

Nov 2nd, 2015
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 9.05 KB | None | 0 0
  1. // Copyright 2015 Dirt Productions. All rights reserved.
  2.  
  3. #pragma once
  4.  
  5. #include "GameFramework/Character.h"
  6. #include "DistantHome.h"
  7. #include "Public/Items/Weapons/ProjectileWeapons/DHProjectileWeapon.h"
  8. #include "Public/Gameplay/Infos/DHPlayerInfo.h"
  9. #include "Public/Gameplay/Utility/DHUtility.h"
  10. #include "DHCharacter.generated.h"
  11.  
  12. UCLASS()
  13. class DISTANTHOME_API ADHCharacter : public ACharacter
  14. {
  15.     GENERATED_BODY()
  16.  
  17.     //** VARIABLES **//
  18. public:
  19.     UPROPERTY()
  20.         // Base control rate for rate-based view control
  21.         float ViewRate;
  22.  
  23.     UPROPERTY()
  24.         // Walking speed
  25.         float WalkingSpeed;
  26.  
  27.     UPROPERTY()
  28.         // Sprinting speed - default walk speed
  29.         float AdditiveSprintingSpeed;
  30.  
  31.     UPROPERTY()
  32.         // Player information
  33.         FPlayerData PlayerData;
  34.  
  35. protected:
  36.     UPROPERTY()
  37.         // True if moving, otherwise false
  38.         bool bIsMoving;
  39.  
  40.     UPROPERTY()
  41.         // True if moving forward, otherwise false
  42.         bool bIsMovingForward;
  43.  
  44.     UPROPERTY()
  45.         // True if in air, otherwise false
  46.         bool bIsAirborne;
  47.  
  48.     UPROPERTY()
  49.         // True if sprinting, otherwise false
  50.         bool bIsSprinting;
  51.  
  52.     UPROPERTY()
  53.         // True if receiving sprint input, otherwise false
  54.         bool bWantsToSprint;
  55.  
  56.     UPROPERTY()
  57.         // True if firing, otherwise false
  58.         bool bIsFiring;
  59.  
  60.     UPROPERTY()
  61.         // True if receiving fire input, otherwise false
  62.         bool bWantsToFire;
  63.  
  64.     UPROPERTY()
  65.         // True if crouching, otherwise false
  66.         bool bIsCrouching;
  67.  
  68.     UPROPERTY()
  69.         // True if receiving crouch input, otherwise false
  70.         bool bWantsToCrouch;
  71.  
  72.     UPROPERTY()
  73.         // True if aiming, otherwise false
  74.         bool bIsAiming;
  75.  
  76.     UPROPERTY()
  77.         // True if receiving aim input, otherwise false
  78.         bool bWantsToAim;
  79.  
  80.     UPROPERTY()
  81.         // True if reloading, otherwise false
  82.         bool bIsReloading;
  83.  
  84.     UPROPERTY()
  85.         // True if receiving reload input, otherwise false
  86.         bool bWantsToReload;
  87.  
  88.     UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Character|Components")
  89.         // First person camera component
  90.         UCameraComponent* FirstPersonCamera;
  91.  
  92.     UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Character|Components")
  93.         // Orbit camera component
  94.         UCameraComponent* OrbitViewCamera;
  95.  
  96.     UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Character|Components")
  97.         // Spring arm component
  98.         USpringArmComponent* OrbitSpringArm;
  99. private:
  100.     UPROPERTY()
  101.         // True to call OnStartSprint() on next tick, otherwise false
  102.         bool bSprintOnNextTick;
  103.  
  104.     UPROPERTY()
  105.         // True if first fire, otherwise false
  106.         bool bIsFirstFire;
  107.  
  108.     //** FUNCTIONS **//
  109. public:
  110.     // Sets default values for this character's properties
  111.     ADHCharacter(const FObjectInitializer& ObjectInitializer);
  112.  
  113.     // Called when the game starts or when spawned
  114.     virtual void BeginPlay() override;
  115.    
  116.     // Called every frame
  117.     virtual void Tick( float DeltaSeconds ) override;
  118.  
  119.     // Called to bind functionality to input
  120.     virtual void SetupPlayerInputComponent(class UInputComponent* InputComponent) override;
  121.  
  122.     UFUNCTION(BlueprintCallable, Category = "Character")
  123.         // Get firing state
  124.         bool IsFiring() const;
  125.  
  126.     UFUNCTION(BlueprintCallable, Category = "Character")
  127.         // Get sprinting state
  128.         bool IsSprinting() const;
  129.  
  130.     UFUNCTION(BlueprintCallable, Category = "Character")
  131.         // Get crouching state
  132.         bool IsCrouching() const;
  133.  
  134.     UFUNCTION(BlueprintCallable, Category = "Character")
  135.         // Get aiming state
  136.         bool IsAiming() const;
  137.  
  138.     UFUNCTION(BlueprintCallable, Category = "Character")
  139.         // Get moving state
  140.         bool IsMoving() const;
  141.  
  142.     UFUNCTION(BlueprintCallable, Category = "Character|Damage")
  143.         // Check if character is alive
  144.         bool IsAlive() const;
  145.  
  146.     UFUNCTION(BlueprintCallable, Category = "Character|Weapon|Control")
  147.         /**
  148.          * Check if character meets the requirements to fire
  149.          * @param bCheckMovement : true to check movement, otherwise false
  150.          * @param bFalseIfFiring : true to account for current fire state, otherwise false
  151.          */
  152.         bool CanFire(bool bCheckMovement, bool bFalseIfFiring) const;
  153.  
  154.     UFUNCTION(BlueprintCallable, Category = "Character|Weapon")
  155.         // Gets instance of weapon from EWeaponSlot
  156.         ADHWeapon* GetWeaponInstance(EWeaponSlot SlotToGet);
  157. protected:
  158.     UFUNCTION(BlueprintCallable, Category = "Character|Movement|Basic")
  159.         // Handles X axis movement
  160.         void MoveForward(float Value);
  161.  
  162.     UFUNCTION(BlueprintCallable, Category = "Character|Movement|Basic")
  163.         // Hanldes Y axis movement
  164.         void MoveRight(float Value);
  165.  
  166.     UFUNCTION(BlueprintCallable, Category = "Character|View")
  167.         // Handles mouse yaw
  168.         void Turn(float Value);
  169.  
  170.     UFUNCTION(BlueprintCallable, Category = "Character|View")
  171.         // Handles mouse pitch
  172.         void LookUp(float Value);
  173.  
  174.     UFUNCTION(BlueprintCallable, Category = "Character|View")
  175.         // Handles stick yaw
  176.         void TurnAtRate(float Value);
  177.  
  178.     UFUNCTION(BlueprintCallable, Category = "Character|View")
  179.         // Handles stick pitch
  180.         void LookUpAtRate(float Value);
  181.  
  182.     UFUNCTION()
  183.         // Called when MoveBackward released
  184.         void OnStopMovingBackward();
  185.  
  186.     UFUNCTION(BlueprintCallable, Category = "Character|Movement|Advanced")
  187.         // Called when jump pressed
  188.         void OnStartJumping();
  189.  
  190.     UFUNCTION(BlueprintCallable, Category = "Character|Movement|Advanced")
  191.         // Called when sprint pressed
  192.         void OnStartSprinting();
  193.  
  194.     UFUNCTION(BlueprintCallable, Category = "Character|Movement|Advanced")
  195.         // Called when sprint released
  196.         void OnStopSprinting();
  197.  
  198.     UFUNCTION(BlueprintCallable, Category = "Character|Movement|Advanced")
  199.         // Called when crouch pressed
  200.         void OnStartCrouching();
  201.  
  202.     UFUNCTION(BlueprintCallable, Category = "Character|Movement|Advanced")
  203.         // Called when crouch released
  204.         void OnStopCrouching();
  205.    
  206.     UFUNCTION(BlueprintCallable, Category = "Character|Movement|Advanced")
  207.         // Called when aim pressed
  208.         void OnStartAiming();
  209.  
  210.     UFUNCTION(BlueprintCallable, Category = "Character|Movement|Advanced")
  211.         // Called when aim released
  212.         void OnStopAiming();
  213.  
  214.     UFUNCTION(BlueprintCallable, Category = "Character|Weapon|Control")
  215.         // Called when fire pressed
  216.         void OnStartFiring();
  217.  
  218.     UFUNCTION(BlueprintCallable, Category = "Character|Weapon|Control")
  219.         // Called when fire released
  220.         void OnStopFiring();
  221.  
  222.     UFUNCTION(BlueprintCallable, Category = "Character|Weapon|Control")
  223.         // Calculates bullet spread, fires line trace, then spawns projectile to calculated destination
  224.         void FireWeapon(EWeaponSlot WeaponToFire);
  225.  
  226.     UFUNCTION(BlueprintCallable, Category = "Character|Weapon|Control")
  227.         // Fires current weapon
  228.         void FireCurrentWeapon();
  229.  
  230.     UFUNCTION(BlueprintCallable, Category = "Character|Weapon|Switch")
  231.         /**
  232.          * Equips weapon from inventory
  233.          * @param WeaponToEquip : Desired EWeaponSlot Value
  234.          */
  235.         void EquipWeapon(EWeaponSlot WeaponToEquip);
  236.  
  237.     UFUNCTION(BlueprintCallable, Category = "Character|Weapon|Switch")
  238.         /**
  239.          * Called when weapon changed
  240.          * @param PreviousWeapon : Previous weapon as EWeaponSlot
  241.          */
  242.         void OnWeaponChanged(EWeaponSlot PreviousWeapon);
  243.  
  244.     UFUNCTION(BlueprintCallable, Category = "Character|Weapon|Control")
  245.         /**
  246.          * Reloads weapon
  247.          * @param WeaponToReload : EWeaponSlot value of desired weapon
  248.          */
  249.         void ReloadWeapon(EWeaponSlot WeaponToReload);
  250.  
  251.     UFUNCTION(BlueprintCallable, Category = "Character|Weapon|Control")
  252.         // Called when reload pressed
  253.         void OnStartReloading();
  254.  
  255.     UFUNCTION(BlueprintCallable, Category = "Character|Weapon|Control")
  256.         // Called when reload released
  257.         void OnStopReloading();
  258.    
  259.     UFUNCTION(BlueprintCallable, Category = "Character|Weapon")
  260.         /**
  261.          * Spawns new weapon then adds to inventory
  262.          * @param WeaponToSpawn : Weapon to spawn
  263.          * @param SlotToUse : Slot to add weapon to
  264.          */
  265.         void MakeWeapon(ADHWeapon* WeaponToSpawn, EWeaponSlot SlotToUse);
  266.  
  267.     UFUNCTION(BlueprintCallable, Category = "Character|Weapon")
  268.         /**
  269.          * Gets fire delay of EWeaponSlot value
  270.          * @param WeaponToGet : EWeaponSlot value of desired weapon
  271.          */
  272.         float GetWeaponFireDelay(EWeaponSlot WeaponToGet);
  273.  
  274.     UFUNCTION(BlueprintCallable, Category = "Character|Weapon")
  275.         // Gets fire delay of current weapon
  276.         float GetCurrentFireDelay();
  277.    
  278.     UFUNCTION(BlueprintCallable, Category = "Character|Weapon|Switch")
  279.         // Handles SwitchWeapon axis input
  280.         void OnSwitchWeaponAxis(float Value);
  281.  
  282.     UFUNCTION(BlueprintCallable, Category = "Character|Weapon|Switch")
  283.         // Handles PrimaryWeapon switch input
  284.         void OnSwitchToPrimary();
  285.  
  286.     UFUNCTION(BlueprintCallable, Category = "Character|Weapon|Switch")
  287.         // Handles SecondaryWeapon switch input
  288.         void OnSwitchToSecondary();
  289.  
  290.     UFUNCTION(BlueprintCallable, Category = "Character|Weapon|Switch")
  291.         // Handles MeleeWeapon switch input
  292.         void OnSwitchToMelee();
  293.  
  294.     UFUNCTION(BlueprintCallable, Category = "Character|Weapon|Switch")
  295.         // Handles MeleeWeaponUse input
  296.         void OnUseMelee();
  297.  
  298.     UFUNCTION(BlueprintCallable, Category = "Character|Weapon|Switch")
  299.         // Handles SpecialWeapon switch input
  300.         void OnSwitchToSpecial();
  301.  
  302.     UFUNCTION(BlueprintCallable, Category = "Character|Weapon|Switch")
  303.         // Handles SpecialWeaponUse input
  304.         void OnUseSpecial();
  305.  
  306.     UFUNCTION(BlueprintCallable, Category = "Character")
  307.         // Updates camera view and misc. properties
  308.         void UpdateCameraView();
  309. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement