11#include "CoreMinimal.h"
12#include "Components/ActorComponent.h"
13#include "UHookSystem.generated.h"
15class UStaticMeshComponent;
22 Launching
UMETA(DisplayName =
"Launching"),
23 Pulling
UMETA(DisplayName =
"Pulling")
31UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
32class ONEPIECE_API UHookSystem :
public UActorComponent
40 virtual
void BeginPlay() override;
41 virtual
void TickComponent(
float DeltaTime, ELevelTick TickType,
42 FActorComponentTickFunction* ThisTickFunction) override;
43 virtual
void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
48 UFUNCTION(BlueprintCallable, Category = "
Hook")
49 void InitSystem(class UStaticMeshComponent* InCableMesh, class UStaticMeshComponent* InProjectileMesh);
52 UFUNCTION(BlueprintCallable, Category = "
Hook")
56 UFUNCTION(BlueprintCallable, Category = "
Hook")
57 void StartHook(const FHitResult&
Hit);
60 UFUNCTION(BlueprintCallable, Category = "
Hook")
65 UFUNCTION(Server, Reliable)
66 void ServerTryHook(const FHitResult& HitResult);
69 UFUNCTION(Server, Reliable)
70 void ServerReleaseHook();
75 UFUNCTION(BlueprintPure, Category = "
Hook")
76 bool IsHooking()
const {
return HookedTarget !=
nullptr; }
79 UFUNCTION(BlueprintPure, Category =
"Hook")
80 bool HasHookTarget()
const {
return CurHookTarget !=
nullptr; }
82 bool PerformCenterLineTrace(FHitResult& OutHit);
90 bool PerformServerLineTrace(FHitResult& OutHit);
94 void DetectHookTarget();
97 void UpdateHookTargetUI();
100 void UpdateHookLaunching(
float DeltaTime);
103 void UpdateHookPulling(
float DeltaTime);
110 void OnRep_HookState();
114 void OnRep_HookProjectileLocation();
118 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "
Hook|Launch")
119 float LaunchSpeed = 2000.0f;
122 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "
Hook|Launch")
123 float MaxHookDistance = 1500.0f;
126 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "
Hook|Pull")
127 float HookSpeed = 500.0f;
130 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "
Hook|Pull")
131 float DesiredDistance = 100.0f;
134 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Interaction")
135 float InteractionDistance = 1200.0f;
138 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "
Hook|Pull")
139 float CompleteThreshold = 100.0f;
142 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Debug")
143 bool bShowDebugInfo = true;
146 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "
Hook|Visual")
147 float CableThickness = 8.0f;
151 UPROPERTY(BlueprintReadOnly, ReplicatedUsing = OnRep_HookState, Category = "
Hook")
155 UPROPERTY(Replicated)
156 TObjectPtr<AActor> HookedTarget;
160 TObjectPtr<AActor> CurHookTarget;
163 TObjectPtr<class
Aluggage> CurHookTarget_Luggage;
171 TObjectPtr<class
Aluggage> PrevHookTarget_Luggage;
174 TObjectPtr<class UStaticMeshComponent> CableMesh;
177 TObjectPtr<class UStaticMeshComponent> ProjectileMesh;
180 UPROPERTY(ReplicatedUsing = OnRep_HookProjectileLocation)
181 FVector HookProjectileLocation;
184 UPROPERTY(Replicated)
185 FVector HookLaunchDirection;
192 float CableMeshBaseLength = 100.0f;
193 float CableMeshBaseRadius = 1.0f;
196 TEnumAsByte<ECollisionEnabled::Type> OriginalCollisionEnabled;
199 void UpdateCableMeshTransform(const FVector& CableStart, const FVector& CableEnd);
Main character driven directly by the player.