Advertisement
Guest User

BaseHand.h

a guest
Apr 12th, 2020
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 7.09 KB | None | 0 0
  1. #pragma once
  2. #include "BaseEnums.h"
  3. #include "GameFramework/Actor.h"
  4. #include "BaseHand.generated.h"
  5.  
  6. class ABaseItem;
  7. class ABaseWeapon;
  8. class ABaseCharacter;
  9. class USkeletalMeshComponent;
  10. class UPhysicsHandleComponent;
  11. class UMotionControllerComponent;
  12. class UWidgetInteractionComponent;
  13.  
  14. UCLASS(config = Game)
  15. class ABaseHand : public AActor
  16. {
  17.     GENERATED_BODY()
  18.  
  19. protected:
  20.  
  21.     UWidgetInteractionComponent* myWidgetInteractionComponent;
  22.     ABaseCharacter* myOwningCharacter;
  23.  
  24.     ////Hand mesh: 1st person view (seen only by self).
  25.     //UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Hand)
  26.     //USkeletalMeshComponent* myFirstPersonHandMesh;
  27.  
  28.     //VR Hand mesh: VR view (attached to the VR controller directly, no arm, just the hand).
  29.     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Hand)
  30.     USkeletalMeshComponent* myVRHandMesh;
  31.  
  32.     //Motion controller (left hand).
  33.     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Hand)
  34.     UMotionControllerComponent* myMotionController;
  35.  
  36.     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Hand)
  37.     EControllerHand myControllerHand;
  38.  
  39.     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Hand)
  40.     bool myIsItemEquipped;
  41.  
  42.     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Hand)
  43.     bool myIsCurrentlyGrabbing;
  44.  
  45.     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Hand)
  46.     bool myIsCurrentlyCrushing;
  47.  
  48.     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Hand)
  49.     bool myIsTriggerPressed;
  50.  
  51.     //Current Distance of grabbed items from their respective controllers.
  52.     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Hand)
  53.     float myDistanceFromController;
  54.  
  55.     //The farthest distance you can extend your grabbing.
  56.     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Hand)
  57.     float myReachDistance;
  58.  
  59.     //Min Distance for Controller for grabbed objects
  60.     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Hand)
  61.     float myMinDistanceFromController;
  62.  
  63.     //Max Distance for Controller for grabbed objects
  64.     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Hand)
  65.     float myMaxDistanceFromController;
  66.  
  67.     //Whether to use motion controller location for aiming. */
  68.     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Hand)
  69.     bool myIsUsingMotionControllers;
  70.  
  71.     UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = Hand)
  72.     FVector myControllerLocation;
  73.  
  74.     UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = Hand)
  75.     FRotator myControllerRotation;
  76.  
  77.     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Hand)
  78.     FTransform myGrabbedObjectTransform;
  79.  
  80.     UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = Hand)
  81.     FTransform myGrabbedPhysicsHandleTransform;
  82.  
  83.     UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = Hand)
  84.     FTransform myControllerTransform;
  85.  
  86.     //Target location for grabbed object
  87.     UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = Hand)
  88.     FVector myNewGrabbedLocation;
  89.  
  90.     //Difference between previous and old grabbed object locations
  91.     UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = Hand)
  92.     FVector myDiffGrabbedLocation;
  93.  
  94.     //Difference between controller rotation and grabbed object rotation
  95.     UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = Hand)
  96.     FQuat myDiffGrabbedRotation;
  97.  
  98.     //If not NULL, the object that is currently being grabbed.
  99.     UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = Hand)
  100.     ABaseItem* myGrabbedItem;
  101.  
  102.     //If not NULL, the physics handle of the item currently being grabbed.
  103.     UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = Hand)
  104.     UPhysicsHandleComponent* myGrabbedPhysicsHandle;
  105.  
  106.     //The currently grabbed component.
  107.     UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = Hand)
  108.     UPrimitiveComponent* myGrabbedPrimitiveComponent;
  109.  
  110.     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Effects)
  111.     TMap<EVibrationType, UForceFeedbackEffect*> myVibrations;
  112.  
  113.     ECollisionChannel myCollisionChannels[33];
  114.  
  115.     FVector myLastHitDistance;
  116.  
  117. public:
  118.     ///Constructor
  119.     ABaseHand();
  120.  
  121.     ///Virtual Override Functions
  122.     virtual void BeginPlay() override;
  123.     virtual void Tick(float deltaTime) override;
  124.  
  125.     ///Functions
  126.     bool Grab(AActor* actorThatIsGrabbing, bool showDebugLine = false);
  127.     bool GrabItem(ABaseItem* grabbedItem);
  128.     bool TouchItem(ABaseItem* grabbedItem);
  129.     bool GrabWeapon(ABaseItem* grabbedItem);
  130.     bool Crush(int playerStrength);
  131.     void UseItem();
  132.     void RemoveGrabbedItem();
  133.     void Drop();
  134.     bool EquipItem();
  135.     bool UnEquipItem();
  136.     AActor* CastCircleOfRays(double radius, FVector& lineTraceStart, FVector& lineTraceEnd, bool showDebugLines = false);
  137.     AActor* CastCircleOfRays(double radius, FVector& lineTraceStart, FVector& lineTraceEnd, FHitResult& outHitResult, bool showDebugLines = false);
  138.     AActor* CastRay(FVector& lineTraceStart, FVector& lineTraceEnd, bool showDebugLine = false);
  139.     AActor* CastRay(FVector& lineTraceStart, FVector& lineTraceEnd, FHitResult& outHitResult, bool showDebugLine = false);
  140.     AActor* LineTrace(FVector& lineTraceStart, FVector& lineTraceEnd, FHitResult& outHitResult);
  141.     void VibrateController(EVibrationType vibrationType);
  142.     void PlayDynamicForceFeedback(float intensity, float duration);
  143.  
  144.     ///Getters
  145.     USkeletalMeshComponent* GetFirstPersonHandMesh();
  146.     USkeletalMeshComponent* GetVRHandMesh();
  147.     UMotionControllerComponent* GetMotionController();
  148.     EControllerHand GetControllerHand();
  149.     bool GetIsItemEquipped();
  150.     bool GetIsCurrentlyGrabbing();
  151.     bool GetIsCurrentlyCrushing();
  152.     bool GetIsTriggerPressed();
  153.     float GetDistanceFromController();
  154.     float GetReachDistance();
  155.     float GetMinDistanceFromController();
  156.     float GetMaxDistanceFromController();
  157.     bool GetIsUsingMotionControllers();
  158.     FVector GetControllerLocation();
  159.     FRotator GetControllerRotation();
  160.     FTransform GetGrabbedPhysicsHandleTransform();
  161.     FTransform GetControllerTransform();
  162.     FVector GetControllerRelativeLocation();
  163.     FRotator GetControllerRelativeRotation();
  164.     FVector GetNewGrabbedLocation();
  165.     FVector GetLastHitDiffrence();
  166.     FVector GetDiffGrabbedLocation();
  167.     FQuat GetDiffGrabbedRotation();
  168.     ABaseItem* GetGrabbedItem();
  169.     UPrimitiveComponent* GetGrabbedPrimitiveComponent();
  170.     UPhysicsHandleComponent* GetGrabbedPhysicsHandle();
  171.     ABaseCharacter* GetOwningCharacter();
  172.     float GetOwnerStrength();
  173.  
  174.     ///Setters
  175.     void SetMinDistanceFromController(float minDistance);
  176.     void SetMaxDistanceFromController(float maxDistance);
  177.     void SetIsUsingMotionControllers(bool isUsingMotionControllers);
  178.     void SetControllerLocation(FVector controllerLocation);
  179.     void SetControllerRotation(FRotator controllerRotation);
  180.     void SetDistanceFromController(float distanceFromController);
  181.     void SetGrabbedItem(ABaseItem* grabbedItem);
  182.     void SetIsItemEquipped(bool isItemEquipped);
  183.     void SetIsCurrentlyGrabbing(bool isCurrentlyGrabbing);
  184.     void SetIsTriggerPressed(bool isTriggerPressed);
  185.     void SetGrabbedPrimitiveComponent(UPrimitiveComponent* grabbedPrimitiveComponent);
  186.     void SetGrabbedObjectTransform(FTransform grabbedObjectTransform);
  187.     void SetControllerTransform(FTransform controllerTransform);
  188.     void SetIsCurrentlyCrushing(bool isCurrentlyCrushing);
  189.     void SetOwningCharacter(ABaseCharacter* owningCharacter);
  190.     void SetVRHandMesh(USkeletalMeshComponent* handMesh);
  191. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement