Advertisement
Dieton

Item.h

Dec 13th, 2023 (edited)
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.48 KB | Gaming | 0 0
  1. // Fill out your copyright notice in the Description page of Project Settings.
  2.  
  3. #pragma once
  4.  
  5. #include "CoreMinimal.h"
  6. #include "GameFramework/Actor.h"
  7. #include "Item.generated.h"
  8.  
  9. class USphereComponent;
  10.  
  11. UENUM(BlueprintType)
  12. enum class EItemState
  13. {
  14.     EIS_Hovering,
  15.     EIS_Equipped
  16. };
  17.  
  18. UCLASS()
  19. class SLASH_API AItem : public AActor
  20. {
  21.     GENERATED_BODY()
  22.    
  23. public:
  24.     // Sets default values for this actor's properties
  25.     AItem();
  26.     // Called every frame
  27.     virtual void Tick(float DeltaTime) override;
  28.  
  29. protected:
  30.     /*These are all variables
  31.     UPROPERTY(EditerVisStates) or,
  32.     UPROPERTY(EditerVisStates, BlueprintVisStates) or,
  33.     UPROPERTY(BlueprintVisStates)
  34.    
  35.     EditerVisStates:
  36.     VisibleAnywhere -internal and external view but not editable
  37.     VisibleInstanceOnly
  38.     VisibleDefaultsOnly
  39.  
  40.     EditDefaultsOnly -internal blueprint view editable
  41.     EditInstanceOnly -My Perferd Visability editable
  42.     EditAnywhere - editable from anywhere
  43.  
  44.     BlueprintVisStates:
  45.     BlueprintReadWrite
  46.     BlueprintReadOnly
  47.     BlueprintWriteOnly
  48.     */
  49.     /*These are functions
  50.     UFUNCTION(BlueprintCallable)//input exicution panel
  51.     UFUNCTION(BlueprintPure)//Pure function
  52.  
  53.  
  54.     */
  55.  
  56.     // Called when the game starts or when spawned
  57.     virtual void BeginPlay() override;
  58.  
  59.     //UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Cat")
  60.     //float catSpeed = 1.f;
  61.  
  62.     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Sine Parameters")
  63.     float Amplitude = 0.25f;
  64.  
  65.     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Sine Parameters")
  66.     float TimeConstant = 5.f;
  67.  
  68.     UFUNCTION(BlueprintPure)
  69.     float TransformedSin();
  70.  
  71.     UFUNCTION(BlueprintPure)
  72.     float TransformCos();
  73.  
  74.     template<typename T>
  75.     T Avg(T First, T Second);
  76.  
  77.     UFUNCTION()
  78.     virtual void OnSphereOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
  79.  
  80.     UFUNCTION()
  81.     virtual void OnSphereEndOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex);
  82.  
  83.     UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
  84.     UStaticMeshComponent* ItemMesh;
  85.  
  86.     EItemState ItemState = EItemState::EIS_Hovering;
  87.  
  88.     UPROPERTY(VisibleAnywhere)
  89.     USphereComponent* Sphere;
  90.  
  91. private:
  92.     UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))
  93.     float RuningTime;
  94.  
  95.    
  96. };
  97.  
  98. template<typename T>
  99. inline T AItem::Avg(T First, T Second)
  100. {
  101.     return (First + Second) / 2;
  102. }
  103.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement