5#include "CoreMinimal.h"
6#include "InputAction.h"
7#include "InputActionValue.h"
8#include "InputTriggers.h"
9#include "UObject/Object.h"
10#include "Layout/Geometry.h"
11#include "Input/Events.h"
12#include "Engine/LocalPlayer.h"
13#include "Framework/Application/SlateApplication.h"
14#include "ComponentLogic.generated.h"
21class UTouchInputComponent;
22class UEnhancedInputLocalPlayerSubsystem;
24class ULayoutComponentDecorator;
26class UForceFeedbackEffect;
33 UPROPERTY(
Category=
"Axis Input Injection", BlueprintReadWrite)
36 UPROPERTY(
Category=
"Axis Input Injection", BlueprintReadWrite)
39 UPROPERTY(
Category=
"Axis Input Injection", BlueprintReadWrite)
42 UPROPERTY(
Category=
"Axis Input Injection", BlueprintReadWrite)
48 UserId = IPlatformInputDeviceMapper::Get().GetPrimaryPlatformUser();
49 InputDeviceId = IPlatformInputDeviceMapper::Get().GetPrimaryInputDeviceForUser(FSlateApplicationBase::SlateAppPrimaryPlatformUser);
52 FAxisInputInjection(
const FKey& Key,
const float Value,
const FPlatformUserId PlatformUserId,
const FInputDeviceId DeviceId)
65 UserId = IPlatformInputDeviceMapper::Get().GetPlatformUserForUserIndex(LocalPlayer->GetControllerId());
82class TOUCHINTERFACE_API UComponentLogic : public UObject
89 virtual void BeginDestroy()
override;
94 UFUNCTION(Category=
"Layout Component Logic", BlueprintNativeEvent)
97 UFUNCTION(Category=
"Layout Component Logic", BlueprintNativeEvent)
101 void AssignLocalPlayer(ULocalPlayer* Player, TSharedRef<SLayoutComponent> Widget);
103 virtual UWorld* GetWorld()
const override;
105 bool ShouldTick()
const {
return bShouldTick; }
108 virtual void ProcessPressEvent(
const FGeometry& ComponentGeometry,
const FGeometry& LayoutGeometry,
const FPointerEvent& PointerEvent);
109 virtual void ProcessMoveEvent(
const FGeometry& ComponentGeometry,
const FGeometry& LayoutGeometry,
const FPointerEvent& PointerEvent);
110 virtual void ProcessReleaseEvent(
const FGeometry& ComponentGeometry,
const FGeometry& LayoutGeometry,
const FPointerEvent& PointerEvent);
111 virtual void ProcessTickEvent(
const FGeometry& ComponentGeometry,
const double InCurrentTime,
const float InDeltaTime);
114 virtual void PreviewDecorator();
120 virtual void Initialize_Implementation() {}
121 virtual void Deinitialize_Implementation() {}
123 UFUNCTION(Category=
"Layout Component Logic", BlueprintCallable, BlueprintPure)
126 UFUNCTION(Category=
"Layout Component Logic", BlueprintCallable, BlueprintPure)
127 APlayerController* GetPlayerController();
130 UFUNCTION(Category=
"Layout Component Logic", BlueprintNativeEvent)
131 void OnPress(
const FGeometry& ComponentGeometry,
const FPointerEvent& PointerEvent);
133 UFUNCTION(Category=
"Layout Component Logic", BlueprintNativeEvent)
134 void OnMove(
const FGeometry& ComponentGeometry,
const FPointerEvent& PointerEvent);
136 UFUNCTION(Category=
"Layout Component Logic", BlueprintNativeEvent)
137 void OnRelease(
const FGeometry& ComponentGeometry,
const FPointerEvent& PointerEvent);
139 UFUNCTION(Category=
"Layout Component Logic", BlueprintNativeEvent)
140 void OnTick(
const FGeometry& ComponentGeometry,
const FPointerEvent& PointerEvent,
double InCurrentTime,
float InDeltaTime);
142 virtual void OnPress_Implementation(
const FGeometry& ComponentGeometry,
const FPointerEvent& PointerEvent) {}
143 virtual void OnMove_Implementation(
const FGeometry& ComponentGeometry,
const FPointerEvent& PointerEvent) {}
144 virtual void OnRelease_Implementation(
const FGeometry& ComponentGeometry,
const FPointerEvent& PointerEvent) {}
145 virtual void OnTick_Implementation(
const FGeometry& ComponentGeometry,
const FPointerEvent& PointerEvent,
const double InCurrentTime,
const float InDeltaTime) {}
148 TSharedPtr<SLayoutComponent> GetSlotWidget();
150 TSharedPtr<STouchInterfaceRuntime> GetLayoutWidget();
152 bool IsPressed()
const {
return bIsPressed; }
154 UFUNCTION(Category=
"Layout Component Logic", BlueprintCallable, BlueprintPure)
155 ULocalPlayer* GetLocalPlayer();
158 UFUNCTION(Category=
"Layout Component Logic", BlueprintCallable, BlueprintPure)
161 UFUNCTION(Category=
"Layout Component Logic", BlueprintCallable, BlueprintPure)
162 const FGeometry& GetLastComponentGeometry()
const {
return LastComponentGeometry; }
167 UFUNCTION(Category=
"Layout Component Logic", BlueprintCallable)
168 void InjectInput(
const UInputAction* Action, FInputActionValue RawValue,
bool bInjectImmediately =
false);
171 UFUNCTION(Category=
"Layout Component Logic", BlueprintCallable)
172 void InjectInputInFrame(
const UInputAction* Action, FInputActionValue RawValue);
175 UFUNCTION(Category=
"Layout Component Logic", BlueprintCallable)
176 void StopInjectingInput(
const UInputAction* Action);
178 UFUNCTION(Category=
"Layout Component Logic", BlueprintCallable)
179 bool IsInputInjected(
const UInputAction* Action)
const;
187 UFUNCTION(Category=
"Layout Component Logic", BlueprintCallable)
188 void InjectActionInput(
const FKey& InputKey);
191 UFUNCTION(Category=
"Layout Component Logic", BlueprintCallable)
192 void StopInjectingActionInput(
const FKey& InputKey);
199 UFUNCTION(Category=
"Layout Component Logic", BlueprintCallable)
200 void InjectAxisInput(
const FAxisInputInjection AxisInput,
const bool bInjectImmediately =
false);
203 UFUNCTION(Category=
"Layout Component Logic", BlueprintCallable)
206 UFUNCTION(Category=
"Layout Component Logic", BlueprintCallable)
207 void StopInjectingAxisInput(FKey AxisInput);
209 UFUNCTION(Category=
"Layout Component Logic", BlueprintCallable)
210 void StopInjectingAxisInputByName(
const FName InputName);
212 UFUNCTION(Category=
"Layout Component Logic", BlueprintCallable, BlueprintPure)
218 UFUNCTION(Category=
"Layout Component Logic", BlueprintCallable, BlueprintNativeEvent)
219 void SetInputAction(UInputAction* NewInputAction);
222 UFUNCTION(Category=
"Layout Component Logic", BlueprintCallable)
223 virtual void EnableInput() { bBlockInput =
false; }
226 UFUNCTION(Category=
"Layout Component Logic", BlueprintCallable)
227 virtual void DisableInput() { bBlockInput =
true; }
230 UFUNCTION(Category=
"Layout Component Logic", BlueprintCallable)
231 virtual bool IsInputEnabled() {
return !bBlockInput; }
240 UFUNCTION(Category=
"Layout Component Logic", BlueprintCallable)
245 UFUNCTION(Category=
"Layout Component Logic", BlueprintCallable)
256 UFUNCTION(Category=
"Layout Component Logic", BlueprintCallable)
257 void PlaySound(USoundBase* Sound);
259 UFUNCTION(Category=
"Layout Component Logic", BlueprintCallable)
260 void PlaySimpleHaptic(
const float Duration = 0.05f,
const float Intensity = 0.3f,
const bool bAffectLarge =
true,
const bool bAffectSmall =
true);
263 UFUNCTION(Category=
"Layout Component Logic", BlueprintCallable)
264 void PlayHaptic(UForceFeedbackEffect* ForceFeedbackEffect,
bool bLooping,
bool bIgnoreTimeDilation,
bool bPlayWhilePaused);
267 UFUNCTION(Category=
"Layout Component Logic", BlueprintCallable)
268 void StopHaptic(UForceFeedbackEffect* ForceFeedbackEffect);
271 UFUNCTION(Category=
"Layout Component Logic", BlueprintCallable)
272 bool IsHapticPlayed(UForceFeedbackEffect* ForceFeedbackEffect);
274 bool ContainPointerIndex(int32 PointerIndex)
const;
278 UFUNCTION(Category=
"Layout Component Logic", BlueprintCallable)
279 UEnhancedInputLocalPlayerSubsystem* GetEnhancedInputSubsystem();
281 UFUNCTION(Category=
"Layout Component Logic", BlueprintCallable, BlueprintPure)
282 FVector2D GetHitLocationFromCenter(
const bool bNormalize,
bool bConvertToWorldSpace =
false);
284 UFUNCTION(Category=
"Layout Component Logic", BlueprintCallable, BlueprintPure)
285 FVector2D GetLocalHitLocation(
const bool bNormalized);
287 UFUNCTION(Category=
"Layout Component Logic", BlueprintCallable, BlueprintPure)
288 FVector2D GetAbsoluteHitLocation();
290 UFUNCTION(Category=
"Layout Component Logic", BlueprintCallable, BlueprintPure)
293 UFUNCTION(Category=
"Layout Component Logic", BlueprintCallable, BlueprintPure)
297 UFUNCTION(Category=
"Layout Component Logic", BlueprintCallable, BlueprintPure)
298 FVector2D ClampOffsetToEllipse(
const FVector2D Offset,
const FVector2D ComponentSize);
300 UFUNCTION(Category=
"Layout Component Logic", BlueprintCallable, BlueprintPure)
301 FVector2D GetNormalizedOffset(
const FVector2D LocalPosition,
const FVector2D ComponentSize);
303 UFUNCTION(Category=
"Layout Component Logic", BlueprintCallable, BlueprintPure)
304 bool IsOrientedInDirection(
const FVector2D Direction,
const FVector2D Other,
const float Threshold)
const;
306 UFUNCTION(Category=
"Layout Component Logic", BlueprintCallable, BlueprintPure)
307 float GetAngleBetweenVector(
const FVector2D VectorA,
const FVector2D VectorB,
const bool bSignedAngle =
true,
const bool bInvert =
false);
309 UFUNCTION(Category=
"Layout Component Logic", BlueprintCallable, BlueprintPure)
310 float ConvertSignedAngleTo360(
const float SignedAngle);
324 UFUNCTION(Category=
"LayoutComponentLogic|Utility", BlueprintCallable, BlueprintPure,
meta=(CompactNodeTitle=
"CheckName"))
325 bool CheckNameValidity(
const FName Name)
const;
328 TArray<FName> GetAllDecoratorNames()
const;
333 UPROPERTY(Category=
"Layout Component", BlueprintReadOnly, EditDefaultsOnly,
meta=(AllowPrivateAccess=
"true"))
339 UPROPERTY(Category=
"Layout Component", EditAnywhere, BlueprintReadWrite, Instanced)
340 TArray<TObjectPtr<UInputTrigger>> InputTriggers;
348 UPROPERTY(Category=
"Layout Component", EditAnywhere, BlueprintReadWrite, Instanced)
349 TArray<TObjectPtr<ULCInputModifier>> InputModifiers;
356 UWorld* WorldContext;
359 ULocalPlayer* LocalPlayer;
362 UEnhancedInputLocalPlayerSubsystem* InputSubsystem;
365 TObjectPtr<ULayoutComponent> Owner;
367 TSharedPtr<SLayoutComponent> OwnerWidget;
369 FPointerEvent LastPointerEvent;
371 FGeometry LastComponentGeometry;
373 FGeometry LastLayoutGeometry;
376 TMap<const UInputAction*, FInputActionValue> InjectedInputs;
378 TArray<FAxisInputInjection> InjectedAxis;
389 TArray<int32> ActivePointerIndex;
391 FVector2D LastLocalCoord;
EditInlineNew
Definition ComponentDecorator_Animation.h:40
Abstract
Definition ComponentDecorator_Animation.h:40
BlueprintType
Definition ComponentDecorator_Animation.h:40
HideCategories
Definition ComponentDecorator_Animation.h:40
@ OnPress
Definition ComponentDecorator_Animation.h:17
@ OnRelease
Definition ComponentDecorator_Animation.h:20
Blueprintable
Definition ComponentDecorator_Animation.h:40
EHitLocationSpace
Definition ComponentLogic.h:72
@ LocalSpace
Definition ComponentLogic.h:73
@ ViewportSpace
Definition ComponentLogic.h:75
@ LayoutSpace
Definition ComponentLogic.h:74
meta
Definition GestureRecognizerComp.h:274
Definition SLayoutComponent.h:55
Definition STouchInterfaceRuntime.h:30
Definition LayoutComponent.h:94