tengri/Source/TengriPlatformer/World/Interactive/TengriPendulumActor.h

66 lines
3.0 KiB
C++

// Request Games © All rights reserved
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "TengriPendulumActor.generated.h"
class UPhysicsConstraintComponent;
class UStaticMeshComponent;
UCLASS()
class TENGRIPLATFORMER_API ATengriPendulumActor : public AActor
{
GENERATED_BODY()
public:
ATengriPendulumActor();
protected:
virtual void BeginPlay() override;
// ════════════════════════════════════════════════════════════════════════
// COMPONENTS
// ════════════════════════════════════════════════════════════════════════
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Components")
USceneComponent* SceneRoot;
/** Неподвижная точка крепления (крюк в потолке, балка) */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Components")
UStaticMeshComponent* AnchorMesh;
/** Подвижная часть (свеча, клетка) */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Components")
UStaticMeshComponent* SwingMesh;
/** Физический шарнир */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Components")
UPhysicsConstraintComponent* ConstraintComp;
// ════════════════════════════════════════════════════════════════════════
// CONFIGURATION
// ════════════════════════════════════════════════════════════════════════
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Pendulum Physics")
float HitImpulseMultiplier = 50.0f;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Pendulum Physics")
bool bDebugPhysics = false;
public:
// ════════════════════════════════════════════════════════════════════════
// API
// ════════════════════════════════════════════════════════════════════════
UFUNCTION(BlueprintPure, Category = "Pendulum Logic")
float GetCurrentSwingAngle() const;
UFUNCTION(BlueprintCallable, Category = "Pendulum Logic")
void AddSwingImpulse(FVector Direction, float Force);
private:
UFUNCTION()
void OnSwingMeshHit(UPrimitiveComponent* HitComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit);
};